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