dolibarr 21.0.0-alpha
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-2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 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", "deliveries", "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(1, 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->getFullName($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($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($object->ref, $encoding);
393
394 // get path of qrcode image
395 $newcode = $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('', 1, $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('', 1, $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('', 1, 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, $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, $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('', 1, 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 if ($reshook < 0) {
664 $this->error = $hookmanager->error;
665 $this->errors = $hookmanager->errors;
666 }
667
668 dolChmod($file);
669
670 $this->result = array('fullpath' => $file);
671
672 return 1; // No error
673 } else {
674 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
675 return 0;
676 }
677 } else {
678 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
679 return 0;
680 }
681 }
682
683 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
684 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
697 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered, $totalAmount = 0)
698 {
699 // phpcs:enable
700 global $conf, $mysoc;
701
702 $sign = 1;
703
704 $default_font_size = pdf_getPDFFontSize($outputlangs);
705
706 $tab2_top = $posy;
707 $tab2_hl = 4;
708 $pdf->SetFont('', 'B', $default_font_size - 1);
709
710 // Tableau total
711 $col1x = $this->posxweightvol - 50;
712 $col2x = $this->posxweightvol;
713 /*if ($this->page_largeur < 210) // To work with US executive format
714 {
715 $col2x-=20;
716 }*/
717 if (!getDolGlobalString('RECEPTION_PDF_HIDE_ORDERED')) {
718 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
719 } else {
720 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
721 }
722
723 $useborder = 0;
724 $index = 0;
725
726 $totalWeighttoshow = '';
727 $totalVolumetoshow = '';
728
729 // Load dim data
730 $tmparray = $object->getTotalWeightVolume();
731 $totalWeight = $tmparray['weight'];
732 $totalVolume = $tmparray['volume'];
733 $totalToShip = $tmparray['toship'];
734
735 // Set trueVolume and volume_units not currently stored into database
736 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
737 $object->trueVolume = price(((float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth), 0, $outputlangs, 0, 0);
738 $object->volume_units = (float) $object->size_units * 3;
739 }
740
741 if ($totalWeight != '') {
742 $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
743 }
744 if ($totalVolume != '') {
745 $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
746 }
747 if (isset($object->trueWeight) && !empty($object->trueWeight)) {
748 $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs, -1, 'no', 1);
749 }
750 if (isset($object->trueVolume) && !empty($object->trueVolume)) {
751 $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs, -1, 'no', 1);
752 }
753
754 $pdf->SetFillColor(255, 255, 255);
755 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
756 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
757
758 $index2 = 0;
759
760 // Total Weight
761 if ($totalWeighttoshow) {
762 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
763 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
764 $index2++;
765 }
766 if ($totalVolumetoshow) {
767 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
768 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
769 $index2++;
770 }
771
772 // Total qty ordered
773 if (!getDolGlobalString('RECEPTION_PDF_HIDE_ORDERED')) {
774 $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
775 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
776 }
777
778 // Total received
779 $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
780 $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
781
782 // Amount
783 if (getDolGlobalString('MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT')) {
784 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
785 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
786
787 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
788 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($totalAmount, 0, $outputlangs), 0, 'C', 1);
789 }
790
791 $pdf->SetTextColor(0, 0, 0);
792
793 $index++;
794 if ($index2) {
795 $index++;
796 }
797
798 return ($tab2_top + ($tab2_hl * $index));
799 }
800
801 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
815 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object = null)
816 {
817 global $conf;
818
819 // Force to disable hidetop and hidebottom
820 $hidebottom = 0;
821 if ($hidetop) {
822 $hidetop = -1;
823 }
824
825 $default_font_size = pdf_getPDFFontSize($outputlangs);
826
827 // Amount in (at tab_top - 1)
828 $pdf->SetTextColor(0, 0, 0);
829 $pdf->SetFont('', '', $default_font_size - 2);
830
831 // Output Rect
832 $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
833
834 $pdf->SetDrawColor(128, 128, 128);
835 $pdf->SetFont('', '', $default_font_size - 1);
836
837 // Description
838 if (empty($hidetop)) {
839 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
840
841 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
842 $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
843 }
844
845 // Volume / Weight
846 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
847 if (empty($hidetop)) {
848 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
849 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
850 }
851
852 // Qty ordered
853 if (!getDolGlobalString('RECEPTION_PDF_HIDE_ORDERED')) {
854 $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
855 if (empty($hidetop)) {
856 $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
857 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
858 }
859 }
860
861 // Qty reception
862 $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
863 if (empty($hidetop)) {
864 $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
865 $statusreceived = Reception::STATUS_CLOSED;
866 if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) {
867 $statusreceived = Reception::STATUS_VALIDATED;
868 }
869 if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) {
870 $statusreceived = Reception::STATUS_CLOSED;
871 }
872 if ($object && $object->statut < $statusreceived) {
873 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyToReceive'), '', 'C');
874 } else {
875 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyReceived'), '', 'C');
876 }
877 }
878
879 // Amount
880 if (getDolGlobalString('MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT')) {
881 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
882 if (empty($hidetop)) {
883 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
884 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
885 }
886
887 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
888 if (empty($hidetop)) {
889 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
890 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
891 }
892 }
893 }
894
895 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
905 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
906 {
907 global $conf, $langs, $mysoc;
908
909 $langs->load("orders");
910
911 $default_font_size = pdf_getPDFFontSize($outputlangs);
912
913 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
914
915 //Prepare la suite
916 $pdf->SetTextColor(0, 0, 60);
917 $pdf->SetFont('', 'B', $default_font_size + 3);
918
919 $w = 110;
920
921 $posy = $this->marge_haute;
922 $posx = $this->page_largeur - $this->marge_droite - $w;
923
924 $pdf->SetXY($this->marge_gauche, $posy);
925
926 // Logo
927 if ($this->emetteur->logo) {
928 $logodir = $conf->mycompany->dir_output;
929 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
930 $logodir = $conf->mycompany->multidir_output[$object->entity];
931 }
932 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
933 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
934 } else {
935 $logo = $logodir.'/logos/'.$this->emetteur->logo;
936 }
937 if (is_readable($logo)) {
938 $height = pdf_getHeightForLogo($logo);
939 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
940 } else {
941 $pdf->SetTextColor(200, 0, 0);
942 $pdf->SetFont('', 'B', $default_font_size - 2);
943 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
944 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
945 }
946 } else {
947 $text = $this->emetteur->name;
948 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
949 }
950
951 $pdf->SetDrawColor(128, 128, 128);
952
953 $posx = $this->page_largeur - $w - $this->marge_droite;
954 $posy = $this->marge_haute;
955
956 $pdf->SetFont('', 'B', $default_font_size + 2);
957 $pdf->SetXY($posx, $posy);
958 $pdf->SetTextColor(0, 0, 60);
959 $title = $outputlangs->transnoentities("ReceptionSheet");
960 $pdf->MultiCell($w, 4, $title, '', 'R');
961
962 $pdf->SetFont('', '', $default_font_size + 1);
963
964 $posy += 5;
965
966 $pdf->SetXY($posx, $posy);
967 $pdf->SetTextColor(0, 0, 60);
968 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception")." : ".$object->ref, '', 'R');
969
970 // Date planned delivery
971 if (!empty($object->date_delivery)) {
972 $posy += 4;
973 $pdf->SetXY($posx, $posy);
974 $pdf->SetTextColor(0, 0, 60);
975 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
976 }
977
978 if (!empty($object->thirdparty->code_fournisseur)) {
979 $posy += 4;
980 $pdf->SetXY($posx, $posy);
981 $pdf->SetTextColor(0, 0, 60);
982 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
983 }
984
985
986 $pdf->SetFont('', '', $default_font_size + 3);
987 $Yoff = 25;
988
989 // Add list of linked orders
990 $origin = $object->origin;
991 $origin_id = $object->origin_id;
992
993 $object->fetch_origin();
994
995 // TODO move to external function
996 if (isModEnabled("supplier_order")) { // commonly $origin='commande'
997 $outputlangs->load('orders');
998
999 $classname = 'CommandeFournisseur';
1000 $linkedobject = new $classname($this->db);
1001 $result = $linkedobject->fetch($origin_id);
1002 if ($result >= 0) {
1003 //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
1004
1005 $pdf->SetFont('', '', $default_font_size - 2);
1006 $text = $linkedobject->ref;
1007 if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) {
1008 $text .= ' ('.$linkedobject->ref_client.')';
1009 }
1010 $Yoff += 8;
1011 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1012 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
1013 $Yoff += 3;
1014 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1015 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
1016 }
1017 }
1018
1019 $top_shift = 0;
1020
1021 if ($showaddress) {
1022 // Sender properties
1023 $carac_emetteur = '';
1024 // Add internal contact of origin element if defined
1025 $arrayidcontact = array();
1026 if (!empty($origin) && is_object($object->origin_object)) {
1027 $arrayidcontact = $object->origin_object->getIdContact('internal', 'SALESREPFOLL');
1028 }
1029 if (empty($arrayidcontact)) {
1030 $arrayidcontact = $object->origin_object->getIdContact('internal', 'SHIPPING');
1031 }
1032 if (count($arrayidcontact) > 0) {
1033 $object->fetch_user(reset($arrayidcontact));
1034 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1035 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1036 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
1037 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
1038 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
1039 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
1040 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
1041 $carac_emetteur .= "\n";
1042 }
1043
1044 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
1045
1046 // Show sender
1047 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1048 $posx = $this->marge_gauche;
1049 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1050 $posx = $this->page_largeur - $this->marge_droite - 80;
1051 }
1052
1053 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
1054 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1055
1056 // Show sender frame
1057 $pdf->SetTextColor(0, 0, 0);
1058 $pdf->SetFont('', '', $default_font_size - 2);
1059 $pdf->SetXY($posx, $posy - 5);
1060 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender"), 0, 'L');
1061 $pdf->SetXY($posx, $posy);
1062 $pdf->SetFillColor(230, 230, 230);
1063 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F');
1064 $pdf->SetTextColor(0, 0, 60);
1065 $pdf->SetFillColor(255, 255, 255);
1066
1067 // If RECEPTION contact defined, we use it
1068 $usecontact = false;
1069 $arrayidcontact = $object->origin_object->getIdContact('external', 'SHIPPING');
1070
1071 if (count($arrayidcontact) > 0) {
1072 $usecontact = true;
1073 $result = $object->fetch_contact($arrayidcontact[0]);
1074 }
1075
1076 // Recipient name
1077 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1078 $thirdparty = $object->contact;
1079 } else {
1080 $thirdparty = $object->thirdparty;
1081 }
1082
1083 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1084
1085 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), ($usecontact ? 1 : 0), 'targetwithdetails', $object);
1086
1087 // Show recipient name
1088 $pdf->SetXY($posx + 2, $posy + 3);
1089 $pdf->SetFont('', 'B', $default_font_size);
1090 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0, 'L');
1091
1092 $posy = $pdf->getY();
1093
1094 // Show recipient information
1095 $pdf->SetFont('', '', $default_font_size - 1);
1096 $pdf->SetXY($posx + 2, $posy);
1097 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, 'L');
1098
1099 // Show recipient
1100 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1101 if ($this->page_largeur < 210) {
1102 $widthrecbox = 84; // To work with US executive format
1103 }
1104 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1105 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1106 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1107 $posx = $this->marge_gauche;
1108 }
1109
1110 // Show recipient frame
1111 $pdf->SetTextColor(0, 0, 0);
1112 $pdf->SetFont('', '', $default_font_size - 2);
1113 $pdf->SetXY($posx + 2, $posy - 5);
1114 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, 'L');
1115 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
1116
1117
1118
1119 // Show sender name
1120 $pdf->SetXY($posx + 2, $posy + 3);
1121 $pdf->SetFont('', 'B', $default_font_size);
1122 $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1123 $posy = $pdf->getY();
1124
1125 // Show sender information
1126 $pdf->SetXY($posx + 2, $posy);
1127 $pdf->SetFont('', '', $default_font_size - 1);
1128 $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L');
1129 }
1130
1131 $pdf->SetTextColor(0, 0, 0);
1132
1133 return $top_shift;
1134 }
1135
1136 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1146 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1147 {
1148 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1149 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);
1150 }
1151}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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.
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 '.
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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 a 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_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)
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:2648
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:1442
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:86
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:288
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:313
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:1027
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:729
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:265
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:434
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:128
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:386
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:137
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.