dolibarr 18.0.6
pdf_squille.modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@atm-consulting.fr>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
25require_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php';
26require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
28
29
34{
39 public $emetteur;
40
41
47 public function __construct(DoliDB $db)
48 {
49 global $conf, $langs, $mysoc;
50
51 $this->db = $db;
52 $this->name = "squille";
53 $this->description = $langs->trans("DocumentModelStandardPDF");
54
55 $this->type = 'pdf';
56 $formatarray = pdf_getFormat();
57 $this->page_largeur = $formatarray['width'];
58 $this->page_hauteur = $formatarray['height'];
59 $this->format = array($this->page_largeur, $this->page_hauteur);
60 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
61 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
62 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
63 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
64
65 $this->option_logo = 1; // Display logo
66 $this->option_draft_watermark = 1; // Support add of a watermark on drafts
67 $this->watermark = '';
68
69 // Get source company
70 $this->emetteur = $mysoc;
71 if (!$this->emetteur->country_code) {
72 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
73 }
74
75 // Define position of columns
76 $this->posxdesc = $this->marge_gauche + 1;
77 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 78;
78 $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56;
79 $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28;
80 $this->posxpuht = $this->page_largeur - $this->marge_droite;
81
82 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
83 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 118;
84 $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96;
85 $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68;
86 $this->posxpuht = $this->page_largeur - $this->marge_droite - 40;
87 $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
88 }
89
90 $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
91
92 if ($this->page_largeur < 210) { // To work with US executive format
93 $this->posxweightvol -= 20;
94 $this->posxpicture -= 20;
95 $this->posxqtyordered -= 20;
96 $this->posxqtytoship -= 20;
97 }
98
99 if (!empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
100 $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
101 $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
102 $this->posxqtyordered = $this->posxqtytoship;
103 }
104 }
105
106 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
118 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
119 {
120 // phpcs:enable
121 global $user, $conf, $langs, $hookmanager;
122
123 $object->fetch_thirdparty();
124
125 if (!is_object($outputlangs)) {
126 $outputlangs = $langs;
127 }
128 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
129 if (!empty($conf->global->MAIN_USE_FPDF)) {
130 $outputlangs->charset_output = 'ISO-8859-1';
131 }
132
133 $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal", "deliveries", "receptions", "productbatch", "sendings"));
134
135 // Show Draft Watermark
136 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK))) {
137 $this->watermark = $conf->global->RECEPTION_DRAFT_WATERMARK;
138 }
139
140 $nblines = count($object->lines);
141
142 // Loop on each lines to detect if there is at least one image to show
143 $realpatharray = array();
144 if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) {
145 $objphoto = new Product($this->db);
146
147 for ($i = 0; $i < $nblines; $i++) {
148 if (empty($object->lines[$i]->fk_product)) {
149 continue;
150 }
151
152 $objphoto = new Product($this->db);
153 $objphoto->fetch($object->lines[$i]->fk_product);
154
155 if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
156 $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
157 $dir = $conf->product->dir_output.'/'.$pdir;
158 } else {
159 $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product');
160 $dir = $conf->product->dir_output.'/'.$pdir;
161 }
162
163 $realpath = '';
164
165 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
166 if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) {
167 // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
168 if ($obj['photo_vignette']) {
169 $filename = $obj['photo_vignette'];
170 } else {
171 $filename = $obj['photo'];
172 }
173 } else {
174 $filename = $obj['photo'];
175 }
176
177 $realpath = $dir.$filename;
178 break;
179 }
180
181 if ($realpath) {
182 $realpatharray[$i] = $realpath;
183 }
184 }
185 }
186
187 if (count($realpatharray) == 0) {
188 $this->posxpicture = $this->posxweightvol;
189 }
190
191 if ($conf->reception->dir_output) {
192 // Definition de $dir et $file
193 if ($object->specimen) {
194 $dir = $conf->reception->dir_output;
195 $file = $dir."/SPECIMEN.pdf";
196 } else {
197 $rcpref = dol_sanitizeFileName($object->ref);
198 $dir = $conf->reception->dir_output."/".$rcpref;
199 $file = $dir."/".$rcpref.".pdf";
200 }
201
202 if (!file_exists($dir)) {
203 if (dol_mkdir($dir) < 0) {
204 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
205 return 0;
206 }
207 }
208
209 if (file_exists($dir)) {
210 // Add pdfgeneration hook
211 if (!is_object($hookmanager)) {
212 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
213 $hookmanager = new HookManager($this->db);
214 }
215 $hookmanager->initHooks(array('pdfgeneration'));
216 $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
217 global $action;
218 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
219
220 // Set nblines with the new facture lines content after hook
221 $nblines = count($object->lines);
222
223 $pdf = pdf_getInstance($this->format);
224 $default_font_size = pdf_getPDFFontSize($outputlangs);
225 $heightforinfotot = 8; // Height reserved to output the info and total part
226 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
227 $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
228 $pdf->SetAutoPageBreak(1, 0);
229
230 if (class_exists('TCPDF')) {
231 $pdf->setPrintHeader(false);
232 $pdf->setPrintFooter(false);
233 }
234 $pdf->SetFont(pdf_getPDFFont($outputlangs));
235 // Set path to the background PDF File
236 if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
237 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
238 $tplidx = $pdf->importPage(1);
239 }
240
241 $pdf->Open();
242 $pagenb = 0;
243 $pdf->SetDrawColor(128, 128, 128);
244
245 if (method_exists($pdf, 'AliasNbPages')) {
246 $pdf->AliasNbPages();
247 }
248
249 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
250 $pdf->SetSubject($outputlangs->transnoentities("Reception"));
251 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
252 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
253 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception"));
254 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
255 $pdf->SetCompression(false);
256 }
257
258 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
259
260 // New page
261 $pdf->AddPage();
262 if (!empty($tplidx)) {
263 $pdf->useTemplate($tplidx);
264 }
265 $pagenb++;
266 $this->_pagehead($pdf, $object, 1, $outputlangs);
267 $pdf->SetFont('', '', $default_font_size - 1);
268 $pdf->MultiCell(0, 3, ''); // Set interline to 3
269 $pdf->SetTextColor(0, 0, 0);
270
271 $tab_top = 90;
272 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
273
274 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
275
276 // Incoterm
277 $height_incoterms = 0;
278 if (isModEnabled('incoterm')) {
279 $desc_incoterms = $object->getIncotermsForPDF();
280 if ($desc_incoterms) {
281 $tab_top -= 2;
282
283 $pdf->SetFont('', '', $default_font_size - 1);
284 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
285 $nexY = $pdf->GetY();
286 $height_incoterms = $nexY - $tab_top;
287
288 // Rect takes a length in 3rd parameter
289 $pdf->SetDrawColor(192, 192, 192);
290 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
291
292 $tab_top = $nexY + 6;
293 $height_incoterms += 4;
294 }
295 }
296
297 if (!empty($object->note_public) || !empty($object->tracking_number)) {
298 $tab_top = 88 + $height_incoterms;
299 $tab_top_alt = $tab_top;
300
301 $pdf->SetFont('', 'B', $default_font_size - 2);
302 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L');
303
304 $tab_top_alt = $pdf->GetY();
305 //$tab_top_alt += 1;
306
307 // Tracking number
308 if (!empty($object->tracking_number)) {
309 $object->getUrlTrackingStatus($object->tracking_number);
310 if (!empty($object->tracking_url)) {
311 if ($object->reception_method_id > 0) {
312 // Get code using getLabelFromKey
313 $code = $outputlangs->getLabelFromKey($this->db, $object->shipment_method_id, 'c_shipment_mode', 'rowid', 'code');
314 $label = '';
315 if ($object->tracking_url != $object->tracking_number) {
316 $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
317 }
318 $label .= $outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code));
319 //var_dump($object->tracking_url != $object->tracking_number);exit;
320 if ($object->tracking_url != $object->tracking_number) {
321 $label .= " : ";
322 $label .= $object->tracking_url;
323 }
324 $pdf->SetFont('', 'B', $default_font_size - 2);
325 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L');
326
327 $tab_top_alt = $pdf->GetY();
328 }
329 }
330 }
331
332 // Notes
333 if (!empty($object->note_public)) {
334 $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page
335 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
336 }
337
338 $nexY = $pdf->GetY();
339 $height_note = $nexY - $tab_top;
340
341 // Rect takes a length in 3rd parameter
342 $pdf->SetDrawColor(192, 192, 192);
343 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
344
345 $tab_height = $tab_height - $height_note;
346 $tab_top = $nexY + 6;
347 } else {
348 $height_note = 0;
349 }
350
351 $iniY = $tab_top + 7;
352 $curY = $tab_top + 7;
353 $nexY = $tab_top + 7;
354 $fk_commandefourndet = 0;
355 $totalOrdered = 0;
356 $totalAmount = 0;
357
358 // Loop on each lines
359 for ($i = 0; $i < $nblines; $i++) {
360 $curY = $nexY;
361 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
362 $pdf->SetTextColor(0, 0, 0);
363
364 // Define size of image if we need it
365 $imglinesize = array();
366 if (!empty($realpatharray[$i])) {
367 $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
368 }
369
370 $pdf->setTopMargin($tab_top_newpage);
371 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
372 $pageposbefore = $pdf->getPage();
373
374 $showpricebeforepagebreak = 1;
375 $posYAfterImage = 0;
376 $posYAfterDescription = 0;
377
378 // We start with Photo of product line
379 if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
380 $pdf->AddPage('', '', true);
381 if (!empty($tplidx)) {
382 $pdf->useTemplate($tplidx);
383 }
384 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
385 $this->_pagehead($pdf, $object, 0, $outputlangs);
386 }
387 $pdf->setPage($pageposbefore + 1);
388
389 $curY = $tab_top_newpage;
390
391 // Allows data in the first page if description is long enough to break in multiples pages
392 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
393 $showpricebeforepagebreak = 1;
394 } else {
395 $showpricebeforepagebreak = 0;
396 }
397 }
398
399 if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
400 $curX = $this->posxpicture - 1;
401 $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
402 // $pdf->Image does not increase value return by getY, so we save it manually
403 $posYAfterImage = $curY + $imglinesize['height'];
404 }
405
406 // Description of product line
407 $curX = $this->posxdesc - 1;
408
409 // The desc of line is not store into reception, so we force it to the value of product.
410 /*
411 if (empty($object->lines[0]->desc)) {
412 // TODO We must get value from fk_commendefourndet
413 $sqldesc = 'SELECT description FROM '.MAIN_DB_PREFIX.' WHERE rowid = '.((int) $object->lines[0]->fk_commandefourndet);
414 $resqldesc = $this->db->query($sqldesc);
415 if ($resqldesc) {
416 $objdesc = $this->db->fetch_object($resqldesc);
417 $object->lines[0]->desc = $objdesc->description;
418 }
419 }*/
420
421 $pdf->startTransaction();
422 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
423
424 $pageposafter = $pdf->getPage();
425 if ($pageposafter > $pageposbefore) { // There is a pagebreak
426 $pdf->rollbackTransaction(true);
427 $pageposafter = $pageposbefore;
428 //print $pageposafter.'-'.$pageposbefore;exit;
429 $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
430
431 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
432
433 $pageposafter = $pdf->getPage();
434 $posyafter = $pdf->GetY();
435 //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
436 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
437 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
438 $pdf->AddPage('', '', true);
439 if (!empty($tplidx)) {
440 $pdf->useTemplate($tplidx);
441 }
442 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
443 $this->_pagehead($pdf, $object, 0, $outputlangs);
444 }
445 $pdf->setPage($pageposafter + 1);
446 }
447 } else {
448 // We found a page break
449
450 // Allows data in the first page if description is long enough to break in multiples pages
451 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
452 $showpricebeforepagebreak = 1;
453 } else {
454 $showpricebeforepagebreak = 0;
455 }
456 }
457 } else // No pagebreak
458 {
459 $pdf->commitTransaction();
460 }
461 $posYAfterDescription = $pdf->GetY();
462
463 $nexY = max($pdf->GetY(), $posYAfterImage);
464 $pageposafter = $pdf->getPage();
465
466 $pdf->setPage($pageposbefore);
467 $pdf->setTopMargin($this->marge_haute);
468 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
469
470 // We suppose that a too long description or photo were moved completely on next page
471 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
472 $pdf->setPage($pageposafter);
473 $curY = $tab_top_newpage;
474 }
475
476 // We suppose that a too long description is moved completely on next page
477 if ($pageposafter > $pageposbefore) {
478 $pdf->setPage($pageposafter);
479 $curY = $tab_top_newpage;
480 }
481
482 $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
483
484 // Description
485 $pdf->SetXY($this->posxweightvol, $curY);
486 $weighttxt = '';
487 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) {
488 $weighttxt = round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->product->weight_units, 1);
489 }
490 $voltxt = '';
491 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) {
492 $voltxt = round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->product->volume_units ? $object->lines[$i]->product->volume_units : 0, 1);
493 }
494
495 $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C');
496 //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
497
498 // Qty ordered
499 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
500 $pdf->SetXY($this->posxqtyordered, $curY);
501 if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
502 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
503 $totalOrdered += $object->lines[$i]->qty_asked;
504 }
505 $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
506 }
507
508 // Qty received
509 $pdf->SetXY($this->posxqtytoship, $curY);
510 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty, '', 'C');
511
512 // Amount
513 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
514 $pdf->SetXY($this->posxpuht, $curY);
515 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R');
516
517 $amountreceived = price2num($object->lines[$i]->subprice * $object->lines[$i]->qty, 'MT');
518 $pdf->SetXY($this->posxtotalht, $curY);
519 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($amountreceived, 0, $outputlangs), '', 'R');
520
521 $totalAmount += $amountreceived;
522 }
523
524 $nexY += 3;
525 if ($weighttxt && $voltxt) {
526 $nexY += 2;
527 }
528
529 // Add line
530 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
531 $pdf->setPage($pageposafter);
532 $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
533 //$pdf->SetDrawColor(190,190,200);
534 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
535 $pdf->SetLineStyle(array('dash'=>0));
536 }
537
538 // Detect if some page were added automatically and output _tableau for past pages
539 while ($pagenb < $pageposafter) {
540 $pdf->setPage($pagenb);
541 if ($pagenb == 1) {
542 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
543 } else {
544 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
545 }
546 $this->_pagefoot($pdf, $object, $outputlangs, 1);
547 $pagenb++;
548 $pdf->setPage($pagenb);
549 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
550 if (!empty($tplidx)) {
551 $pdf->useTemplate($tplidx);
552 }
553 }
554 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
555 if ($pagenb == 1) {
556 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
557 } else {
558 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
559 }
560 $this->_pagefoot($pdf, $object, $outputlangs, 1);
561 // New page
562 $pdf->AddPage();
563 if (!empty($tplidx)) {
564 $pdf->useTemplate($tplidx);
565 }
566 $pagenb++;
567 }
568 }
569
570 // Show square
571 if ($pagenb == 1) {
572 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object);
573 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
574 } else {
575 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object);
576 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
577 }
578
579 // Affiche zone totaux
580 $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered, $totalAmount);
581
582 // Pied de page
583 $this->_pagefoot($pdf, $object, $outputlangs);
584 if (method_exists($pdf, 'AliasNbPages')) {
585 $pdf->AliasNbPages();
586 }
587
588 $pdf->Close();
589
590 $pdf->Output($file, 'F');
591
592 // Add pdfgeneration hook
593 $hookmanager->initHooks(array('pdfgeneration'));
594 $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
595 global $action;
596 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
597 if ($reshook < 0) {
598 $this->error = $hookmanager->error;
599 $this->errors = $hookmanager->errors;
600 }
601
602 dolChmod($file);
603
604 return 1; // No error
605 } else {
606 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
607 return 0;
608 }
609 } else {
610 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
611 return 0;
612 }
613 }
614
615 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
616 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
629 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered, $totalAmount = 0)
630 {
631 // phpcs:enable
632 global $conf, $mysoc;
633
634 $sign = 1;
635
636 $default_font_size = pdf_getPDFFontSize($outputlangs);
637
638 $tab2_top = $posy;
639 $tab2_hl = 4;
640 $pdf->SetFont('', 'B', $default_font_size - 1);
641
642 // Tableau total
643 $col1x = $this->posxweightvol - 50;
644 $col2x = $this->posxweightvol;
645 /*if ($this->page_largeur < 210) // To work with US executive format
646 {
647 $col2x-=20;
648 }*/
649 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
650 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
651 } else {
652 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
653 }
654
655 $useborder = 0;
656 $index = 0;
657
658 $totalWeighttoshow = '';
659 $totalVolumetoshow = '';
660
661 // Load dim data
662 $tmparray = $object->getTotalWeightVolume();
663 $totalWeight = $tmparray['weight'];
664 $totalVolume = $tmparray['volume'];
665 $totalToShip = $tmparray['toship'];
666
667
668 // Set trueVolume and volume_units not currently stored into database
669 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
670 $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
671 $object->volume_units = $object->size_units * 3;
672 }
673
674 if ($totalWeight != '') {
675 $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
676 }
677 if ($totalVolume != '') {
678 $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
679 }
680 if (isset($object->trueWeight) && !empty($object->trueWeight)) {
681 $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs, -1, 'no', 1);
682 }
683 if (isset($object->trueVolume) && !empty($object->trueVolume)) {
684 $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs, -1, 'no', 1);
685 }
686
687 $pdf->SetFillColor(255, 255, 255);
688 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
689 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
690
691 $index2 = 0;
692
693 // Total Weight
694 if ($totalWeighttoshow) {
695 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
696 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
697 $index2++;
698 }
699 if ($totalVolumetoshow) {
700 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
701 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
702 $index2++;
703 }
704
705 // Total qty ordered
706 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
707 $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
708 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
709 }
710
711 // Total received
712 $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
713 $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
714
715 // Amount
716 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
717 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
718 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
719
720 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
721 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($totalAmount, 0, $outputlangs), 0, 'C', 1);
722 }
723
724 $pdf->SetTextColor(0, 0, 0);
725
726 $index++;
727 if ($index2) {
728 $index++;
729 }
730
731 return ($tab2_top + ($tab2_hl * $index));
732 }
733
734 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
748 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object = null)
749 {
750 global $conf;
751
752 // Force to disable hidetop and hidebottom
753 $hidebottom = 0;
754 if ($hidetop) {
755 $hidetop = -1;
756 }
757
758 $default_font_size = pdf_getPDFFontSize($outputlangs);
759
760 // Amount in (at tab_top - 1)
761 $pdf->SetTextColor(0, 0, 0);
762 $pdf->SetFont('', '', $default_font_size - 2);
763
764 // Output Rect
765 $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
766
767 $pdf->SetDrawColor(128, 128, 128);
768 $pdf->SetFont('', '', $default_font_size - 1);
769
770 // Description
771 if (empty($hidetop)) {
772 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
773
774 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
775 $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
776 }
777
778 // Volume / Weight
779 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
780 if (empty($hidetop)) {
781 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
782 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
783 }
784
785 // Qty ordered
786 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
787 $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
788 if (empty($hidetop)) {
789 $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
790 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
791 }
792 }
793
794 // Qty reception
795 $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
796 if (empty($hidetop)) {
797 $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
798 $statusreceived = Reception::STATUS_CLOSED;
799 if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) {
800 $statusreceived = Reception::STATUS_VALIDATED;
801 }
802 if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) {
803 $statusreceived = Reception::STATUS_CLOSED;
804 }
805 if ($object && $object->statut < $statusreceived) {
806 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyToReceive'), '', 'C');
807 } else {
808 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyReceived'), '', 'C');
809 }
810 }
811
812 // Amount
813 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
814 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
815 if (empty($hidetop)) {
816 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
817 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
818 }
819
820 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
821 if (empty($hidetop)) {
822 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
823 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
824 }
825 }
826 }
827
828 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
838 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
839 {
840 global $conf, $langs, $mysoc;
841
842 $langs->load("orders");
843
844 $default_font_size = pdf_getPDFFontSize($outputlangs);
845
846 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
847
848 //Prepare la suite
849 $pdf->SetTextColor(0, 0, 60);
850 $pdf->SetFont('', 'B', $default_font_size + 3);
851
852 $w = 110;
853
854 $posy = $this->marge_haute;
855 $posx = $this->page_largeur - $this->marge_droite - $w;
856
857 $pdf->SetXY($this->marge_gauche, $posy);
858
859 // Logo
860 $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
861 if ($this->emetteur->logo) {
862 if (is_readable($logo)) {
863 $height = pdf_getHeightForLogo($logo);
864 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
865 } else {
866 $pdf->SetTextColor(200, 0, 0);
867 $pdf->SetFont('', 'B', $default_font_size - 2);
868 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
869 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
870 }
871 } else {
872 $text = $this->emetteur->name;
873 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
874 }
875
876 // Show barcode
877 if (isModEnabled('barcode')) {
878 $posx = 105;
879 } else {
880 $posx = $this->marge_gauche + 3;
881 }
882 //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
883 if (isModEnabled('barcode')) {
884 // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
885 //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
886 //$pdf->Image($logo,10, 5, 0, 24);
887 }
888
889 $pdf->SetDrawColor(128, 128, 128);
890 if (isModEnabled('barcode')) {
891 // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
892 //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
893 //$pdf->Image($logo,10, 5, 0, 24);
894 }
895
896
897 $posx = $this->page_largeur - $w - $this->marge_droite;
898 $posy = $this->marge_haute;
899
900 $pdf->SetFont('', 'B', $default_font_size + 2);
901 $pdf->SetXY($posx, $posy);
902 $pdf->SetTextColor(0, 0, 60);
903 $title = $outputlangs->transnoentities("ReceptionSheet");
904 $pdf->MultiCell($w, 4, $title, '', 'R');
905
906 $pdf->SetFont('', '', $default_font_size + 1);
907
908 $posy += 5;
909
910 $pdf->SetXY($posx, $posy);
911 $pdf->SetTextColor(0, 0, 60);
912 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception")." : ".$object->ref, '', 'R');
913
914 // Date planned delivery
915 if (!empty($object->date_delivery)) {
916 $posy += 4;
917 $pdf->SetXY($posx, $posy);
918 $pdf->SetTextColor(0, 0, 60);
919 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
920 }
921
922 if (!empty($object->thirdparty->code_fournisseur)) {
923 $posy += 4;
924 $pdf->SetXY($posx, $posy);
925 $pdf->SetTextColor(0, 0, 60);
926 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
927 }
928
929
930 $pdf->SetFont('', '', $default_font_size + 3);
931 $Yoff = 25;
932
933 // Add list of linked orders
934 $origin = $object->origin;
935 $origin_id = $object->origin_id;
936
937 // TODO move to external function
938 if (isModEnabled("supplier_order")) { // commonly $origin='commande'
939 $outputlangs->load('orders');
940
941 $classname = 'CommandeFournisseur';
942 $linkedobject = new $classname($this->db);
943 $result = $linkedobject->fetch($origin_id);
944 if ($result >= 0) {
945 //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
946
947 $pdf->SetFont('', '', $default_font_size - 2);
948 $text = $linkedobject->ref;
949 if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) {
950 $text .= ' ('.$linkedobject->ref_client.')';
951 }
952 $Yoff = $Yoff + 8;
953 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
954 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
955 $Yoff = $Yoff + 3;
956 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
957 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
958 }
959 }
960
961 if ($showaddress) {
962 // Sender properties
963 $carac_emetteur = '';
964 // Add internal contact of origin element if defined
965 $arrayidcontact = array();
966 if (!empty($origin) && is_object($object->$origin)) {
967 $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL');
968 }
969 if (empty($arrayidcontact)) {
970 $arrayidcontact = $object->$origin->getIdContact('internal', 'SHIPPING');
971 }
972 if (count($arrayidcontact) > 0) {
973 $object->fetch_user(reset($arrayidcontact));
974 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
975 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
976 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
977 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
978 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
979 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
980 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
981 $carac_emetteur .= "\n";
982 }
983
984 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
985
986 // Show sender
987 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
988 $posx = $this->marge_gauche;
989 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
990 $posx = $this->page_largeur - $this->marge_droite - 80;
991 }
992
993 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
994 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
995
996 // Show sender frame
997 $pdf->SetTextColor(0, 0, 0);
998 $pdf->SetFont('', '', $default_font_size - 2);
999 $pdf->SetXY($posx, $posy - 5);
1000 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender"), 0, 'L');
1001 $pdf->SetXY($posx, $posy);
1002 $pdf->SetFillColor(230, 230, 230);
1003 $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1004 $pdf->SetTextColor(0, 0, 60);
1005 $pdf->SetFillColor(255, 255, 255);
1006
1007 // If RECEPTION contact defined, we use it
1008 $usecontact = false;
1009 $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
1010
1011 if (count($arrayidcontact) > 0) {
1012 $usecontact = true;
1013 $result = $object->fetch_contact($arrayidcontact[0]);
1014 }
1015
1016 // Recipient name
1017 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1018 $thirdparty = $object->contact;
1019 } else {
1020 $thirdparty = $object->thirdparty;
1021 }
1022
1023 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1024
1025 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
1026
1027 // Show recipient name
1028 $pdf->SetXY($posx + 2, $posy + 3);
1029 $pdf->SetFont('', 'B', $default_font_size);
1030 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0, 'L');
1031
1032 $posy = $pdf->getY();
1033
1034 // Show recipient information
1035 $pdf->SetFont('', '', $default_font_size - 1);
1036 $pdf->SetXY($posx + 2, $posy);
1037 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, 'L');
1038
1039 // Show recipient
1040 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1041 if ($this->page_largeur < 210) {
1042 $widthrecbox = 84; // To work with US executive format
1043 }
1044 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1045 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1046 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1047 $posx = $this->marge_gauche;
1048 }
1049
1050 // Show recipient frame
1051 $pdf->SetTextColor(0, 0, 0);
1052 $pdf->SetFont('', '', $default_font_size - 2);
1053 $pdf->SetXY($posx + 2, $posy - 5);
1054 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, 'L');
1055 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1056
1057
1058
1059 // Show sender name
1060 $pdf->SetXY($posx + 2, $posy + 3);
1061 $pdf->SetFont('', 'B', $default_font_size);
1062 $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1063 $posy = $pdf->getY();
1064
1065 // Show sender information
1066 $pdf->SetXY($posx + 2, $posy);
1067 $pdf->SetFont('', '', $default_font_size - 1);
1068 $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L');
1069 }
1070
1071 $pdf->SetTextColor(0, 0, 0);
1072 }
1073
1074 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1084 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1085 {
1086 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1087 return pdf_pagefoot($pdf, $outputlangs, 'RECEPTION_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
1088 }
1089}
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Class to manage Dolibarr database access.
Class to manage hooks.
Parent class of sending receipts models.
Class to manage products or services.
Classe permettant de generer les borderaux envoi au modele Squille.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
__construct(DoliDB $db)
Constructor.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered, $totalAmount=0)
Show total to pay.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $object=null)
Show table for lines.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition pdf.lib.php:2529
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:289
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:85
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
Definition pdf.lib.php:1374
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:314
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition pdf.lib.php:1010
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:726
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:266
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formated for output on documents.
Definition pdf.lib.php:435
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:127
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:387
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:120
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:123