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