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