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