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