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