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