dolibarr  9.0.0
pdf_strato.modules.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
6  * Copyright (C) 2011 Fabrice CHERRIER
7  * Copyright (C) 2013-2018 Philippe Grand <philippe.grand@atoo-net.com>
8  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
9  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  * or see http://www.gnu.org/
24  */
25 
31 require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
36 
37 
42 {
46  public $db;
47 
51  public $name;
52 
56  public $description;
57 
61  public $type;
62 
67  public $phpmin = array(5, 4);
68 
73  public $version = 'dolibarr';
74 
78  public $page_largeur;
79 
83  public $page_hauteur;
84 
88  public $format;
89 
93  public $marge_gauche;
94 
98  public $marge_droite;
99 
103  public $marge_haute;
104 
108  public $marge_basse;
109 
114  public $emetteur;
115 
120  public $recipient;
121 
127  function __construct($db)
128  {
129  global $conf,$langs,$mysoc;
130 
131  $this->db = $db;
132  $this->name = 'strato';
133  $this->description = $langs->trans("StandardContractsTemplate");
134 
135  // Dimension page pour format A4
136  $this->type = 'pdf';
137  $formatarray=pdf_getFormat();
138 
139  $this->page_largeur = $formatarray['width'];
140  $this->page_hauteur = $formatarray['height'];
141  $this->format = array($this->page_largeur,$this->page_hauteur);
142  $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
143  $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
144  $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
145  $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
146 
147  $this->option_logo = 1; // Affiche logo
148  $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION
149  $this->option_modereg = 0; // Affiche mode reglement
150  $this->option_condreg = 0; // Affiche conditions reglement
151  $this->option_codeproduitservice = 0; // Affiche code produit-service
152  $this->option_multilang = 0; // Dispo en plusieurs langues
153  $this->option_draft_watermark = 1; //Support add of a watermark on drafts
154 
155  // Get source company
156  $this->emetteur=$mysoc;
157  if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if not defined
158 
159  // Define position of columns
160  $this->posxdesc=$this->marge_gauche+1;
161  }
162 
163  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
175  function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
176  {
177  // phpcs:enable
178  global $user,$langs,$conf,$hookmanager,$mysoc;
179 
180  if (! is_object($outputlangs)) $outputlangs=$langs;
181  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
182  if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
183 
184  // Load traductions files requiredby by page
185  $outputlangs->loadLangs(array("main", "dict", "companies", "contracts"));
186 
187  if ($conf->contrat->dir_output)
188  {
189  $object->fetch_thirdparty();
190 
191  // Definition of $dir and $file
192  if ($object->specimen)
193  {
194  $dir = $conf->contrat->dir_output;
195  $file = $dir . "/SPECIMEN.pdf";
196  }
197  else
198  {
199  $objectref = dol_sanitizeFileName($object->ref);
200  $dir = $conf->contrat->dir_output . "/" . $objectref;
201  $file = $dir . "/" . $objectref . ".pdf";
202  }
203 
204  if (! file_exists($dir))
205  {
206  if (dol_mkdir($dir) < 0)
207  {
208  $this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir);
209  return 0;
210  }
211  }
212 
213  if (file_exists($dir))
214  {
215  // Add pdfgeneration hook
216  if (! is_object($hookmanager))
217  {
218  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
219  $hookmanager=new HookManager($this->db);
220  }
221  $hookmanager->initHooks(array('pdfgeneration'));
222  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
223  global $action;
224  $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
225 
226  $pdf=pdf_getInstance($this->format);
227  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
228  $heightforinfotot = 50; // Height reserved to output the info and total part
229  $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
230  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
231  if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
232  $pdf->SetAutoPageBreak(1,0);
233 
234  if (class_exists('TCPDF'))
235  {
236  $pdf->setPrintHeader(false);
237  $pdf->setPrintFooter(false);
238  }
239  $pdf->SetFont(pdf_getPDFFont($outputlangs));
240  // Set path to the background PDF File
241  if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
242  {
243  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
244  $tplidx = $pdf->importPage(1);
245  }
246 
247  $pdf->Open();
248  $pagenb=0;
249  $pdf->SetDrawColor(128,128,128);
250 
251  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
252  $pdf->SetSubject($outputlangs->transnoentities("ContractCard"));
253  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
254  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
255  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("ContractCard")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
256  if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
257 
258  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
259 
260  // New page
261  $pdf->AddPage();
262  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
263  $pagenb++;
264  $this->_pagehead($pdf, $object, 1, $outputlangs);
265  $pdf->SetFont('','', $default_font_size - 1);
266  $pdf->MultiCell(0, 3, ''); // Set interline to 3
267  $pdf->SetTextColor(0,0,0);
268 
269  $tab_top = 90;
270  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
271 
272  // Affiche notes
273  if (! empty($object->note_public))
274  {
275  $tab_top -= 2;
276 
277  $pdf->SetFont('','', $default_font_size - 1);
278  $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
279  $nexY = $pdf->GetY();
280  $height_note=$nexY-$tab_top;
281 
282  // Rect prend une longueur en 3eme param
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_top = $nexY+6;
287  }
288 
289  $iniY = $tab_top + 7;
290  $curY = $tab_top + 7;
291  $nexY = $tab_top + 2;
292 
293  $pdf->SetXY($this->marge_gauche, $tab_top);
294 
295  $pdf->MultiCell(0, 2, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
296 
297  $nblines = count($object->lines);
298 
299  // Loop on each lines
300  for ($i = 0; $i < $nblines; $i++)
301  {
302  $objectligne = $object->lines[$i];
303 
304  $valide = $objectligne->id ? 1 : 0;
305 
306  if ($valide > 0 || $object->specimen)
307  {
308  $curX = $this->posxdesc-1;
309  $curY = $nexY;
310  $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
311  $pdf->SetTextColor(0,0,0);
312 
313  $pdf->setTopMargin($tab_top_newpage);
314  $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
315  $pageposbefore=$pdf->getPage();
316 
317  // Description of product line
318 
319  if ($objectligne->date_ouverture_prevue) {
320  $datei = dol_print_date($objectligne->date_ouverture_prevue,'day',false,$outputlangs,true);
321  } else {
322  $datei = $langs->trans("Unknown");
323  }
324 
325  if ($objectligne->date_fin_validite) {
326  $durationi = convertSecondToTime($objectligne->date_fin_validite - $objectligne->date_ouverture_prevue, 'allwithouthour');
327  $datee = dol_print_date($objectligne->date_fin_validite,'day',false,$outputlangs,true);
328  } else {
329  $durationi = $langs->trans("Unknown");
330  $datee = $langs->trans("Unknown");
331  }
332 
333  if ($objectligne->date_ouverture) {
334  $daters = dol_print_date($objectligne->date_ouverture,'day',false,$outputlangs,true);
335  } else {
336  $daters = $langs->trans("Unknown");
337  }
338 
339  if ($objectligne->date_cloture) {
340  $datere = dol_print_date($objectligne->date_cloture,'day',false,$outputlangs,true);
341  } else {
342  $datere = $langs->trans("Unknown");
343  }
344 
345  $txtpredefinedservice='';
346  $txtpredefinedservice = $objectligne->product_label;
347  if ($objectligne->product_label)
348  {
349  $txtpredefinedservice .= ' - ';
350  $txtpredefinedservice .= $objectligne->product_label;
351  }
352 
353  $desc=dol_htmlentitiesbr($objectligne->desc,1); // Desc (not empty for free lines)
354  $txt='';
355  $txt.=$outputlangs->transnoentities("Quantity").' : <strong>'.$objectligne->qty.'</strong> - '.$outputlangs->transnoentities("UnitPrice").' : <strong>'.price($objectligne->subprice).'</strong>'; // Desc (not empty for free lines)
356  $txt.='<br>';
357  $txt.=$outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>';
358  $txt.='<br>';
359  $txt.=$outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>';
360  if ($objectligne->date_cloture) $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>';
361 
362  $pdf->startTransaction();
363  $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0);
364  $pageposafter=$pdf->getPage();
365  if ($pageposafter > $pageposbefore) // There is a pagebreak
366  {
367  $pdf->rollbackTransaction(true);
368  $pageposafter=$pageposbefore;
369  //print $pageposafter.'-'.$pageposbefore;exit;
370  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
371  $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0);
372  $pageposafter=$pdf->getPage();
373  $posyafter=$pdf->GetY();
374 
375  if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
376  {
377  if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
378  {
379  $pdf->AddPage('','',true);
380  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
381  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
382  $pdf->setPage($pageposafter+1);
383  }
384  }
385  else
386  {
387  // We found a page break
388  $showpricebeforepagebreak=0;
389  }
390  }
391  else // No pagebreak
392  {
393  $pdf->commitTransaction();
394  }
395 
396  $nexY = $pdf->GetY() + 2;
397  $pageposafter=$pdf->getPage();
398 
399  $pdf->setPage($pageposbefore);
400  $pdf->setTopMargin($this->marge_haute);
401  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
402 
403  // We suppose that a too long description is moved completely on next page
404  if ($pageposafter > $pageposbefore) {
405  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
406  }
407 
408  $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
409 
410  // Detect if some page were added automatically and output _tableau for past pages
411  while ($pagenb < $pageposafter)
412  {
413  $pdf->setPage($pagenb);
414  if ($pagenb == 1)
415  {
416  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1);
417  }
418  else
419  {
420  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1);
421  }
422  $this->_pagefoot($pdf,$object,$outputlangs,1);
423  $pagenb++;
424  $pdf->setPage($pagenb);
425  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
426  }
427 
428  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
429  {
430  if ($pagenb == 1)
431  {
432  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1);
433  }
434  else
435  {
436  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1);
437  }
438  $this->_pagefoot($pdf,$object,$outputlangs,1);
439  // New page
440  $pdf->AddPage();
441  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
442  $pagenb++;
443  }
444  }
445  }
446 
447  // Show square
448  if ($pagenb == 1)
449  {
450  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
451  $this->tabSignature($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs);
452  $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
453  }
454  else
455  {
456  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
457  $this->tabSignature($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, $outputlangs);
458  $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
459  }
460 
461  $this->_pagefoot($pdf,$object,$outputlangs);
462  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
463 
464  $pdf->Close();
465 
466  $pdf->Output($file,'F');
467 
468  // Add pdfgeneration hook
469  if (! is_object($hookmanager))
470  {
471  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
472  $hookmanager=new HookManager($this->db);
473  }
474  $hookmanager->initHooks(array('pdfgeneration'));
475  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
476  global $action;
477  $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
478 
479  if (! empty($conf->global->MAIN_UMASK))
480  @chmod($file, octdec($conf->global->MAIN_UMASK));
481 
482  $this->result = array('fullpath'=>$file);
483 
484  return 1;
485  }
486  else
487  {
488  $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
489  return 0;
490  }
491  }
492  else
493  {
494  $this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR");
495  return 0;
496  }
497  }
498 
511  function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
512  {
513  global $conf;
514 
515  // Force to disable hidetop and hidebottom
516  $hidebottom=0;
517  if ($hidetop) $hidetop=-1;
518 
519  $default_font_size = pdf_getPDFFontSize($outputlangs);
520 /*
521  $pdf->SetXY($this->marge_gauche, $tab_top);
522  $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
523  $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
524 
525  $pdf->SetFont('','', $default_font_size - 1);
526 
527  $pdf->MultiCell(0, 3, ''); // Set interline to 3
528  $pdf->SetXY($this->marge_gauche, $tab_top + 8);
529  $text=$object->description;
530  if ($object->duree > 0)
531  {
532  $totaltime=convertSecondToTime($object->duree,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
533  $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
534  }
535  $desc=dol_htmlentitiesbr($text,1);
536  //print $outputlangs->convToOutputCharset($desc); exit;
537 
538  $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1);
539  $nexY = $pdf->GetY();
540 
541  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
542 
543  $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
544 */
545 
546  // Output Rect
547  $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3); // Rect prend une longueur en 3eme param et 4eme param
548  }
549 
558  private function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs)
559  {
560  $pdf->SetDrawColor(128,128,128);
561  $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2);
562  $posy = $tab_top + $tab_height + 3 + 3;
563 
564  $pdf->SetXY($this->marge_gauche, $posy);
565  $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0);
566 
567  $pdf->SetXY($this->marge_gauche, $posy + 5);
568  $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 20, '', 1);
569 
570  $pdf->SetXY($posmiddle + 5, $posy);
571  $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0);
572 
573  $pdf->SetXY($posmiddle + 5, $posy + 5);
574  $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1);
575  }
576 
586  function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
587  {
588  global $conf,$langs;
589 
590  $default_font_size = pdf_getPDFFontSize($outputlangs);
591 
592  // Load traductions files requiredby by page
593  $outputlangs->loadLangs(array("main", "dict", "contract", "companies"));
594 
595  pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
596 
597  //Affiche le filigrane brouillon - Print Draft Watermark
598  if($object->statut==0 && (! empty($conf->global->CONTRACT_DRAFT_WATERMARK)) )
599  {
600  pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->CONTRACT_DRAFT_WATERMARK);
601  }
602 
603  //Prepare la suite
604  $pdf->SetTextColor(0,0,60);
605  $pdf->SetFont('','B', $default_font_size + 3);
606 
607  $posx=$this->page_largeur-$this->marge_droite-100;
608  $posy=$this->marge_haute;
609 
610  $pdf->SetXY($this->marge_gauche,$posy);
611 
612  // Logo
613  $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
614  if ($this->emetteur->logo)
615  {
616  if (is_readable($logo))
617  {
618  $height=pdf_getHeightForLogo($logo);
619  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
620  }
621  else
622  {
623  $pdf->SetTextColor(200,0,0);
624  $pdf->SetFont('','B',$default_font_size - 2);
625  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
626  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
627  }
628  }
629  else
630  {
631  $text=$this->emetteur->name;
632  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
633  }
634 
635  $pdf->SetFont('','B',$default_font_size + 3);
636  $pdf->SetXY($posx,$posy);
637  $pdf->SetTextColor(0,0,60);
638  $title=$outputlangs->transnoentities("ContractCard");
639  $pdf->MultiCell(100, 4, $title, '', 'R');
640 
641  $pdf->SetFont('','B',$default_font_size + 2);
642 
643  $posy+=5;
644  $pdf->SetXY($posx,$posy);
645  $pdf->SetTextColor(0,0,60);
646  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
647 
648  $posy+=1;
649  $pdf->SetFont('','', $default_font_size);
650 
651  $posy+=4;
652  $pdf->SetXY($posx,$posy);
653  $pdf->SetTextColor(0,0,60);
654  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_contrat,"day",false,$outputlangs,true), '', 'R');
655 
656  if ($object->thirdparty->code_client)
657  {
658  $posy+=4;
659  $pdf->SetXY($posx,$posy);
660  $pdf->SetTextColor(0,0,60);
661  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
662  }
663 
664  if ($showaddress)
665  {
666  // Sender properties
667  $carac_emetteur='';
668  // Add internal contact of proposal if defined
669  $arrayidcontact=$object->getIdContact('internal','INTERREPFOLL');
670  if (count($arrayidcontact) > 0)
671  {
672  $object->fetch_user($arrayidcontact[0]);
673  $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
674  }
675 
676  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
677 
678  // Show sender
679  $posy=42;
680  $posx=$this->marge_gauche;
681  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
682  $hautcadre=40;
683 
684  // Show sender frame
685  $pdf->SetTextColor(0,0,0);
686  $pdf->SetFont('','', $default_font_size - 2);
687  $pdf->SetXY($posx,$posy-5);
688  $pdf->SetXY($posx,$posy);
689  $pdf->SetFillColor(230,230,230);
690  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
691 
692  // Show sender name
693  $pdf->SetXY($posx+2,$posy+3);
694  $pdf->SetTextColor(0,0,60);
695  $pdf->SetFont('','B',$default_font_size);
696  $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
697  $posy=$pdf->getY();
698 
699  // Show sender information
700  $pdf->SetFont('','', $default_font_size - 1);
701  $pdf->SetXY($posx+2,$posy);
702  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
703 
704 
705  // If CUSTOMER contact defined, we use it
706  $usecontact=false;
707  $arrayidcontact=$object->getIdContact('external','CUSTOMER');
708  if (count($arrayidcontact) > 0)
709  {
710  $usecontact=true;
711  $result=$object->fetch_contact($arrayidcontact[0]);
712  }
713 
714  $this->recipient = $object->thirdparty;
715 
716  //Recipient name
717  // On peut utiliser le nom de la societe du contact
718  if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
719  $thirdparty = $object->contact;
720  } else {
721  $thirdparty = $object->thirdparty;
722  }
723 
724  $this->recipient->name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
725 
726  $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target', $object);
727 
728  // Show recipient
729  $widthrecbox=100;
730  if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
731  $posy=42;
732  $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
733  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
734 
735  // Show recipient frame
736  $pdf->SetTextColor(0,0,0);
737  $pdf->SetFont('','', $default_font_size - 2);
738  $pdf->SetXY($posx+2,$posy-5);
739  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
740  $pdf->SetTextColor(0,0,0);
741 
742  // Show recipient name
743  $pdf->SetXY($posx+2,$posy+3);
744  $pdf->SetFont('','B', $default_font_size);
745  $pdf->MultiCell($widthrecbox, 4, $this->recipient->name, 0, 'L');
746 
747  $posy = $pdf->getY();
748 
749  // Show recipient information
750  $pdf->SetFont('','', $default_font_size - 1);
751  $pdf->SetXY($posx+2,$posy);
752  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
753  }
754  }
755 
765  function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
766  {
767  global $conf;
768  $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
769  return pdf_pagefoot($pdf,$outputlangs,'CONTRACT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
770  }
771 }
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
Definition: date.lib.php:180
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
tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs)
Show footer signature of page.
Parent class to manage intervention document templates.
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
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.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:224
__construct($db)
Constructor.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:201
dol_concatdesc($text1, $text2, $forxml=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
$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
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
Definition: pdf.lib.php:872
$version
Dolibarr version of the loaded document string.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:245
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
Class to build contracts documents with model Strato.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.