dolibarr 20.0.0
pdf_merou.modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
6 * Copyright (C) 2015 Marcos GarcĂ­a <marcosgdf@gmail.com>
7 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
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/expedition/modules_expedition.php';
31require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
34
35
40{
44 public $db;
45
49 public $name;
50
54 public $description;
55
59 public $update_main_doc_field;
60
64 public $type;
65
66 public $destinataire;
67 public $expediteur;
68 public $livreur;
69
74 public $version = 'dolibarr';
75
76
82 public function __construct(DoliDB $db)
83 {
84 global $langs, $mysoc;
85
86 $this->db = $db;
87 $this->name = "merou";
88 $this->description = $langs->trans("DocumentModelMerou");
89 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
90
91 $this->type = 'pdf';
92 $formatarray = pdf_getFormat();
93 $this->page_largeur = $formatarray['width'];
94 $this->page_hauteur = round($formatarray['height'] / 2);
95 $this->format = array($this->page_largeur, $this->page_hauteur);
96 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
97 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
98 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
99 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
100
101 $this->option_logo = 1; // Display logo
102
103 // Get source company
104 $this->emetteur = $mysoc;
105 if (!$this->emetteur->country_code) {
106 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
107 }
108 }
109
110
111 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
123 public function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
124 {
125 // phpcs:enable
126 global $user, $conf, $langs, $mysoc, $hookmanager;
127
128 $object->fetch_thirdparty();
129
130 if (!is_object($outputlangs)) {
131 $outputlangs = $langs;
132 }
133 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
134 if (getDolGlobalString('MAIN_USE_FPDF')) {
135 $outputlangs->charset_output = 'ISO-8859-1';
136 }
137
138 // Load traductions files required by page
139 $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
140
141 if ($conf->expedition->dir_output) {
142 $object->fetch_thirdparty();
143
144 $origin = $object->origin;
145
146 $object->fetch_origin();
147
148 //Create sender
149 $this->expediteur = $mysoc;
150
151 //Create recipient
152 $idcontact = $object->origin_object->getIdContact('external', 'SHIPPING');
153 $this->destinataire = new Contact($this->db);
154 if (!empty($idcontact[0])) {
155 $this->destinataire->fetch($idcontact[0]);
156 }
157
158 //Create deliverer
159 $idcontact = $object->origin_object->getIdContact('internal', 'LIVREUR');
160 $this->livreur = new User($this->db);
161 if (!empty($idcontact[0])) {
162 $this->livreur->fetch($idcontact[0]);
163 }
164
165 // Definition of $dir and $file
166 if ($object->specimen) {
167 $dir = $conf->expedition->dir_output."/sending";
168 $file = $dir."/SPECIMEN.pdf";
169 } else {
170 $expref = dol_sanitizeFileName($object->ref);
171 $dir = $conf->expedition->dir_output."/sending/".$expref;
172 $file = $dir."/".$expref.".pdf";
173 }
174
175 if (!file_exists($dir)) {
176 if (dol_mkdir($dir) < 0) {
177 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
178 return 0;
179 }
180 }
181
182 if (file_exists($dir)) {
183 // Add pdfgeneration hook
184 if (!is_object($hookmanager)) {
185 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
186 $hookmanager = new HookManager($this->db);
187 }
188 $hookmanager->initHooks(array('pdfgeneration'));
189 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
190 global $action;
191 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
192
193 $nblines = count($object->lines);
194
195 $pdf = pdf_getInstance($this->format, 'mm', 'l');
196 $default_font_size = pdf_getPDFFontSize($outputlangs);
197 $heightforinfotot = 0; // Height reserved to output the info and total part
198 $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
199 $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
200 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
201 $heightforfooter += 6;
202 }
203 $pdf->SetAutoPageBreak(1, 0);
204
205 if (class_exists('TCPDF')) {
206 $pdf->setPrintHeader(false);
207 $pdf->setPrintFooter(false);
208 }
209 $pdf->SetFont(pdf_getPDFFont($outputlangs));
210 // Set path to the background PDF File
211 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
212 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
213 $tplidx = $pdf->importPage(1);
214 }
215
216 $pdf->Open();
217 $pagenb = 0;
218 $pdf->SetDrawColor(128, 128, 128);
219
220 if (method_exists($pdf, 'AliasNbPages')) {
221 $pdf->AliasNbPages();
222 }
223
224 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
225 $pdf->SetSubject($outputlangs->transnoentities("Shipment"));
226 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
227 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
228 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
229 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
230 $pdf->SetCompression(false);
231 }
232
233 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
234 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
235
236 // New page
237 $pdf->AddPage();
238 $pagenb++;
239 $this->_pagehead($pdf, $object, 1, $outputlangs);
240 $pdf->SetFont('', '', $default_font_size - 3);
241 $pdf->MultiCell(0, 3, ''); // Set interline to 3
242 $pdf->SetTextColor(0, 0, 0);
243
244 $tab_top = 52;
245 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
246
247 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
248
249 // Display notes
250 if (!empty($object->note_public)) {
251 $pdf->SetFont('', '', $default_font_size - 1);
252 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
253 $nexY = $pdf->GetY();
254 $height_note = $nexY - $tab_top;
255
256 // Rect takes a length in 3rd parameter
257 $pdf->SetDrawColor(192, 192, 192);
258 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
259
260 $tab_height = $tab_height - $height_note;
261 $tab_top = $nexY + 6;
262 } else {
263 $height_note = 0;
264 }
265
266
267 $pdf->SetFillColor(240, 240, 240);
268 $pdf->SetTextColor(0, 0, 0);
269 $pdf->SetXY(10, $tab_top + 5);
270
271 $iniY = $tab_top + 7;
272 $curY = $tab_top + 7;
273 $nexY = $tab_top + 7;
274
275 $num = count($object->lines);
276 // Loop on each lines
277 for ($i = 0; $i < $num; $i++) {
278 $curY = $nexY;
279 $pdf->SetFont('', '', $default_font_size - 3);
280 $pdf->SetTextColor(0, 0, 0);
281
282 $pdf->setTopMargin($tab_top_newpage);
283 $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
284 $pageposbefore = $pdf->getPage();
285
286 // Description of product line
287 $libelleproduitservice = pdf_writelinedesc($pdf, $object, $i, $outputlangs, 90, 3, 50, $curY, 0, 1);
288
289 $nexY = $pdf->GetY();
290 $pageposafter = $pdf->getPage();
291 $pdf->setPage($pageposbefore);
292 $pdf->setTopMargin($this->marge_haute);
293 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
294
295 // We suppose that a too long description is moved completely on next page
296 if ($pageposafter > $pageposbefore) {
297 $pdf->setPage($pageposafter);
298 $curY = $tab_top_newpage;
299 }
300
301 $pdf->SetFont('', '', $default_font_size - 3);
302
303 // Check boxes
304 $pdf->SetDrawColor(120, 120, 120);
305 $pdf->Rect(10 + 3, $curY, 3, 3);
306 $pdf->Rect(20 + 3, $curY, 3, 3);
307
308 //Inserting the product reference
309 $pdf->SetXY(30, $curY);
310 $pdf->SetFont('', 'B', $default_font_size - 3);
311 $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0);
312
313 $pdf->SetXY(140, $curY);
314 $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked, 0, 'C', 0);
315
316 $pdf->SetXY(170, $curY);
317 $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
318
319 // Add line
320 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
321 $pdf->setPage($pageposafter);
322 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
323 //$pdf->SetDrawColor(190,190,200);
324 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
325 $pdf->SetLineStyle(array('dash' => 0));
326 }
327
328 $nexY += 2; // Add space between lines
329
330 // Detect if some page were added automatically and output _tableau for past pages
331 while ($pagenb < $pageposafter) {
332 $pdf->setPage($pagenb);
333 if ($pagenb == 1) {
334 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
335 } else {
336 $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
337 }
338 $this->_pagefoot($pdf, $object, $outputlangs, 1);
339 $pagenb++;
340 $pdf->setPage($pagenb);
341 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
342 }
343 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
344 if ($pagenb == 1) {
345 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
346 } else {
347 $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
348 }
349 $this->_pagefoot($pdf, $object, $outputlangs, 1);
350 // New page
351 $pdf->AddPage();
352 $pagenb++;
353 }
354 }
355
356 // Show square
357 if ($pagenb == 1) {
358 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
359 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
360 } else {
361 $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
362 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
363 }
364
365 // Pagefoot
366 $this->_pagefoot($pdf, $object, $outputlangs);
367 if (method_exists($pdf, 'AliasNbPages')) {
368 $pdf->AliasNbPages();
369 }
370
371 $pdf->Close();
372
373 $pdf->Output($file, 'F');
374
375 // Add pdfgeneration hook
376 if (!is_object($hookmanager)) {
377 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
378 $hookmanager = new HookManager($this->db);
379 }
380 $hookmanager->initHooks(array('pdfgeneration'));
381 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
382 global $action;
383 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
384 if ($reshook < 0) {
385 $this->error = $hookmanager->error;
386 $this->errors = $hookmanager->errors;
387 }
388
389 dolChmod($file);
390
391 $this->result = array('fullpath' => $file);
392
393 return 1;
394 } else {
395 $this->error = $outputlangs->transnoentities("ErrorCanNotCreateDir", $dir);
396 return 0;
397 }
398 } else {
399 $this->error = $outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
400 return 0;
401 }
402 }
403
404 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
417 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
418 {
419 global $langs;
420 $default_font_size = pdf_getPDFFontSize($outputlangs);
421
422 // Translations
423 $langs->loadLangs(array("main", "bills", "orders"));
424
425 if (empty($hidetop)) {
426 $pdf->SetFont('', 'B', $default_font_size - 2);
427 $pdf->SetXY(10, $tab_top);
428 $pdf->MultiCell(10, 5, "LS", 0, 'C', 1);
429 $pdf->line(20, $tab_top, 20, $tab_top + $tab_height);
430 $pdf->SetXY(20, $tab_top);
431 $pdf->MultiCell(10, 5, "LR", 0, 'C', 1);
432 $pdf->line(30, $tab_top, 30, $tab_top + $tab_height);
433 $pdf->SetXY(30, $tab_top);
434 $pdf->MultiCell(20, 5, $outputlangs->transnoentities("Ref"), 0, 'C', 1);
435 $pdf->SetXY(50, $tab_top);
436 $pdf->MultiCell(90, 5, $outputlangs->transnoentities("Description"), 0, 'L', 1);
437 $pdf->SetXY(140, $tab_top);
438 $pdf->MultiCell(30, 5, $outputlangs->transnoentities("QtyOrdered"), 0, 'C', 1);
439 $pdf->SetXY(170, $tab_top);
440 $pdf->MultiCell(30, 5, $outputlangs->transnoentities("QtyToShip"), 0, 'C', 1);
441 }
442 $pdf->Rect(10, $tab_top, 190, $tab_height);
443 }
444
445 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
455 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
456 {
457 $default_font_size = pdf_getPDFFontSize($outputlangs);
458 $pdf->SetFont('', '', $default_font_size - 2);
459 $pdf->SetY(-23);
460 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("GoodStatusDeclaration"), 0, 'L');
461 $pdf->SetY(-13);
462 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ToAndDate"), 0, 'C');
463 $pdf->SetXY(120, -23);
464 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
465
466 // Show page nb only on iso languages (so default Helvetica font)
467 //if (pdf_getPDFFont($outputlangs) == 'Helvetica')
468 //{
469 // $pdf->SetXY(-10,-10);
470 // $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
471 //}
472 }
473
474 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
484 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
485 {
486 global $conf, $langs, $hookmanager;
487
488 $default_font_size = pdf_getPDFFontSize($outputlangs);
489
490 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
491
492 //Affiche le filigrane brouillon - Print Draft Watermark
493 if ($object->statut == 0 && (getDolGlobalString('SENDING_DRAFT_WATERMARK'))) {
494 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK);
495 }
496
497 $posy = $this->marge_haute;
498 $posx = $this->page_largeur - $this->marge_droite - 100;
499
500 $Xoff = 90;
501 $Yoff = 0;
502
503 $tab4_top = 60;
504 $tab4_hl = 6;
505 $tab4_sl = 4;
506 $line = 2;
507
508 //*********************LOGO****************************
509 $pdf->SetXY(11, 7);
510 if ($this->emetteur->logo) {
511 $logodir = $conf->mycompany->dir_output;
512 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
513 $logodir = $conf->mycompany->multidir_output[$object->entity];
514 }
515 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
516 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
517 } else {
518 $logo = $logodir.'/logos/'.$this->emetteur->logo;
519 }
520 if (is_readable($logo)) {
521 $height = pdf_getHeightForLogo($logo);
522 $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
523 } else {
524 $pdf->SetTextColor(200, 0, 0);
525 $pdf->SetFont('', 'B', $default_font_size - 2);
526 $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
527 $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
528 }
529 } else {
530 $text = $this->emetteur->name;
531 $pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
532 }
533
534 //*********************Entete****************************
535 //Document name
536 $pdf->SetXY($Xoff, 7);
537 $pdf->SetFont('', 'B', $default_font_size + 2);
538 $pdf->SetTextColor(0, 0, 0);
539 $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet
540 //Num Expedition
541 $Yoff = $Yoff + 7;
542 $Xoff = 142;
543 //$pdf->Rect($Xoff, $Yoff, 85, 8);
544 $pdf->SetXY($Xoff, $Yoff);
545 $pdf->SetFont('', '', $default_font_size - 2);
546 $pdf->SetTextColor(0, 0, 0);
547 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $Xoff, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R');
548 //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
549
550 $origin = $object->origin;
551 $origin_id = $object->origin_id;
552
553 // Add list of linked elements
554 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1);
555
556 //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
557 //Definition Location of the Company block
558 $Xoff = 110;
559 $blSocX = 90;
560 $blSocY = 24;
561 $blSocW = 50;
562 $blSocX2 = $blSocW + $blSocX;
563
564 // Sender name
565 $pdf->SetTextColor(0, 0, 0);
566 $pdf->SetFont('', 'B', $default_font_size - 3);
567 $pdf->SetXY($blSocX, $blSocY + 1);
568 $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
569 $pdf->SetTextColor(0, 0, 0);
570
571 // Sender properties
572 $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
573
574 $pdf->SetFont('', '', $default_font_size - 3);
575 $pdf->SetXY($blSocX, $blSocY + 4);
576 $pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
577
578
579 if ($object->thirdparty->code_client) {
580 $Yoff += 3;
581 $posy = $Yoff;
582 $pdf->SetXY($Xoff, $posy);
583 $pdf->SetTextColor(0, 0, 0);
584 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $Xoff, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
585 }
586
587 // Date delivery
588 $Yoff = $Yoff + 7;
589 $pdf->SetXY($blSocX - 80, $blSocY + 17);
590
591 $pdf->SetFont('', 'B', $default_font_size - 3);
592 $pdf->SetTextColor(0, 0, 0);
593 $pdf->MultiCell(70, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L');
594
595 $pdf->SetXY($blSocX - 80, $blSocY + 20);
596 $pdf->SetFont('', 'B', $default_font_size - 3);
597 $pdf->SetTextColor(0, 0, 0);
598 $pdf->MultiCell(70, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L');
599
600 // Deliverer
601 $pdf->SetXY($blSocX - 80, $blSocY + 23);
602 $pdf->SetFont('', '', $default_font_size - 3);
603 $pdf->SetTextColor(0, 0, 0);
604
605 if (!empty($object->tracking_number)) {
606 $object->getUrlTrackingStatus($object->tracking_number);
607 if (!empty($object->tracking_url)) {
608 if ($object->shipping_method_id > 0) {
609 // Get code using getLabelFromKey
610 $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
611
612 $label = '';
613 $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
614 //var_dump($object->tracking_url != $object->tracking_number);exit;
615 if ($object->tracking_url != $object->tracking_number) {
616 $label .= " : ";
617 $label .= $object->tracking_url;
618 }
619 $pdf->SetFont('', 'B', $default_font_size - 3);
620 $pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
621 }
622 }
623 } else {
624 $pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
625 }
626
627
628 // Shipping company (My Company)
629 $Yoff = $blSocY;
630 $blExpX = $Xoff - 20;
631 $blW = 52;
632 $Ydef = $Yoff;
633 $pdf->Rect($blExpX, $Yoff, $blW, 26);
634
635 $object->fetch_thirdparty();
636
637 // If SHIPPING contact defined on order, we use it
638 $usecontact = false;
639 $arrayidcontact = $object->origin_object->getIdContact('external', 'SHIPPING');
640 if (count($arrayidcontact) > 0) {
641 $usecontact = true;
642 $result = $object->fetch_contact($arrayidcontact[0]);
643 }
644
645 // Recipient name
646 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
647 $thirdparty = $object->contact;
648 } else {
649 $thirdparty = $object->thirdparty;
650 }
651
652 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
653
654 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
655
656 $blDestX = $blExpX + 55;
657 $blW = 54;
658 $Yoff = $Ydef + 1;
659
660 $widthrecbox = $blW;
661
662 $top_shift = 0;
663 // Show list of linked objects
664 /*
665 $current_y = $pdf->getY();
666 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
667 if ($current_y < $pdf->getY()) {
668 $top_shift = $pdf->getY() - $current_y;
669 }
670 */
671
672 // Show Recipient frame
673 $pdf->SetFont('', 'B', $default_font_size - 3);
674 $pdf->SetXY($blDestX, $Yoff - 4);
675 $pdf->MultiCell($blW, 3, $outputlangs->transnoentities("Recipient"), 0, 'L');
676 $pdf->Rect($blDestX, $Yoff - 1, $blW, 26);
677
678 // Show recipient name
679 $pdf->SetFont('', 'B', $default_font_size - 3);
680 $pdf->SetXY($blDestX, $Yoff);
681 $pdf->MultiCell($blW, 3, $carac_client_name, 0, 'L');
682
683 $posy = $pdf->getY();
684
685 // Show recipient information
686 $pdf->SetFont('', '', $default_font_size - 3);
687 $pdf->SetXY($blDestX, $posy);
688 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
689
690 return $top_shift;
691 }
692}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage contact/addresses.
Class to manage Dolibarr database access.
Class to manage hooks.
Parent class of sending receipts models.
Class to manage Dolibarr users.
Class to build sending documents with model Merou.
__construct(DoliDB $db)
Constructor.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
write_file(&$object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
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.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0, $align='J')
Output line description into PDF.
Definition pdf.lib.php:1431
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:290
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:86
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:315
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:733
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition pdf.lib.php:1394
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:267
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
Definition pdf.lib.php:436
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:128
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:388
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition pdf.lib.php:789
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:139
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:142