dolibarr 25.0.0-alpha
pdf_espadon.modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
6 * Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2023 Charlene Benke <charlene@patas-monkey.com>
8 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2024 Nick Fragoulis
10 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 * or see https://www.gnu.org/
25 */
26
33require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
37
42{
46 public $db;
47
51 public $name;
52
56 public $description;
57
61 public $update_main_doc_field;
62
66 public $type;
67
72 public $version = 'dolibarr';
73
77 public $posxweightvol;
81 public $posxqtytoship;
85 public $posxqtyordered;
86
87
93 public function __construct(DoliDB $db)
94 {
95 global $langs, $mysoc;
96
97 $this->db = $db;
98 $this->name = "espadon";
99 $this->description = $langs->trans("DocumentModelStandardPDF");
100 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
101
102 // Dimension page
103 $this->type = 'pdf';
104 $formatarray = pdf_getFormat();
105 $this->page_largeur = $formatarray['width'];
106 $this->page_hauteur = $formatarray['height'];
107 $this->format = array($this->page_largeur, $this->page_hauteur);
108 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
109 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
110 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
111 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
112 $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0);
113 $this->option_logo = 1; // Display logo
114 $this->option_draft_watermark = 1; // Support add of a watermark on drafts
115 $this->watermark = '';
116
117 if ($mysoc === null) {
118 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
119 return;
120 }
121
122 // Get source company
123 $this->emetteur = $mysoc;
124 if (empty($this->emetteur->country_code)) {
125 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
126 }
127
128 $this->tabTitleHeight = 5; // default height
129 }
130
131 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
143 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
144 {
145 // phpcs:enable
146 global $user, $conf, $langs, $hookmanager;
147
148 $object->fetch_thirdparty();
149
150 if (!is_object($outputlangs)) {
151 $outputlangs = $langs;
152 }
153 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
154 if (getDolGlobalString('MAIN_USE_FPDF')) {
155 $outputlangs->charset_output = 'ISO-8859-1';
156 }
157
158 // Load traductions files required by page
159 $outputlangs->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "other", "propal", "sendings", "productbatch", "compta"));
160
161 // Show Draft Watermark
162 if ($object->statut == $object::STATUS_DRAFT && (getDolGlobalString('SHIPPING_DRAFT_WATERMARK'))) {
163 $this->watermark = getDolGlobalString('SHIPPING_DRAFT_WATERMARK');
164 }
165
166 global $outputlangsbis;
167 $outputlangsbis = null;
168 if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) {
169 $outputlangsbis = new Translate('', $conf);
170 $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'));
171 $outputlangsbis->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "other", "propal", "sendings", "productbatch", "compta"));
172 }
173
174 $nblines = count($object->lines);
175
176 // Loop on each lines to detect if there is at least one image to show
177 $realpatharray = array();
178 $this->atleastonephoto = false;
179 if (getDolGlobalString('MAIN_GENERATE_SHIPMENT_WITH_PICTURE')) {
180 $objphoto = new Product($this->db);
181
182 for ($i = 0; $i < $nblines; $i++) {
183 if (empty($object->lines[$i]->fk_product)) {
184 continue;
185 }
186
187 $objphoto->fetch($object->lines[$i]->fk_product);
188
189 if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
190 $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
191 $dir = $conf->product->dir_output.'/'.$pdir;
192 } else {
193 $pdir = get_exdir(0, 0, 0, 0, $objphoto, 'product');
194 $dir = $conf->product->dir_output.'/'.$pdir;
195 }
196
197 $realpath = '';
198
199 $arephoto = false;
200 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
201 if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
202 if ($obj['photo_vignette']) {
203 $filename = $obj['photo_vignette'];
204 } else {
205 $filename = $obj['photo'];
206 }
207 } else {
208 $filename = $obj['photo'];
209 }
210
211 $realpath = $dir.$filename;
212 $arephoto = true;
213 $this->atleastonephoto = true;
214 break;
215 }
216
217 if ($realpath && $arephoto) {
218 $realpatharray[$i] = $realpath;
219 }
220 }
221 }
222
223 if (count($realpatharray) == 0) {
224 $this->posxpicture = $this->posxweightvol;
225 }
226
227 if ($conf->expedition->dir_output) {
228 // Definition of $dir and $file
229 if ($object->specimen) {
230 $dir = $conf->expedition->dir_output."/sending";
231 $file = $dir."/SPECIMEN.pdf";
232 } else {
233 $expref = dol_sanitizeFileName($object->ref);
234 $dir = $conf->expedition->dir_output."/sending/".$expref;
235 $file = $dir."/".$expref.".pdf";
236 }
237
238 if (!file_exists($dir)) {
239 if (dol_mkdir($dir) < 0) {
240 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
241 return 0;
242 }
243 }
244
245 if (file_exists($dir)) {
246 // Add pdfgeneration hook
247 if (!is_object($hookmanager)) {
248 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
249 $hookmanager = new HookManager($this->db);
250 }
251 $hookmanager->initHooks(array('pdfgeneration'));
252 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
253 global $action;
254 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
255
256 // Set nblines with the new facture lines content after hook
257 $nblines = is_array($object->lines) ? count($object->lines) : 0;
258
259 $pdf = pdf_getInstance($this->format);
260 $default_font_size = pdf_getPDFFontSize($outputlangs);
261 $heightforinfotot = 8; // Height reserved to output the info and total part
262 $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
263 $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
264 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
265 $heightforfooter += 6;
266 }
267 $pdf->setAutoPageBreak(true, 0);
268
269 if (class_exists('TCPDF')) {
270 $pdf->setPrintHeader(false);
271 $pdf->setPrintFooter(false);
272 }
273 $pdf->SetFont(pdf_getPDFFont($outputlangs));
274 // Set path to the background PDF File
275 if (!getDolGlobalString('MAIN_DISABLE_FPDI') && getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
276 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
277 $tplidx = $pdf->importPage(1);
278 }
279
280 $pdf->Open();
281 $pagenb = 0;
282 $pdf->SetDrawColor(128, 128, 128);
283
284 if (method_exists($pdf, 'AliasNbPages')) {
285 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
286 }
287
288 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
289 $pdf->SetSubject($outputlangs->transnoentities("Shipment"));
290 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
291 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)));
292 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
293 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
294 $pdf->SetCompression(false);
295 }
296
297 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
298 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
299
300 // New page
301 $pdf->AddPage();
302 if (!empty($tplidx)) {
303 $pdf->useTemplate($tplidx);
304 }
305 $pagenb++;
306 $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
307 $pdf->SetFont('', '', $default_font_size - 1);
308 $pdf->MultiCell(0, 3, ''); // Set interline to 3
309 $pdf->SetTextColor(0, 0, 0);
310
311 $tab_top = 80 + $this->marge_haute + $top_shift; // position of top tab
312 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? $this->marge_haute + 32 + $top_shift : $this->marge_haute);
313
314 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
315
316 $this->posxdesc = $this->marge_gauche + 1;
317
318 // Incoterm
319 $height_incoterms = 0;
320 if (isModEnabled('incoterm')) {
321 $desc_incoterms = $object->getIncotermsForPDF();
322 if ($desc_incoterms) {
323 $tab_top -= 2;
324
325 $pdf->SetFont('', '', $default_font_size - 1);
326 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
327 $nexY = $pdf->GetY();
328 $height_incoterms = $nexY - $tab_top;
329
330 // Rect takes a length in 3rd parameter
331 $pdf->SetDrawColor(192, 192, 192);
332 $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');
333
334 $tab_top = $nexY + 6;
335 $height_incoterms += 4;
336 }
337 }
338
339 // Displays notes. Here we are still on code executed only for the first page.
340 $notetoshow = empty($object->note_public) ? '' : $object->note_public;
341
342 // Extrafields in note
343 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
344 if (!empty($extranote)) {
345 $notetoshow = dol_concatdesc($notetoshow, $extranote);
346 }
347
348 if (!empty($notetoshow) || !empty($object->tracking_number) || $object->shipping_method_id > 0) {
349 $tab_top -= 2;
350 $tab_topbeforetrackingnumber = $tab_top;
351 $height_trackingnumber = 0;
352
353 // Tracking number
354 if (!empty($object->tracking_number)) {
355 $tracking_block_start_y = $tab_top;
356
357 $pdf->SetFont('', 'B', $default_font_size - 2);
358 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber") . " : " . $object->tracking_number, 0, 1, false, true, 'L');
359 $tab_top_alt = $pdf->GetY();
360
361 $object->getUrlTrackingStatus((string) $object->tracking_number);
362 if (!empty($object->tracking_url)) {
363 if ($object->shipping_method_id > 0) {
364 // Get code using getLabelFromKey
365 $code = $outputlangs->getLabelFromKey($this->db, (string) $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
366 $label = '';
367 if ($object->tracking_url != $object->tracking_number) {
368 $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
369 }
370 $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
371 //var_dump($object->tracking_url != $object->tracking_number);exit;
372 if ($object->tracking_url != $object->tracking_number) {
373 $label .= " : ";
374 $label .= $object->tracking_url;
375 }
376
377 $pdf->SetFont('', 'B', $default_font_size - 2);
378 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L');
379 }
380 }
381 $tab_top = $pdf->GetY();
382 $height_trackingnumber = $tab_top - $tracking_block_start_y;
383 if ($height_trackingnumber < 4) {
384 $height_trackingnumber = 4;
385 }
386 }
387
388 // Shipping method, even when no tracking number is set
389 if (empty($object->tracking_number) && $object->shipping_method_id > 0) {
390 $code = $outputlangs->getLabelFromKey($this->db, (string) $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
391 $pdf->SetFont('', 'B', $default_font_size - 2);
392 $pdf->writeHTMLCell(90, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)), 0, 1, false, true, 'L');
393 $tab_top = $pdf->GetY();
394 }
395
396 // Notes
397 $pagenb = $pdf->getPage();
398 if (!empty($notetoshow) || !empty($object->tracking_number)) {
399 $tab_top -= 1;
400
401 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
402 $pageposbeforenote = $pagenb;
403
404 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
405 complete_substitutions_array($substitutionarray, $outputlangs, $object);
406 $notetoshow = make_substitutions((string) $notetoshow, $substitutionarray, $outputlangs);
407 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
408
409 $pdf->startTransaction();
410
411 $pdf->SetFont('', '', $default_font_size - 1);
412 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
413 // Description
414 $pageposafternote = $pdf->getPage();
415 $posyafter = $pdf->GetY();
416
417 if ($pageposafternote > $pageposbeforenote) {
418 $pdf->rollbackTransaction(true);
419
420 // prepare pages to receive notes
421 while ($pagenb < $pageposafternote) {
422 $pdf->AddPage();
423 $pagenb++;
424 if (!empty($tplidx)) {
425 $pdf->useTemplate($tplidx);
426 }
427 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
428 $this->_pagehead($pdf, $object, 0, $outputlangs);
429 }
430 // $this->_pagefoot($pdf,$object,$outputlangs,1);
431 $pdf->setTopMargin($tab_top_newpage);
432 // The only function to edit the bottom margin of current page to set it.
433 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
434 }
435
436 // back to start
437 $pdf->setPage($pageposbeforenote);
438 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
439 $pdf->SetFont('', '', $default_font_size - 1);
440 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
441 $pageposafternote = $pdf->getPage();
442
443 $posyafter = $pdf->GetY();
444
445 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
446 $pdf->AddPage('', '', true);
447 $pagenb++;
448 $pageposafternote++;
449 $pdf->setPage($pageposafternote);
450 $pdf->setTopMargin($tab_top_newpage);
451 // The only function to edit the bottom margin of current page to set it.
452 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
453 //$posyafter = $tab_top_newpage;
454 }
455
456
457 // apply note frame to previous pages
458 $i = $pageposbeforenote;
459 while ($i < $pageposafternote) {
460 $pdf->setPage($i);
461
462
463 $pdf->SetDrawColor(128, 128, 128);
464 // Draw note frame
465 if ($i > $pageposbeforenote) {
466 if (empty($height_trackingnumber)) {
467 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
468 } else {
469 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter) + $height_trackingnumber + 1;
470 $tab_top_newpage = $tab_topbeforetrackingnumber;
471 }
472 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
473 } else {
474 if (empty($height_trackingnumber)) {
475 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
476 } else {
477 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter) + $height_trackingnumber + 1;
478 $tab_top = $tab_topbeforetrackingnumber;
479 }
480 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
481 }
482
483 // Add footer
484 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
485 $this->_pagefoot($pdf, $object, $outputlangs, 1);
486
487 $i++;
488 }
489
490 // apply note frame to last page
491 $pdf->setPage($pageposafternote);
492 if (!empty($tplidx)) {
493 $pdf->useTemplate($tplidx);
494 }
495 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
496 $this->_pagehead($pdf, $object, 0, $outputlangs);
497 }
498 $height_note = $posyafter - $tab_top_newpage;
499 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D');
500 } else { // No pagebreak
501 $pdf->commitTransaction();
502 $posyafter = $pdf->GetY();
503 if (empty($height_trackingnumber)) {
504 $height_note = $posyafter - $tab_top + 1;
505 } else {
506 $height_note = $posyafter - $tab_top + $height_trackingnumber + 1;
507 $tab_top = $tab_topbeforetrackingnumber;
508 }
509 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
510
511
512 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
513 // not enough space, need to add page
514 $pdf->AddPage('', '', true);
515 $pagenb++;
516 $pageposafternote++;
517 $pdf->setPage($pageposafternote);
518 if (!empty($tplidx)) {
519 $pdf->useTemplate($tplidx);
520 }
521 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
522 $this->_pagehead($pdf, $object, 0, $outputlangs);
523 }
524
525 $posyafter = $tab_top_newpage;
526 }
527 }
528
529 $tab_height -= $height_note;
530 $tab_top = $posyafter + 6;
531 } else {
532 $height_note = 0;
533 }
534 }
535
536 // Show barcode
537 $height_barcode = 0;
538 //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
539 if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) {
540 require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php';
541
542 $encoding = 'QRCODE';
543 $module = new modTcpdfbarcode();
544 $barcode_path = '';
545 $result = 0;
546 if ($module->encodingIsSupported($encoding)) {
547 $result = $module->writeBarCode((string) $object->ref, $encoding);
548
549 // get path of qrcode image
550 $newcode = (string) $object->ref;
551 if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) {
552 $newcode = dol_hash($newcode, 'md5');
553 }
554 $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png';
555 }
556
557 if ($result > 0) {
558 $tab_top -= 2;
559
560 $pdf->Image($barcode_path, $this->marge_gauche, $tab_top, 20, 20);
561
562 $nexY = $pdf->GetY();
563 $height_barcode = 20;
564
565 $tab_top += 22;
566 } else {
567 $this->error = 'Failed to generate barcode';
568 }
569 }
570
571 // Use new auto column system
572 $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
573
574 // Table simulation to know the height of the title line
575 $pdf->startTransaction();
576 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs);
577 $pdf->rollbackTransaction(true);
578
579
580 $nexY = $tab_top + $this->tabTitleHeight;
581
582 // Loop on each lines
583 $pageposbeforeprintlines = $pdf->getPage();
584 $pagenb = $pageposbeforeprintlines;
585 for ($i = 0; $i < $nblines; $i++) {
586 $curY = $nexY;
587
588 $sub_options = $object->lines[$i]->extraparams["subtotal"] ?? array();
589
590 if (($curY + 6) > ($this->page_hauteur - $heightforfooter) || isset($sub_options['titleforcepagebreak']) && !($pdf->getNumPages() == 1 && $curY == $tab_top + $this->tabTitleHeight)) {
591 $pdf->AddPage();
592 if (!empty($tplidx)) {
593 $pdf->useTemplate($tplidx);
594 }
595
596 $pdf->setPage($pdf->getNumPages());
597 $nexY = $curY = $tab_top_newpage;
598 }
599
600 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
601 $pdf->SetTextColor(0, 0, 0);
602
603 // Define size of image if we need it
604 $imglinesize = array();
605 if (!empty($realpatharray[$i])) {
606 $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
607 }
608
609 $pdf->setTopMargin($tab_top_newpage);
610 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
611 $pageposbefore = $pdf->getPage();
612
613 $showpricebeforepagebreak = 1;
614 $posYAfterImage = 0;
615 $posYAfterDescription = 0;
616 $heightforsignature = 0;
617
618 if ($this->getColumnStatus('photo')) {
619 // We start with Photo of product line
620 if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) { // If photo too high, we moved completely on new page
621 $pdf->AddPage('', '', true);
622 if (!empty($tplidx)) {
623 $pdf->useTemplate($tplidx);
624 }
625 //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
626 $pdf->setPage($pageposbefore + 1);
627
628 $curY = $tab_top_newpage;
629
630 // Allows data in the first page if description is long enough to break in multiples pages
631 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
632 $showpricebeforepagebreak = 1;
633 } else {
634 $showpricebeforepagebreak = 0;
635 }
636 }
637
638
639 if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
640 $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
641 // $pdf->Image does not increase value return by getY, so we save it manually
642 $posYAfterImage = $curY + $imglinesize['height'];
643 }
644 }
645
646 // Description of product line
647 if ($this->getColumnStatus('desc')) {
648 if ($object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
649 $bg_color = colorStringToArray(getDolGlobalString("SUBTOTAL_BACK_COLOR_LEVEL_".abs($object->lines[$i]->qty), 'ffffff'));
650 pdf_render_subtotals($pdf, $this, $curY, $object, $i, $outputlangs, $hideref, $hidedesc, $bg_color, true, true);
651 } else {
652 $pdf->startTransaction();
653
654 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
655
656 $pageposafter = $pdf->getPage();
657 if ($pageposafter > $pageposbefore) { // There is a pagebreak
658 $pdf->rollbackTransaction(true);
659
660 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
661
662 $pageposafter = $pdf->getPage();
663 $posyafter = $pdf->GetY();
664 //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
665 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) { // There is no space left for total+free text
666 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
667 $pdf->AddPage('', '', true);
668 if (!empty($tplidx)) {
669 $pdf->useTemplate($tplidx);
670 }
671 //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
672 $pdf->setPage($pageposafter + 1);
673 }
674 } else {
675 // We found a page break
676 // Allows data in the first page if description is long enough to break in multiples pages
677 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
678 $showpricebeforepagebreak = 1;
679 } else {
680 $showpricebeforepagebreak = 0;
681 }
682 }
683 } else { // No pagebreak
684 $pdf->commitTransaction();
685 }
686 $posYAfterDescription = $pdf->GetY();
687 }
688 }
689
690 $nexY = max($pdf->GetY(), $posYAfterImage);
691 $pageposafter = $pdf->getPage();
692
693 $pdf->setPage($pageposbefore);
694 $pdf->setTopMargin($this->marge_haute);
695 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
696
697 // We suppose that a too long description or photo were moved completely on next page
698 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
699 $pdf->setPage($pageposafter);
700 $curY = $tab_top_newpage;
701 }
702
703 // We suppose that a too long description is moved completely on next page
704 if ($pageposafter > $pageposbefore) {
705 $pdf->setPage($pageposafter);
706 $curY = $tab_top_newpage;
707 }
708
709 $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
710
711 // # of line
712 if ($this->getColumnStatus('position')) {
713 $this->printStdColumnContent($pdf, $curY, 'position', (string) ($i + 1));
714 }
715
716 // weight
717 $weighttxt = '';
718 if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->weight && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
719 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, getDolGlobalInt('SHIPMENT_ROUND_WEIGHT_ON_PDF', 5)).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
720 }
721 $voltxt = '';
722 if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->volume && !getDolGlobalString('SHIPPING_PDF_HIDE_VOLUME') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
723 $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, getDolGlobalInt('SHIPMENT_ROUND_VOLUME_ON_PDF', 5)).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
724 }
725
726 // weight and volume
727 if ($this->getColumnStatus('weight') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
728 $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt);
729 $nexY = max($pdf->GetY(), $nexY);
730 }
731
732 if ($this->getColumnStatus('qty_asked') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
733 $this->printStdColumnContent($pdf, $curY, 'qty_asked', (string) $object->lines[$i]->qty_asked);
734 $nexY = max($pdf->GetY(), $nexY);
735 }
736
737 if ($this->getColumnStatus('unit_order') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
738 $this->printStdColumnContent($pdf, $curY, 'unit_order', measuringUnitString((int) $object->lines[$i]->fk_unit));
739 $nexY = max($pdf->GetY(), $nexY);
740 }
741
742 if ($this->getColumnStatus('qty_shipped') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
743 $this->printStdColumnContent($pdf, $curY, 'qty_shipped', (string) $object->lines[$i]->qty_shipped);
744 $nexY = max($pdf->GetY(), $nexY);
745 }
746
747 if ($this->getColumnStatus('subprice') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
748 $this->printStdColumnContent($pdf, $curY, 'subprice', price($object->lines[$i]->subprice, 0, $outputlangs));
749 $nexY = max($pdf->GetY(), $nexY);
750 }
751
752 if ($this->getColumnStatus('totalexcltax') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
753 $this->printStdColumnContent($pdf, $curY, 'totalexcltax', price($object->lines[$i]->total_ht, 0, $outputlangs));
754 $nexY = max($pdf->GetY(), $nexY);
755 }
756
757 // Extrafields
758 if (!empty($object->lines[$i]->array_options) && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
759 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
760 if ($this->getColumnStatus($extrafieldColKey)) {
761 $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
762 $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
763 $nexY = max($pdf->GetY(), $nexY);
764 }
765 }
766 }
767
768 $parameters = array(
769 'object' => $object,
770 'i' => $i,
771 'pdf' => & $pdf,
772 'curY' => & $curY,
773 'nexY' => & $nexY,
774 'outputlangs' => $outputlangs,
775 'hidedetails' => $hidedetails
776 );
777 $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this);
778
779 // Add line
780 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
781 $pdf->setPage($pageposafter);
782 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
783 //$pdf->SetDrawColor(190,190,200);
784 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
785 $pdf->SetLineStyle(array('dash' => 0));
786 }
787
788 // Detect if some page were added automatically and output _tableau for past pages
789 while ($pagenb < $pageposafter) {
790 $pdf->setPage($pagenb);
791 if ($pagenb == $pageposbeforeprintlines) {
792 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
793 } else {
794 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
795 }
796 $this->_pagefoot($pdf, $object, $outputlangs, 1);
797 $pagenb++;
798 $pdf->setPage($pagenb);
799 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
800 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
801 $this->_pagehead($pdf, $object, 0, $outputlangs);
802 }
803 if (!empty($tplidx)) {
804 $pdf->useTemplate($tplidx);
805 }
806 }
807 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { // @phan-suppress-current-line PhanUndeclaredProperty
808 if ($pagenb == 1) {
809 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
810 } else {
811 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
812 }
813 $this->_pagefoot($pdf, $object, $outputlangs, 1);
814 // New page
815 $pdf->AddPage();
816 if (!empty($tplidx)) {
817 $pdf->useTemplate($tplidx);
818 }
819 $pagenb++;
820 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
821 $this->_pagehead($pdf, $object, 0, $outputlangs);
822 }
823 }
824 }
825
826 // Show square
827 if ($pagenb == 1) {
828 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
829 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
830 } else {
831 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
832 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
833 }
834
835 // Display total area
836 $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
837
838 // Pagefoot
839 $this->_pagefoot($pdf, $object, $outputlangs);
840 if (method_exists($pdf, 'AliasNbPages')) {
841 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
842 }
843
844 $pdf->Close();
845
846 $pdf->Output($file, 'F');
847
848 // Add pdfgeneration hook
849 $hookmanager->initHooks(array('pdfgeneration'));
850 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
851 global $action;
852 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
853 $this->warnings = $hookmanager->warnings;
854 if ($reshook < 0) {
855 $this->error = $hookmanager->error;
856 $this->errors = $hookmanager->errors;
857 dolChmod($file);
858 return -1;
859 }
860
861 dolChmod($file);
862
863 $this->result = array('fullpath' => $file);
864
865 return 1; // No error
866 } else {
867 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
868 return 0;
869 }
870 } else {
871 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
872 return 0;
873 }
874 }
875
876 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
877 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
888 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
889 {
890 // phpcs:enable
891 global $conf, $mysoc;
892
893 $sign = 1;
894
895 $default_font_size = pdf_getPDFFontSize($outputlangs);
896
897 $tab2_top = $posy;
898 $tab2_hl = 4;
899 $pdf->SetFont('', 'B', $default_font_size - 1);
900
901 // Total table
902 $col1x = $this->posxweightvol - 50;
903 $col2x = $this->posxweightvol;
904 /*if ($this->page_largeur < 210) // To work with US executive format
905 {
906 $col2x-=20;
907 }*/
908 if (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) {
909 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
910 } else {
911 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
912 }
913
914 $useborder = 0;
915 $index = 0;
916
917 $totalWeighttoshow = '';
918 $totalVolumetoshow = '';
919
920 // Load dim data
921 $tmparray = $object->getTotalWeightVolume();
922 $totalWeight = $tmparray['weight'];
923 $totalVolume = $tmparray['volume'];
924 $totalOrdered = $tmparray['ordered'];
925 $totalToShip = $tmparray['toship'];
926 // Set trueVolume and volume_units not currently stored into database
927 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
928 $object->trueVolume = price(((float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth), 0, $outputlangs, 0, 0);
929 $object->volume_units = (float) $object->size_units * 3;
930 }
931
932 if (!empty($totalWeight)) {
933 $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
934 }
935 if (!empty($totalVolume) && !getDolGlobalString('SHIPPING_PDF_HIDE_VOLUME')) {
936 $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
937 }
938 if (!empty($object->trueWeight)) {
939 $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, (int) $object->weight_units, "weight", $outputlangs);
940 }
941 if (!empty($object->trueVolume) && !getDolGlobalString('SHIPPING_PDF_HIDE_VOLUME')) {
942 if ($object->volume_units < 50) {
943 $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
944 } else {
945 $totalVolumetoshow = price($object->trueVolume, 0, $outputlangs, 0, 0).' '.measuringUnitString(0, "volume", $object->volume_units);
946 }
947 }
948
949 if ($this->getColumnStatus('desc')) {
950 $this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total"));
951 }
952
953
954 if ($this->getColumnStatus('weight')) {
955 if ($totalWeighttoshow) {
956 $this->printStdColumnContent($pdf, $tab2_top, 'weight', $totalWeighttoshow);
957 $index++;
958 }
959
960 if ($totalVolumetoshow) {
961 $y = $tab2_top + ($tab2_hl * $index);
962 $this->printStdColumnContent($pdf, $y, 'weight', $totalVolumetoshow);
963 }
964 }
965
966 if ($this->getColumnStatus('qty_asked') && $totalOrdered) {
967 $this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', (string) $totalOrdered);
968 }
969
970 if ($this->getColumnStatus('qty_shipped') && $totalToShip) {
971 $this->printStdColumnContent($pdf, $tab2_top, 'qty_shipped', (string) $totalToShip);
972 }
973
974 if ($this->getColumnStatus('totalexcltax')) {
975 $this->printStdColumnContent($pdf, $tab2_top, 'totalexcltax', price($object->total_ht, 0, $outputlangs));
976 }
977
978 $pdf->SetTextColor(0, 0, 0);
979
980 return ($tab2_top + ($tab2_hl * $index));
981 }
982
983 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
998 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
999 {
1000 global $conf;
1001
1002 // Force to disable hidetop and hidebottom
1003 $hidebottom = 0;
1004 if ($hidetop) {
1005 $hidetop = -1;
1006 }
1007
1008 $currency = !empty($currency) ? $currency : $conf->currency;
1009 $default_font_size = pdf_getPDFFontSize($outputlangs);
1010
1011 // Amount in (at tab_top - 1)
1012 $pdf->SetTextColor(0, 0, 0);
1013 $pdf->SetFont('', '', $default_font_size - 2);
1014
1015 if (empty($hidetop)) {
1016 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
1017 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1018 }
1019 }
1020
1021 $pdf->SetDrawColor(128, 128, 128);
1022 $pdf->SetFont('', '', $default_font_size - 1);
1023
1024 // Output Rect
1025 $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
1026
1027
1028 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1029
1030 if (empty($hidetop)) {
1031 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
1032 }
1033 }
1034
1035 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1045 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1046 {
1047 global $conf, $mysoc;
1048
1049 $ltrdirection = 'L';
1050 if ($outputlangs->trans("DIRECTION") == 'rtl') {
1051 $ltrdirection = 'R';
1052 }
1053
1054 $outputlangs->load("orders");
1055
1056 $default_font_size = pdf_getPDFFontSize($outputlangs);
1057
1058 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1059
1060 //Prepare next
1061 $pdf->SetTextColor(0, 0, 60);
1062 $pdf->SetFont('', 'B', $default_font_size + 3);
1063
1064 $w = 110;
1065
1066 $posy = $this->marge_haute;
1067 $posx = $this->page_largeur - $this->marge_droite - $w;
1068
1069 $pdf->SetXY($this->marge_gauche, $posy);
1070
1071 // Logo
1072 if ($this->emetteur->logo) {
1073 $logodir = $conf->mycompany->dir_output;
1074 if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) {
1075 $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity];
1076 }
1077 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
1078 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1079 } else {
1080 $logo = $logodir.'/logos/'.$this->emetteur->logo;
1081 }
1082 if (is_readable($logo)) {
1083 $height = pdf_getHeightForLogo($logo);
1084 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1085 } else {
1086 $pdf->SetTextColor(200, 0, 0);
1087 $pdf->SetFont('', 'B', $default_font_size - 2);
1088 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1089 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1090 }
1091 } else {
1092 $text = $this->emetteur->name;
1093 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1094 }
1095
1096 $pdf->SetDrawColor(128, 128, 128);
1097
1098 $posx = $this->page_largeur - $w - $this->marge_droite;
1099 $posy = $this->marge_haute;
1100
1101 $pdf->SetFont('', 'B', $default_font_size + 2);
1102 $pdf->SetXY($posx, $posy);
1103 $pdf->SetTextColor(0, 0, 60);
1104 $title = $outputlangs->transnoentities("SendingSheet");
1105 $pdf->MultiCell($w, 4, $title, '', 'R');
1106
1107 $pdf->SetFont('', '', $default_font_size + 1);
1108
1109 $posy += 5;
1110
1111 $pdf->SetXY($posx, $posy);
1112 $pdf->SetTextColor(0, 0, 60);
1113 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R');
1114
1115 // Date planned delivery
1116 if (!empty($object->date_delivery)) {
1117 $posy += 4;
1118 $pdf->SetXY($posx, $posy);
1119 $pdf->SetTextColor(0, 0, 60);
1120 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
1121 }
1122
1123 if (getDolGlobalInt('PDF_SHOW_PROJECT_TITLE')) {
1124 $object->fetchProject();
1125 if (!empty($object->project->ref)) {
1126 $posy += 4;
1127 $pdf->SetXY($posx, $posy);
1128 $pdf->SetTextColor(0, 0, 60);
1129 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : pdf_truncate_text($pdf, $object->project->title, 50)), '', 'R');
1130 }
1131 }
1132
1133 if (getDolGlobalInt('PDF_SHOW_PROJECT')) {
1134 $object->fetchProject();
1135 if (!empty($object->project->ref)) {
1136 $outputlangs->load("projects");
1137 $posy += 4;
1138 $pdf->SetXY($posx, $posy);
1139 $pdf->SetTextColor(0, 0, 60);
1140 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
1141 }
1142 }
1143
1144 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) {
1145 $posy += 4;
1146 $pdf->SetXY($posx, $posy);
1147 $pdf->SetTextColor(0, 0, 60);
1148 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities((string) $object->thirdparty->code_client), '', 'R');
1149 }
1150
1151 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_ACCOUNTING_CODE') && !empty($object->thirdparty->code_compta_client)) {
1152 $posy += 4;
1153 $pdf->SetXY($posx, $posy);
1154 $pdf->SetTextColor(0, 0, 60);
1155 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerAccountancyCode")." : ".$outputlangs->transnoentities((string) $object->thirdparty->code_compta_client), '', 'R');
1156 }
1157
1158 $pdf->SetFont('', '', $default_font_size + 3);
1159 $Yoff = 25;
1160
1161 // Add list of linked orders
1162 $origin = $object->origin;
1163 $origin_id = $object->origin_id;
1164 $object->fetch_origin();
1165
1166 // TODO move to external function
1167 if (isModEnabled($origin)) { // commonly $origin='commande'
1168 $outputlangs->load('orders');
1169
1170 $classname = ucfirst($origin);
1171 $linkedobject = new $classname($this->db);
1172 '@phan-var-force Commande|Facture $linkedobject';
1173 $result = $linkedobject->fetch($origin_id);
1174 if ($result >= 0) {
1175 //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
1176
1177 $pdf->SetFont('', '', $default_font_size - 2);
1178 $text = $linkedobject->ref;
1179 if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) {
1180 $text .= ' ('.$linkedobject->ref_client.')';
1181 }
1182 $Yoff += 8;
1183 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1184 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities((string) $text), 0, 'R');
1185 $Yoff += 3;
1186 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1187 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
1188 }
1189 }
1190
1191 $top_shift = 0;
1192 // Show list of linked objects
1193 /*
1194 $current_y = $pdf->getY();
1195 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
1196 if ($current_y < $pdf->getY()) {
1197 $top_shift = $pdf->getY() - $current_y;
1198 }
1199 */
1200
1201 if ($showaddress) {
1202 // Sender properties
1203 $carac_emetteur = '';
1204 // Add internal contact of origin element if defined
1205 $arrayidcontact = array();
1206 if (!empty($origin) && is_object($object->origin_object)) {
1207 $arrayidcontact = $object->origin_object->getIdContact('internal', 'SALESREPFOLL');
1208 }
1209 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1210 $object->fetch_user(reset($arrayidcontact));
1211 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1212 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1213 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
1214 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
1215 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
1216 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
1217 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
1218 $carac_emetteur .= "\n";
1219 }
1220
1221 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1222
1223 // Show sender
1224 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? $this->marge_haute + 30 : $this->marge_haute + 32;
1225 $posx = $this->marge_gauche;
1226 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1227 $posx = $this->page_largeur - $this->marge_droite - 80;
1228 }
1229
1230 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
1231 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1232
1233 // Show sender frame
1234 if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
1235 $pdf->SetTextColor(0, 0, 0);
1236 $pdf->SetFont('', '', $default_font_size - 2);
1237 $pdf->SetXY($posx, $posy - 5);
1238 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender"), 0, $ltrdirection);
1239 $pdf->SetXY($posx, $posy);
1240 $pdf->SetFillColor(230, 230, 230);
1241 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F');
1242 $pdf->SetTextColor(0, 0, 60);
1243 $pdf->SetFillColor(255, 255, 255);
1244 }
1245
1246 // Show sender name
1247 if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
1248 $pdf->SetXY($posx + 2, $posy + 3);
1249 $pdf->SetFont('', 'B', $default_font_size);
1250 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1251 $posy = $pdf->getY();
1252 }
1253
1254 // Show sender information
1255 $pdf->SetXY($posx + 2, $posy);
1256 $pdf->SetFont('', '', $default_font_size - 1);
1257 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1258
1259
1260 // If SHIPPING contact defined, we use it
1261 $usecontact = false;
1262 $arrayidcontact = $object->origin_object->getIdContact('external', 'SHIPPING');
1263 if (count($arrayidcontact) > 0) {
1264 $usecontact = true;
1265 $result = $object->fetch_contact($arrayidcontact[0]);
1266 }
1267
1268 // Recipient name
1269 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1270 $thirdparty = $object->contact;
1271 } else {
1272 $thirdparty = $object->thirdparty;
1273 }
1274
1275 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1276
1277 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), ($usecontact ? 1 : 0), 'targetwithdetails', $object);
1278
1279 // Show recipient
1280 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1281 if ($this->page_largeur < 210) {
1282 $widthrecbox = 84; // To work with US executive format
1283 }
1284 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? $this->marge_haute + 30 : $this->marge_haute + 32;
1285 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1286 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1287 $posx = $this->marge_gauche;
1288 }
1289
1290 // Show recipient frame
1291 if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
1292 $pdf->SetTextColor(0, 0, 0);
1293 $pdf->SetFont('', '', $default_font_size - 2);
1294 $pdf->SetXY($posx + 2, $posy - 5);
1295 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, $ltrdirection);
1296 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
1297 }
1298
1299 // Show recipient name
1300 $pdf->SetXY($posx + 2, $posy + 3);
1301 $pdf->SetFont('', 'B', $default_font_size);
1302 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1303 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1304
1305 $posy = $pdf->getY();
1306
1307 // Show recipient information
1308 $pdf->SetXY($posx + 2, $posy);
1309 $pdf->SetFont('', '', $default_font_size - 1);
1310 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1311 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1312 }
1313
1314 $pdf->SetTextColor(0, 0, 0);
1315
1316 return $top_shift;
1317 }
1318
1319 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1329 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1330 {
1331 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1332 return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
1333 }
1334
1345 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1346 {
1347 global $conf, $hookmanager;
1348
1349 // Default field style for content
1350 $this->defaultContentsFieldsStyle = array(
1351 'align' => 'R', // R,C,L
1352 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1353 );
1354
1355 // Default field style for content
1356 $this->defaultTitlesFieldsStyle = array(
1357 'align' => 'C', // R,C,L
1358 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1359 );
1360
1361 /*
1362 * For example
1363 $this->cols['theColKey'] = array(
1364 'rank' => $rank, // int : use for ordering columns
1365 'width' => 20, // the column width in mm
1366 'title' => array(
1367 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1368 'label' => ' ', // the final label : used fore final generated text
1369 'align' => 'L', // text alignment : R,C,L
1370 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1371 ),
1372 'content' => array(
1373 'align' => 'L', // text alignment : R,C,L
1374 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1375 ),
1376 );
1377 */
1378
1379 $rank = 0; // do not use negative rank
1380 $this->cols['position'] = array(
1381 'rank' => $rank,
1382 'width' => 10.0,
1383 'status' => getDolGlobalInt('PDF_ESPADON_ADD_POSITION') ? true : (getDolGlobalInt('PDF_ADD_POSITION') ? true : false),
1384 'title' => array(
1385 'textkey' => '#', // use lang key is useful in some case with module
1386 'align' => 'C',
1387 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1388 // 'label' => ' ', // the final label
1389 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1390 ),
1391 'content' => array(
1392 'align' => 'C',
1393 'padding' => array(1.0, 0.5, 1.0, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1394 ),
1395 );
1396
1397 $rank += 10; // do not use negative rank
1398 $this->cols['desc'] = array(
1399 'rank' => $rank,
1400 'width' => false, // only for desc
1401 'status' => true,
1402 'title' => array(
1403 'textkey' => 'Designation', // use lang key is useful in some case with module
1404 'align' => 'L',
1405 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1406 // 'label' => ' ', // the final label
1407 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1408 ),
1409 'content' => array(
1410 'align' => 'L',
1411 'padding' => array(1.0, 0.5, 1.0, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1412 ),
1413 );
1414
1415 // Image of product
1416 $rank += 10;
1417 $this->cols['photo'] = array(
1418 'rank' => $rank,
1419 'width' => (float) getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20), // in mm
1420 'status' => false,
1421 'title' => array(
1422 'textkey' => 'Photo',
1423 'label' => ' '
1424 ),
1425 'content' => array(
1426 'padding' => array(0.0, 0.0, 0.0, 0.0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1427 ),
1428 'border-left' => false, // remove left line separator
1429 );
1430
1431 if (getDolGlobalString('MAIN_GENERATE_SHIPMENT_WITH_PICTURE') && !empty($this->atleastonephoto)) {
1432 $this->cols['photo']['status'] = true;
1433 }
1434
1435 $rank += 10;
1436 $this->cols['weight'] = array(
1437 'rank' => $rank,
1438 'width' => 30.0, // in mm
1439 'status' => true,
1440 'title' => array(
1441 'textkey' => 'WeightVolShort'
1442 ),
1443 'border-left' => true, // add left line separator
1444 );
1445
1446
1447 $rank += 10;
1448 $this->cols['subprice'] = array(
1449 'rank' => $rank,
1450 'width' => 19.0, // in mm
1451 'status' => getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT') ? 1 : 0,
1452 'title' => array(
1453 'textkey' => 'PriceUHT'
1454 ),
1455 'border-left' => true, // add left line separator
1456 );
1457
1458 $rank += 10;
1459 $this->cols['totalexcltax'] = array(
1460 'rank' => $rank,
1461 'width' => 26.0, // in mm
1462 'status' => getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT') ? 1 : 0,
1463 'title' => array(
1464 'textkey' => 'TotalHT'
1465 ),
1466 'border-left' => true, // add left line separator
1467 );
1468
1469 $rank += 10;
1470 $this->cols['qty_asked'] = array(
1471 'rank' => $rank,
1472 'width' => 30.0, // in mm
1473 'status' => !getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED') ? 1 : 0,
1474 'title' => array(
1475 'textkey' => 'QtyOrdered'
1476 ),
1477 'border-left' => true, // add left line separator
1478 'content' => array(
1479 'align' => 'C',
1480 ),
1481 );
1482
1483 $rank += 10;
1484 $this->cols['unit_order'] = array(
1485 'rank' => $rank,
1486 'width' => 15.0, // in mm
1487 'status' => !getDolGlobalString('PRODUCT_USE_UNITS') ? 0 : 1,
1488 'title' => array(
1489 'textkey' => 'Unit'
1490 ),
1491 'border-left' => true, // add left line separator
1492 'content' => array(
1493 'align' => 'C',
1494 ),
1495 );
1496
1497 $rank += 10;
1498 $this->cols['qty_shipped'] = array(
1499 'rank' => $rank,
1500 'width' => 30.0, // in mm
1501 'status' => !getDolGlobalString('SHIPPING_PDF_HIDE_QTYTOSHIP'),
1502 'title' => array(
1503 'textkey' => 'QtyToShip'
1504 ),
1505 'border-left' => true, // add left line separator
1506 'content' => array(
1507 'align' => 'C',
1508 ),
1509 );
1510
1511 // Add extrafields cols
1512 if (!empty($object->lines)) {
1513 $line = reset($object->lines);
1514 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1515 }
1516
1517 $parameters = array(
1518 'object' => $object,
1519 'outputlangs' => $outputlangs,
1520 'hidedetails' => $hidedetails,
1521 'hidedesc' => $hidedesc,
1522 'hideref' => $hideref
1523 );
1524
1525 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1526 if ($reshook < 0) {
1527 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1528 } elseif (empty($reshook)) {
1529 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
1530 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1531 } else {
1532 $this->cols = $hookmanager->resArray;
1533 }
1534 }
1535}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:280
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
getColumnStatus($colKey)
get column status from column key
printStdColumnContent($pdf, &$curY, $colKey, $columnText='')
print standard column content
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
getExtrafieldContent($object, $extrafieldKey, $outputlangs=null)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop=0, $hidebottom=0, $style='D')
Print a rounded rectangle on the PDF.
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
Class to manage Dolibarr database access.
Class to manage hooks.
Parent class of sending receipts models.
Class to manage products or services.
Class to manage translations.
Class to generate barcode images using tcpdf barcode generator.
Class to build sending documents with model Espadon.
__construct(DoliDB $db)
Constructor.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='', $outputlangsbis=null)
Show table for lines.
_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.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
if(! $sortfield) if(! $sortorder) $module
Definition list.php:193
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(!function_exists( 'dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
colorStringToArray($stringcolor, $colorifnotfound=array(88, 88, 88))
Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,...
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.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
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)
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
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:3235
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:296
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:319
pdf_pagehead($pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:792
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:1466
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:275
pdf_render_subtotals(TCPDF $pdf, CommonDocGenerator $generator, float $curY, CommonObject $object, int $i, Translate $outputlangs, int $hideref, int $hidedesc, array $bgColor, bool $isSubtotal=false, bool $applySubtotalLogic=true)
Render subtotals line with a colored background and adapted text color .
Definition pdf.lib.php:3365
pdf_truncate_text($pdf, $text, $max_width, $ellipsis_pos=1, $ellipsis="\u{2026}")
Truncates text to fit a specified width in TCPDF, with configurable ellipsis position.
Definition pdf.lib.php:3437
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:481
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition pdf.lib.php:1180
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:436
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
$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, $mode=0)
Returns a hash (non reversible encryption) of a string.