dolibarr 24.0.0-beta
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 = 90; // position of top tab
312 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
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)) {
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 // Notes
389 $pagenb = $pdf->getPage();
390 if (!empty($notetoshow) || !empty($object->tracking_number)) {
391 $tab_top -= 1;
392
393 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
394 $pageposbeforenote = $pagenb;
395
396 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
397 complete_substitutions_array($substitutionarray, $outputlangs, $object);
398 $notetoshow = make_substitutions((string) $notetoshow, $substitutionarray, $outputlangs);
399 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
400
401 $pdf->startTransaction();
402
403 $pdf->SetFont('', '', $default_font_size - 1);
404 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
405 // Description
406 $pageposafternote = $pdf->getPage();
407 $posyafter = $pdf->GetY();
408
409 if ($pageposafternote > $pageposbeforenote) {
410 $pdf->rollbackTransaction(true);
411
412 // prepare pages to receive notes
413 while ($pagenb < $pageposafternote) {
414 $pdf->AddPage();
415 $pagenb++;
416 if (!empty($tplidx)) {
417 $pdf->useTemplate($tplidx);
418 }
419 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
420 $this->_pagehead($pdf, $object, 0, $outputlangs);
421 }
422 // $this->_pagefoot($pdf,$object,$outputlangs,1);
423 $pdf->setTopMargin($tab_top_newpage);
424 // The only function to edit the bottom margin of current page to set it.
425 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
426 }
427
428 // back to start
429 $pdf->setPage($pageposbeforenote);
430 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
431 $pdf->SetFont('', '', $default_font_size - 1);
432 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
433 $pageposafternote = $pdf->getPage();
434
435 $posyafter = $pdf->GetY();
436
437 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
438 $pdf->AddPage('', '', true);
439 $pagenb++;
440 $pageposafternote++;
441 $pdf->setPage($pageposafternote);
442 $pdf->setTopMargin($tab_top_newpage);
443 // The only function to edit the bottom margin of current page to set it.
444 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext);
445 //$posyafter = $tab_top_newpage;
446 }
447
448
449 // apply note frame to previous pages
450 $i = $pageposbeforenote;
451 while ($i < $pageposafternote) {
452 $pdf->setPage($i);
453
454
455 $pdf->SetDrawColor(128, 128, 128);
456 // Draw note frame
457 if ($i > $pageposbeforenote) {
458 if (empty($height_trackingnumber)) {
459 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
460 } else {
461 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter) + $height_trackingnumber + 1;
462 $tab_top_newpage = $tab_topbeforetrackingnumber;
463 }
464 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
465 } else {
466 if (empty($height_trackingnumber)) {
467 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
468 } else {
469 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter) + $height_trackingnumber + 1;
470 $tab_top = $tab_topbeforetrackingnumber;
471 }
472 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
473 }
474
475 // Add footer
476 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
477 $this->_pagefoot($pdf, $object, $outputlangs, 1);
478
479 $i++;
480 }
481
482 // apply note frame to last page
483 $pdf->setPage($pageposafternote);
484 if (!empty($tplidx)) {
485 $pdf->useTemplate($tplidx);
486 }
487 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
488 $this->_pagehead($pdf, $object, 0, $outputlangs);
489 }
490 $height_note = $posyafter - $tab_top_newpage;
491 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius, '1234', 'D');
492 } else { // No pagebreak
493 $pdf->commitTransaction();
494 $posyafter = $pdf->GetY();
495 if (empty($height_trackingnumber)) {
496 $height_note = $posyafter - $tab_top + 1;
497 } else {
498 $height_note = $posyafter - $tab_top + $height_trackingnumber + 1;
499 $tab_top = $tab_topbeforetrackingnumber;
500 }
501 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius, '1234', 'D');
502
503
504 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
505 // not enough space, need to add page
506 $pdf->AddPage('', '', true);
507 $pagenb++;
508 $pageposafternote++;
509 $pdf->setPage($pageposafternote);
510 if (!empty($tplidx)) {
511 $pdf->useTemplate($tplidx);
512 }
513 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
514 $this->_pagehead($pdf, $object, 0, $outputlangs);
515 }
516
517 $posyafter = $tab_top_newpage;
518 }
519 }
520
521 $tab_height -= $height_note;
522 $tab_top = $posyafter + 6;
523 } else {
524 $height_note = 0;
525 }
526 }
527
528 // Show barcode
529 $height_barcode = 0;
530 //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
531 if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) {
532 require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php';
533
534 $encoding = 'QRCODE';
535 $module = new modTcpdfbarcode();
536 $barcode_path = '';
537 $result = 0;
538 if ($module->encodingIsSupported($encoding)) {
539 $result = $module->writeBarCode((string) $object->ref, $encoding);
540
541 // get path of qrcode image
542 $newcode = (string) $object->ref;
543 if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) {
544 $newcode = dol_hash($newcode, 'md5');
545 }
546 $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png';
547 }
548
549 if ($result > 0) {
550 $tab_top -= 2;
551
552 $pdf->Image($barcode_path, $this->marge_gauche, $tab_top, 20, 20);
553
554 $nexY = $pdf->GetY();
555 $height_barcode = 20;
556
557 $tab_top += 22;
558 } else {
559 $this->error = 'Failed to generate barcode';
560 }
561 }
562
563 // Use new auto column system
564 $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
565
566 // Table simulation to know the height of the title line
567 $pdf->startTransaction();
568 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs);
569 $pdf->rollbackTransaction(true);
570
571
572 $nexY = $tab_top + $this->tabTitleHeight;
573
574 // Loop on each lines
575 $pageposbeforeprintlines = $pdf->getPage();
576 $pagenb = $pageposbeforeprintlines;
577 for ($i = 0; $i < $nblines; $i++) {
578 $curY = $nexY;
579
580 $sub_options = $object->lines[$i]->extraparams["subtotal"] ?? array();
581
582 if (($curY + 6) > ($this->page_hauteur - $heightforfooter) || isset($sub_options['titleforcepagebreak']) && !($pdf->getNumPages() == 1 && $curY == $tab_top + $this->tabTitleHeight)) {
583 $pdf->AddPage();
584 if (!empty($tplidx)) {
585 $pdf->useTemplate($tplidx);
586 }
587
588 $pdf->setPage($pdf->getNumPages());
589 $nexY = $curY = $tab_top_newpage;
590 }
591
592 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
593 $pdf->SetTextColor(0, 0, 0);
594
595 // Define size of image if we need it
596 $imglinesize = array();
597 if (!empty($realpatharray[$i])) {
598 $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
599 }
600
601 $pdf->setTopMargin($tab_top_newpage);
602 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
603 $pageposbefore = $pdf->getPage();
604
605 $showpricebeforepagebreak = 1;
606 $posYAfterImage = 0;
607 $posYAfterDescription = 0;
608 $heightforsignature = 0;
609
610 if ($this->getColumnStatus('photo')) {
611 // We start with Photo of product line
612 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
613 $pdf->AddPage('', '', true);
614 if (!empty($tplidx)) {
615 $pdf->useTemplate($tplidx);
616 }
617 //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
618 $pdf->setPage($pageposbefore + 1);
619
620 $curY = $tab_top_newpage;
621
622 // Allows data in the first page if description is long enough to break in multiples pages
623 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
624 $showpricebeforepagebreak = 1;
625 } else {
626 $showpricebeforepagebreak = 0;
627 }
628 }
629
630
631 if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
632 $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
633 // $pdf->Image does not increase value return by getY, so we save it manually
634 $posYAfterImage = $curY + $imglinesize['height'];
635 }
636 }
637
638 // Description of product line
639 if ($this->getColumnStatus('desc')) {
640 if ($object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
641 $bg_color = colorStringToArray(getDolGlobalString("SUBTOTAL_BACK_COLOR_LEVEL_".abs($object->lines[$i]->qty)));
642 pdf_render_subtotals($pdf, $this, $curY, $object, $i, $outputlangs, $hideref, $hidedesc, $bg_color, true, true);
643 } else {
644 $pdf->startTransaction();
645
646 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
647
648 $pageposafter = $pdf->getPage();
649 if ($pageposafter > $pageposbefore) { // There is a pagebreak
650 $pdf->rollbackTransaction(true);
651
652 $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
653
654 $pageposafter = $pdf->getPage();
655 $posyafter = $pdf->GetY();
656 //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
657 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) { // There is no space left for total+free text
658 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
659 $pdf->AddPage('', '', true);
660 if (!empty($tplidx)) {
661 $pdf->useTemplate($tplidx);
662 }
663 //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
664 $pdf->setPage($pageposafter + 1);
665 }
666 } else {
667 // We found a page break
668 // Allows data in the first page if description is long enough to break in multiples pages
669 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
670 $showpricebeforepagebreak = 1;
671 } else {
672 $showpricebeforepagebreak = 0;
673 }
674 }
675 } else { // No pagebreak
676 $pdf->commitTransaction();
677 }
678 $posYAfterDescription = $pdf->GetY();
679 }
680 }
681
682 $nexY = max($pdf->GetY(), $posYAfterImage);
683 $pageposafter = $pdf->getPage();
684
685 $pdf->setPage($pageposbefore);
686 $pdf->setTopMargin($this->marge_haute);
687 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
688
689 // We suppose that a too long description or photo were moved completely on next page
690 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
691 $pdf->setPage($pageposafter);
692 $curY = $tab_top_newpage;
693 }
694
695 // We suppose that a too long description is moved completely on next page
696 if ($pageposafter > $pageposbefore) {
697 $pdf->setPage($pageposafter);
698 $curY = $tab_top_newpage;
699 }
700
701 $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
702
703 // # of line
704 if ($this->getColumnStatus('position')) {
705 $this->printStdColumnContent($pdf, $curY, 'position', (string) ($i + 1));
706 }
707
708 // weight
709 $weighttxt = '';
710 if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->weight && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
711 $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);
712 }
713 $voltxt = '';
714 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) {
715 $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);
716 }
717
718 // weight and volume
719 if ($this->getColumnStatus('weight') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
720 $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt);
721 $nexY = max($pdf->GetY(), $nexY);
722 }
723
724 if ($this->getColumnStatus('qty_asked') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
725 $this->printStdColumnContent($pdf, $curY, 'qty_asked', (string) $object->lines[$i]->qty_asked);
726 $nexY = max($pdf->GetY(), $nexY);
727 }
728
729 if ($this->getColumnStatus('unit_order') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
730 $this->printStdColumnContent($pdf, $curY, 'unit_order', measuringUnitString((int) $object->lines[$i]->fk_unit));
731 $nexY = max($pdf->GetY(), $nexY);
732 }
733
734 if ($this->getColumnStatus('qty_shipped') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
735 $this->printStdColumnContent($pdf, $curY, 'qty_shipped', (string) $object->lines[$i]->qty_shipped);
736 $nexY = max($pdf->GetY(), $nexY);
737 }
738
739 if ($this->getColumnStatus('subprice') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
740 $this->printStdColumnContent($pdf, $curY, 'subprice', price($object->lines[$i]->subprice, 0, $outputlangs));
741 $nexY = max($pdf->GetY(), $nexY);
742 }
743
744 if ($this->getColumnStatus('totalexcltax') && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
745 $this->printStdColumnContent($pdf, $curY, 'totalexcltax', price($object->lines[$i]->total_ht, 0, $outputlangs));
746 $nexY = max($pdf->GetY(), $nexY);
747 }
748
749 // Extrafields
750 if (!empty($object->lines[$i]->array_options) && $object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
751 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
752 if ($this->getColumnStatus($extrafieldColKey)) {
753 $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
754 $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
755 $nexY = max($pdf->GetY(), $nexY);
756 }
757 }
758 }
759
760 $parameters = array(
761 'object' => $object,
762 'i' => $i,
763 'pdf' => & $pdf,
764 'curY' => & $curY,
765 'nexY' => & $nexY,
766 'outputlangs' => $outputlangs,
767 'hidedetails' => $hidedetails
768 );
769 $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this);
770
771 // Add line
772 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
773 $pdf->setPage($pageposafter);
774 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
775 //$pdf->SetDrawColor(190,190,200);
776 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
777 $pdf->SetLineStyle(array('dash' => 0));
778 }
779
780 // Detect if some page were added automatically and output _tableau for past pages
781 while ($pagenb < $pageposafter) {
782 $pdf->setPage($pagenb);
783 if ($pagenb == $pageposbeforeprintlines) {
784 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
785 } else {
786 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
787 }
788 $this->_pagefoot($pdf, $object, $outputlangs, 1);
789 $pagenb++;
790 $pdf->setPage($pagenb);
791 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
792 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
793 $this->_pagehead($pdf, $object, 0, $outputlangs);
794 }
795 if (!empty($tplidx)) {
796 $pdf->useTemplate($tplidx);
797 }
798 }
799 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { // @phan-suppress-current-line PhanUndeclaredProperty
800 if ($pagenb == 1) {
801 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
802 } else {
803 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
804 }
805 $this->_pagefoot($pdf, $object, $outputlangs, 1);
806 // New page
807 $pdf->AddPage();
808 if (!empty($tplidx)) {
809 $pdf->useTemplate($tplidx);
810 }
811 $pagenb++;
812 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
813 $this->_pagehead($pdf, $object, 0, $outputlangs);
814 }
815 }
816 }
817
818 // Show square
819 if ($pagenb == 1) {
820 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
821 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
822 } else {
823 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
824 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
825 }
826
827 // Display total area
828 $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
829
830 // Pagefoot
831 $this->_pagefoot($pdf, $object, $outputlangs);
832 if (method_exists($pdf, 'AliasNbPages')) {
833 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
834 }
835
836 $pdf->Close();
837
838 $pdf->Output($file, 'F');
839
840 // Add pdfgeneration hook
841 $hookmanager->initHooks(array('pdfgeneration'));
842 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
843 global $action;
844 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
845 $this->warnings = $hookmanager->warnings;
846 if ($reshook < 0) {
847 $this->error = $hookmanager->error;
848 $this->errors = $hookmanager->errors;
849 dolChmod($file);
850 return -1;
851 }
852
853 dolChmod($file);
854
855 $this->result = array('fullpath' => $file);
856
857 return 1; // No error
858 } else {
859 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
860 return 0;
861 }
862 } else {
863 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
864 return 0;
865 }
866 }
867
868 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
869 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
880 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
881 {
882 // phpcs:enable
883 global $conf, $mysoc;
884
885 $sign = 1;
886
887 $default_font_size = pdf_getPDFFontSize($outputlangs);
888
889 $tab2_top = $posy;
890 $tab2_hl = 4;
891 $pdf->SetFont('', 'B', $default_font_size - 1);
892
893 // Total table
894 $col1x = $this->posxweightvol - 50;
895 $col2x = $this->posxweightvol;
896 /*if ($this->page_largeur < 210) // To work with US executive format
897 {
898 $col2x-=20;
899 }*/
900 if (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) {
901 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
902 } else {
903 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
904 }
905
906 $useborder = 0;
907 $index = 0;
908
909 $totalWeighttoshow = '';
910 $totalVolumetoshow = '';
911
912 // Load dim data
913 $tmparray = $object->getTotalWeightVolume();
914 $totalWeight = $tmparray['weight'];
915 $totalVolume = $tmparray['volume'];
916 $totalOrdered = $tmparray['ordered'];
917 $totalToShip = $tmparray['toship'];
918 // Set trueVolume and volume_units not currently stored into database
919 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
920 $object->trueVolume = price(((float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth), 0, $outputlangs, 0, 0);
921 $object->volume_units = (float) $object->size_units * 3;
922 }
923
924 if (!empty($totalWeight)) {
925 $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
926 }
927 if (!empty($totalVolume) && !getDolGlobalString('SHIPPING_PDF_HIDE_VOLUME')) {
928 $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
929 }
930 if (!empty($object->trueWeight)) {
931 $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, (int) $object->weight_units, "weight", $outputlangs);
932 }
933 if (!empty($object->trueVolume) && !getDolGlobalString('SHIPPING_PDF_HIDE_VOLUME')) {
934 if ($object->volume_units < 50) {
935 $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
936 } else {
937 $totalVolumetoshow = price($object->trueVolume, 0, $outputlangs, 0, 0).' '.measuringUnitString(0, "volume", $object->volume_units);
938 }
939 }
940
941 if ($this->getColumnStatus('desc')) {
942 $this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total"));
943 }
944
945
946 if ($this->getColumnStatus('weight')) {
947 if ($totalWeighttoshow) {
948 $this->printStdColumnContent($pdf, $tab2_top, 'weight', $totalWeighttoshow);
949 $index++;
950 }
951
952 if ($totalVolumetoshow) {
953 $y = $tab2_top + ($tab2_hl * $index);
954 $this->printStdColumnContent($pdf, $y, 'weight', $totalVolumetoshow);
955 }
956 }
957
958 if ($this->getColumnStatus('qty_asked') && $totalOrdered) {
959 $this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', (string) $totalOrdered);
960 }
961
962 if ($this->getColumnStatus('qty_shipped') && $totalToShip) {
963 $this->printStdColumnContent($pdf, $tab2_top, 'qty_shipped', (string) $totalToShip);
964 }
965
966 if ($this->getColumnStatus('totalexcltax')) {
967 $this->printStdColumnContent($pdf, $tab2_top, 'totalexcltax', price($object->total_ht, 0, $outputlangs));
968 }
969
970 $pdf->SetTextColor(0, 0, 0);
971
972 return ($tab2_top + ($tab2_hl * $index));
973 }
974
975 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
990 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
991 {
992 global $conf;
993
994 // Force to disable hidetop and hidebottom
995 $hidebottom = 0;
996 if ($hidetop) {
997 $hidetop = -1;
998 }
999
1000 $currency = !empty($currency) ? $currency : $conf->currency;
1001 $default_font_size = pdf_getPDFFontSize($outputlangs);
1002
1003 // Amount in (at tab_top - 1)
1004 $pdf->SetTextColor(0, 0, 0);
1005 $pdf->SetFont('', '', $default_font_size - 2);
1006
1007 if (empty($hidetop)) {
1008 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
1009 $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')));
1010 }
1011 }
1012
1013 $pdf->SetDrawColor(128, 128, 128);
1014 $pdf->SetFont('', '', $default_font_size - 1);
1015
1016 // Output Rect
1017 $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
1018
1019
1020 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1021
1022 if (empty($hidetop)) {
1023 $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
1024 }
1025 }
1026
1027 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1037 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1038 {
1039 global $conf, $mysoc;
1040
1041 $ltrdirection = 'L';
1042 if ($outputlangs->trans("DIRECTION") == 'rtl') {
1043 $ltrdirection = 'R';
1044 }
1045
1046 $outputlangs->load("orders");
1047
1048 $default_font_size = pdf_getPDFFontSize($outputlangs);
1049
1050 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1051
1052 //Prepare next
1053 $pdf->SetTextColor(0, 0, 60);
1054 $pdf->SetFont('', 'B', $default_font_size + 3);
1055
1056 $w = 110;
1057
1058 $posy = $this->marge_haute;
1059 $posx = $this->page_largeur - $this->marge_droite - $w;
1060
1061 $pdf->SetXY($this->marge_gauche, $posy);
1062
1063 // Logo
1064 if ($this->emetteur->logo) {
1065 $logodir = $conf->mycompany->dir_output;
1066 if (!empty($conf->mycompany->multidir_output[$object->entity ?? $conf->entity])) {
1067 $logodir = $conf->mycompany->multidir_output[$object->entity ?? $conf->entity];
1068 }
1069 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
1070 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1071 } else {
1072 $logo = $logodir.'/logos/'.$this->emetteur->logo;
1073 }
1074 if (is_readable($logo)) {
1075 $height = pdf_getHeightForLogo($logo);
1076 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1077 } else {
1078 $pdf->SetTextColor(200, 0, 0);
1079 $pdf->SetFont('', 'B', $default_font_size - 2);
1080 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1081 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1082 }
1083 } else {
1084 $text = $this->emetteur->name;
1085 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1086 }
1087
1088 $pdf->SetDrawColor(128, 128, 128);
1089
1090 $posx = $this->page_largeur - $w - $this->marge_droite;
1091 $posy = $this->marge_haute;
1092
1093 $pdf->SetFont('', 'B', $default_font_size + 2);
1094 $pdf->SetXY($posx, $posy);
1095 $pdf->SetTextColor(0, 0, 60);
1096 $title = $outputlangs->transnoentities("SendingSheet");
1097 $pdf->MultiCell($w, 4, $title, '', 'R');
1098
1099 $pdf->SetFont('', '', $default_font_size + 1);
1100
1101 $posy += 5;
1102
1103 $pdf->SetXY($posx, $posy);
1104 $pdf->SetTextColor(0, 0, 60);
1105 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R');
1106
1107 // Date planned delivery
1108 if (!empty($object->date_delivery)) {
1109 $posy += 4;
1110 $pdf->SetXY($posx, $posy);
1111 $pdf->SetTextColor(0, 0, 60);
1112 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
1113 }
1114
1115 if (getDolGlobalInt('PDF_SHOW_PROJECT_TITLE')) {
1116 $object->fetchProject();
1117 if (!empty($object->project->ref)) {
1118 $posy += 4;
1119 $pdf->SetXY($posx, $posy);
1120 $pdf->SetTextColor(0, 0, 60);
1121 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
1122 }
1123 }
1124
1125 if (getDolGlobalInt('PDF_SHOW_PROJECT')) {
1126 $object->fetchProject();
1127 if (!empty($object->project->ref)) {
1128 $outputlangs->load("projects");
1129 $posy += 4;
1130 $pdf->SetXY($posx, $posy);
1131 $pdf->SetTextColor(0, 0, 60);
1132 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
1133 }
1134 }
1135
1136 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) {
1137 $posy += 4;
1138 $pdf->SetXY($posx, $posy);
1139 $pdf->SetTextColor(0, 0, 60);
1140 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities((string) $object->thirdparty->code_client), '', 'R');
1141 }
1142
1143 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_ACCOUNTING_CODE') && !empty($object->thirdparty->code_compta_client)) {
1144 $posy += 4;
1145 $pdf->SetXY($posx, $posy);
1146 $pdf->SetTextColor(0, 0, 60);
1147 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerAccountancyCode")." : ".$outputlangs->transnoentities((string) $object->thirdparty->code_compta_client), '', 'R');
1148 }
1149
1150 $pdf->SetFont('', '', $default_font_size + 3);
1151 $Yoff = 25;
1152
1153 // Add list of linked orders
1154 $origin = $object->origin;
1155 $origin_id = $object->origin_id;
1156 $object->fetch_origin();
1157
1158 // TODO move to external function
1159 if (isModEnabled($origin)) { // commonly $origin='commande'
1160 $outputlangs->load('orders');
1161
1162 $classname = ucfirst($origin);
1163 $linkedobject = new $classname($this->db);
1164 '@phan-var-force Commande|Facture $linkedobject';
1165 $result = $linkedobject->fetch($origin_id);
1166 if ($result >= 0) {
1167 //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
1168
1169 $pdf->SetFont('', '', $default_font_size - 2);
1170 $text = $linkedobject->ref;
1171 if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) {
1172 $text .= ' ('.$linkedobject->ref_client.')';
1173 }
1174 $Yoff += 8;
1175 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1176 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities((string) $text), 0, 'R');
1177 $Yoff += 3;
1178 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1179 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
1180 }
1181 }
1182
1183 $top_shift = 0;
1184 // Show list of linked objects
1185 /*
1186 $current_y = $pdf->getY();
1187 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
1188 if ($current_y < $pdf->getY()) {
1189 $top_shift = $pdf->getY() - $current_y;
1190 }
1191 */
1192
1193 if ($showaddress) {
1194 // Sender properties
1195 $carac_emetteur = '';
1196 // Add internal contact of origin element if defined
1197 $arrayidcontact = array();
1198 if (!empty($origin) && is_object($object->origin_object)) {
1199 $arrayidcontact = $object->origin_object->getIdContact('internal', 'SALESREPFOLL');
1200 }
1201 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1202 $object->fetch_user(reset($arrayidcontact));
1203 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1204 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1205 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
1206 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
1207 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
1208 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
1209 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
1210 $carac_emetteur .= "\n";
1211 }
1212
1213 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1214
1215 // Show sender
1216 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1217 $posx = $this->marge_gauche;
1218 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1219 $posx = $this->page_largeur - $this->marge_droite - 80;
1220 }
1221
1222 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
1223 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1224
1225 // Show sender frame
1226 if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
1227 $pdf->SetTextColor(0, 0, 0);
1228 $pdf->SetFont('', '', $default_font_size - 2);
1229 $pdf->SetXY($posx, $posy - 5);
1230 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender"), 0, $ltrdirection);
1231 $pdf->SetXY($posx, $posy);
1232 $pdf->SetFillColor(230, 230, 230);
1233 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F');
1234 $pdf->SetTextColor(0, 0, 60);
1235 $pdf->SetFillColor(255, 255, 255);
1236 }
1237
1238 // Show sender name
1239 if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
1240 $pdf->SetXY($posx + 2, $posy + 3);
1241 $pdf->SetFont('', 'B', $default_font_size);
1242 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1243 $posy = $pdf->getY();
1244 }
1245
1246 // Show sender information
1247 $pdf->SetXY($posx + 2, $posy);
1248 $pdf->SetFont('', '', $default_font_size - 1);
1249 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1250
1251
1252 // If SHIPPING contact defined, we use it
1253 $usecontact = false;
1254 $arrayidcontact = $object->origin_object->getIdContact('external', 'SHIPPING');
1255 if (count($arrayidcontact) > 0) {
1256 $usecontact = true;
1257 $result = $object->fetch_contact($arrayidcontact[0]);
1258 }
1259
1260 // Recipient name
1261 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1262 $thirdparty = $object->contact;
1263 } else {
1264 $thirdparty = $object->thirdparty;
1265 }
1266
1267 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1268
1269 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), ($usecontact ? 1 : 0), 'targetwithdetails', $object);
1270
1271 // Show recipient
1272 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1273 if ($this->page_largeur < 210) {
1274 $widthrecbox = 84; // To work with US executive format
1275 }
1276 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1277 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1278 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1279 $posx = $this->marge_gauche;
1280 }
1281
1282 // Show recipient frame
1283 if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
1284 $pdf->SetTextColor(0, 0, 0);
1285 $pdf->SetFont('', '', $default_font_size - 2);
1286 $pdf->SetXY($posx + 2, $posy - 5);
1287 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, $ltrdirection);
1288 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
1289 }
1290
1291 // Show recipient name
1292 $pdf->SetXY($posx + 2, $posy + 3);
1293 $pdf->SetFont('', 'B', $default_font_size);
1294 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1295 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1296
1297 $posy = $pdf->getY();
1298
1299 // Show recipient information
1300 $pdf->SetXY($posx + 2, $posy);
1301 $pdf->SetFont('', '', $default_font_size - 1);
1302 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1303 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1304 }
1305
1306 $pdf->SetTextColor(0, 0, 0);
1307
1308 return $top_shift;
1309 }
1310
1311 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1321 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1322 {
1323 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1324 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);
1325 }
1326
1337 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1338 {
1339 global $conf, $hookmanager;
1340
1341 // Default field style for content
1342 $this->defaultContentsFieldsStyle = array(
1343 'align' => 'R', // R,C,L
1344 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1345 );
1346
1347 // Default field style for content
1348 $this->defaultTitlesFieldsStyle = array(
1349 'align' => 'C', // R,C,L
1350 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1351 );
1352
1353 /*
1354 * For example
1355 $this->cols['theColKey'] = array(
1356 'rank' => $rank, // int : use for ordering columns
1357 'width' => 20, // the column width in mm
1358 'title' => array(
1359 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1360 'label' => ' ', // the final label : used fore final generated text
1361 'align' => 'L', // text alignment : R,C,L
1362 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1363 ),
1364 'content' => array(
1365 'align' => 'L', // text alignment : R,C,L
1366 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1367 ),
1368 );
1369 */
1370
1371 $rank = 0; // do not use negative rank
1372 $this->cols['position'] = array(
1373 'rank' => $rank,
1374 'width' => 10,
1375 'status' => getDolGlobalInt('PDF_ESPADON_ADD_POSITION') ? true : (getDolGlobalInt('PDF_ADD_POSITION') ? true : false),
1376 'title' => array(
1377 'textkey' => '#', // use lang key is useful in some case with module
1378 'align' => 'C',
1379 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1380 // 'label' => ' ', // the final label
1381 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1382 ),
1383 'content' => array(
1384 'align' => 'C',
1385 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1386 ),
1387 );
1388
1389 $rank += 10; // do not use negative rank
1390 $this->cols['desc'] = array(
1391 'rank' => $rank,
1392 'width' => false, // only for desc
1393 'status' => true,
1394 'title' => array(
1395 'textkey' => 'Designation', // use lang key is useful in some case with module
1396 'align' => 'L',
1397 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1398 // 'label' => ' ', // the final label
1399 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1400 ),
1401 'content' => array(
1402 'align' => 'L',
1403 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1404 ),
1405 );
1406
1407 // Image of product
1408 $rank += 10;
1409 $this->cols['photo'] = array(
1410 'rank' => $rank,
1411 'width' => getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20), // in mm
1412 'status' => false,
1413 'title' => array(
1414 'textkey' => 'Photo',
1415 'label' => ' '
1416 ),
1417 'content' => array(
1418 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1419 ),
1420 'border-left' => false, // remove left line separator
1421 );
1422
1423 if (getDolGlobalString('MAIN_GENERATE_SHIPMENT_WITH_PICTURE') && !empty($this->atleastonephoto)) {
1424 $this->cols['photo']['status'] = true;
1425 }
1426
1427 $rank += 10;
1428 $this->cols['weight'] = array(
1429 'rank' => $rank,
1430 'width' => 30, // in mm
1431 'status' => true,
1432 'title' => array(
1433 'textkey' => 'WeightVolShort'
1434 ),
1435 'border-left' => true, // add left line separator
1436 );
1437
1438
1439 $rank += 10;
1440 $this->cols['subprice'] = array(
1441 'rank' => $rank,
1442 'width' => 19, // in mm
1443 'status' => getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT') ? 1 : 0,
1444 'title' => array(
1445 'textkey' => 'PriceUHT'
1446 ),
1447 'border-left' => true, // add left line separator
1448 );
1449
1450 $rank += 10;
1451 $this->cols['totalexcltax'] = array(
1452 'rank' => $rank,
1453 'width' => 26, // in mm
1454 'status' => getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT') ? 1 : 0,
1455 'title' => array(
1456 'textkey' => 'TotalHT'
1457 ),
1458 'border-left' => true, // add left line separator
1459 );
1460
1461 $rank += 10;
1462 $this->cols['qty_asked'] = array(
1463 'rank' => $rank,
1464 'width' => 30, // in mm
1465 'status' => !getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED') ? 1 : 0,
1466 'title' => array(
1467 'textkey' => 'QtyOrdered'
1468 ),
1469 'border-left' => true, // add left line separator
1470 'content' => array(
1471 'align' => 'C',
1472 ),
1473 );
1474
1475 $rank += 10;
1476 $this->cols['unit_order'] = array(
1477 'rank' => $rank,
1478 'width' => 15, // in mm
1479 'status' => !getDolGlobalString('PRODUCT_USE_UNITS') ? 0 : 1,
1480 'title' => array(
1481 'textkey' => 'Unit'
1482 ),
1483 'border-left' => true, // add left line separator
1484 'content' => array(
1485 'align' => 'C',
1486 ),
1487 );
1488
1489 $rank += 10;
1490 $this->cols['qty_shipped'] = array(
1491 'rank' => $rank,
1492 'width' => 30, // in mm
1493 'status' => !getDolGlobalString('SHIPPING_PDF_HIDE_QTYTOSHIP'),
1494 'title' => array(
1495 'textkey' => 'QtyToShip'
1496 ),
1497 'border-left' => true, // add left line separator
1498 'content' => array(
1499 'align' => 'C',
1500 ),
1501 );
1502
1503 // Add extrafields cols
1504 if (!empty($object->lines)) {
1505 $line = reset($object->lines);
1506 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1507 }
1508
1509 $parameters = array(
1510 'object' => $object,
1511 'outputlangs' => $outputlangs,
1512 'hidedetails' => $hidedetails,
1513 'hidedesc' => $hidedesc,
1514 'hideref' => $hideref
1515 );
1516
1517 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1518 if ($reshook < 0) {
1519 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1520 } elseif (empty($reshook)) {
1521 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
1522 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1523 } else {
1524 $this->cols = $hookmanager->resArray;
1525 }
1526 }
1527}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
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.
global $mysoc
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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,...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
dol_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)
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition pdf.lib.php:3160
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:87
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:294
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:317
pdf_pagehead($pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:747
pdf_pagefoot($pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition pdf.lib.php:1421
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:273
pdf_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:3288
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
Definition pdf.lib.php:438
pdf_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:1135
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:129
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:393
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.