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