dolibarr 19.0.4
pdf_eagle.modules.php
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
6 * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
7 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 * or see https://www.gnu.org/
22 */
23
30require_once DOL_DOCUMENT_ROOT . '/core/modules/stocktransfer/modules_stocktransfer.php';
31require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
35
36
41{
45 public $db;
46
50 public $name;
51
55 public $description;
56
60 public $type;
61
66 public $version = 'dolibarr';
67
71 public $posxlot;
72
76 public $posxweightvol;
77 public $posxwarehousesource;
78 public $posxwarehousedestination;
79 public $atLeastOneBatch;
80
86 public function __construct($db = 0)
87 {
88 global $conf, $langs, $mysoc;
89
90 $this->db = $db;
91 $this->name = $langs->trans("StockTransferSheet");
92 $this->description = $langs->trans("DocumentModelStandardPDF");
93
94 $this->type = 'pdf';
95 $formatarray = pdf_getFormat();
96 $this->page_largeur = $formatarray['width'];
97 $this->page_hauteur = $formatarray['height'];
98 $this->format = array($this->page_largeur, $this->page_hauteur);
99 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
100 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
101 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
102 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
103
104 $this->option_logo = 1; // Display logo
105
106 // Get source company
107 $this->emetteur = $mysoc;
108 if (!$this->emetteur->country_code) {
109 $this->emetteur->country_code = substr($langs->defaultlang, -2);
110 } // By default if not defined
111
112 // Define position of columns
113 $this->posxdesc = $this->marge_gauche + 1;
114 $this->posxlot = $this->page_largeur - $this->marge_droite - 135;
115 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 115;
116 $this->posxqty = $this->page_largeur - $this->marge_droite - 95;
117 $this->posxwarehousesource = $this->page_largeur - $this->marge_droite - 70;
118 $this->posxwarehousedestination = $this->page_largeur - $this->marge_droite - 35;
119 $this->posxpuht = $this->page_largeur - $this->marge_droite;
120
121 /*if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) { // Show also the prices
122 $this->posxqty = $this->page_largeur - $this->marge_droite - 118;
123 $this->posxwarehousesource = $this->page_largeur - $this->marge_droite - 96;
124 $this->posxwarehousedestination = $this->page_largeur - $this->marge_droite - 68;
125 $this->posxpuht = $this->page_largeur - $this->marge_droite - 40;
126 $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
127 }*/
128
129 if (getDolGlobalString('STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME')) {
130 $this->posxweightvol = $this->posxqty;
131 }
132
133 $this->posxpicture = $this->posxweightvol - (!getDolGlobalString('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
134 //var_dump($this->posxpicture, $this->posxweightvol);exit;
135
136 // To work with US executive format
137 if ($this->page_largeur < 210) {
138 $this->posxqty -= 20;
139 $this->posxpicture -= 20;
140 $this->posxwarehousesource -= 20;
141 $this->posxwarehousedestination -= 20;
142 }
143
144 /*if (!empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED)) {
145 $this->posxqty += ($this->posxwarehousedestination - $this->posxwarehousesource);
146 $this->posxpicture += ($this->posxwarehousedestination - $this->posxwarehousesource);
147 $this->posxwarehousesource = $this->posxwarehousedestination;
148 }*/
149 }
150
151 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
163 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
164 {
165 // phpcs:enable
166 global $db, $user, $conf, $langs, $hookmanager;
167
168 $object->fetch_thirdparty();
169
170 $this->atLeastOneBatch = $this->atLeastOneBatch($object);
171
172 if (!is_object($outputlangs)) {
173 $outputlangs = $langs;
174 }
175 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
176 if (getDolGlobalString('MAIN_USE_FPDF')) {
177 $outputlangs->charset_output = 'ISO-8859-1';
178 }
179
180 // Load traductions files required by page
181 $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "stocks", "stocktransfer@stocktransfer"));
182
183 $nblines = is_array($object->lines) ? count($object->lines) : 0;
184
185 // Loop on each lines to detect if there is at least one image to show
186 $realpatharray = array();
187 if (getDolGlobalString('MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE')) {
188 $objphoto = new Product($this->db);
189
190 for ($i = 0; $i < $nblines; $i++) {
191 if (empty($object->lines[$i]->fk_product)) {
192 continue;
193 }
194
195 $objphoto = new Product($this->db);
196 $objphoto->fetch($object->lines[$i]->fk_product);
197 if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
198 $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
199 $dir = $conf->product->dir_output.'/'.$pdir;
200 } else {
201 $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
202 $dir = $conf->product->dir_output.'/'.$pdir;
203 }
204
205 $realpath = '';
206
207 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
208 if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) {
209 // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
210 if ($obj['photo_vignette']) {
211 $filename = $obj['photo_vignette'];
212 } else {
213 $filename = $obj['photo'];
214 }
215 } else {
216 $filename = $obj['photo'];
217 }
218
219 $realpath = $dir.$filename;
220 break;
221 }
222
223 if ($realpath) {
224 $realpatharray[$i] = $realpath;
225 }
226 }
227 }
228
229 if (count($realpatharray) == 0) {
230 $this->posxpicture = $this->posxweightvol;
231 }
232
233
234 if (!empty($this->atLeastOneBatch)) {
235 $this->posxpicture = $this->posxlot;
236 if (getDolGlobalString('MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE')) {
237 $this->posxpicture -= (!getDolGlobalString('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
238 } // width of images
239 }
240
241 if ($conf->stocktransfer->dir_output) {
242 // Definition de $dir et $file
243 if ($object->specimen) {
244 $dir = $conf->stocktransfer->dir_output;
245 $file = $dir."/SPECIMEN.pdf";
246 } else {
247 $stocktransferref = dol_sanitizeFileName($object->ref);
248 $dir = $conf->stocktransfer->dir_output.'/'.$object->element."/".$stocktransferref;
249 $file = $dir."/".$stocktransferref.".pdf";
250 }
251
252 if (!file_exists($dir)) {
253 if (dol_mkdir($dir) < 0) {
254 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
255 return 0;
256 }
257 }
258
259 if (file_exists($dir)) {
260 // Add pdfgeneration hook
261 if (!is_object($hookmanager)) {
262 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
263 $hookmanager = new HookManager($this->db);
264 }
265 $hookmanager->initHooks(array('pdfgeneration'));
266 $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
267 global $action;
268 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
269
270 // Set nblines with the new facture lines content after hook
271 $nblines = is_array($object->lines) ? count($object->lines) : 0;
272
273 $pdf = pdf_getInstance($this->format);
274 $default_font_size = pdf_getPDFFontSize($outputlangs);
275 $heightforinfotot = 8; // Height reserved to output the info and total part
276 $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
277 $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
278 if (getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') > 0) {
279 $heightforfooter += 6;
280 }
281 $pdf->SetAutoPageBreak(1, 0);
282
283 if (class_exists('TCPDF')) {
284 $pdf->setPrintHeader(false);
285 $pdf->setPrintFooter(false);
286 }
287 $pdf->SetFont(pdf_getPDFFont($outputlangs));
288 // Set path to the background PDF File
289 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
290 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
291 $tplidx = $pdf->importPage(1);
292 }
293
294 $pdf->Open();
295 $pagenb = 0;
296 $pdf->SetDrawColor(128, 128, 128);
297
298 if (method_exists($pdf, 'AliasNbPages')) {
299 $pdf->AliasNbPages();
300 }
301
302 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
303 $pdf->SetSubject($outputlangs->transnoentities("Shipment"));
304 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
305 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
306 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
307 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
308 $pdf->SetCompression(false);
309 }
310
311 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
312
313 // New page
314 $pdf->AddPage();
315 if (!empty($tplidx)) {
316 $pdf->useTemplate($tplidx);
317 }
318 $pagenb++;
319 $this->_pagehead($pdf, $object, 1, $outputlangs);
320 $pdf->SetFont('', '', $default_font_size - 1);
321 $pdf->MultiCell(0, 3, ''); // Set interline to 3
322 $pdf->SetTextColor(0, 0, 0);
323
324 $tab_top = 90;
325 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
326 $tab_height = 130;
327 $tab_height_newpage = 150;
328
329 // Incoterm
330 $height_incoterms = 0;
331 if ($conf->incoterm->enabled) {
332 $desc_incoterms = $object->getIncotermsForPDF();
333 if ($desc_incoterms) {
334 $tab_top = 88;
335
336 $pdf->SetFont('', '', $default_font_size - 1);
337 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
338 $nexY = $pdf->GetY();
339 $height_incoterms = $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_incoterms + 1);
344
345 $tab_top = $nexY + 6;
346 $height_incoterms += 4;
347 }
348 }
349
350 if (!empty($object->note_public) || !empty($object->tracking_number)) {
351 $tab_top = 88 + $height_incoterms;
352 $tab_top_alt = $tab_top;
353
354 $pdf->SetFont('', 'B', $default_font_size - 2);
355
356 //$tab_top_alt += 1;
357
358 // Tracking number
359 if (!empty($object->tracking_number)) {
360 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L');
361 $tab_top_alt = $pdf->GetY();
362
363 $object->getUrlTrackingStatus($object->tracking_number);
364 if (!empty($object->tracking_url)) {
365 if ($object->shipping_method_id > 0) {
366 // Get code using getLabelFromKey
367 $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
368 $label = '';
369 if ($object->tracking_url != $object->tracking_number) {
370 $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
371 }
372 $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
373 //var_dump($object->tracking_url != $object->tracking_number);exit;
374 if ($object->tracking_url != $object->tracking_number) {
375 $label .= " : ";
376 $label .= $object->tracking_url;
377 }
378 $pdf->SetFont('', 'B', $default_font_size - 2);
379 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L');
380
381 $tab_top_alt = $pdf->GetY();
382 }
383 }
384 }
385
386 // Notes
387 if (!empty($object->note_public)) {
388 $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page
389 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
390 }
391
392 $nexY = $pdf->GetY();
393 $height_note = $nexY - $tab_top;
394
395 // Rect takes a length in 3rd parameter
396 $pdf->SetDrawColor(192, 192, 192);
397 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
398
399 $tab_height = $tab_height - $height_note;
400 $tab_top = $nexY + 6;
401 } else {
402 $height_note = 0;
403 }
404
405 $iniY = $tab_top + 7;
406 $curY = $tab_top + 7;
407 $nexY = $tab_top + 7;
408
409 $TCacheEntrepots=array();
410 // Loop on each lines
411 for ($i = 0; $i < $nblines; $i++) {
412 $curY = $nexY;
413 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
414 $pdf->SetTextColor(0, 0, 0);
415
416 // Define size of image if we need it
417 $imglinesize = array();
418 if (!empty($realpatharray[$i])) {
419 $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
420 }
421
422 $pdf->setTopMargin($tab_top_newpage);
423 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
424 $pageposbefore = $pdf->getPage();
425
426 $showpricebeforepagebreak = 1;
427 $posYAfterImage = 0;
428 $posYAfterDescription = 0;
429
430 // We start with Photo of product line
431 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
432 $pdf->AddPage('', '', true);
433 if (!empty($tplidx)) {
434 $pdf->useTemplate($tplidx);
435 }
436 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
437 $this->_pagehead($pdf, $object, 0, $outputlangs);
438 }
439 $pdf->setPage($pageposbefore + 1);
440
441 $curY = $tab_top_newpage;
442
443 // Allows data in the first page if description is long enough to break in multiples pages
444 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
445 $showpricebeforepagebreak = 1;
446 } else {
447 $showpricebeforepagebreak = 0;
448 }
449 }
450
451 if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
452 $curX = $this->posxpicture - 1;
453 $pdf->Image($realpatharray[$i], $curX + (($this->posxqty - $this->posxweightvol - $imglinesize['width']
454 + (getDolGlobalString('STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME') ? (!getDolGlobalString('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) : 0)) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
455 // $pdf->Image does not increase value return by getY, so we save it manually
456 $posYAfterImage = $curY + $imglinesize['height'];
457 }
458
459 // Description of product line
460 $curX = $this->posxdesc - 1;
461
462 $pdf->startTransaction();
463 if (method_exists($object->lines[$i], 'fetch_product')) {
464 $object->lines[$i]->fetch_product();
465 $object->lines[$i]->label = $object->lines[$i]->product->label;
466 $object->lines[$i]->description = $object->lines[$i]->product->description;
467 $object->lines[$i]->weight = $object->lines[$i]->product->weight;
468 $object->lines[$i]->weight_units = $object->lines[$i]->product->weight_units;
469 $object->lines[$i]->length = $object->lines[$i]->product->length;
470 $object->lines[$i]->length_units = $object->lines[$i]->product->length_units;
471 $object->lines[$i]->surface = $object->lines[$i]->product->surface;
472 $object->lines[$i]->surface_units = $object->lines[$i]->product->surface_units;
473 $object->lines[$i]->volume = $object->lines[$i]->product->volume;
474 $object->lines[$i]->volume_units = $object->lines[$i]->product->volume_units;
475 $object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
476 //var_dump($object->lines[$i]);exit;
477 }
478
479 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
480
481 $pageposafter = $pdf->getPage();
482 if ($pageposafter > $pageposbefore) { // There is a pagebreak
483 $pdf->rollbackTransaction(true);
484 $pageposafter = $pageposbefore;
485 //print $pageposafter.'-'.$pageposbefore;exit;
486 $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
487 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
488
489 $pageposafter = $pdf->getPage();
490 $posyafter = $pdf->GetY();
491 //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
492 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
493 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
494 $pdf->AddPage('', '', true);
495 if (!empty($tplidx)) {
496 $pdf->useTemplate($tplidx);
497 }
498 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
499 $this->_pagehead($pdf, $object, 0, $outputlangs);
500 }
501 $pdf->setPage($pageposafter + 1);
502 }
503 } else {
504 // We found a page break
505
506 // Allows data in the first page if description is long enough to break in multiples pages
507 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
508 $showpricebeforepagebreak = 1;
509 } else {
510 $showpricebeforepagebreak = 0;
511 }
512 }
513 } else { // No pagebreak
514 $pdf->commitTransaction();
515 }
516 $posYAfterDescription = $pdf->GetY();
517
518 $nexY = $pdf->GetY();
519 $pageposafter = $pdf->getPage();
520
521 $pdf->setPage($pageposbefore);
522 $pdf->setTopMargin($this->marge_haute);
523 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
524
525 // We suppose that a too long description or photo were moved completely on next page
526 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
527 $pdf->setPage($pageposafter);
528 $curY = $tab_top_newpage;
529 }
530
531 // We suppose that a too long description is moved completely on next page
532 if ($pageposafter > $pageposbefore) {
533 $pdf->setPage($pageposafter);
534 $curY = $tab_top_newpage;
535 }
536
537 $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
538
539 // Lot / série
540 if (isModEnabled('productbatch')) {
541 $pdf->SetXY($this->posxlot, $curY);
542 $pdf->MultiCell(($this->posxweightvol - $this->posxlot), 3, $object->lines[$i]->batch, '', 'C');
543 }
544
545 // Weight
546 $pdf->SetXY($this->posxweightvol, $curY);
547 $weighttxt = '';
548 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) {
549 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
550 }
551 $voltxt = '';
552 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) {
553 $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
554 }
555
556 // Weight
557 if (!getDolGlobalString('STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME')) {
558 $pdf->writeHTMLCell($this->posxqty - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C');
559 //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
560 }
561
562 // Qty
563 $pdf->SetXY($this->posxqty, $curY);
564 $pdf->writeHTMLCell($this->posxwarehousesource - $this->posxqty + 2, 3, $this->posxqty - 1, $curY, $object->lines[$i]->qty, 0, 0, false, true, 'C');
565 //$pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
566
567 // Warehouse source
568 $wh_source = new Entrepot($db);
569 if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_source])) {
570 $wh_source = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source];
571 } else {
572 $wh_source->fetch($object->lines[$i]->fk_warehouse_source);
573 $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source] = $wh_source;
574 }
575 $pdf->SetXY($this->posxwarehousesource, $curY);
576 $pdf->MultiCell(($this->posxwarehousedestination - $this->posxwarehousesource), 3, $wh_source->ref.(!empty($wh_source->lieu) ? ' - '.$wh_source->lieu : ''), '', 'C');
577
578 // Warehouse destination
579 $wh_destination = new Entrepot($db);
580 if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination])) {
581 $wh_destination = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination];
582 } else {
583 $wh_destination->fetch($object->lines[$i]->fk_warehouse_destination);
584 $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination] = $wh_destination;
585 }
586 $pdf->SetXY($this->posxwarehousedestination, $curY);
587 $pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination), 3, $wh_destination->ref.(!empty($wh_destination->lieu) ? ' - '.$wh_destination->lieu : ''), '', 'C');
588
589 if (getDolGlobalString('STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT')) {
590 $pdf->SetXY($this->posxpuht, $curY);
591 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R');
592
593 $pdf->SetXY($this->posxtotalht, $curY);
594 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R');
595 }
596
597 $nexY += 3;
598 if ($weighttxt && $voltxt) {
599 $nexY += 2;
600 }
601
602 // Add line
603 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
604 $pdf->setPage($pageposafter);
605 $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
606 //$pdf->SetDrawColor(190,190,200);
607 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
608 $pdf->SetLineStyle(array('dash'=>0));
609 }
610
611 // Detect if some page were added automatically and output _tableau for past pages
612 while ($pagenb < $pageposafter) {
613 $pdf->setPage($pagenb);
614 if ($pagenb == 1) {
615 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
616 } else {
617 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
618 }
619 $this->_pagefoot($pdf, $object, $outputlangs, 1);
620 $pagenb++;
621 $pdf->setPage($pagenb);
622 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
623 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
624 $this->_pagehead($pdf, $object, 0, $outputlangs);
625 }
626 }
627 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
628 if ($pagenb == 1) {
629 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
630 } else {
631 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
632 }
633 $this->_pagefoot($pdf, $object, $outputlangs, 1);
634 // New page
635 $pdf->AddPage();
636 if (!empty($tplidx)) {
637 $pdf->useTemplate($tplidx);
638 }
639 $pagenb++;
640 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
641 $this->_pagehead($pdf, $object, 0, $outputlangs);
642 }
643 }
644 }
645
646 // Show square
647 if ($pagenb == 1) {
648 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
649 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
650 } else {
651 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
652 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
653 }
654
655 // Affiche zone totaux
656 $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
657
658 // Pied de page
659 $this->_pagefoot($pdf, $object, $outputlangs);
660 if (method_exists($pdf, 'AliasNbPages')) {
661 $pdf->AliasNbPages();
662 }
663
664 $pdf->Close();
665
666 $pdf->Output($file, 'F');
667
668 // Add pdfgeneration hook
669 $hookmanager->initHooks(array('pdfgeneration'));
670 $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
671 global $action;
672 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
673 if ($reshook < 0) {
674 $this->error = $hookmanager->error;
675 $this->errors = $hookmanager->errors;
676 }
677
678 dolChmod($file);
679
680 $this->result = array('fullpath'=>$file);
681
682 return 1; // No error
683 } else {
684 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
685 return 0;
686 }
687 } else {
688 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
689 return 0;
690 }
691 }
692
693 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
694 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
705 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
706 {
707 // phpcs:enable
708 global $conf, $mysoc;
709
710 $sign = 1;
711
712 $default_font_size = pdf_getPDFFontSize($outputlangs);
713
714 $tab2_top = $posy;
715 $tab2_hl = 4;
716 $pdf->SetFont('', 'B', $default_font_size - 1);
717
718 // Tableau total
719 $col1x = $this->posxqty - 50;
720 $col2x = $this->posxqty;
721 /*if ($this->page_largeur < 210) // To work with US executive format
722 {
723 $col2x-=20;
724 }*/
725 if (!getDolGlobalString('STOCKTRANSFER_PDF_HIDE_ORDERED')) {
726 $largcol2 = ($this->posxwarehousesource - $this->posxqty);
727 } else {
728 $largcol2 = ($this->posxwarehousedestination - $this->posxqty);
729 }
730
731 $useborder = 0;
732 $index = 0;
733
734 $totalWeighttoshow = '';
735 $totalVolumetoshow = '';
736
737 // Load dim data
738 $tmparray = $object->getTotalWeightVolume();
739 $totalWeight = $tmparray['weight'];
740 $totalVolume = $tmparray['volume'];
741 $totalQty = 0;
742 if (!empty($object->lines)) {
743 foreach ($object->lines as $line) {
744 $totalQty+=$line->qty;
745 }
746 }
747 // Set trueVolume and volume_units not currently stored into database
748 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
749 $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
750 $object->volume_units = $object->size_units * 3;
751 }
752
753 if ($totalWeight != '') {
754 $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
755 }
756 if ($totalVolume != '') {
757 $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
758 }
759 if ($object->trueWeight) {
760 $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
761 }
762 if ($object->trueVolume) {
763 $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
764 }
765
766 $pdf->SetFillColor(255, 255, 255);
767 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
768 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
769
770 if (!getDolGlobalString('STOCKTRANSFER_PDF_HIDE_ORDERED')) {
771 $pdf->SetXY($this->posxqty, $tab2_top + $tab2_hl * $index);
772 $pdf->MultiCell($this->posxwarehousesource - $this->posxqty, $tab2_hl, $totalQty, 0, 'C', 1);
773 }
774
775 if (getDolGlobalString('STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT')) {
776 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
777 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
778
779 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
780 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
781 }
782
783 if (!getDolGlobalString('STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME')) {
784 // Total Weight
785 if ($totalWeighttoshow) {
786 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
787 $pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
788
789 $index++;
790 }
791 if ($totalVolumetoshow) {
792 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
793 $pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
794
795 $index++;
796 }
797 if (!$totalWeighttoshow && !$totalVolumetoshow) {
798 $index++;
799 }
800 }
801
802 $pdf->SetTextColor(0, 0, 0);
803
804 return ($tab2_top + ($tab2_hl * $index));
805 }
806
807 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
820 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
821 {
822 // phpcs:enable
823 global $conf;
824
825 // Force to disable hidetop and hidebottom
826 $hidebottom = 0;
827 if ($hidetop) {
828 $hidetop = -1;
829 }
830
831 $default_font_size = pdf_getPDFFontSize($outputlangs);
832
833 // Amount in (at tab_top - 1)
834 $pdf->SetTextColor(0, 0, 0);
835 $pdf->SetFont('', '', $default_font_size - 2);
836
837 // Output Rect
838 $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
839
840 $pdf->SetDrawColor(128, 128, 128);
841 $pdf->SetFont('', '', $default_font_size - 1);
842
843 if (empty($hidetop)) {
844 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
845
846 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
847 $pdf->MultiCell($this->posxlot - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
848 }
849
850 if (isModEnabled('productbatch') && $this->atLeastOneBatch) {
851 $pdf->line($this->posxlot - 1, $tab_top, $this->posxlot - 1, $tab_top + $tab_height);
852 if (empty($hidetop)) {
853 $pdf->SetXY($this->posxlot, $tab_top + 1);
854 $pdf->MultiCell(($this->posxweightvol - $this->posxlot), 2, $outputlangs->transnoentities("Batch"), '', 'C');
855 }
856 }
857
858 if (!getDolGlobalString('STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME')) {
859 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
860 if (empty($hidetop)) {
861 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
862 $pdf->MultiCell(($this->posxqty - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
863 }
864 }
865
866 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
867 if (empty($hidetop)) {
868 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
869 $pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), 2, $outputlangs->transnoentities("Qty"), '', 'C');
870 }
871
872 $pdf->line($this->posxwarehousesource - 1, $tab_top, $this->posxwarehousesource - 1, $tab_top + $tab_height);
873 if (empty($hidetop)) {
874 $pdf->SetXY($this->posxwarehousesource - 1, $tab_top + 1);
875 $pdf->MultiCell(($this->posxwarehousedestination - $this->posxwarehousesource), 2, $outputlangs->transnoentities("WarehouseSource"), '', 'C');
876 }
877
878
879 $pdf->line($this->posxwarehousedestination - 1, $tab_top, $this->posxwarehousedestination - 1, $tab_top + $tab_height);
880 if (empty($hidetop)) {
881 $pdf->SetXY($this->posxwarehousedestination-2.5, $tab_top + 1);
882 $pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination+4), 2, $outputlangs->transnoentities("WarehouseTarget"), '', 'C');
883 }
884
885 /*if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
886 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
887 if (empty($hidetop))
888 {
889 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
890 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
891 }
892
893 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
894 if (empty($hidetop))
895 {
896 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
897 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
898 }
899 }*/
900 }
901
908 public function atLeastOneBatch($object)
909 {
910 global $conf;
911
912 $atLeastOneBatch = false;
913
914 if (!isModEnabled('productbatch')) {
915 return false;
916 }
917
918 foreach ($object->lines as $line) {
919 if (!empty($line->batch)) {
920 return true;
921 }
922 }
923
924 return false;
925 }
926
927 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
937 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
938 {
939 // phpcs:enable
940 global $conf, $langs, $mysoc;
941
942 $langs->load("orders");
943
944 $default_font_size = pdf_getPDFFontSize($outputlangs);
945
946 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
947
948 // Show Draft Watermark
949 if ($object->statut == 0 && (getDolGlobalString('SHIPPING_DRAFT_WATERMARK'))) {
950 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
951 }
952
953 //Prepare la suite
954 $pdf->SetTextColor(0, 0, 60);
955 $pdf->SetFont('', 'B', $default_font_size + 3);
956
957 $w = 110;
958
959 $posy = $this->marge_haute;
960 $posx = $this->page_largeur - $this->marge_droite - $w;
961
962 $pdf->SetXY($this->marge_gauche, $posy);
963
964 // Logo
965 $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
966 if ($this->emetteur->logo) {
967 if (is_readable($logo)) {
968 $height = pdf_getHeightForLogo($logo);
969 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
970 } else {
971 $pdf->SetTextColor(200, 0, 0);
972 $pdf->SetFont('', 'B', $default_font_size - 2);
973 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
974 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
975 }
976 } else {
977 $text = $this->emetteur->name;
978 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
979 }
980
981 // Show barcode
982 if (isModEnabled('barcode')) {
983 $posx = 105;
984 } else {
985 $posx = $this->marge_gauche + 3;
986 }
987 //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
988 if (isModEnabled('barcode')) {
989 // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
990 //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
991 //$pdf->Image($logo,10, 5, 0, 24);
992 }
993
994 $pdf->SetDrawColor(128, 128, 128);
995
996 $posx = $this->page_largeur - $w - $this->marge_droite;
997 $posy = $this->marge_haute;
998
999 $pdf->SetFont('', 'B', $default_font_size + 2);
1000 $pdf->SetXY($posx, $posy);
1001 $pdf->SetTextColor(0, 0, 60);
1002 $title = $outputlangs->transnoentities("StockTransferSheet").' '.$object->ref;
1003 $pdf->MultiCell($w, 4, $title, '', 'R');
1004
1005 $pdf->SetFont('', '', $default_font_size + 1);
1006
1007 // Date prévue depart
1008 if (!empty($object->date_prevue_depart)) {
1009 $posy += 4;
1010 $pdf->SetXY($posx, $posy);
1011 $pdf->SetTextColor(0, 0, 60);
1012 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DatePrevueDepart")." : ".dol_print_date($object->date_prevue_depart, "day", false, $outputlangs, true), '', 'R');
1013 }
1014
1015 // Date prévue arrivée
1016 if (!empty($object->date_prevue_arrivee)) {
1017 $posy += 4;
1018 $pdf->SetXY($posx, $posy);
1019 $pdf->SetTextColor(0, 0, 60);
1020 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DatePrevueArrivee")." : ".dol_print_date($object->date_prevue_arrivee, "day", false, $outputlangs, true), '', 'R');
1021 }
1022
1023 // Date reelle depart
1024 if (!empty($object->date_reelle_depart)) {
1025 $posy += 4;
1026 $pdf->SetXY($posx, $posy);
1027 $pdf->SetTextColor(0, 0, 60);
1028 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleDepart")." : ".dol_print_date($object->date_reelle_depart, "day", false, $outputlangs, true), '', 'R');
1029 }
1030
1031 // Date reelle arrivée
1032 if (!empty($object->date_reelle_arrivee)) {
1033 $posy += 4;
1034 $pdf->SetXY($posx, $posy);
1035 $pdf->SetTextColor(0, 0, 60);
1036 $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleArrivee")." : ".dol_print_date($object->date_reelle_arrivee, "day", false, $outputlangs, true), '', 'R');
1037 }
1038
1039 if (!empty($object->thirdparty->code_client)) {
1040 $posy += 4;
1041 $pdf->SetXY($posx, $posy);
1042 $pdf->SetTextColor(0, 0, 60);
1043 $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1044 }
1045
1046
1047 $pdf->SetFont('', '', $default_font_size + 3);
1048 $Yoff = 25;
1049
1050 // Add list of linked orders
1051 $origin = $object->origin;
1052 $origin_id = $object->origin_id;
1053
1054 // TODO move to external function
1055 if (!empty($conf->$origin->enabled)) { // commonly $origin='commande'
1056 $outputlangs->load('orders');
1057
1058 $classname = ucfirst($origin);
1059 $linkedobject = new $classname($this->db);
1060 $result = $linkedobject->fetch($origin_id);
1061 if ($result >= 0) {
1062 //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
1063
1064 $pdf->SetFont('', '', $default_font_size - 2);
1065 $text = $linkedobject->ref;
1066 if ($linkedobject->ref_client) {
1067 $text .= ' ('.$linkedobject->ref_client.')';
1068 }
1069 $Yoff = $Yoff + 8;
1070 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1071 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
1072 $Yoff = $Yoff + 3;
1073 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1074 $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
1075 }
1076 }
1077
1078 if ($showaddress) {
1079 // Sender properties
1080 $carac_emetteur = '';
1081 // Add internal contact of origin element if defined
1082 $arrayidcontact = array();
1083 $arrayidcontact = $object->getIdContact('external', 'STFROM');
1084
1085 $usecontact = false;
1086 if (count($arrayidcontact) > 0) {
1087 /*$object->fetch_user(reset($arrayidcontact));
1088 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";*/
1089 $usecontact = true;
1090 $result = $object->fetch_contact($arrayidcontact[0]);
1091 }
1092
1093 if ($usecontact) {
1094 $thirdparty = $object->contact;
1095 } else {
1096 $thirdparty = $this->emetteur;
1097 }
1098
1099 if (!empty($thirdparty)) {
1100 $carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1101 }
1102
1103 if ($usecontact) {
1104 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
1105 } else {
1106 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1107 }
1108
1109 // Show sender
1110 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1111 $posx = $this->marge_gauche;
1112 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1113 $posx = $this->page_largeur - $this->marge_droite - 80;
1114 }
1115
1116 $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
1117 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1118
1119 // Show sender frame
1120 $pdf->SetTextColor(0, 0, 0);
1121 $pdf->SetFont('', '', $default_font_size - 2);
1122 $pdf->SetXY($posx, $posy - 5);
1123 $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
1124 $pdf->SetXY($posx, $posy);
1125 $pdf->SetFillColor(230, 230, 230);
1126 $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1127 $pdf->SetTextColor(0, 0, 60);
1128 $pdf->SetFillColor(255, 255, 255);
1129
1130 // Show sender name
1131 $pdf->SetXY($posx + 2, $posy + 3);
1132 $pdf->SetFont('', 'B', $default_font_size);
1133 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0, 'L');
1134 $posy = $pdf->getY();
1135
1136 // Show sender information
1137 $pdf->SetXY($posx + 2, $posy);
1138 $pdf->SetFont('', '', $default_font_size - 1);
1139 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
1140
1141
1142 // If SHIPPING contact defined, we use it
1143 $usecontact = false;
1144 $arrayidcontact = $object->getIdContact('external', 'STDEST');
1145 if (count($arrayidcontact) > 0) {
1146 $usecontact = true;
1147 $result = $object->fetch_contact($arrayidcontact[0]);
1148 }
1149
1150 //Recipient name
1151 // On peut utiliser le nom de la societe du contact
1152 if ($usecontact/* && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)*/) {
1153 $thirdparty = $object->contact;
1154 } else {
1155 $thirdparty = $object->thirdparty;
1156 }
1157
1158 if (!empty($thirdparty)) {
1159 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1160 }
1161
1162 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
1163
1164 // Show recipient
1165 $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1166 if ($this->page_largeur < 210) {
1167 $widthrecbox = 84;
1168 } // To work with US executive format
1169 $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
1170 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1171 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
1172 $posx = $this->marge_gauche;
1173 }
1174
1175 // Show recipient frame
1176 $pdf->SetTextColor(0, 0, 0);
1177 $pdf->SetFont('', '', $default_font_size - 2);
1178 $pdf->SetXY($posx + 2, $posy - 5);
1179 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1180 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1181
1182 // Show recipient name
1183 $pdf->SetXY($posx + 2, $posy + 3);
1184 $pdf->SetFont('', 'B', $default_font_size);
1185 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1186
1187 $posy = $pdf->getY();
1188
1189 // Show recipient information
1190 $pdf->SetFont('', '', $default_font_size - 1);
1191 $pdf->SetXY($posx + 2, $posy);
1192 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1193 }
1194
1195 $pdf->SetTextColor(0, 0, 0);
1196 }
1197
1198 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1208 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1209 {
1210 // phpcs:enable
1211 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1212 return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1213 }
1214}
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Class to manage warehouses.
Class to manage hooks.
Parent class for documents models.
Class to manage products or services.
Class to build sending documents with model Eagle.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
atLeastOneBatch($object)
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
__construct($db=0)
Constructor.
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.
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
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition pdf.lib.php:782
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