dolibarr  17.0.4
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 = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
61  $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
62  $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
63  $this->marge_basse = getDolGlobalInt('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 (getDolGlobalInt('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 (!getDolGlobalInt('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 (getDolGlobalString('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 = (!getDolGlobalInt('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 (isModEnabled('incoterm')) {
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  $totalAmount = 0;
357 
358  // Loop on each lines
359  for ($i = 0; $i < $nblines; $i++) {
360  $curY = $nexY;
361  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
362  $pdf->SetTextColor(0, 0, 0);
363 
364  // Define size of image if we need it
365  $imglinesize = array();
366  if (!empty($realpatharray[$i])) {
367  $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
368  }
369 
370  $pdf->setTopMargin($tab_top_newpage);
371  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
372  $pageposbefore = $pdf->getPage();
373 
374  $showpricebeforepagebreak = 1;
375  $posYAfterImage = 0;
376  $posYAfterDescription = 0;
377 
378  // We start with Photo of product line
379  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
380  $pdf->AddPage('', '', true);
381  if (!empty($tplidx)) {
382  $pdf->useTemplate($tplidx);
383  }
384  if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
385  $this->_pagehead($pdf, $object, 0, $outputlangs);
386  }
387  $pdf->setPage($pageposbefore + 1);
388 
389  $curY = $tab_top_newpage;
390 
391  // Allows data in the first page if description is long enough to break in multiples pages
392  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
393  $showpricebeforepagebreak = 1;
394  } else {
395  $showpricebeforepagebreak = 0;
396  }
397  }
398 
399  if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
400  $curX = $this->posxpicture - 1;
401  $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
402  // $pdf->Image does not increase value return by getY, so we save it manually
403  $posYAfterImage = $curY + $imglinesize['height'];
404  }
405 
406  // Description of product line
407  $curX = $this->posxdesc - 1;
408 
409  // The desc of line is not store into reception, so we force it to the value of product.
410  /*
411  if (empty($object->lines[0]->desc)) {
412  // TODO We must get value from fk_commendefourndet
413  $sqldesc = 'SELECT description FROM '.MAIN_DB_PREFIX.' WHERE rowid = '.((int) $object->lines[0]->fk_commandefourndet);
414  $resqldesc = $this->db->query($sqldesc);
415  if ($resqldesc) {
416  $objdesc = $this->db->fetch_object($resqldesc);
417  $object->lines[0]->desc = $objdesc->description;
418  }
419  }*/
420 
421  $pdf->startTransaction();
422  pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
423 
424  $pageposafter = $pdf->getPage();
425  if ($pageposafter > $pageposbefore) { // There is a pagebreak
426  $pdf->rollbackTransaction(true);
427  $pageposafter = $pageposbefore;
428  //print $pageposafter.'-'.$pageposbefore;exit;
429  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
430 
431  pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
432 
433  $pageposafter = $pdf->getPage();
434  $posyafter = $pdf->GetY();
435  //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
436  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
437  if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
438  $pdf->AddPage('', '', true);
439  if (!empty($tplidx)) {
440  $pdf->useTemplate($tplidx);
441  }
442  if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
443  $this->_pagehead($pdf, $object, 0, $outputlangs);
444  }
445  $pdf->setPage($pageposafter + 1);
446  }
447  } else {
448  // We found a page break
449 
450  // Allows data in the first page if description is long enough to break in multiples pages
451  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
452  $showpricebeforepagebreak = 1;
453  } else {
454  $showpricebeforepagebreak = 0;
455  }
456  }
457  } else // No pagebreak
458  {
459  $pdf->commitTransaction();
460  }
461  $posYAfterDescription = $pdf->GetY();
462 
463  $nexY = max($pdf->GetY(), $posYAfterImage);
464  $pageposafter = $pdf->getPage();
465 
466  $pdf->setPage($pageposbefore);
467  $pdf->setTopMargin($this->marge_haute);
468  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
469 
470  // We suppose that a too long description or photo were moved completely on next page
471  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
472  $pdf->setPage($pageposafter);
473  $curY = $tab_top_newpage;
474  }
475 
476  // We suppose that a too long description is moved completely on next page
477  if ($pageposafter > $pageposbefore) {
478  $pdf->setPage($pageposafter);
479  $curY = $tab_top_newpage;
480  }
481 
482  $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
483 
484  // Description
485  $pdf->SetXY($this->posxweightvol, $curY);
486  $weighttxt = '';
487  if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) {
488  $weighttxt = round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->product->weight_units, 1);
489  }
490  $voltxt = '';
491  if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) {
492  $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, 1);
493  }
494 
495  $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C');
496  //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
497 
498  // Qty ordered
499  if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
500  $pdf->SetXY($this->posxqtyordered, $curY);
501  if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
502  $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
503  $totalOrdered += $object->lines[$i]->qty_asked;
504  }
505  $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
506  }
507 
508  // Qty received
509  $pdf->SetXY($this->posxqtytoship, $curY);
510  $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty, '', 'C');
511 
512  // Amount
513  if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
514  $pdf->SetXY($this->posxpuht, $curY);
515  $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R');
516 
517  $amountreceived = price2num($object->lines[$i]->subprice * $object->lines[$i]->qty, 'MT');
518  $pdf->SetXY($this->posxtotalht, $curY);
519  $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($amountreceived, 0, $outputlangs), '', 'R');
520 
521  $totalAmount += $amountreceived;
522  }
523 
524  $nexY += 3;
525  if ($weighttxt && $voltxt) {
526  $nexY += 2;
527  }
528 
529  // Add line
530  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
531  $pdf->setPage($pageposafter);
532  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
533  //$pdf->SetDrawColor(190,190,200);
534  $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
535  $pdf->SetLineStyle(array('dash'=>0));
536  }
537 
538  // Detect if some page were added automatically and output _tableau for past pages
539  while ($pagenb < $pageposafter) {
540  $pdf->setPage($pagenb);
541  if ($pagenb == 1) {
542  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
543  } else {
544  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
545  }
546  $this->_pagefoot($pdf, $object, $outputlangs, 1);
547  $pagenb++;
548  $pdf->setPage($pagenb);
549  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
550  if (!empty($tplidx)) {
551  $pdf->useTemplate($tplidx);
552  }
553  }
554  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
555  if ($pagenb == 1) {
556  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
557  } else {
558  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
559  }
560  $this->_pagefoot($pdf, $object, $outputlangs, 1);
561  // New page
562  $pdf->AddPage();
563  if (!empty($tplidx)) {
564  $pdf->useTemplate($tplidx);
565  }
566  $pagenb++;
567  }
568  }
569 
570  // Show square
571  if ($pagenb == 1) {
572  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object);
573  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
574  } else {
575  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object);
576  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
577  }
578 
579  // Affiche zone totaux
580  $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered, $totalAmount);
581 
582  // Pied de page
583  $this->_pagefoot($pdf, $object, $outputlangs);
584  if (method_exists($pdf, 'AliasNbPages')) {
585  $pdf->AliasNbPages();
586  }
587 
588  $pdf->Close();
589 
590  $pdf->Output($file, 'F');
591 
592  // Add pdfgeneration hook
593  $hookmanager->initHooks(array('pdfgeneration'));
594  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
595  global $action;
596  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
597  if ($reshook < 0) {
598  $this->error = $hookmanager->error;
599  $this->errors = $hookmanager->errors;
600  }
601 
602  if (!empty($conf->global->MAIN_UMASK)) {
603  @chmod($file, octdec($conf->global->MAIN_UMASK));
604  }
605 
606  return 1; // No error
607  } else {
608  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
609  return 0;
610  }
611  } else {
612  $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
613  return 0;
614  }
615  }
616 
617  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
618  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
631  protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered, $totalAmount = 0)
632  {
633  // phpcs:enable
634  global $conf, $mysoc;
635 
636  $sign = 1;
637 
638  $default_font_size = pdf_getPDFFontSize($outputlangs);
639 
640  $tab2_top = $posy;
641  $tab2_hl = 4;
642  $pdf->SetFont('', 'B', $default_font_size - 1);
643 
644  // Tableau total
645  $col1x = $this->posxweightvol - 50;
646  $col2x = $this->posxweightvol;
647  /*if ($this->page_largeur < 210) // To work with US executive format
648  {
649  $col2x-=20;
650  }*/
651  if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
652  $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
653  } else {
654  $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
655  }
656 
657  $useborder = 0;
658  $index = 0;
659 
660  $totalWeighttoshow = '';
661  $totalVolumetoshow = '';
662 
663  // Load dim data
664  $tmparray = $object->getTotalWeightVolume();
665  $totalWeight = $tmparray['weight'];
666  $totalVolume = $tmparray['volume'];
667  $totalToShip = $tmparray['toship'];
668 
669 
670  // Set trueVolume and volume_units not currently stored into database
671  if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
672  $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
673  $object->volume_units = $object->size_units * 3;
674  }
675 
676  if ($totalWeight != '') {
677  $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
678  }
679  if ($totalVolume != '') {
680  $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
681  }
682  if ($object->trueWeight) {
683  $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs, -1, 'no', 1);
684  }
685  if ($object->trueVolume) {
686  $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs, -1, 'no', 1);
687  }
688 
689  $pdf->SetFillColor(255, 255, 255);
690  $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
691  $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
692 
693  $index2 = 0;
694 
695  // Total Weight
696  if ($totalWeighttoshow) {
697  $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
698  $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
699  $index2++;
700  }
701  if ($totalVolumetoshow) {
702  $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
703  $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
704  $index2++;
705  }
706 
707  // Total qty ordered
708  if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
709  $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
710  $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
711  }
712 
713  // Total received
714  $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
715  $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
716 
717  // Amount
718  if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
719  $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
720  $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
721 
722  $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
723  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($totalAmount, 0, $outputlangs), 0, 'C', 1);
724  }
725 
726  $pdf->SetTextColor(0, 0, 0);
727 
728  $index++;
729  if ($index2) {
730  $index++;
731  }
732 
733  return ($tab2_top + ($tab2_hl * $index));
734  }
735 
736  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
750  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object = null)
751  {
752  global $conf;
753 
754  // Force to disable hidetop and hidebottom
755  $hidebottom = 0;
756  if ($hidetop) {
757  $hidetop = -1;
758  }
759 
760  $default_font_size = pdf_getPDFFontSize($outputlangs);
761 
762  // Amount in (at tab_top - 1)
763  $pdf->SetTextColor(0, 0, 0);
764  $pdf->SetFont('', '', $default_font_size - 2);
765 
766  // Output Rect
767  $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
768 
769  $pdf->SetDrawColor(128, 128, 128);
770  $pdf->SetFont('', '', $default_font_size - 1);
771 
772  // Description
773  if (empty($hidetop)) {
774  $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
775 
776  $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
777  $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
778  }
779 
780  // Volume / Weight
781  $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
782  if (empty($hidetop)) {
783  $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
784  $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
785  }
786 
787  // Qty ordered
788  if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
789  $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
790  if (empty($hidetop)) {
791  $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
792  $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
793  }
794  }
795 
796  // Qty reception
797  $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
798  if (empty($hidetop)) {
799  $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
800  $statusreceived = Reception::STATUS_CLOSED;
801  if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) {
802  $statusreceived = Reception::STATUS_VALIDATED;
803  }
804  if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) {
805  $statusreceived = Reception::STATUS_CLOSED;
806  }
807  if ($object && $object->statut < $statusreceived) {
808  $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyToReceive'), '', 'C');
809  } else {
810  $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyReceived'), '', 'C');
811  }
812  }
813 
814  // Amount
815  if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
816  $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
817  if (empty($hidetop)) {
818  $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
819  $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
820  }
821 
822  $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
823  if (empty($hidetop)) {
824  $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
825  $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
826  }
827  }
828  }
829 
830  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
840  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
841  {
842  global $conf, $langs, $mysoc;
843 
844  $langs->load("orders");
845 
846  $default_font_size = pdf_getPDFFontSize($outputlangs);
847 
848  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
849 
850  //Prepare la suite
851  $pdf->SetTextColor(0, 0, 60);
852  $pdf->SetFont('', 'B', $default_font_size + 3);
853 
854  $w = 110;
855 
856  $posy = $this->marge_haute;
857  $posx = $this->page_largeur - $this->marge_droite - $w;
858 
859  $pdf->SetXY($this->marge_gauche, $posy);
860 
861  // Logo
862  $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
863  if ($this->emetteur->logo) {
864  if (is_readable($logo)) {
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 (isModEnabled('barcode')) {
880  $posx = 105;
881  } else {
882  $posx = $this->marge_gauche + 3;
883  }
884  //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
885  if (isModEnabled('barcode')) {
886  // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
887  //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
888  //$pdf->Image($logo,10, 5, 0, 24);
889  }
890 
891  $pdf->SetDrawColor(128, 128, 128);
892  if (isModEnabled('barcode')) {
893  // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
894  //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
895  //$pdf->Image($logo,10, 5, 0, 24);
896  }
897 
898 
899  $posx = $this->page_largeur - $w - $this->marge_droite;
900  $posy = $this->marge_haute;
901 
902  $pdf->SetFont('', 'B', $default_font_size + 2);
903  $pdf->SetXY($posx, $posy);
904  $pdf->SetTextColor(0, 0, 60);
905  $title = $outputlangs->transnoentities("ReceptionSheet");
906  $pdf->MultiCell($w, 4, $title, '', 'R');
907 
908  $pdf->SetFont('', '', $default_font_size + 1);
909 
910  $posy += 5;
911 
912  $pdf->SetXY($posx, $posy);
913  $pdf->SetTextColor(0, 0, 60);
914  $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception")." : ".$object->ref, '', 'R');
915 
916  // Date planned delivery
917  if (!empty($object->date_delivery)) {
918  $posy += 4;
919  $pdf->SetXY($posx, $posy);
920  $pdf->SetTextColor(0, 0, 60);
921  $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
922  }
923 
924  if (!empty($object->thirdparty->code_fournisseur)) {
925  $posy += 4;
926  $pdf->SetXY($posx, $posy);
927  $pdf->SetTextColor(0, 0, 60);
928  $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
929  }
930 
931 
932  $pdf->SetFont('', '', $default_font_size + 3);
933  $Yoff = 25;
934 
935  // Add list of linked orders
936  $origin = $object->origin;
937  $origin_id = $object->origin_id;
938 
939  // TODO move to external function
940  if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { // commonly $origin='commande'
941  $outputlangs->load('orders');
942 
943  $classname = 'CommandeFournisseur';
944  $linkedobject = new $classname($this->db);
945  $result = $linkedobject->fetch($origin_id);
946  if ($result >= 0) {
947  //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
948 
949  $pdf->SetFont('', '', $default_font_size - 2);
950  $text = $linkedobject->ref;
951  if ($linkedobject->ref_client) {
952  $text .= ' ('.$linkedobject->ref_client.')';
953  }
954  $Yoff = $Yoff + 8;
955  $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
956  $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
957  $Yoff = $Yoff + 3;
958  $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
959  $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
960  }
961  }
962 
963  if ($showaddress) {
964  // Sender properties
965  $carac_emetteur = '';
966  // Add internal contact of origin element if defined
967  $arrayidcontact = array();
968  if (!empty($origin) && is_object($object->$origin)) {
969  $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL');
970  }
971  if (empty($arrayidcontact)) {
972  $arrayidcontact = $object->$origin->getIdContact('internal', 'SHIPPING');
973  }
974  if (count($arrayidcontact) > 0) {
975  $object->fetch_user(reset($arrayidcontact));
976  $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
977  }
978 
979  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
980 
981  // Show sender
982  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
983  $posx = $this->marge_gauche;
984  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
985  $posx = $this->page_largeur - $this->marge_droite - 80;
986  }
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($widthrecbox, 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  // If RECEPTION contact defined, we use it
1003  $usecontact = false;
1004  $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
1005 
1006  if (count($arrayidcontact) > 0) {
1007  $usecontact = true;
1008  $result = $object->fetch_contact($arrayidcontact[0]);
1009  }
1010 
1011  // Recipient name
1012  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)))) {
1013  $thirdparty = $object->contact;
1014  } else {
1015  $thirdparty = $object->thirdparty;
1016  }
1017 
1018  $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1019 
1020  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
1021 
1022  // Show recipient name
1023  $pdf->SetXY($posx + 2, $posy + 3);
1024  $pdf->SetFont('', 'B', $default_font_size);
1025  $pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0, 'L');
1026 
1027  $posy = $pdf->getY();
1028 
1029  // Show recipient information
1030  $pdf->SetFont('', '', $default_font_size - 1);
1031  $pdf->SetXY($posx + 2, $posy);
1032  $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, 'L');
1033 
1034  // Show recipient
1035  $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1036  if ($this->page_largeur < 210) {
1037  $widthrecbox = 84; // To work with US executive format
1038  }
1039  $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1040  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1041  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1042  $posx = $this->marge_gauche;
1043  }
1044 
1045  // Show recipient frame
1046  $pdf->SetTextColor(0, 0, 0);
1047  $pdf->SetFont('', '', $default_font_size - 2);
1048  $pdf->SetXY($posx + 2, $posy - 5);
1049  $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, 'L');
1050  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1051 
1052 
1053 
1054  // Show sender name
1055  $pdf->SetXY($posx + 2, $posy + 3);
1056  $pdf->SetFont('', 'B', $default_font_size);
1057  $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1058  $posy = $pdf->getY();
1059 
1060  // Show sender information
1061  $pdf->SetXY($posx + 2, $posy);
1062  $pdf->SetFont('', '', $default_font_size - 1);
1063  $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L');
1064  }
1065 
1066  $pdf->SetTextColor(0, 0, 0);
1067  }
1068 
1069  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1079  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1080  {
1081  $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1082  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);
1083  }
1084 }
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Class to manage Dolibarr database access.
Class to manage hooks.
Parent class of sending receipts models.
Class to manage products or services.
Classe permettant de generer les borderaux envoi au modele Squille.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
__construct(DoliDB $db)
Constructor.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered, $totalAmount=0)
Show total to pay.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $object=null)
Show table for lines.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Definition: pdf.lib.php:2514
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:288
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:84
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
Definition: pdf.lib.php:1359
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:313
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition: pdf.lib.php:1001
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:723
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:265
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formated for output on documents.
Definition: pdf.lib.php:434
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:126
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition: pdf.lib.php:386
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:122
$conf db
API class for accounts.
Definition: inc.php:41