dolibarr 22.0.5
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-2025 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", "deliveries", "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", "deliveries", "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->getFullName($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($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($object->ref, $encoding);
540
541 // get path of qrcode image
542 $newcode = $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 if ($reshook < 0) {
846 $this->error = $hookmanager->error;
847 $this->errors = $hookmanager->errors;
848 }
849
850 dolChmod($file);
851
852 $this->result = array('fullpath' => $file);
853
854 return 1; // No error
855 } else {
856 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
857 return 0;
858 }
859 } else {
860 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
861 return 0;
862 }
863 }
864
865 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
866 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
877 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
878 {
879 // phpcs:enable
880 global $conf, $mysoc;
881
882 $sign = 1;
883
884 $default_font_size = pdf_getPDFFontSize($outputlangs);
885
886 $tab2_top = $posy;
887 $tab2_hl = 4;
888 $pdf->SetFont('', 'B', $default_font_size - 1);
889
890 // Total table
891 $col1x = $this->posxweightvol - 50;
892 $col2x = $this->posxweightvol;
893 /*if ($this->page_largeur < 210) // To work with US executive format
894 {
895 $col2x-=20;
896 }*/
897 if (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) {
898 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
899 } else {
900 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
901 }
902
903 $useborder = 0;
904 $index = 0;
905
906 $totalWeighttoshow = '';
907 $totalVolumetoshow = '';
908
909 // Load dim data
910 $tmparray = $object->getTotalWeightVolume();
911 $totalWeight = $tmparray['weight'];
912 $totalVolume = $tmparray['volume'];
913 $totalOrdered = $tmparray['ordered'];
914 $totalToShip = $tmparray['toship'];
915 // Set trueVolume and volume_units not currently stored into database
916 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
917 $object->trueVolume = price(((float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth), 0, $outputlangs, 0, 0);
918 $object->volume_units = (float) $object->size_units * 3;
919 }
920
921 if (!empty($totalWeight)) {
922 $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
923 }
924 if (!empty($totalVolume) && !getDolGlobalString('SHIPPING_PDF_HIDE_VOLUME')) {
925 $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
926 }
927 if (!empty($object->trueWeight)) {
928 $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, (int) $object->weight_units, "weight", $outputlangs);
929 }
930 if (!empty($object->trueVolume) && !getDolGlobalString('SHIPPING_PDF_HIDE_VOLUME')) {
931 if ($object->volume_units < 50) {
932 $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
933 } else {
934 $totalVolumetoshow = price($object->trueVolume, 0, $outputlangs, 0, 0).' '.measuringUnitString(0, "volume", $object->volume_units);
935 }
936 }
937
938 if ($this->getColumnStatus('desc')) {
939 $this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total"));
940 }
941
942
943 if ($this->getColumnStatus('weight')) {
944 if ($totalWeighttoshow) {
945 $this->printStdColumnContent($pdf, $tab2_top, 'weight', $totalWeighttoshow);
946 $index++;
947 }
948
949 if ($totalVolumetoshow) {
950 $y = $tab2_top + ($tab2_hl * $index);
951 $this->printStdColumnContent($pdf, $y, 'weight', $totalVolumetoshow);
952 }
953 }
954
955 if ($this->getColumnStatus('qty_asked') && $totalOrdered) {
956 $this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', (string) $totalOrdered);
957 }
958
959 if ($this->getColumnStatus('qty_shipped') && $totalToShip) {
960 $this->printStdColumnContent($pdf, $tab2_top, 'qty_shipped', $totalToShip);
961 }
962
963 if ($this->getColumnStatus('totalexcltax')) {
964 $this->printStdColumnContent($pdf, $tab2_top, 'totalexcltax', price($object->total_ht, 0, $outputlangs));
965 }
966
967 $pdf->SetTextColor(0, 0, 0);
968
969 return ($tab2_top + ($tab2_hl * $index));
970 }
971
972 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
987 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
988 {
989 global $conf;
990
991 // Force to disable hidetop and hidebottom
992 $hidebottom = 0;
993 if ($hidetop) {
994 $hidetop = -1;
995 }
996
997 $currency = !empty($currency) ? $currency : $conf->currency;
998 $default_font_size = pdf_getPDFFontSize($outputlangs);
999
1000 // Amount in (at tab_top - 1)
1001 $pdf->SetTextColor(0, 0, 0);
1002 $pdf->SetFont('', '', $default_font_size - 2);
1003
1004 if (empty($hidetop)) {
1005 if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
1006 $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')));
1007 }
1008 }
1009
1010 $pdf->SetDrawColor(128, 128, 128);
1011 $pdf->SetFont('', '', $default_font_size - 1);
1012
1013 // Output Rect
1014 $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
1015
1016
1017 $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1018
1019 if (empty($hidetop)) {
1020 $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
1021 }
1022 }
1023
1024 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1034 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1035 {
1036 global $conf, $mysoc;
1037
1038 $ltrdirection = 'L';
1039 if ($outputlangs->trans("DIRECTION") == 'rtl') {
1040 $ltrdirection = 'R';
1041 }
1042
1043 $outputlangs->load("orders");
1044
1045 $default_font_size = pdf_getPDFFontSize($outputlangs);
1046
1047 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1048
1049 //Prepare next
1050 $pdf->SetTextColor(0, 0, 60);
1051 $pdf->SetFont('', 'B', $default_font_size + 3);
1052
1053 $w = 110;
1054
1055 $posy = $this->marge_haute;
1056 $posx = $this->page_largeur - $this->marge_droite - $w;
1057
1058 $pdf->SetXY($this->marge_gauche, $posy);
1059
1060 // Logo
1061 if ($this->emetteur->logo) {
1062 $logodir = $conf->mycompany->dir_output;
1063 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1064 $logodir = $conf->mycompany->multidir_output[$object->entity];
1065 }
1066 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
1067 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
1068 } else {
1069 $logo = $logodir.'/logos/'.$this->emetteur->logo;
1070 }
1071 if (is_readable($logo)) {
1072 $height = pdf_getHeightForLogo($logo);
1073 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1074 } else {
1075 $pdf->SetTextColor(200, 0, 0);
1076 $pdf->SetFont('', 'B', $default_font_size - 2);
1077 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1078 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1079 }
1080 } else {
1081 $text = $this->emetteur->name;
1082 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1083 }
1084
1085 $pdf->SetDrawColor(128, 128, 128);
1086
1087 $posx = $this->page_largeur - $w - $this->marge_droite;
1088 $posy = $this->marge_haute;
1089
1090 $pdf->SetFont('', 'B', $default_font_size + 2);
1091 $pdf->SetXY($posx, $posy);
1092 $pdf->SetTextColor(0, 0, 60);
1093 $title = $outputlangs->transnoentities("SendingSheet");
1094 $pdf->MultiCell($w, 4, $title, '', 'R');
1095
1096 $pdf->SetFont('', '', $default_font_size + 1);
1097
1098 $posy += 5;
1099
1100 $pdf->SetXY($posx, $posy);
1101 $pdf->SetTextColor(0, 0, 60);
1102 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R');
1103
1104 // Date planned delivery
1105 if (!empty($object->date_delivery)) {
1106 $posy += 4;
1107 $pdf->SetXY($posx, $posy);
1108 $pdf->SetTextColor(0, 0, 60);
1109 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
1110 }
1111
1112 if (getDolGlobalInt('PDF_SHOW_PROJECT_TITLE')) {
1113 $object->fetchProject();
1114 if (!empty($object->project->ref)) {
1115 $posy += 4;
1116 $pdf->SetXY($posx, $posy);
1117 $pdf->SetTextColor(0, 0, 60);
1118 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
1119 }
1120 }
1121
1122 if (getDolGlobalInt('PDF_SHOW_PROJECT')) {
1123 $object->fetchProject();
1124 if (!empty($object->project->ref)) {
1125 $outputlangs->load("projects");
1126 $posy += 4;
1127 $pdf->SetXY($posx, $posy);
1128 $pdf->SetTextColor(0, 0, 60);
1129 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
1130 }
1131 }
1132
1133 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) {
1134 $posy += 4;
1135 $pdf->SetXY($posx, $posy);
1136 $pdf->SetTextColor(0, 0, 60);
1137 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1138 }
1139
1140 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_ACCOUNTING_CODE') && !empty($object->thirdparty->code_compta_client)) {
1141 $posy += 4;
1142 $pdf->SetXY($posx, $posy);
1143 $pdf->SetTextColor(0, 0, 60);
1144 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerAccountancyCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_compta_client), '', 'R');
1145 }
1146
1147 $pdf->SetFont('', '', $default_font_size + 3);
1148 $Yoff = 25;
1149
1150 // Add list of linked orders
1151 $origin = $object->origin;
1152 $origin_id = $object->origin_id;
1153 $object->fetch_origin();
1154
1155 // TODO move to external function
1156 if (isModEnabled($origin)) { // commonly $origin='commande'
1157 $outputlangs->load('orders');
1158
1159 $classname = ucfirst($origin);
1160 $linkedobject = new $classname($this->db);
1161 '@phan-var-force Commande|Facture $linkedobject';
1162 $result = $linkedobject->fetch($origin_id);
1163 if ($result >= 0) {
1164 //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
1165
1166 $pdf->SetFont('', '', $default_font_size - 2);
1167 $text = $linkedobject->ref;
1168 if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) {
1169 $text .= ' ('.$linkedobject->ref_client.')';
1170 }
1171 $Yoff += 8;
1172 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1173 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
1174 $Yoff += 3;
1175 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1176 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
1177 }
1178 }
1179
1180 $top_shift = 0;
1181 // Show list of linked objects
1182 /*
1183 $current_y = $pdf->getY();
1184 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
1185 if ($current_y < $pdf->getY()) {
1186 $top_shift = $pdf->getY() - $current_y;
1187 }
1188 */
1189
1190 if ($showaddress) {
1191 // Sender properties
1192 $carac_emetteur = '';
1193 // Add internal contact of origin element if defined
1194 $arrayidcontact = array();
1195 if (!empty($origin) && is_object($object->origin_object)) {
1196 $arrayidcontact = $object->origin_object->getIdContact('internal', 'SALESREPFOLL');
1197 }
1198 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1199 $object->fetch_user(reset($arrayidcontact));
1200 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1201 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1202 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
1203 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
1204 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
1205 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
1206 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
1207 $carac_emetteur .= "\n";
1208 }
1209
1210 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1211
1212 // Show sender
1213 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1214 $posx = $this->marge_gauche;
1215 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1216 $posx = $this->page_largeur - $this->marge_droite - 80;
1217 }
1218
1219 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
1220 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1221
1222 // Show sender frame
1223 if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
1224 $pdf->SetTextColor(0, 0, 0);
1225 $pdf->SetFont('', '', $default_font_size - 2);
1226 $pdf->SetXY($posx, $posy - 5);
1227 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender"), 0, $ltrdirection);
1228 $pdf->SetXY($posx, $posy);
1229 $pdf->SetFillColor(230, 230, 230);
1230 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'F');
1231 $pdf->SetTextColor(0, 0, 60);
1232 $pdf->SetFillColor(255, 255, 255);
1233 }
1234
1235 // Show sender name
1236 if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
1237 $pdf->SetXY($posx + 2, $posy + 3);
1238 $pdf->SetFont('', 'B', $default_font_size);
1239 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1240 $posy = $pdf->getY();
1241 }
1242
1243 // Show sender information
1244 $pdf->SetXY($posx + 2, $posy);
1245 $pdf->SetFont('', '', $default_font_size - 1);
1246 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1247
1248
1249 // If SHIPPING contact defined, we use it
1250 $usecontact = false;
1251 $arrayidcontact = $object->origin_object->getIdContact('external', 'SHIPPING');
1252 if (count($arrayidcontact) > 0) {
1253 $usecontact = true;
1254 $result = $object->fetch_contact($arrayidcontact[0]);
1255 }
1256
1257 // Recipient name
1258 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1259 $thirdparty = $object->contact;
1260 } else {
1261 $thirdparty = $object->thirdparty;
1262 }
1263
1264 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1265
1266 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), ($usecontact ? 1 : 0), 'targetwithdetails', $object);
1267
1268 // Show recipient
1269 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1270 if ($this->page_largeur < 210) {
1271 $widthrecbox = 84; // To work with US executive format
1272 }
1273 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1274 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1275 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1276 $posx = $this->marge_gauche;
1277 }
1278
1279 // Show recipient frame
1280 if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
1281 $pdf->SetTextColor(0, 0, 0);
1282 $pdf->SetFont('', '', $default_font_size - 2);
1283 $pdf->SetXY($posx + 2, $posy - 5);
1284 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, $ltrdirection);
1285 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
1286 }
1287
1288 // Show recipient name
1289 $pdf->SetXY($posx + 2, $posy + 3);
1290 $pdf->SetFont('', 'B', $default_font_size);
1291 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1292 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1293
1294 $posy = $pdf->getY();
1295
1296 // Show recipient information
1297 $pdf->SetXY($posx + 2, $posy);
1298 $pdf->SetFont('', '', $default_font_size - 1);
1299 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1300 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1301 }
1302
1303 $pdf->SetTextColor(0, 0, 0);
1304
1305 return $top_shift;
1306 }
1307
1308 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1318 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1319 {
1320 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1321 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);
1322 }
1323
1334 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1335 {
1336 global $conf, $hookmanager;
1337
1338 // Default field style for content
1339 $this->defaultContentsFieldsStyle = array(
1340 'align' => 'R', // R,C,L
1341 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1342 );
1343
1344 // Default field style for content
1345 $this->defaultTitlesFieldsStyle = array(
1346 'align' => 'C', // R,C,L
1347 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1348 );
1349
1350 /*
1351 * For example
1352 $this->cols['theColKey'] = array(
1353 'rank' => $rank, // int : use for ordering columns
1354 'width' => 20, // the column width in mm
1355 'title' => array(
1356 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1357 'label' => ' ', // the final label : used fore final generated text
1358 'align' => 'L', // text alignment : R,C,L
1359 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1360 ),
1361 'content' => array(
1362 'align' => 'L', // text alignment : R,C,L
1363 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1364 ),
1365 );
1366 */
1367
1368 $rank = 0; // do not use negative rank
1369 $this->cols['position'] = array(
1370 'rank' => $rank,
1371 'width' => 10,
1372 'status' => getDolGlobalInt('PDF_ESPADON_ADD_POSITION') ? true : (getDolGlobalInt('PDF_ADD_POSITION') ? true : false),
1373 'title' => array(
1374 'textkey' => '#', // use lang key is useful in somme case with module
1375 'align' => 'C',
1376 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1377 // 'label' => ' ', // the final label
1378 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1379 ),
1380 'content' => array(
1381 'align' => 'C',
1382 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1383 ),
1384 );
1385
1386 $rank += 10; // do not use negative rank
1387 $this->cols['desc'] = array(
1388 'rank' => $rank,
1389 'width' => false, // only for desc
1390 'status' => true,
1391 'title' => array(
1392 'textkey' => 'Designation', // use lang key is useful in somme case with module
1393 'align' => 'L',
1394 // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1395 // 'label' => ' ', // the final label
1396 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1397 ),
1398 'content' => array(
1399 'align' => 'L',
1400 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1401 ),
1402 );
1403
1404 // Image of product
1405 $rank += 10;
1406 $this->cols['photo'] = array(
1407 'rank' => $rank,
1408 'width' => getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20), // in mm
1409 'status' => false,
1410 'title' => array(
1411 'textkey' => 'Photo',
1412 'label' => ' '
1413 ),
1414 'content' => array(
1415 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1416 ),
1417 'border-left' => false, // remove left line separator
1418 );
1419
1420 if (getDolGlobalString('MAIN_GENERATE_SHIPMENT_WITH_PICTURE') && !empty($this->atleastonephoto)) {
1421 $this->cols['photo']['status'] = true;
1422 }
1423
1424 $rank += 10;
1425 $this->cols['weight'] = array(
1426 'rank' => $rank,
1427 'width' => 30, // in mm
1428 'status' => true,
1429 'title' => array(
1430 'textkey' => 'WeightVolShort'
1431 ),
1432 'border-left' => true, // add left line separator
1433 );
1434
1435
1436 $rank += 10;
1437 $this->cols['subprice'] = array(
1438 'rank' => $rank,
1439 'width' => 19, // in mm
1440 'status' => getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT') ? 1 : 0,
1441 'title' => array(
1442 'textkey' => 'PriceUHT'
1443 ),
1444 'border-left' => true, // add left line separator
1445 );
1446
1447 $rank += 10;
1448 $this->cols['totalexcltax'] = array(
1449 'rank' => $rank,
1450 'width' => 26, // in mm
1451 'status' => getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT') ? 1 : 0,
1452 'title' => array(
1453 'textkey' => 'TotalHT'
1454 ),
1455 'border-left' => true, // add left line separator
1456 );
1457
1458 $rank += 10;
1459 $this->cols['qty_asked'] = array(
1460 'rank' => $rank,
1461 'width' => 30, // in mm
1462 'status' => !getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED') ? 1 : 0,
1463 'title' => array(
1464 'textkey' => 'QtyOrdered'
1465 ),
1466 'border-left' => true, // add left line separator
1467 'content' => array(
1468 'align' => 'C',
1469 ),
1470 );
1471
1472 $rank += 10;
1473 $this->cols['unit_order'] = array(
1474 'rank' => $rank,
1475 'width' => 15, // in mm
1476 'status' => !getDolGlobalString('PRODUCT_USE_UNITS') ? 0 : 1,
1477 'title' => array(
1478 'textkey' => 'Unit'
1479 ),
1480 'border-left' => true, // add left line separator
1481 'content' => array(
1482 'align' => 'C',
1483 ),
1484 );
1485
1486 $rank += 10;
1487 $this->cols['qty_shipped'] = array(
1488 'rank' => $rank,
1489 'width' => 30, // in mm
1490 'status' => !getDolGlobalString('SHIPPING_PDF_HIDE_QTYTOSHIP'),
1491 'title' => array(
1492 'textkey' => 'QtyToShip'
1493 ),
1494 'border-left' => true, // add left line separator
1495 'content' => array(
1496 'align' => 'C',
1497 ),
1498 );
1499
1500 // Add extrafields cols
1501 if (!empty($object->lines)) {
1502 $line = reset($object->lines);
1503 $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1504 }
1505
1506 $parameters = array(
1507 'object' => $object,
1508 'outputlangs' => $outputlangs,
1509 'hidedetails' => $hidedetails,
1510 'hidedesc' => $hidedesc,
1511 'hideref' => $hideref
1512 );
1513
1514 $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1515 if ($reshook < 0) {
1516 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1517 } elseif (empty($reshook)) {
1518 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
1519 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1520 } else {
1521 $this->cols = $hookmanager->resArray;
1522 }
1523 }
1524}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
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.
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(!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_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
dol_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_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...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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:2731
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:289
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:314
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition pdf.lib.php:1047
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:742
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:266
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:2859
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:439
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:778
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:391
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
Definition repair.php:158
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:161
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.