dolibarr 22.0.5
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 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", "deliveries", "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 if ($reshook < 0) {
405 $this->error = $hookmanager->error;
406 $this->errors = $hookmanager->errors;
407 }
408
409 dolChmod($file);
410
411 $this->result = array('fullpath' => $file);
412
413 return 1;
414 } else {
415 $this->error = $outputlangs->transnoentities("ErrorCanNotCreateDir", $dir);
416 return 0;
417 }
418 } else {
419 $this->error = $outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
420 return 0;
421 }
422 }
423
424 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
437 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
438 {
439 global $langs;
440 $default_font_size = pdf_getPDFFontSize($outputlangs);
441
442 // Translations
443 $langs->loadLangs(array("main", "bills", "orders"));
444
445 if (empty($hidetop)) {
446 $pdf->SetFont('', 'B', $default_font_size - 2);
447 $pdf->SetXY(10, $tab_top);
448 $pdf->MultiCell(10, 5, "LS", 0, 'C', true);
449 $pdf->line(20, $tab_top, 20, $tab_top + $tab_height);
450 $pdf->SetXY(20, $tab_top);
451 $pdf->MultiCell(10, 5, "LR", 0, 'C', true);
452 $pdf->line(30, $tab_top, 30, $tab_top + $tab_height);
453 $pdf->SetXY(30, $tab_top);
454 $pdf->MultiCell(20, 5, $outputlangs->transnoentities("Ref"), 0, 'C', true);
455 $pdf->SetXY(50, $tab_top);
456 $pdf->MultiCell(90, 5, $outputlangs->transnoentities("Description"), 0, 'L', true);
457 if (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) {
458 $pdf->SetXY(140, $tab_top);
459 $pdf->MultiCell(30, 5, $outputlangs->transnoentities("QtyOrdered"), 0, 'C', true);
460 }
461 if (!getDolGlobalString('SHIPPING_PDF_HIDE_QTYTOSHIP')) {
462 $pdf->SetXY(170, $tab_top);
463 $pdf->MultiCell(30, 5, $outputlangs->transnoentities("QtyToShip"), 0, 'C', true);
464 }
465 }
466 $pdf->RoundedRect(10, $tab_top, 190, $tab_height, $this->corner_radius, '1234', 'D');
467 }
468
469 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
479 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
480 {
481 $default_font_size = pdf_getPDFFontSize($outputlangs);
482 $pdf->SetFont('', '', $default_font_size - 2);
483 $pdf->SetY(-23);
484 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("GoodStatusDeclaration"), 0, 'L');
485 $pdf->SetY(-13);
486 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ToAndDate"), 0, 'C');
487 $pdf->SetXY(120, -23);
488 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
489
490 // Show page nb only on iso languages (so default Helvetica font)
491 //if (pdf_getPDFFont($outputlangs) == 'Helvetica')
492 //{
493 // $pdf->SetXY(-10,-10);
494 // $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
495 //}
496 }
497
498 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
508 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
509 {
510 global $conf, $langs, $hookmanager;
511
512 $default_font_size = pdf_getPDFFontSize($outputlangs);
513
514 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
515
516 //Affiche le filigrane brouillon - Print Draft Watermark
517 if ($object->statut == 0 && (getDolGlobalString('SENDING_DRAFT_WATERMARK'))) {
518 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK);
519 }
520
521 $posy = $this->marge_haute;
522 $posx = $this->page_largeur - $this->marge_droite - 100;
523
524 $Xoff = 90;
525 $Yoff = 0;
526
527 $tab4_top = 60;
528 $tab4_hl = 6;
529 $tab4_sl = 4;
530 $line = 2;
531
532 //*********************LOGO****************************
533 $pdf->SetXY(11, 7);
534 if ($this->emetteur->logo) {
535 $logodir = $conf->mycompany->dir_output;
536 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
537 $logodir = $conf->mycompany->multidir_output[$object->entity];
538 }
539 if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
540 $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
541 } else {
542 $logo = $logodir.'/logos/'.$this->emetteur->logo;
543 }
544 if (is_readable($logo)) {
545 $height = pdf_getHeightForLogo($logo);
546 $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
547 } else {
548 $pdf->SetTextColor(200, 0, 0);
549 $pdf->SetFont('', 'B', $default_font_size - 2);
550 $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
551 $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
552 }
553 } else {
554 $text = $this->emetteur->name;
555 $pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
556 }
557
558 //*********************Entete****************************
559 //Document name
560 $pdf->SetXY($Xoff, 7);
561 $pdf->SetFont('', 'B', $default_font_size + 2);
562 $pdf->SetTextColor(0, 0, 0);
563 $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet
564 //Num Expedition
565 $Yoff += 7;
566 $Xoff = 142;
567 //$pdf->Rect($Xoff, $Yoff, 85, 8);
568 $pdf->SetXY($Xoff, $Yoff);
569 $pdf->SetFont('', '', $default_font_size - 2);
570 $pdf->SetTextColor(0, 0, 0);
571 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $Xoff, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R');
572 //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
573
574 $origin = $object->origin;
575 $origin_id = $object->origin_id;
576
577 // Add list of linked elements
578 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1);
579
580 //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
581 //Definition Location of the Company block
582 $Xoff = 110;
583 $blSocX = 90;
584 $blSocY = 24;
585 $blSocW = 50;
586 $blSocX2 = $blSocW + $blSocX;
587
588 // Sender name
589 $pdf->SetTextColor(0, 0, 0);
590 $pdf->SetFont('', 'B', $default_font_size - 3);
591 $pdf->SetXY($blSocX, $blSocY + 1);
592 $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
593 $pdf->SetTextColor(0, 0, 0);
594
595 // Sender properties
596 $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
597
598 $pdf->SetFont('', '', $default_font_size - 3);
599 $pdf->SetXY($blSocX, $blSocY + 4);
600 $pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
601
602
603 if ($object->thirdparty->code_client) {
604 $Yoff += 3;
605 $posy = $Yoff;
606 $pdf->SetXY($Xoff, $posy);
607 $pdf->SetTextColor(0, 0, 0);
608 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $Xoff, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
609 }
610
611 // Date delivery
612 $Yoff += 7;
613 $pdf->SetXY($blSocX - 80, $blSocY + 17);
614
615 $pdf->SetFont('', 'B', $default_font_size - 3);
616 $pdf->SetTextColor(0, 0, 0);
617 $pdf->MultiCell(70, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L');
618
619 $pdf->SetXY($blSocX - 80, $blSocY + 20);
620 $pdf->SetFont('', 'B', $default_font_size - 3);
621 $pdf->SetTextColor(0, 0, 0);
622 $pdf->MultiCell(70, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L');
623
624 // Deliverer
625 $pdf->SetXY($blSocX - 80, $blSocY + 23);
626 $pdf->SetFont('', '', $default_font_size - 3);
627 $pdf->SetTextColor(0, 0, 0);
628
629 if (!empty($object->tracking_number)) {
630 $object->getUrlTrackingStatus($object->tracking_number);
631 if (!empty($object->tracking_url)) {
632 if ($object->shipping_method_id > 0) {
633 // Get code using getLabelFromKey
634 $code = $outputlangs->getLabelFromKey($this->db, (string) $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
635
636 $label = '';
637 $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
638 //var_dump($object->tracking_url != $object->tracking_number);exit;
639 if ($object->tracking_url != $object->tracking_number) {
640 $label .= " : ";
641 $label .= $object->tracking_url;
642 }
643 $pdf->SetFont('', 'B', $default_font_size - 3);
644 $pdf->writeHTMLCell(50, 8, null, null, $label, 0, 1, false, true, 'L');
645 }
646 }
647 } else {
648 $pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
649 }
650
651
652 // Shipping company (My Company)
653 $Yoff = $blSocY;
654 $blExpX = $Xoff - 20;
655 $blW = 52;
656 $Ydef = $Yoff;
657 $pdf->RoundedRect($blExpX, $Yoff, $blW, 26, $this->corner_radius, '1234', 'D');
658
659 $object->fetch_thirdparty();
660
661 // If SHIPPING contact defined on order, we use it
662 $usecontact = false;
663 $arrayidcontact = $object->origin_object->getIdContact('external', 'SHIPPING');
664 if (count($arrayidcontact) > 0) {
665 $usecontact = true;
666 $result = $object->fetch_contact($arrayidcontact[0]);
667 }
668
669 // Recipient name
670 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
671 $thirdparty = $object->contact;
672 } else {
673 $thirdparty = $object->thirdparty;
674 }
675
676 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
677
678 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact)) ? $object->contact : null), ($usecontact ? 1 : 0), 'targetwithdetails', $object);
679
680 $blDestX = $blExpX + 55;
681 $blW = 54;
682 $Yoff = $Ydef + 1;
683
684 $widthrecbox = $blW;
685
686 $top_shift = 0;
687 // Show list of linked objects
688 /*
689 $current_y = $pdf->getY();
690 $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
691 if ($current_y < $pdf->getY()) {
692 $top_shift = $pdf->getY() - $current_y;
693 }
694 */
695
696 // Show Recipient frame
697 $pdf->SetFont('', 'B', $default_font_size - 3);
698 $pdf->SetXY($blDestX, $Yoff - 4);
699 $pdf->MultiCell($blW, 3, $outputlangs->transnoentities("Recipient"), 0, 'L');
700 $pdf->RoundedRect($blDestX, $Yoff - 1, $blW, 26, $this->corner_radius, '1234', 'D');
701
702 // Show recipient name
703 $pdf->SetFont('', 'B', $default_font_size - 3);
704 $pdf->SetXY($blDestX, $Yoff);
705 $pdf->MultiCell($blW, 3, $carac_client_name, 0, 'L');
706
707 $posy = $pdf->getY();
708
709 // Show recipient information
710 $pdf->SetFont('', '', $default_font_size - 3);
711 $pdf->SetXY($blDestX, $posy);
712 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
713
714 return $top_shift;
715 }
716}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
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_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...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
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)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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:1463
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:314
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:1425
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 formatted for output on PDF documents.
Definition pdf.lib.php:439
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:391
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition pdf.lib.php:798
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:158
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:161