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