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