dolibarr  7.0.0-beta
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@capnetworks.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 {
40  var $emetteur; // Objet societe qui emet
41 
42 
48  function __construct($db=0)
49  {
50  global $conf,$langs,$mysoc;
51 
52  $this->db = $db;
53  $this->name = "merou";
54  $this->description = $langs->trans("DocumentModelMerou");
55 
56  $this->type = 'pdf';
57  $formatarray=pdf_getFormat();
58  $this->page_largeur = $formatarray['width'];
59  $this->page_hauteur = round($formatarray['height']/2);
60  $this->format = array($this->page_largeur,$this->page_hauteur);
61  $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
62  $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
63  $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
64  $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
65 
66  $this->option_logo = 1;
67 
68  // Recupere emmetteur
69  $this->emetteur=$mysoc;
70  if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined
71  }
72 
73 
85  function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
86  {
87  global $user,$conf,$langs,$mysoc,$hookmanager;
88 
89  $object->fetch_thirdparty();
90 
91  if (! is_object($outputlangs)) $outputlangs=$langs;
92  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
93  if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
94 
95  $outputlangs->load("main");
96  $outputlangs->load("dict");
97  $outputlangs->load("companies");
98  $outputlangs->load("bills");
99  $outputlangs->load("products");
100  $outputlangs->load("propal");
101  $outputlangs->load("deliveries");
102  $outputlangs->load("sendings");
103  $outputlangs->load("productbatch");
104 
105  if ($conf->expedition->dir_output)
106  {
107  $object->fetch_thirdparty();
108 
109  $origin = $object->origin;
110 
111  //Creation de l expediteur
112  $this->expediteur = $mysoc;
113 
114  //Creation du destinataire
115  $idcontact = $object->$origin->getIdContact('external','SHIPPING');
116  $this->destinataire = new Contact($this->db);
117  if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
118 
119  //Creation du livreur
120  $idcontact = $object->$origin->getIdContact('internal','LIVREUR');
121  $this->livreur = new User($this->db);
122  if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
123 
124  // Definition de $dir et $file
125  if ($object->specimen)
126  {
127  $dir = $conf->expedition->dir_output."/sending";
128  $file = $dir . "/SPECIMEN.pdf";
129  }
130  else
131  {
132  $expref = dol_sanitizeFileName($object->ref);
133  $dir = $conf->expedition->dir_output . "/sending/" . $expref;
134  $file = $dir . "/" . $expref . ".pdf";
135  }
136 
137  if (! file_exists($dir))
138  {
139  if (dol_mkdir($dir) < 0)
140  {
141  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
142  return 0;
143  }
144  }
145 
146  if (file_exists($dir))
147  {
148  // Add pdfgeneration hook
149  if (! is_object($hookmanager))
150  {
151  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
152  $hookmanager=new HookManager($this->db);
153  }
154  $hookmanager->initHooks(array('pdfgeneration'));
155  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
156  global $action;
157  $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
158 
159  $nblignes = count($object->lines);
160 
161  $pdf=pdf_getInstance($this->format,'mm','l');
162  $default_font_size = pdf_getPDFFontSize($outputlangs);
163  $heightforinfotot = 0; // Height reserved to output the info and total part
164  $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
165  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
166  $pdf->SetAutoPageBreak(1,0);
167 
168  if (class_exists('TCPDF'))
169  {
170  $pdf->setPrintHeader(false);
171  $pdf->setPrintFooter(false);
172  }
173  $pdf->SetFont(pdf_getPDFFont($outputlangs));
174  // Set path to the background PDF File
175  if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
176  {
177  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
178  $tplidx = $pdf->importPage(1);
179  }
180 
181  $pdf->Open();
182  $pagenb=0;
183  $pdf->SetDrawColor(128,128,128);
184 
185  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
186 
187  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
188  $pdf->SetSubject($outputlangs->transnoentities("Shipment"));
189  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
190  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
191  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
192  if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
193 
194  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
195 
196  // New page
197  $pdf->AddPage();
198  $pagenb++;
199  $this->_pagehead($pdf, $object, 1, $outputlangs);
200  $pdf->SetFont('','', $default_font_size - 3);
201  $pdf->MultiCell(0, 3, ''); // Set interline to 3
202  $pdf->SetTextColor(0,0,0);
203 
204  $tab_top = 52;
205  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
206  $tab_height = $this->page_hauteur - $tab_top - $heightforfooter;
207  $tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter;
208 
209  // Affiche notes
210  if (! empty($object->note_public))
211  {
212  $pdf->SetFont('','', $default_font_size - 1);
213  $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
214  $nexY = $pdf->GetY();
215  $height_note=$nexY-$tab_top;
216 
217  // Rect prend une longueur en 3eme param
218  $pdf->SetDrawColor(192,192,192);
219  $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
220 
221  $tab_height = $tab_height - $height_note;
222  $tab_top = $nexY+6;
223  }
224  else
225  {
226  $height_note=0;
227  }
228 
229 
230  $pdf->SetFillColor(240,240,240);
231  $pdf->SetTextColor(0,0,0);
232  $pdf->SetXY(10, $tab_top + 5);
233 
234  $iniY = $tab_top + 7;
235  $curY = $tab_top + 7;
236  $nexY = $tab_top + 7;
237 
238  $num=count($object->lines);
239  // Loop on each lines
240  for ($i = 0; $i < $num; $i++)
241  {
242  $curY = $nexY;
243  $pdf->SetFont('','', $default_font_size - 3);
244  $pdf->SetTextColor(0,0,0);
245 
246  $pdf->setTopMargin($tab_top_newpage);
247  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
248  $pageposbefore=$pdf->getPage();
249 
250  // Description de la ligne produit
251  $libelleproduitservice = pdf_writelinedesc($pdf,$object,$i,$outputlangs,90,3,50,$curY,0,1);
252 
253  $nexY = $pdf->GetY();
254  $pageposafter=$pdf->getPage();
255  $pdf->setPage($pageposbefore);
256  $pdf->setTopMargin($this->marge_haute);
257  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
258 
259  // We suppose that a too long description is moved completely on next page
260  if ($pageposafter > $pageposbefore) {
261  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
262  }
263 
264  $pdf->SetFont('','', $default_font_size - 3);
265 
266  // Check boxes
267  $pdf->SetDrawColor(120,120,120);
268  $pdf->Rect(10+3, $curY, 3, 3);
269  $pdf->Rect(20+3, $curY, 3, 3);
270 
271  //Insertion de la reference du produit
272  $pdf->SetXY(30, $curY);
273  $pdf->SetFont('','B', $default_font_size - 3);
274  $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0);
275 
276  $pdf->SetXY(140, $curY);
277  $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked, 0, 'C', 0);
278 
279  $pdf->SetXY(170, $curY);
280  $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
281 
282  // Add line
283  if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
284  {
285  $pdf->setPage($pageposafter);
286  $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
287  //$pdf->SetDrawColor(190,190,200);
288  $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
289  $pdf->SetLineStyle(array('dash'=>0));
290  }
291 
292  $nexY+=2; // Passe espace entre les lignes
293 
294  // Detect if some page were added automatically and output _tableau for past pages
295  while ($pagenb < $pageposafter)
296  {
297  $pdf->setPage($pagenb);
298  if ($pagenb == 1)
299  {
300  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
301  }
302  else
303  {
304  $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
305  }
306  $this->_pagefoot($pdf,$object,$outputlangs,1);
307  $pagenb++;
308  $pdf->setPage($pagenb);
309  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
310  }
311  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
312  {
313  if ($pagenb == 1)
314  {
315  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
316  }
317  else
318  {
319  $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
320  }
321  $this->_pagefoot($pdf,$object,$outputlangs,1);
322  // New page
323  $pdf->AddPage();
324  $pagenb++;
325  }
326  }
327 
328  // Show square
329  if ($pagenb == 1)
330  {
331  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
332  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
333  }
334  else
335  {
336  $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
337  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
338  }
339 
340  // Pied de page
341  $this->_pagefoot($pdf, $object, $outputlangs);
342  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
343 
344  $pdf->Close();
345 
346  $pdf->Output($file,'F');
347 
348  // Add pdfgeneration hook
349  if (! is_object($hookmanager))
350  {
351  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
352  $hookmanager=new HookManager($this->db);
353  }
354  $hookmanager->initHooks(array('pdfgeneration'));
355  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
356  global $action;
357  $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
358 
359  if (! empty($conf->global->MAIN_UMASK))
360  @chmod($file, octdec($conf->global->MAIN_UMASK));
361 
362  $this->result = array('fullpath'=>$file);
363 
364  return 1;
365  }
366  else
367  {
368  $this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
369  return 0;
370  }
371  }
372  else
373  {
374  $this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
375  return 0;
376  }
377  }
378 
391  function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
392  {
393  global $langs;
394  $default_font_size = pdf_getPDFFontSize($outputlangs);
395 
396  $langs->load("main");
397  $langs->load("bills");
398 
399  if (empty($hidetop))
400  {
401  $pdf->SetFont('','B', $default_font_size - 2);
402  $pdf->SetXY(10,$tab_top);
403  $pdf->MultiCell(10,5,"LS",0,'C',1);
404  $pdf->line(20, $tab_top, 20, $tab_top + $tab_height);
405  $pdf->SetXY(20,$tab_top);
406  $pdf->MultiCell(10,5,"LR",0,'C',1);
407  $pdf->line(30, $tab_top, 30, $tab_top + $tab_height);
408  $pdf->SetXY(30,$tab_top);
409  $pdf->MultiCell(20,5,$outputlangs->transnoentities("Ref"),0,'C',1);
410  $pdf->SetXY(50,$tab_top);
411  $pdf->MultiCell(90,5,$outputlangs->transnoentities("Description"),0,'L',1);
412  $pdf->SetXY(140,$tab_top);
413  $pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyOrdered"),0,'C',1);
414  $pdf->SetXY(170,$tab_top);
415  $pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyToShip"),0,'C',1);
416  }
417  $pdf->Rect(10, $tab_top, 190, $tab_height);
418  }
419 
429  function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0)
430  {
431  $default_font_size = pdf_getPDFFontSize($outputlangs);
432  $pdf->SetFont('','', $default_font_size - 2);
433  $pdf->SetY(-23);
434  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("GoodStatusDeclaration"), 0, 'L');
435  $pdf->SetY(-13);
436  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ToAndDate"), 0, 'C');
437  $pdf->SetXY(120,-23);
438  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
439 
440  // Show page nb only on iso languages (so default Helvetica font)
441  //if (pdf_getPDFFont($outputlangs) == 'Helvetica')
442  //{
443  // $pdf->SetXY(-10,-10);
444  // $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
445  //}
446  }
447 
448 
458  function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
459  {
460  global $conf, $langs,$hookmanager;
461 
462  $default_font_size = pdf_getPDFFontSize($outputlangs);
463 
464  pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
465 
466  //Affiche le filigrane brouillon - Print Draft Watermark
467  if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) )
468  {
469  pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SENDING_DRAFT_WATERMARK);
470  }
471 
472  $posy=$this->marge_haute;
473  $posx=$this->page_largeur-$this->marge_droite-100;
474 
475  $Xoff = 90;
476  $Yoff = 0;
477 
478  $tab4_top = 60;
479  $tab4_hl = 6;
480  $tab4_sl = 4;
481  $line = 2;
482 
483  //*********************LOGO****************************
484  $pdf->SetXY(11,7);
485  $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
486  if ($this->emetteur->logo)
487  {
488  if (is_readable($logo))
489  {
490  $height=pdf_getHeightForLogo($logo);
491  $pdf->Image($logo,10, 5, 0, $height); // width=0 (auto)
492  }
493  else
494  {
495  $pdf->SetTextColor(200,0,0);
496  $pdf->SetFont('','B', $default_font_size - 2);
497  $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
498  $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
499  }
500  }
501  else
502  {
503  $text=$this->emetteur->name;
504  $pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
505  }
506 
507  //*********************Entete****************************
508  //Nom du Document
509  $pdf->SetXY($Xoff,7);
510  $pdf->SetFont('','B', $default_font_size + 2);
511  $pdf->SetTextColor(0,0,0);
512  $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Bordereau expedition
513  //Num Expedition
514  $Yoff = $Yoff+7;
515  $Xoff = 142;
516  //$pdf->Rect($Xoff, $Yoff, 85, 8);
517  $pdf->SetXY($Xoff,$Yoff);
518  $pdf->SetFont('','', $default_font_size - 2);
519  $pdf->SetTextColor(0,0,0);
520  $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R');
521  //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
522 
523  $origin = $object->origin;
524  $origin_id = $object->origin_id;
525 
526  // Add list of linked elements
527  $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager);
528 
529  //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
530  //Definition Emplacement du bloc Societe
531  $Xoff = 110;
532  $blSocX=90;
533  $blSocY=24;
534  $blSocW=50;
535  $blSocX2=$blSocW+$blSocX;
536 
537  // Sender name
538  $pdf->SetTextColor(0,0,0);
539  $pdf->SetFont('','B', $default_font_size - 3);
540  $pdf->SetXY($blSocX,$blSocY+1);
541  $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
542  $pdf->SetTextColor(0,0,0);
543 
544  // Sender properties
545  $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
546 
547  $pdf->SetFont('','', $default_font_size - 3);
548  $pdf->SetXY($blSocX,$blSocY+4);
549  $pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
550 
551 
552  if ($object->thirdparty->code_client)
553  {
554  $Yoff+=3;
555  $posy=$Yoff;
556  $pdf->SetXY(100,$posy);
557  $pdf->SetTextColor(0,0,0);
558  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
559  }
560 
561  // Date Expedition
562  $Yoff = $Yoff+7;
563  $pdf->SetXY($blSocX-80,$blSocY+17);
564 
565  $pdf->SetFont('','B', $default_font_size - 3);
566  $pdf->SetTextColor(0,0,0);
567  $pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_delivery,'day',false,$outputlangs,true), '', 'L');
568 
569  $pdf->SetXY($blSocX-80,$blSocY+20);
570  $pdf->SetFont('','B', $default_font_size - 3);
571  $pdf->SetTextColor(0,0,0);
572  $pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, '', 'L');
573 
574  // Deliverer
575  $pdf->SetXY($blSocX-80,$blSocY+23);
576  $pdf->SetFont('','', $default_font_size - 3);
577  $pdf->SetTextColor(0,0,0);
578 
579  if (! empty($object->tracking_number))
580  {
581  $object->GetUrlTrackingStatus($object->tracking_number);
582  if (! empty($object->tracking_url))
583  {
584  if ($object->shipping_method_id > 0)
585  {
586  // Get code using getLabelFromKey
587  $code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
588 
589  $label='';
590  $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
591  //var_dump($object->tracking_url != $object->tracking_number);exit;
592  if ($object->tracking_url != $object->tracking_number)
593  {
594  $label.=" : ";
595  $label.=$object->tracking_url;
596  }
597  $pdf->SetFont('','B', $default_font_size - 3);
598  $pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
599  }
600  }
601  }
602  else
603  {
604  $pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
605  }
606 
607 
608  // Shipping company (My Company)
609  $Yoff = $blSocY;
610  $blExpX=$Xoff-20;
611  $blW=52;
612  $Ydef = $Yoff;
613  $pdf->Rect($blExpX, $Yoff, $blW, 26);
614 
615  $object->fetch_thirdparty();
616 
617  // If SHIPPING contact defined on order, we use it
618  $usecontact=false;
619  $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
620  if (count($arrayidcontact) > 0)
621  {
622  $usecontact=true;
623  $result=$object->fetch_contact($arrayidcontact[0]);
624  }
625 
626  // Recipient name
627  // On peut utiliser le nom de la societe du contact
628  if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
629  $thirdparty = $object->contact;
630  } else {
631  $thirdparty = $object->thirdparty;
632  }
633 
634  $carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
635 
636  $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,((!empty($object->contact))?$object->contact:null),$usecontact,'targetwithdetails',$object);
637 
638  $blDestX=$blExpX+55;
639  $blW=54;
640  $Yoff = $Ydef +1;
641 
642  // Show Recipient frame
643  $pdf->SetFont('','B', $default_font_size - 3);
644  $pdf->SetXY($blDestX,$Yoff-4);
645  $pdf->MultiCell($blW,3, $outputlangs->transnoentities("Recipient"), 0, 'L');
646  $pdf->Rect($blDestX, $Yoff-1, $blW, 26);
647 
648  // Show recipient name
649  $pdf->SetFont('','B', $default_font_size - 3);
650  $pdf->SetXY($blDestX,$Yoff);
651  $pdf->MultiCell($blW,3, $carac_client_name, 0, 'L');
652 
653  $posy = $pdf->getY();
654 
655  // Show recipient information
656  $pdf->SetFont('','', $default_font_size - 3);
657  $pdf->SetXY($blDestX,$posy);
658  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
659  }
660 }
__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:350
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:580
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition: pdf.lib.php:623
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:384
Parent class of sending receipts models.
Class to manage contact/addresses.
</td >< tdclass="liste_titre"align="right"></td ></tr >< trclass="liste_titre">< inputtype="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< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="'.$i.'"'.$disabled.'></td >< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"></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:554
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:256
Class to manage Dolibarr users.
Definition: user.class.php:39
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:233
Class to manage hooks.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:277
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
Definition: pdf.lib.php:1100
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
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:1139
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.
Classe permettant de generer les borderaux envoi au modele Merou.
type
Definition: viewcat.php:283
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.