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