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