dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
20  * or see http://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, 4);
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  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;
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.NotCamelCaps
157  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 requiredby 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  //Creation de l expediteur
178  $this->expediteur = $mysoc;
179 
180  //Creation du destinataire
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  //Creation du livreur
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 de $dir et $file
191  if ($object->specimen)
192  {
193  $dir = $conf->expedition->dir_output."/sending";
194  $file = $dir . "/SPECIMEN.pdf";
195  }
196  else
197  {
198  $expref = dol_sanitizeFileName($object->ref);
199  $dir = $conf->expedition->dir_output . "/sending/" . $expref;
200  $file = $dir . "/" . $expref . ".pdf";
201  }
202 
203  if (! file_exists($dir))
204  {
205  if (dol_mkdir($dir) < 0)
206  {
207  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
208  return 0;
209  }
210  }
211 
212  if (file_exists($dir))
213  {
214  // Add pdfgeneration hook
215  if (! is_object($hookmanager))
216  {
217  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
218  $hookmanager=new HookManager($this->db);
219  }
220  $hookmanager->initHooks(array('pdfgeneration'));
221  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
222  global $action;
223  $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
224 
225  $nblignes = count($object->lines);
226 
227  $pdf=pdf_getInstance($this->format,'mm','l');
228  $default_font_size = pdf_getPDFFontSize($outputlangs);
229  $heightforinfotot = 0; // Height reserved to output the info and total part
230  $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
231  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
232  if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
233  $pdf->SetAutoPageBreak(1,0);
234 
235  if (class_exists('TCPDF'))
236  {
237  $pdf->setPrintHeader(false);
238  $pdf->setPrintFooter(false);
239  }
240  $pdf->SetFont(pdf_getPDFFont($outputlangs));
241  // Set path to the background PDF File
242  if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
243  {
244  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
245  $tplidx = $pdf->importPage(1);
246  }
247 
248  $pdf->Open();
249  $pagenb=0;
250  $pdf->SetDrawColor(128,128,128);
251 
252  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
253 
254  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
255  $pdf->SetSubject($outputlangs->transnoentities("Shipment"));
256  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
257  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
258  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
259  if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
260 
261  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
262 
263  // New page
264  $pdf->AddPage();
265  $pagenb++;
266  $this->_pagehead($pdf, $object, 1, $outputlangs);
267  $pdf->SetFont('','', $default_font_size - 3);
268  $pdf->MultiCell(0, 3, ''); // Set interline to 3
269  $pdf->SetTextColor(0,0,0);
270 
271  $tab_top = 52;
272  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
273  $tab_height = $this->page_hauteur - $tab_top - $heightforfooter;
274  $tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter;
275 
276  // Affiche notes
277  if (! empty($object->note_public))
278  {
279  $pdf->SetFont('','', $default_font_size - 1);
280  $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
281  $nexY = $pdf->GetY();
282  $height_note=$nexY-$tab_top;
283 
284  // Rect prend une longueur en 3eme param
285  $pdf->SetDrawColor(192,192,192);
286  $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
287 
288  $tab_height = $tab_height - $height_note;
289  $tab_top = $nexY+6;
290  }
291  else
292  {
293  $height_note=0;
294  }
295 
296 
297  $pdf->SetFillColor(240,240,240);
298  $pdf->SetTextColor(0,0,0);
299  $pdf->SetXY(10, $tab_top + 5);
300 
301  $iniY = $tab_top + 7;
302  $curY = $tab_top + 7;
303  $nexY = $tab_top + 7;
304 
305  $num=count($object->lines);
306  // Loop on each lines
307  for ($i = 0; $i < $num; $i++)
308  {
309  $curY = $nexY;
310  $pdf->SetFont('','', $default_font_size - 3);
311  $pdf->SetTextColor(0,0,0);
312 
313  $pdf->setTopMargin($tab_top_newpage);
314  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
315  $pageposbefore=$pdf->getPage();
316 
317  // Description de la ligne produit
318  $libelleproduitservice = pdf_writelinedesc($pdf,$object,$i,$outputlangs,90,3,50,$curY,0,1);
319 
320  $nexY = $pdf->GetY();
321  $pageposafter=$pdf->getPage();
322  $pdf->setPage($pageposbefore);
323  $pdf->setTopMargin($this->marge_haute);
324  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
325 
326  // We suppose that a too long description is moved completely on next page
327  if ($pageposafter > $pageposbefore) {
328  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
329  }
330 
331  $pdf->SetFont('','', $default_font_size - 3);
332 
333  // Check boxes
334  $pdf->SetDrawColor(120,120,120);
335  $pdf->Rect(10+3, $curY, 3, 3);
336  $pdf->Rect(20+3, $curY, 3, 3);
337 
338  //Insertion de la reference du produit
339  $pdf->SetXY(30, $curY);
340  $pdf->SetFont('','B', $default_font_size - 3);
341  $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0);
342 
343  $pdf->SetXY(140, $curY);
344  $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked, 0, 'C', 0);
345 
346  $pdf->SetXY(170, $curY);
347  $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
348 
349  // Add line
350  if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
351  {
352  $pdf->setPage($pageposafter);
353  $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
354  //$pdf->SetDrawColor(190,190,200);
355  $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
356  $pdf->SetLineStyle(array('dash'=>0));
357  }
358 
359  $nexY+=2; // Passe espace entre les lignes
360 
361  // Detect if some page were added automatically and output _tableau for past pages
362  while ($pagenb < $pageposafter)
363  {
364  $pdf->setPage($pagenb);
365  if ($pagenb == 1)
366  {
367  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
368  }
369  else
370  {
371  $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
372  }
373  $this->_pagefoot($pdf,$object,$outputlangs,1);
374  $pagenb++;
375  $pdf->setPage($pagenb);
376  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
377  }
378  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
379  {
380  if ($pagenb == 1)
381  {
382  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
383  }
384  else
385  {
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  {
398  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
399  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
400  }
401  else
402  {
403  $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
404  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
405  }
406 
407  // Pied de page
408  $this->_pagefoot($pdf, $object, $outputlangs);
409  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
410 
411  $pdf->Close();
412 
413  $pdf->Output($file,'F');
414 
415  // Add pdfgeneration hook
416  if (! is_object($hookmanager))
417  {
418  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
419  $hookmanager=new HookManager($this->db);
420  }
421  $hookmanager->initHooks(array('pdfgeneration'));
422  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
423  global $action;
424  $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
425 
426  if (! empty($conf->global->MAIN_UMASK))
427  @chmod($file, octdec($conf->global->MAIN_UMASK));
428 
429  $this->result = array('fullpath'=>$file);
430 
431  return 1;
432  }
433  else
434  {
435  $this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
436  return 0;
437  }
438  }
439  else
440  {
441  $this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
442  return 0;
443  }
444  }
445 
458  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"));
465 
466  if (empty($hidetop))
467  {
468  $pdf->SetFont('','B', $default_font_size - 2);
469  $pdf->SetXY(10,$tab_top);
470  $pdf->MultiCell(10,5,"LS",0,'C',1);
471  $pdf->line(20, $tab_top, 20, $tab_top + $tab_height);
472  $pdf->SetXY(20,$tab_top);
473  $pdf->MultiCell(10,5,"LR",0,'C',1);
474  $pdf->line(30, $tab_top, 30, $tab_top + $tab_height);
475  $pdf->SetXY(30,$tab_top);
476  $pdf->MultiCell(20,5,$outputlangs->transnoentities("Ref"),0,'C',1);
477  $pdf->SetXY(50,$tab_top);
478  $pdf->MultiCell(90,5,$outputlangs->transnoentities("Description"),0,'L',1);
479  $pdf->SetXY(140,$tab_top);
480  $pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyOrdered"),0,'C',1);
481  $pdf->SetXY(170,$tab_top);
482  $pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyToShip"),0,'C',1);
483  }
484  $pdf->Rect(10, $tab_top, 190, $tab_height);
485  }
486 
496  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 
525  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  {
536  pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SENDING_DRAFT_WATERMARK);
537  }
538 
539  $posy=$this->marge_haute;
540  $posx=$this->page_largeur-$this->marge_droite-100;
541 
542  $Xoff = 90;
543  $Yoff = 0;
544 
545  $tab4_top = 60;
546  $tab4_hl = 6;
547  $tab4_sl = 4;
548  $line = 2;
549 
550  //*********************LOGO****************************
551  $pdf->SetXY(11,7);
552  $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
553  if ($this->emetteur->logo)
554  {
555  if (is_readable($logo))
556  {
557  $height=pdf_getHeightForLogo($logo);
558  $pdf->Image($logo,10, 5, 0, $height); // width=0 (auto)
559  }
560  else
561  {
562  $pdf->SetTextColor(200,0,0);
563  $pdf->SetFont('','B', $default_font_size - 2);
564  $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
565  $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
566  }
567  }
568  else
569  {
570  $text=$this->emetteur->name;
571  $pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
572  }
573 
574  //*********************Entete****************************
575  //Nom du Document
576  $pdf->SetXY($Xoff,7);
577  $pdf->SetFont('','B', $default_font_size + 2);
578  $pdf->SetTextColor(0,0,0);
579  $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Bordereau expedition
580  //Num Expedition
581  $Yoff = $Yoff+7;
582  $Xoff = 142;
583  //$pdf->Rect($Xoff, $Yoff, 85, 8);
584  $pdf->SetXY($Xoff,$Yoff);
585  $pdf->SetFont('','', $default_font_size - 2);
586  $pdf->SetTextColor(0,0,0);
587  $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R');
588  //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
589 
590  $origin = $object->origin;
591  $origin_id = $object->origin_id;
592 
593  // Add list of linked elements
594  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager);
595 
596  //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
597  //Definition Emplacement du bloc Societe
598  $Xoff = 110;
599  $blSocX=90;
600  $blSocY=24;
601  $blSocW=50;
602  $blSocX2=$blSocW+$blSocX;
603 
604  // Sender name
605  $pdf->SetTextColor(0,0,0);
606  $pdf->SetFont('','B', $default_font_size - 3);
607  $pdf->SetXY($blSocX,$blSocY+1);
608  $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
609  $pdf->SetTextColor(0,0,0);
610 
611  // Sender properties
612  $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
613 
614  $pdf->SetFont('','', $default_font_size - 3);
615  $pdf->SetXY($blSocX,$blSocY+4);
616  $pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
617 
618 
619  if ($object->thirdparty->code_client)
620  {
621  $Yoff+=3;
622  $posy=$Yoff;
623  $pdf->SetXY(100,$posy);
624  $pdf->SetTextColor(0,0,0);
625  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
626  }
627 
628  // Date Expedition
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(50, 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(50, 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  {
648  $object->GetUrlTrackingStatus($object->tracking_number);
649  if (! empty($object->tracking_url))
650  {
651  if ($object->shipping_method_id > 0)
652  {
653  // Get code using getLabelFromKey
654  $code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
655 
656  $label='';
657  $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
658  //var_dump($object->tracking_url != $object->tracking_number);exit;
659  if ($object->tracking_url != $object->tracking_number)
660  {
661  $label.=" : ";
662  $label.=$object->tracking_url;
663  }
664  $pdf->SetFont('','B', $default_font_size - 3);
665  $pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
666  }
667  }
668  }
669  else
670  {
671  $pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
672  }
673 
674 
675  // Shipping company (My Company)
676  $Yoff = $blSocY;
677  $blExpX=$Xoff-20;
678  $blW=52;
679  $Ydef = $Yoff;
680  $pdf->Rect($blExpX, $Yoff, $blW, 26);
681 
682  $object->fetch_thirdparty();
683 
684  // If SHIPPING contact defined on order, we use it
685  $usecontact=false;
686  $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
687  if (count($arrayidcontact) > 0)
688  {
689  $usecontact=true;
690  $result=$object->fetch_contact($arrayidcontact[0]);
691  }
692 
693  // Recipient name
694  // On peut utiliser le nom de la societe du contact
695  if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
696  $thirdparty = $object->contact;
697  } else {
698  $thirdparty = $object->thirdparty;
699  }
700 
701  $carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
702 
703  $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,((!empty($object->contact))?$object->contact:null),$usecontact,'targetwithdetails',$object);
704 
705  $blDestX=$blExpX+55;
706  $blW=54;
707  $Yoff = $Ydef +1;
708 
709  // Show Recipient frame
710  $pdf->SetFont('','B', $default_font_size - 3);
711  $pdf->SetXY($blDestX,$Yoff-4);
712  $pdf->MultiCell($blW,3, $outputlangs->transnoentities("Recipient"), 0, 'L');
713  $pdf->Rect($blDestX, $Yoff-1, $blW, 26);
714 
715  // Show recipient name
716  $pdf->SetFont('','B', $default_font_size - 3);
717  $pdf->SetXY($blDestX,$Yoff);
718  $pdf->MultiCell($blW,3, $carac_client_name, 0, 'L');
719 
720  $posy = $pdf->getY();
721 
722  // Show recipient information
723  $pdf->SetFont('','', $default_font_size - 3);
724  $pdf->SetXY($blDestX,$posy);
725  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
726  }
727 }
__construct($db=0)
Constructor.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:82
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition: pdf.lib.php:319
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:600
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition: pdf.lib.php:643
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:353
</td >< td class="liste_titre" align="right"></td ></tr >< tr class="liste_titre">< input type="checkbox" onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< tr class="oddeven">< td >< input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td >< td >< input type="checkbox" class="check" name="choose'.$i.'"></td >< td class="nowrap"></td >< td >< input type="hidden" name="desc' . $i . '" value="' . dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:573
Parent class of sending receipts models.
Class to manage contact/addresses.
pdf_getFormat(Translate $outputlangs=null)
Return array with format properties of default PDF format.
Definition: pdf.lib.php:42
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
_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:224
Class to manage Dolibarr users.
Definition: user.class.php:41
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:201
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
Class to manage hooks.
type
Definition: viewcat.php:284
$version
Dolibarr version of the loaded document string.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:245
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition: pdf.lib.php:1119
write_file(&$object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
dol_print_date($time, $format='', $tzoutput='tzserver', $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:1158
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
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...
_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.