dolibarr 19.0.3
pdf_rouget.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-2023 Frédéric France <frederic.france@netlogic.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 * or see https://www.gnu.org/
21 */
22
29require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
33
34
39{
43 public $db;
44
48 public $name;
49
53 public $description;
54
58 public $update_main_doc_field;
59
63 public $type;
64
69 public $version = 'dolibarr';
70
71 public $posxweightvol;
72 public $posxqtytoship;
73 public $posxqtyordered;
74
75
81 public function __construct(DoliDB $db)
82 {
83 global $conf, $langs, $mysoc;
84
85 $this->db = $db;
86 $this->name = "rouget";
87 $this->description = $langs->trans("DocumentModelStandardPDF").' ('.$langs->trans("OldImplementation").')';
88 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
89
90 $this->type = 'pdf';
91 $formatarray = pdf_getFormat();
92 $this->page_largeur = $formatarray['width'];
93 $this->page_hauteur = $formatarray['height'];
94 $this->format = array($this->page_largeur, $this->page_hauteur);
95 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
96 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
97 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
98 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
99
100 $this->option_logo = 1; // Display logo
101 $this->option_draft_watermark = 1; // Support add of a watermark on drafts
102 $this->watermark = '';
103
104 // Get source company
105 $this->emetteur = $mysoc;
106 if (!$this->emetteur->country_code) {
107 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
108 }
109
110 // Define position of columns
111 $this->posxdesc = $this->marge_gauche + 1;
112 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 82;
113 $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 60;
114 $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28;
115 $this->posxpuht = $this->page_largeur - $this->marge_droite;
116
117 if (getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT')) { // Show also the prices
118 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 118;
119 $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96;
120 $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68;
121 $this->posxpuht = $this->page_largeur - $this->marge_droite - 40;
122 $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
123 }
124
125 if (getDolGlobalString('SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME')) {
126 $this->posxweightvol = $this->posxqtyordered;
127 }
128
129 $this->posxpicture = $this->posxweightvol - (!getDolGlobalString('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
130
131 // To work with US executive format
132 if ($this->page_largeur < 210) {
133 $this->posxweightvol -= 20;
134 $this->posxpicture -= 20;
135 $this->posxqtyordered -= 20;
136 $this->posxqtytoship -= 20;
137 }
138
139 if (getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) {
140 $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
141 $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
142 $this->posxqtyordered = $this->posxqtytoship;
143 }
144 }
145
146 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
158 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
159 {
160 // phpcs:enable
161 global $user, $conf, $langs, $hookmanager;
162
163 $object->fetch_thirdparty();
164
165 if (!is_object($outputlangs)) {
166 $outputlangs = $langs;
167 }
168 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
169 if (getDolGlobalString('MAIN_USE_FPDF')) {
170 $outputlangs->charset_output = 'ISO-8859-1';
171 }
172
173 // Load traductions files required by page
174 $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "other"));
175
176 // Show Draft Watermark
177 if ($object->statut == $object::STATUS_DRAFT && (getDolGlobalString('SHIPPING_DRAFT_WATERMARK'))) {
178 $this->watermark = $conf->global->SHIPPING_DRAFT_WATERMARK;
179 }
180
181 $nblines = count($object->lines);
182
183 // Loop on each lines to detect if there is at least one image to show
184 $realpatharray = array();
185 if (getDolGlobalString('MAIN_GENERATE_SHIPMENT_WITH_PICTURE')) {
186 $objphoto = new Product($this->db);
187
188 for ($i = 0; $i < $nblines; $i++) {
189 if (empty($object->lines[$i]->fk_product)) {
190 continue;
191 }
192
193 $objphoto = new Product($this->db);
194 $objphoto->fetch($object->lines[$i]->fk_product);
195 if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
196 $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
197 $dir = $conf->product->dir_output.'/'.$pdir;
198 } else {
199 $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
200 $dir = $conf->product->dir_output.'/'.$pdir;
201 }
202
203 $realpath = '';
204
205 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
206 if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) {
207 // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
208 if ($obj['photo_vignette']) {
209 $filename = $obj['photo_vignette'];
210 } else {
211 $filename = $obj['photo'];
212 }
213 } else {
214 $filename = $obj['photo'];
215 }
216
217 $realpath = $dir.$filename;
218 break;
219 }
220
221 if ($realpath) {
222 $realpatharray[$i] = $realpath;
223 }
224 }
225 }
226
227 if (count($realpatharray) == 0) {
228 $this->posxpicture = $this->posxweightvol;
229 }
230
231 if ($conf->expedition->dir_output) {
232 // Definition de $dir et $file
233 if ($object->specimen) {
234 $dir = $conf->expedition->dir_output."/sending";
235 $file = $dir."/SPECIMEN.pdf";
236 } else {
237 $expref = dol_sanitizeFileName($object->ref);
238 $dir = $conf->expedition->dir_output."/sending/".$expref;
239 $file = $dir."/".$expref.".pdf";
240 }
241
242 if (!file_exists($dir)) {
243 if (dol_mkdir($dir) < 0) {
244 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
245 return 0;
246 }
247 }
248
249 if (file_exists($dir)) {
250 // Add pdfgeneration hook
251 if (!is_object($hookmanager)) {
252 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
253 $hookmanager = new HookManager($this->db);
254 }
255 $hookmanager->initHooks(array('pdfgeneration'));
256 $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
257 global $action;
258 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
259
260 // Set nblines with the new facture lines content after hook
261 $nblines = count($object->lines);
262
263 $pdf = pdf_getInstance($this->format);
264 $default_font_size = pdf_getPDFFontSize($outputlangs);
265 $heightforinfotot = 8; // Height reserved to output the info and total part
266 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
267 $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
268 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
269 $heightforfooter += 6;
270 }
271 $pdf->SetAutoPageBreak(1, 0);
272
273 if (class_exists('TCPDF')) {
274 $pdf->setPrintHeader(false);
275 $pdf->setPrintFooter(false);
276 }
277 $pdf->SetFont(pdf_getPDFFont($outputlangs));
278 // Set path to the background PDF File
279 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
280 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
281 $tplidx = $pdf->importPage(1);
282 }
283
284 $pdf->Open();
285 $pagenb = 0;
286 $pdf->SetDrawColor(128, 128, 128);
287
288 if (method_exists($pdf, 'AliasNbPages')) {
289 $pdf->AliasNbPages();
290 }
291
292 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
293 $pdf->SetSubject($outputlangs->transnoentities("Shipment"));
294 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
295 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
296 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
297 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
298 $pdf->SetCompression(false);
299 }
300
301 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
302
303 // New page
304 $pdf->AddPage();
305 if (!empty($tplidx)) {
306 $pdf->useTemplate($tplidx);
307 }
308 $pagenb++;
309 $this->_pagehead($pdf, $object, 1, $outputlangs);
310 $pdf->SetFont('', '', $default_font_size - 1);
311 $pdf->MultiCell(0, 3, ''); // Set interline to 3
312 $pdf->SetTextColor(0, 0, 0);
313
314 $tab_top = 90;
315 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
316
317 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
318
319 // Incoterm
320 $height_incoterms = 0;
321 if (isModEnabled('incoterm')) {
322 $desc_incoterms = $object->getIncotermsForPDF();
323 if ($desc_incoterms) {
324 $tab_top -= 2;
325
326 $pdf->SetFont('', '', $default_font_size - 1);
327 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
328 $nexY = $pdf->GetY();
329 $height_incoterms = $nexY - $tab_top;
330
331 // Rect takes a length in 3rd parameter
332 $pdf->SetDrawColor(192, 192, 192);
333 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
334
335 $tab_top = $nexY + 6;
336 $height_incoterms += 4;
337 }
338 }
339
340 if (!empty($object->note_public) || !empty($object->tracking_number)) {
341 $tab_top = 88 + $height_incoterms;
342 $tab_top_alt = $tab_top;
343
344 $pdf->SetFont('', 'B', $default_font_size - 2);
345
346 //$tab_top_alt += 1;
347
348 // Tracking number
349 if (!empty($object->tracking_number)) {
350 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L');
351 $tab_top_alt = $pdf->GetY();
352
353 $object->getUrlTrackingStatus($object->tracking_number);
354 if (!empty($object->tracking_url)) {
355 if ($object->shipping_method_id > 0) {
356 // Get code using getLabelFromKey
357 $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
358 $label = '';
359 if ($object->tracking_url != $object->tracking_number) {
360 $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
361 }
362 $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
363 //var_dump($object->tracking_url != $object->tracking_number);exit;
364 if ($object->tracking_url != $object->tracking_number) {
365 $label .= " : ";
366 $label .= $object->tracking_url;
367 }
368 $pdf->SetFont('', 'B', $default_font_size - 2);
369 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L');
370
371 $tab_top_alt = $pdf->GetY();
372 }
373 }
374 }
375
376 // Notes
377 if (!empty($object->note_public)) {
378 $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page
379 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
380 }
381
382 $nexY = $pdf->GetY();
383 $height_note = $nexY - $tab_top;
384
385 // Rect takes a length in 3rd parameter
386 $pdf->SetDrawColor(192, 192, 192);
387 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
388
389 $tab_height = $tab_height - $height_note;
390 $tab_top = $nexY + 6;
391 } else {
392 $height_note = 0;
393 }
394
395 $iniY = $tab_top + 7;
396 $curY = $tab_top + 7;
397 $nexY = $tab_top + 7;
398
399 // Loop on each lines
400 for ($i = 0; $i < $nblines; $i++) {
401 $curY = $nexY;
402 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
403 $pdf->SetTextColor(0, 0, 0);
404
405 // Define size of image if we need it
406 $imglinesize = array();
407 if (!empty($realpatharray[$i])) {
408 $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
409 }
410
411 $pdf->setTopMargin($tab_top_newpage);
412 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
413 $pageposbefore = $pdf->getPage();
414
415 $showpricebeforepagebreak = 1;
416 $posYAfterImage = 0;
417 $posYAfterDescription = 0;
418
419 // We start with Photo of product line
420 if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
421 $pdf->AddPage('', '', true);
422 if (!empty($tplidx)) {
423 $pdf->useTemplate($tplidx);
424 }
425 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
426 $this->_pagehead($pdf, $object, 0, $outputlangs);
427 }
428 $pdf->setPage($pageposbefore + 1);
429
430 $curY = $tab_top_newpage;
431
432 // Allows data in the first page if description is long enough to break in multiples pages
433 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
434 $showpricebeforepagebreak = 1;
435 } else {
436 $showpricebeforepagebreak = 0;
437 }
438 }
439
440 if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
441 $curX = $this->posxpicture - 1;
442 $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
443 // $pdf->Image does not increase value return by getY, so we save it manually
444 $posYAfterImage = $curY + $imglinesize['height'];
445 }
446
447 // Description of product line
448 $curX = $this->posxdesc - 1;
449
450 $pdf->startTransaction();
451 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
452
453 $pageposafter = $pdf->getPage();
454 if ($pageposafter > $pageposbefore) { // There is a pagebreak
455 $pdf->rollbackTransaction(true);
456 $pageposafter = $pageposbefore;
457 //print $pageposafter.'-'.$pageposbefore;exit;
458 $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
459 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
460
461 $pageposafter = $pdf->getPage();
462 $posyafter = $pdf->GetY();
463 //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
464 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
465 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
466 $pdf->AddPage('', '', true);
467 if (!empty($tplidx)) {
468 $pdf->useTemplate($tplidx);
469 }
470 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
471 $this->_pagehead($pdf, $object, 0, $outputlangs);
472 }
473 $pdf->setPage($pageposafter + 1);
474 }
475 } else {
476 // We found a page break
477
478 // Allows data in the first page if description is long enough to break in multiples pages
479 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
480 $showpricebeforepagebreak = 1;
481 } else {
482 $showpricebeforepagebreak = 0;
483 }
484 }
485 } else { // No pagebreak
486 $pdf->commitTransaction();
487 }
488 $posYAfterDescription = $pdf->GetY();
489
490 $nexY = $pdf->GetY();
491 $pageposafter = $pdf->getPage();
492
493 $pdf->setPage($pageposbefore);
494 $pdf->setTopMargin($this->marge_haute);
495 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
496
497 // We suppose that a too long description or photo were moved completely on next page
498 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
499 $pdf->setPage($pageposafter);
500 $curY = $tab_top_newpage;
501 }
502
503 // We suppose that a too long description is moved completely on next page
504 if ($pageposafter > $pageposbefore) {
505 $pdf->setPage($pageposafter);
506 $curY = $tab_top_newpage;
507 }
508
509 $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
510
511 $pdf->SetXY($this->posxweightvol, $curY);
512 $weighttxt = '';
513 if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->weight) {
514 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
515 }
516 $voltxt = '';
517 if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->volume) {
518 $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
519 }
520
521 if (!getDolGlobalString('SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME')) {
522 $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C');
523 //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
524 }
525
526 if (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) {
527 $pdf->SetXY($this->posxqtyordered, $curY);
528 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
529 }
530
531 if (!getDolGlobalString('SHIPPING_PDF_HIDE_QTYTOSHIP')) {
532 $pdf->SetXY($this->posxqtytoship, $curY);
533 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped, '', 'C');
534 }
535
536 if (getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT')) {
537 $pdf->SetXY($this->posxpuht, $curY);
538 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R');
539
540 $pdf->SetXY($this->posxtotalht, $curY);
541 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R');
542 }
543
544 $nexY += 3;
545 if ($weighttxt && $voltxt) {
546 $nexY += 2;
547 }
548
549 // Add line
550 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
551 $pdf->setPage($pageposafter);
552 $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
553 //$pdf->SetDrawColor(190,190,200);
554 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
555 $pdf->SetLineStyle(array('dash'=>0));
556 }
557
558 // Detect if some page were added automatically and output _tableau for past pages
559 while ($pagenb < $pageposafter) {
560 $pdf->setPage($pagenb);
561 if ($pagenb == 1) {
562 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
563 } else {
564 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
565 }
566 $this->_pagefoot($pdf, $object, $outputlangs, 1);
567 $pagenb++;
568 $pdf->setPage($pagenb);
569 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
570 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
571 $this->_pagehead($pdf, $object, 0, $outputlangs);
572 }
573 if (!empty($tplidx)) {
574 $pdf->useTemplate($tplidx);
575 }
576 }
577 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
578 if ($pagenb == 1) {
579 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
580 } else {
581 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
582 }
583 $this->_pagefoot($pdf, $object, $outputlangs, 1);
584 // New page
585 $pdf->AddPage();
586 if (!empty($tplidx)) {
587 $pdf->useTemplate($tplidx);
588 }
589 $pagenb++;
590 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
591 $this->_pagehead($pdf, $object, 0, $outputlangs);
592 }
593 }
594 }
595
596 // Show square
597 if ($pagenb == 1) {
598 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
599 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
600 } else {
601 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
602 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
603 }
604
605 // Affiche zone totaux
606 $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
607
608 // Pied de page
609 $this->_pagefoot($pdf, $object, $outputlangs);
610 if (method_exists($pdf, 'AliasNbPages')) {
611 $pdf->AliasNbPages();
612 }
613
614 $pdf->Close();
615
616 $pdf->Output($file, 'F');
617
618 // Add pdfgeneration hook
619 $hookmanager->initHooks(array('pdfgeneration'));
620 $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
621 global $action;
622 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
623 if ($reshook < 0) {
624 $this->error = $hookmanager->error;
625 $this->errors = $hookmanager->errors;
626 }
627
628 dolChmod($file);
629
630 $this->result = array('fullpath'=>$file);
631
632 return 1; // No error
633 } else {
634 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
635 return 0;
636 }
637 } else {
638 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
639 return 0;
640 }
641 }
642
643 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
644 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
655 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
656 {
657 // phpcs:enable
658 global $conf, $mysoc;
659
660 $sign = 1;
661
662 $default_font_size = pdf_getPDFFontSize($outputlangs);
663
664 $tab2_top = $posy;
665 $tab2_hl = 4;
666 $pdf->SetFont('', 'B', $default_font_size - 1);
667
668 // Tableau total
669 $col1x = $this->posxweightvol - 50;
670 $col2x = $this->posxweightvol;
671 /*if ($this->page_largeur < 210) // To work with US executive format
672 {
673 $col2x-=20;
674 }*/
675 if (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) {
676 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
677 } else {
678 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
679 }
680
681 $useborder = 0;
682 $index = 0;
683
684 $totalWeighttoshow = '';
685 $totalVolumetoshow = '';
686
687 // Load dim data
688 $tmparray = $object->getTotalWeightVolume();
689 $totalWeight = $tmparray['weight'];
690 $totalVolume = $tmparray['volume'];
691 $totalOrdered = $tmparray['ordered'];
692 $totalToShip = $tmparray['toship'];
693 // Set trueVolume and volume_units not currently stored into database
694 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
695 $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
696 $object->volume_units = $object->size_units * 3;
697 }
698
699 if (!empty($totalWeight)) {
700 $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
701 }
702 if (!empty($totalVolume)) {
703 $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
704 }
705 if (!empty($object->trueWeight)) {
706 $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
707 }
708 if (!empty($object->trueVolume)) {
709 $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
710 }
711
712 $pdf->SetFillColor(255, 255, 255);
713 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
714 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
715
716 if (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) {
717 $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
718 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
719 }
720
721 if (!getDolGlobalString('SHIPPING_PDF_HIDE_QTYTOSHIP')) {
722 $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
723 $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
724 }
725
726 if (getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT')) {
727 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
728 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
729
730 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
731 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
732 }
733
734 if (!getDolGlobalString('SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME')) {
735 // Total Weight
736 if ($totalWeighttoshow) {
737 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
738 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
739
740 $index++;
741 }
742 if ($totalVolumetoshow) {
743 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
744 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
745
746 $index++;
747 }
748 if (!$totalWeighttoshow && !$totalVolumetoshow) {
749 $index++;
750 }
751 }
752
753 $pdf->SetTextColor(0, 0, 0);
754
755 return ($tab2_top + ($tab2_hl * $index));
756 }
757
758 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
771 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
772 {
773 global $conf;
774
775 // Force to disable hidetop and hidebottom
776 $hidebottom = 0;
777 if ($hidetop) {
778 $hidetop = -1;
779 }
780
781 $default_font_size = pdf_getPDFFontSize($outputlangs);
782
783 // Amount in (at tab_top - 1)
784 $pdf->SetTextColor(0, 0, 0);
785 $pdf->SetFont('', '', $default_font_size - 2);
786
787 // Output Rect
788 $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
789
790 $pdf->SetDrawColor(128, 128, 128);
791 $pdf->SetFont('', '', $default_font_size - 1);
792
793 if (empty($hidetop)) {
794 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
795
796 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
797 $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
798 }
799
800 if (!getDolGlobalString('SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME')) {
801 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
802 if (empty($hidetop)) {
803 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
804 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
805 }
806 }
807
808 if (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) {
809 $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
810 if (empty($hidetop)) {
811 $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
812 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
813 }
814 }
815
816 if (!getDolGlobalString('SHIPPING_PDF_HIDE_QTYTOSHIP')) {
817 $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
818 if (empty($hidetop)) {
819 $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
820 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"), '', 'C');
821 }
822 }
823
824 if (getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT')) {
825 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
826 if (empty($hidetop)) {
827 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
828 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
829 }
830
831 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
832 if (empty($hidetop)) {
833 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
834 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
835 }
836 }
837 }
838
839 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
849 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
850 {
851 global $conf, $langs, $mysoc;
852
853 $langs->load("orders");
854
855 $default_font_size = pdf_getPDFFontSize($outputlangs);
856
857 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
858
859 //Prepare la suite
860 $pdf->SetTextColor(0, 0, 60);
861 $pdf->SetFont('', 'B', $default_font_size + 3);
862
863 $w = 110;
864
865 $posy = $this->marge_haute;
866 $posx = $this->page_largeur - $this->marge_droite - $w;
867
868 $pdf->SetXY($this->marge_gauche, $posy);
869
870 // Logo
871 if ($this->emetteur->logo) {
872 $logodir = $conf->mycompany->dir_output;
873 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
874 $logodir = $conf->mycompany->multidir_output[$object->entity];
875 }
876 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
877 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
878 } else {
879 $logo = $logodir.'/logos/'.$this->emetteur->logo;
880 }
881 if (is_readable($logo)) {
882 $height = pdf_getHeightForLogo($logo);
883 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
884 } else {
885 $pdf->SetTextColor(200, 0, 0);
886 $pdf->SetFont('', 'B', $default_font_size - 2);
887 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
888 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
889 }
890 } else {
891 $text = $this->emetteur->name;
892 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
893 }
894
895 // Show barcode
896 if (isModEnabled('barcode')) {
897 $posx = 105;
898 } else {
899 $posx = $this->marge_gauche + 3;
900 }
901 //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
902 if (isModEnabled('barcode')) {
903 // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
904 //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
905 //$pdf->Image($logo,10, 5, 0, 24);
906 }
907
908 $pdf->SetDrawColor(128, 128, 128);
909
910 $posx = $this->page_largeur - $w - $this->marge_droite;
911 $posy = $this->marge_haute;
912
913 $pdf->SetFont('', 'B', $default_font_size + 2);
914 $pdf->SetXY($posx, $posy);
915 $pdf->SetTextColor(0, 0, 60);
916 $title = $outputlangs->transnoentities("SendingSheet");
917 $pdf->MultiCell($w, 4, $title, '', 'R');
918
919 $pdf->SetFont('', '', $default_font_size + 1);
920
921 $posy += 5;
922
923 $pdf->SetXY($posx, $posy);
924 $pdf->SetTextColor(0, 0, 60);
925 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R');
926
927 // Date planned delivery
928 if (!empty($object->date_delivery)) {
929 $posy += 4;
930 $pdf->SetXY($posx, $posy);
931 $pdf->SetTextColor(0, 0, 60);
932 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
933 }
934
935 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) {
936 $posy += 4;
937 $pdf->SetXY($posx, $posy);
938 $pdf->SetTextColor(0, 0, 60);
939 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
940 }
941
942
943 $pdf->SetFont('', '', $default_font_size + 3);
944 $Yoff = 25;
945
946 // Add list of linked orders
947 $origin = $object->origin;
948 $origin_id = $object->origin_id;
949
950 // TODO move to external function
951 if (!empty($conf->$origin->enabled)) { // commonly $origin='commande'
952 $outputlangs->load('orders');
953
954 $classname = ucfirst($origin);
955 $linkedobject = new $classname($this->db);
956 $result = $linkedobject->fetch($origin_id);
957 if ($result >= 0) {
958 //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
959
960 $pdf->SetFont('', '', $default_font_size - 2);
961 $text = $linkedobject->ref;
962 if ($linkedobject->ref_client) {
963 $text .= ' ('.$linkedobject->ref_client.')';
964 }
965 $Yoff = $Yoff + 8;
966 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
967 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
968 $Yoff = $Yoff + 3;
969 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
970 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
971 }
972 }
973
974 $top_shift = 0;
975 // Show list of linked objects
976 /*
977 $current_y = $pdf->getY();
978 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
979 if ($current_y < $pdf->getY()) {
980 $top_shift = $pdf->getY() - $current_y;
981 }
982 */
983
984 if ($showaddress) {
985 // Sender properties
986 $carac_emetteur = '';
987 // Add internal contact of origin element if defined
988 $arrayidcontact = array();
989 if (!empty($origin) && is_object($object->$origin)) {
990 $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL');
991 }
992 if (count($arrayidcontact) > 0) {
993 $object->fetch_user(reset($arrayidcontact));
994 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
995 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
996 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
997 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
998 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
999 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
1000 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
1001 $carac_emetteur .= "\n";
1002 }
1003
1004 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1005
1006 // Show sender
1007 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1008 $posx = $this->marge_gauche;
1009 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1010 $posx = $this->page_largeur - $this->marge_droite - 80;
1011 }
1012
1013 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
1014 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1015
1016 // Show sender frame
1017 if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
1018 $pdf->SetTextColor(0, 0, 0);
1019 $pdf->SetFont('', '', $default_font_size - 2);
1020 $pdf->SetXY($posx, $posy - 5);
1021 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender"), 0, 'L');
1022 $pdf->SetXY($posx, $posy);
1023 $pdf->SetFillColor(230, 230, 230);
1024 $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1025 $pdf->SetTextColor(0, 0, 60);
1026 $pdf->SetFillColor(255, 255, 255);
1027 }
1028
1029 // Show sender name
1030 if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
1031 $pdf->SetXY($posx + 2, $posy + 3);
1032 $pdf->SetFont('', 'B', $default_font_size);
1033 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1034 $posy = $pdf->getY();
1035 }
1036
1037 // Show sender information
1038 $pdf->SetXY($posx + 2, $posy);
1039 $pdf->SetFont('', '', $default_font_size - 1);
1040 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
1041
1042
1043 // If SHIPPING contact defined, we use it
1044 $usecontact = false;
1045 $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
1046 if (count($arrayidcontact) > 0) {
1047 $usecontact = true;
1048 $result = $object->fetch_contact($arrayidcontact[0]);
1049 }
1050
1051 // Recipient name
1052 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1053 $thirdparty = $object->contact;
1054 } else {
1055 $thirdparty = $object->thirdparty;
1056 }
1057
1058 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1059
1060 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
1061
1062 // Show recipient
1063 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1064 if ($this->page_largeur < 210) {
1065 $widthrecbox = 84; // To work with US executive format
1066 }
1067 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1068 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1069 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1070 $posx = $this->marge_gauche;
1071 }
1072
1073 // Show recipient frame
1074 if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
1075 $pdf->SetTextColor(0, 0, 0);
1076 $pdf->SetFont('', '', $default_font_size - 2);
1077 $pdf->SetXY($posx + 2, $posy - 5);
1078 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, 'L');
1079 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1080 }
1081
1082 // Show recipient name
1083 $pdf->SetXY($posx + 2, $posy + 3);
1084 $pdf->SetFont('', 'B', $default_font_size);
1085 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1086
1087 $posy = $pdf->getY();
1088
1089 // Show recipient information
1090 $pdf->SetFont('', '', $default_font_size - 1);
1091 $pdf->SetXY($posx + 2, $posy);
1092 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1093 }
1094
1095 $pdf->SetTextColor(0, 0, 0);
1096 return $top_shift;
1097 }
1098
1099 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1109 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1110 {
1111 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1112 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);
1113 }
1114}
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Class to manage Dolibarr database access.
Class to manage hooks.
Parent class of sending receipts models.
Class to manage products or services.
Class to build sending documents with model Rouget.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
__construct(DoliDB $db)
Constructor.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return 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_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition pdf.lib.php:2611
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:289
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:85
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
Definition pdf.lib.php:1422
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:1014
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:726
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:266
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formated for output on documents.
Definition pdf.lib.php:435
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:127
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:387
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:121
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124