dolibarr  13.0.2
pdf_espadon.modules.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
6  * Copyright (C) 2018-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 
33 
38 {
42  public $db;
43 
47  public $name;
48 
52  public $description;
53 
57  public $type;
58 
63  public $phpmin = array(5, 6);
64 
69  public $version = 'dolibarr';
70 
74  public $page_largeur;
75 
79  public $page_hauteur;
80 
84  public $format;
85 
89  public $marge_gauche;
90 
94  public $marge_droite;
95 
99  public $marge_haute;
100 
104  public $marge_basse;
105 
110  public $emetteur;
111 
112 
118  public function __construct($db = 0)
119  {
120  global $conf, $langs, $mysoc;
121 
122  $this->db = $db;
123  $this->name = "espadon";
124  $this->description = $langs->trans("DocumentModelStandardPDF");
125 
126  $this->type = 'pdf';
127  $formatarray = pdf_getFormat();
128  $this->page_largeur = $formatarray['width'];
129  $this->page_hauteur = $formatarray['height'];
130  $this->format = array($this->page_largeur, $this->page_hauteur);
131  $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
132  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
133  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
134  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
135 
136  $this->option_logo = 1;
137 
138  // Get source company
139  $this->emetteur = $mysoc;
140  if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
141 
142  $this->tabTitleHeight = 5; // default height
143  }
144 
145  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
157  public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
158  {
159  // phpcs:enable
160  global $user, $conf, $langs, $hookmanager;
161 
162  $object->fetch_thirdparty();
163 
164  if (!is_object($outputlangs)) $outputlangs = $langs;
165  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
166  if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
167 
168  // Load traductions files required by page
169  $outputlangs->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
170 
171  global $outputlangsbis;
172  $outputlangsbis = null;
173  if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
174  $outputlangsbis = new Translate('', $conf);
175  $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
176  $outputlangsbis->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
177  }
178 
179  $nblines = count($object->lines);
180 
181  // Loop on each lines to detect if there is at least one image to show
182  $realpatharray = array();
183  $this->atleastonephoto = false;
184  if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
185  {
186  $objphoto = new Product($this->db);
187 
188  for ($i = 0; $i < $nblines; $i++)
189  {
190  if (empty($object->lines[$i]->fk_product)) continue;
191 
192  $objphoto = new Product($this->db);
193  $objphoto->fetch($object->lines[$i]->fk_product);
194 
195  if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
196  {
197  $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
198  $dir = $conf->product->dir_output.'/'.$pdir;
199  } else {
200  $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
201  $dir = $conf->product->dir_output.'/'.$pdir;
202  }
203 
204  $realpath = '';
205 
206  foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
207  {
208  if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
209  {
210  if ($obj['photo_vignette'])
211  {
212  $filename = $obj['photo_vignette'];
213  } else {
214  $filename = $obj['photo'];
215  }
216  } else {
217  $filename = $obj['photo'];
218  }
219 
220  $realpath = $dir.$filename;
221  $this->atleastonephoto = true;
222  break;
223  }
224 
225  if ($realpath) $realpatharray[$i] = $realpath;
226  }
227  }
228 
229  if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
230 
231  if ($conf->expedition->dir_output)
232  {
233  // Definition of $dir and $file
234  if ($object->specimen)
235  {
236  $dir = $conf->expedition->dir_output."/sending";
237  $file = $dir."/SPECIMEN.pdf";
238  } else {
239  $expref = dol_sanitizeFileName($object->ref);
240  $dir = $conf->expedition->dir_output."/sending/".$expref;
241  $file = $dir."/".$expref.".pdf";
242  }
243 
244  if (!file_exists($dir))
245  {
246  if (dol_mkdir($dir) < 0)
247  {
248  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
249  return 0;
250  }
251  }
252 
253  if (file_exists($dir))
254  {
255  // Add pdfgeneration hook
256  if (!is_object($hookmanager))
257  {
258  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
259  $hookmanager = new HookManager($this->db);
260  }
261  $hookmanager->initHooks(array('pdfgeneration'));
262  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
263  global $action;
264  $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
265 
266  // Set nblines with the new facture lines content after hook
267  $nblines = count($object->lines);
268 
269  $pdf = pdf_getInstance($this->format);
270  $default_font_size = pdf_getPDFFontSize($outputlangs);
271  $heightforinfotot = 8; // Height reserved to output the info and total part
272  $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
273  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
274  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;
275  $pdf->SetAutoPageBreak(1, 0);
276 
277  if (class_exists('TCPDF'))
278  {
279  $pdf->setPrintHeader(false);
280  $pdf->setPrintFooter(false);
281  }
282  $pdf->SetFont(pdf_getPDFFont($outputlangs));
283  // Set path to the background PDF File
284  if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
285  {
286  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
287  $tplidx = $pdf->importPage(1);
288  }
289 
290  $pdf->Open();
291  $pagenb = 0;
292  $pdf->SetDrawColor(128, 128, 128);
293 
294  if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
295 
296  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
297  $pdf->SetSubject($outputlangs->transnoentities("Shipment"));
298  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
299  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
300  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
301  if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
302 
303  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
304 
305  // New page
306  $pdf->AddPage();
307  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
308  $pagenb++;
309  $this->_pagehead($pdf, $object, 1, $outputlangs);
310  $pdf->SetFont('', '', $default_font_size - 1);
311  $pdf->MultiCell(0, 3, ''); // Set interline to 3
312  $pdf->SetTextColor(0, 0, 0);
313 
314  $tab_top = 90;
315  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
316  $tab_height = 130;
317  $tab_height_newpage = 150;
318 
319  $this->posxdesc = $this->marge_gauche + 1;
320 
321  // Incoterm
322  $height_incoterms = 0;
323  if (!empty($conf->incoterm->enabled))
324  {
325  $desc_incoterms = $object->getIncotermsForPDF();
326  if ($desc_incoterms)
327  {
328  $tab_top = 88;
329 
330  $pdf->SetFont('', '', $default_font_size - 1);
331  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
332  $nexY = $pdf->GetY();
333  $height_incoterms = $nexY - $tab_top;
334 
335  // Rect takes a length in 3rd parameter
336  $pdf->SetDrawColor(192, 192, 192);
337  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
338 
339  $tab_top = $nexY + 6;
340  $height_incoterms += 4;
341  }
342  }
343 
344  // display note
345  $notetoshow = empty($object->note_public) ? '' : $object->note_public;
346 
347  // Extrafields in note
348  $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
349  if (!empty($extranote))
350  {
351  $notetoshow = dol_concatdesc($notetoshow, $extranote);
352  }
353 
354  if (!empty($notetoshow) || !empty($object->tracking_number))
355  {
356  $tab_top = 88 + $height_incoterms;
357  $tab_top_alt = $tab_top;
358 
359  $pdf->SetFont('', 'B', $default_font_size - 2);
360  $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L');
361 
362  $tab_top_alt = $pdf->GetY();
363  //$tab_top_alt += 1;
364 
365  // Tracking number
366  if (!empty($object->tracking_number))
367  {
368  $object->getUrlTrackingStatus($object->tracking_number);
369  if (!empty($object->tracking_url))
370  {
371  if ($object->shipping_method_id > 0)
372  {
373  // Get code using getLabelFromKey
374  $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
375  $label = '';
376  if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
377  $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
378  //var_dump($object->tracking_url != $object->tracking_number);exit;
379  if ($object->tracking_url != $object->tracking_number)
380  {
381  $label .= " : ";
382  $label .= $object->tracking_url;
383  }
384  $pdf->SetFont('', 'B', $default_font_size - 2);
385  $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L');
386 
387  $tab_top_alt = $pdf->GetY();
388  }
389  }
390  }
391 
392  // Notes
393  if (!empty($notetoshow))
394  {
395  $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page
396  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($notetoshow), 0, 1);
397  }
398 
399  $nexY = $pdf->GetY();
400  $height_note = $nexY - $tab_top;
401 
402  // Rect takes a length in 3rd parameter
403  $pdf->SetDrawColor(192, 192, 192);
404  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
405 
406  $tab_height = $tab_height - $height_note;
407  $tab_top = $nexY + 6;
408  } else {
409  $height_note = 0;
410  }
411 
412 
413  // Use new auto column system
414  $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
415 
416  // Table simulation to know the height of the title line
417  $pdf->startTransaction();
418  $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
419  $pdf->rollbackTransaction(true);
420 
421 
422  $nexY = $tab_top + $this->tabTitleHeight;
423 
424  // Loop on each lines
425  for ($i = 0; $i < $nblines; $i++)
426  {
427  $curY = $nexY;
428  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
429  $pdf->SetTextColor(0, 0, 0);
430 
431  // Define size of image if we need it
432  $imglinesize = array();
433  if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
434 
435  $pdf->setTopMargin($tab_top_newpage);
436  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
437  $pageposbefore = $pdf->getPage();
438 
439  $showpricebeforepagebreak = 1;
440  $posYAfterImage = 0;
441  $posYAfterDescription = 0;
442 
443  if ($this->getColumnStatus('photo'))
444  {
445  // We start with Photo of product line
446  if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page
447  {
448  $pdf->AddPage('', '', true);
449  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
450  //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
451  $pdf->setPage($pageposbefore + 1);
452 
453  $curY = $tab_top_newpage;
454 
455  // Allows data in the first page if description is long enough to break in multiples pages
456  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
457  $showpricebeforepagebreak = 1;
458  else $showpricebeforepagebreak = 0;
459  }
460 
461 
462  if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
463  {
464  $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
465  // $pdf->Image does not increase value return by getY, so we save it manually
466  $posYAfterImage = $curY + $imglinesize['height'];
467  }
468  }
469 
470  // Description of product line
471  if ($this->getColumnStatus('desc'))
472  {
473  $pdf->startTransaction();
474 
475  $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
476 
477  $pageposafter = $pdf->getPage();
478  if ($pageposafter > $pageposbefore) // There is a pagebreak
479  {
480  $pdf->rollbackTransaction(true);
481 
482  $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
483 
484  $pageposafter = $pdf->getPage();
485  $posyafter = $pdf->GetY();
486  //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
487  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // There is no space left for total+free text
488  {
489  if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
490  {
491  $pdf->AddPage('', '', true);
492  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
493  //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
494  $pdf->setPage($pageposafter + 1);
495  }
496  } else {
497  // We found a page break
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 
510  $nexY = $pdf->GetY();
511  $pageposafter = $pdf->getPage();
512 
513  $pdf->setPage($pageposbefore);
514  $pdf->setTopMargin($this->marge_haute);
515  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
516 
517  // We suppose that a too long description or photo were moved completely on next page
518  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
519  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
520  }
521 
522  // We suppose that a too long description is moved completely on next page
523  if ($pageposafter > $pageposbefore) {
524  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
525  }
526 
527  $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
528 
529  // weight
530 
531  $weighttxt = '';
532  if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
533  {
534  $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
535  }
536  $voltxt = '';
537  if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
538  {
539  $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);
540  }
541 
542 
543  if ($this->getColumnStatus('weight'))
544  {
545  $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, array('html'=>1));
546  $nexY = max($pdf->GetY(), $nexY);
547  }
548 
549  if ($this->getColumnStatus('qty_asked'))
550  {
551  $this->printStdColumnContent($pdf, $curY, 'qty_asked', $object->lines[$i]->qty_asked);
552  $nexY = max($pdf->GetY(), $nexY);
553  }
554 
555  if ($this->getColumnStatus('qty_shipped'))
556  {
557  $this->printStdColumnContent($pdf, $curY, 'qty_shipped', $object->lines[$i]->qty_shipped);
558  $nexY = max($pdf->GetY(), $nexY);
559  }
560 
561  if ($this->getColumnStatus('subprice'))
562  {
563  $this->printStdColumnContent($pdf, $curY, 'subprice', price($object->lines[$i]->subprice, 0, $outputlangs));
564  $nexY = max($pdf->GetY(), $nexY);
565  }
566 
567  // Extrafields
568  if (!empty($object->lines[$i]->array_options)) {
569  foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
570  if ($this->getColumnStatus($extrafieldColKey))
571  {
572  $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
573  $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
574  $nexY = max($pdf->GetY(), $nexY);
575  }
576  }
577  }
578 
579  // Add line
580  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
581  {
582  $pdf->setPage($pageposafter);
583  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
584  //$pdf->SetDrawColor(190,190,200);
585  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
586  $pdf->SetLineStyle(array('dash'=>0));
587  }
588 
589  // Detect if some page were added automatically and output _tableau for past pages
590  while ($pagenb < $pageposafter)
591  {
592  $pdf->setPage($pagenb);
593  if ($pagenb == 1)
594  {
595  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
596  } else {
597  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
598  }
599  $this->_pagefoot($pdf, $object, $outputlangs, 1);
600  $pagenb++;
601  $pdf->setPage($pagenb);
602  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
603  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
604  }
605  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
606  {
607  if ($pagenb == 1)
608  {
609  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
610  } else {
611  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
612  }
613  $this->_pagefoot($pdf, $object, $outputlangs, 1);
614  // New page
615  $pdf->AddPage();
616  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
617  $pagenb++;
618  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
619  }
620  }
621 
622  // Show square
623  if ($pagenb == 1)
624  {
625  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
626  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
627  } else {
628  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
629  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
630  }
631 
632  // Display total area
633  $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
634 
635  // Pagefoot
636  $this->_pagefoot($pdf, $object, $outputlangs);
637  if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
638 
639  $pdf->Close();
640 
641  $pdf->Output($file, 'F');
642 
643  // Add pdfgeneration hook
644  $hookmanager->initHooks(array('pdfgeneration'));
645  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
646  global $action;
647  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
648  if ($reshook < 0)
649  {
650  $this->error = $hookmanager->error;
651  $this->errors = $hookmanager->errors;
652  }
653 
654  if (!empty($conf->global->MAIN_UMASK))
655  @chmod($file, octdec($conf->global->MAIN_UMASK));
656 
657  $this->result = array('fullpath'=>$file);
658 
659  return 1; // No error
660  } else {
661  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
662  return 0;
663  }
664  } else {
665  $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
666  return 0;
667  }
668  }
669 
670  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
671  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
682  protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
683  {
684  // phpcs:enable
685  global $conf, $mysoc;
686 
687  $sign = 1;
688 
689  $default_font_size = pdf_getPDFFontSize($outputlangs);
690 
691  $tab2_top = $posy;
692  $tab2_hl = 4;
693  $pdf->SetFont('', 'B', $default_font_size - 1);
694 
695  // Total table
696  $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol;
697  /*if ($this->page_largeur < 210) // To work with US executive format
698  {
699  $col2x-=20;
700  }*/
701  if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
702  else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
703 
704  $useborder = 0;
705  $index = 0;
706 
707  $totalWeighttoshow = '';
708  $totalVolumetoshow = '';
709 
710  // Load dim data
711  $tmparray = $object->getTotalWeightVolume();
712  $totalWeight = $tmparray['weight'];
713  $totalVolume = $tmparray['volume'];
714  $totalOrdered = $tmparray['ordered'];
715  $totalToShip = $tmparray['toship'];
716  // Set trueVolume and volume_units not currently stored into database
717  if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
718  {
719  $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
720  $object->volume_units = $object->size_units * 3;
721  }
722 
723  if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
724  if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
725  if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
726  if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
727 
728 
729 
730 
731  if ($this->getColumnStatus('desc'))
732  {
733  $this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total"));
734  }
735 
736 
737  if ($this->getColumnStatus('weight'))
738  {
739  if ($totalWeighttoshow)
740  {
741  $this->printStdColumnContent($pdf, $tab2_top, 'weight', $totalWeighttoshow);
742  $index++;
743  }
744 
745  if ($totalVolumetoshow)
746  {
747  $y = $tab2_top + ($tab2_hl * $index);
748  $this->printStdColumnContent($pdf, $y, 'weight', $totalVolumetoshow);
749  }
750  }
751 
752  if ($this->getColumnStatus('qty_asked') && $totalOrdered)
753  {
754  $this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', $totalOrdered);
755  }
756 
757  if ($this->getColumnStatus('qty_shipped') && $totalToShip)
758  {
759  $this->printStdColumnContent($pdf, $tab2_top, 'qty_shipped', $totalToShip);
760  }
761 
762  if ($this->getColumnStatus('subprice'))
763  {
764  $this->printStdColumnContent($pdf, $tab2_top, 'subprice', price($object->total_ht, 0, $outputlangs));
765  }
766 
767  $pdf->SetTextColor(0, 0, 0);
768 
769  return ($tab2_top + ($tab2_hl * $index));
770  }
771 
772  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
785  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
786  {
787  global $conf;
788 
789  // Force to disable hidetop and hidebottom
790  $hidebottom = 0;
791  if ($hidetop) $hidetop = -1;
792 
793  $currency = !empty($currency) ? $currency : $conf->currency;
794  $default_font_size = pdf_getPDFFontSize($outputlangs);
795 
796  // Amount in (at tab_top - 1)
797  $pdf->SetTextColor(0, 0, 0);
798  $pdf->SetFont('', '', $default_font_size - 2);
799 
800  if (empty($hidetop))
801  {
802  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
803  if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
804  $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
805  }
806  }
807 
808  $pdf->SetDrawColor(128, 128, 128);
809  $pdf->SetFont('', '', $default_font_size - 1);
810 
811  // Output Rect
812  $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
813 
814 
815  $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
816 
817  if (empty($hidetop)) {
818  $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
819  }
820  }
821 
822  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
832  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
833  {
834  global $conf, $langs, $mysoc;
835 
836  $langs->load("orders");
837 
838  $default_font_size = pdf_getPDFFontSize($outputlangs);
839 
840  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
841 
842  // Show Draft Watermark
843  if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK)))
844  {
845  pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
846  }
847 
848  //Prepare next
849  $pdf->SetTextColor(0, 0, 60);
850  $pdf->SetFont('', 'B', $default_font_size + 3);
851 
852  $w = 110;
853 
854  $posy = $this->marge_haute;
855  $posx = $this->page_largeur - $this->marge_droite - $w;
856 
857  $pdf->SetXY($this->marge_gauche, $posy);
858 
859  // Logo
860  $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
861  if ($this->emetteur->logo)
862  {
863  if (is_readable($logo))
864  {
865  $height = pdf_getHeightForLogo($logo);
866  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
867  } else {
868  $pdf->SetTextColor(200, 0, 0);
869  $pdf->SetFont('', 'B', $default_font_size - 2);
870  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
871  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
872  }
873  } else {
874  $text = $this->emetteur->name;
875  $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
876  }
877 
878  // Show barcode
879  if (!empty($conf->barcode->enabled))
880  {
881  $posx = 105;
882  } else {
883  $posx = $this->marge_gauche + 3;
884  }
885  //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
886  if (!empty($conf->barcode->enabled))
887  {
888  // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
889  //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
890  //$pdf->Image($logo,10, 5, 0, 24);
891  }
892 
893  $pdf->SetDrawColor(128, 128, 128);
894  if (!empty($conf->barcode->enabled))
895  {
896  // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
897  //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
898  //$pdf->Image($logo,10, 5, 0, 24);
899  }
900 
901 
902  $posx = $this->page_largeur - $w - $this->marge_droite;
903  $posy = $this->marge_haute;
904 
905  $pdf->SetFont('', 'B', $default_font_size + 2);
906  $pdf->SetXY($posx, $posy);
907  $pdf->SetTextColor(0, 0, 60);
908  $title = $outputlangs->transnoentities("SendingSheet");
909  $pdf->MultiCell($w, 4, $title, '', 'R');
910 
911  $pdf->SetFont('', '', $default_font_size + 1);
912 
913  $posy += 5;
914 
915  $pdf->SetXY($posx, $posy);
916  $pdf->SetTextColor(0, 0, 60);
917  $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R');
918 
919  // Date planned delivery
920  if (!empty($object->date_delivery))
921  {
922  $posy += 4;
923  $pdf->SetXY($posx, $posy);
924  $pdf->SetTextColor(0, 0, 60);
925  $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
926  }
927 
928  if (!empty($object->thirdparty->code_client))
929  {
930  $posy += 4;
931  $pdf->SetXY($posx, $posy);
932  $pdf->SetTextColor(0, 0, 60);
933  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
934  }
935 
936 
937  $pdf->SetFont('', '', $default_font_size + 3);
938  $Yoff = 25;
939 
940  // Add list of linked orders
941  $origin = $object->origin;
942  $origin_id = $object->origin_id;
943 
944  // TODO move to external function
945  if (!empty($conf->$origin->enabled)) // commonly $origin='commande'
946  {
947  $outputlangs->load('orders');
948 
949  $classname = ucfirst($origin);
950  $linkedobject = new $classname($this->db);
951  $result = $linkedobject->fetch($origin_id);
952  if ($result >= 0)
953  {
954  //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
955 
956  $pdf->SetFont('', '', $default_font_size - 2);
957  $text = $linkedobject->ref;
958  if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')';
959  $Yoff = $Yoff + 8;
960  $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
961  $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
962  $Yoff = $Yoff + 3;
963  $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
964  $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
965  }
966  }
967 
968  if ($showaddress)
969  {
970  // Sender properties
971  $carac_emetteur = '';
972  // Add internal contact of origin element if defined
973  $arrayidcontact = array();
974  if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL');
975  if (is_array($arrayidcontact) && count($arrayidcontact) > 0)
976  {
977  $object->fetch_user(reset($arrayidcontact));
978  $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
979  }
980 
981  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
982 
983  // Show sender
984  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
985  $posx = $this->marge_gauche;
986  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
987 
988  $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
989  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
990 
991  // Show sender frame
992  $pdf->SetTextColor(0, 0, 0);
993  $pdf->SetFont('', '', $default_font_size - 2);
994  $pdf->SetXY($posx, $posy - 5);
995  $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
996  $pdf->SetXY($posx, $posy);
997  $pdf->SetFillColor(230, 230, 230);
998  $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
999  $pdf->SetTextColor(0, 0, 60);
1000  $pdf->SetFillColor(255, 255, 255);
1001 
1002  // Show sender name
1003  $pdf->SetXY($posx + 2, $posy + 3);
1004  $pdf->SetFont('', 'B', $default_font_size);
1005  $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1006  $posy = $pdf->getY();
1007 
1008  // Show sender information
1009  $pdf->SetXY($posx + 2, $posy);
1010  $pdf->SetFont('', '', $default_font_size - 1);
1011  $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
1012 
1013 
1014  // If SHIPPING contact defined, we use it
1015  $usecontact = false;
1016  $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
1017  if (count($arrayidcontact) > 0)
1018  {
1019  $usecontact = true;
1020  $result = $object->fetch_contact($arrayidcontact[0]);
1021  }
1022 
1023  // Recipient name
1024  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)))) {
1025  $thirdparty = $object->contact;
1026  } else {
1027  $thirdparty = $object->thirdparty;
1028  }
1029 
1030  $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1031 
1032  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
1033 
1034  // Show recipient
1035  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1036  if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1037  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1038  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1039  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1040 
1041  // Show recipient frame
1042  $pdf->SetTextColor(0, 0, 0);
1043  $pdf->SetFont('', '', $default_font_size - 2);
1044  $pdf->SetXY($posx + 2, $posy - 5);
1045  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1046  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1047 
1048  // Show recipient name
1049  $pdf->SetXY($posx + 2, $posy + 3);
1050  $pdf->SetFont('', 'B', $default_font_size);
1051  $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1052 
1053  $posy = $pdf->getY();
1054 
1055  // Show recipient information
1056  $pdf->SetFont('', '', $default_font_size - 1);
1057  $pdf->SetXY($posx + 2, $posy);
1058  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1059  }
1060 
1061  $pdf->SetTextColor(0, 0, 0);
1062  }
1063 
1064  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1074  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1075  {
1076  global $conf;
1077  $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1078  return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1079  }
1080 
1091  public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1092  {
1093  global $conf, $hookmanager;
1094 
1095  // Default field style for content
1096  $this->defaultContentsFieldsStyle = array(
1097  'align' => 'R', // R,C,L
1098  'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1099  );
1100 
1101  // Default field style for content
1102  $this->defaultTitlesFieldsStyle = array(
1103  'align' => 'C', // R,C,L
1104  'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1105  );
1106 
1107  /*
1108  * For exemple
1109  $this->cols['theColKey'] = array(
1110  'rank' => $rank, // int : use for ordering columns
1111  'width' => 20, // the column width in mm
1112  'title' => array(
1113  'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1114  'label' => ' ', // the final label : used fore final generated text
1115  'align' => 'L', // text alignement : R,C,L
1116  'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1117  ),
1118  'content' => array(
1119  'align' => 'L', // text alignement : R,C,L
1120  'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1121  ),
1122  );
1123  */
1124 
1125  $rank = 0; // do not use negative rank
1126  $this->cols['desc'] = array(
1127  'rank' => $rank,
1128  'width' => false, // only for desc
1129  'status' => true,
1130  'title' => array(
1131  'textkey' => 'Designation', // use lang key is usefull in somme case with module
1132  'align' => 'L',
1133  // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1134  // 'label' => ' ', // the final label
1135  'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1136  ),
1137  'content' => array(
1138  'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1139  ),
1140  );
1141 
1142  $rank = $rank + 10;
1143  $this->cols['photo'] = array(
1144  'rank' => $rank,
1145  'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1146  'status' => false,
1147  'title' => array(
1148  'textkey' => 'Photo',
1149  'label' => ' '
1150  ),
1151  'content' => array(
1152  'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1153  ),
1154  'border-left' => false, // remove left line separator
1155  );
1156 
1157  if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE) && !empty($this->atleastonephoto))
1158  {
1159  $this->cols['photo']['status'] = true;
1160  }
1161 
1162  $rank = $rank + 10;
1163  $this->cols['weight'] = array(
1164  'rank' => $rank,
1165  'width' => 30, // in mm
1166  'status' => true,
1167  'title' => array(
1168  'textkey' => 'WeightVolShort'
1169  ),
1170  'border-left' => true, // add left line separator
1171  );
1172 
1173 
1174  $rank = $rank + 10;
1175  $this->cols['subprice'] = array(
1176  'rank' => $rank,
1177  'width' => 19, // in mm
1178  'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
1179  'title' => array(
1180  'textkey' => 'PriceUHT'
1181  ),
1182  'border-left' => true, // add left line separator
1183  );
1184 
1185  $rank = $rank + 10;
1186  $this->cols['totalexcltax'] = array(
1187  'rank' => $rank,
1188  'width' => 26, // in mm
1189  'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
1190  'title' => array(
1191  'textkey' => 'TotalHT'
1192  ),
1193  'border-left' => true, // add left line separator
1194  );
1195 
1196  $rank = $rank + 10;
1197  $this->cols['qty_asked'] = array(
1198  'rank' => $rank,
1199  'width' => 30, // in mm
1200  'status' => empty($conf->global->SHIPPING_PDF_HIDE_ORDERED) ? 1 : 0,
1201  'title' => array(
1202  'textkey' => 'QtyOrdered'
1203  ),
1204  'border-left' => true, // add left line separator
1205  'content' => array(
1206  'align' => 'C',
1207  ),
1208  );
1209 
1210  $rank = $rank + 10;
1211  $this->cols['qty_shipped'] = array(
1212  'rank' => $rank,
1213  'width' => 30, // in mm
1214  'status' => true,
1215  'title' => array(
1216  'textkey' => 'QtyToShip'
1217  ),
1218  'border-left' => true, // add left line separator
1219  'content' => array(
1220  'align' => 'C',
1221  ),
1222  );
1223 
1224  // Add extrafields cols
1225  if (!empty($object->lines)) {
1226  $line = reset($object->lines);
1227  $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
1228  }
1229 
1230  $parameters = array(
1231  'object' => $object,
1232  'outputlangs' => $outputlangs,
1233  'hidedetails' => $hidedetails,
1234  'hidedesc' => $hidedesc,
1235  'hideref' => $hideref
1236  );
1237 
1238  $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1239  if ($reshook < 0)
1240  {
1241  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1242  } elseif (empty($reshook))
1243  {
1244  $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1245  } else {
1246  $this->cols = $hookmanager->resArray;
1247  }
1248  }
1249 }
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:45
getExtrafieldContent($object, $extrafieldKey)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
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
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition: pdf.lib.php:663
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
</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
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
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.
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
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...
printStdColumnContent($pdf, &$curY, $colKey, $columnText= '')
print standard column content
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
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
$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...
getColumnStatus($colKey)
get column status from column key
Class to manage hooks.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
Print standard column content.
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.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
__construct($db=0)
Constructor.
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
Class to manage translations.
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).
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
Class to build sending documents with model espadon.
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.