dolibarr  9.0.0
pdf_soleil.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 Cédric Salvador <csalvador@gpcsolutions.fr>
8  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  * or see http://www.gnu.org/
23  */
24 
30 require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34 
35 
40 {
44  public $db;
45 
49  public $name;
50 
54  public $description;
55 
59  public $type;
60 
65  public $phpmin = array(5, 4);
66 
71  public $version = 'dolibarr';
72 
76  public $page_largeur;
77 
81  public $page_hauteur;
82 
86  public $format;
87 
91  public $marge_gauche;
92 
96  public $marge_droite;
97 
101  public $marge_haute;
102 
106  public $marge_basse;
107 
112  public $emetteur;
113 
119  function __construct($db)
120  {
121  global $conf,$langs,$mysoc;
122 
123  $this->db = $db;
124  $this->name = 'soleil';
125  $this->description = $langs->trans("DocumentModelStandardPDF");
126 
127  // Dimension page pour format A4
128  $this->type = 'pdf';
129  $formatarray=pdf_getFormat();
130  $this->page_largeur = $formatarray['width'];
131  $this->page_hauteur = $formatarray['height'];
132  $this->format = array($this->page_largeur,$this->page_hauteur);
133  $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
134  $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
135  $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
136  $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
137 
138  $this->option_logo = 1; // Affiche logo
139  $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION
140  $this->option_modereg = 0; // Affiche mode reglement
141  $this->option_condreg = 0; // Affiche conditions reglement
142  $this->option_codeproduitservice = 0; // Affiche code produit-service
143  $this->option_multilang = 1; // Dispo en plusieurs langues
144  $this->option_draft_watermark = 1; //Support add of a watermark on drafts
145 
146  // Get source company
147  $this->emetteur=$mysoc;
148  if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if not defined
149 
150  // Define position of columns
151  $this->posxdesc=$this->marge_gauche+1;
152  }
153 
154  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
166  function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
167  {
168  // phpcs:enable
169  global $user,$langs,$conf,$mysoc,$db,$hookmanager;
170 
171  if (! is_object($outputlangs)) $outputlangs=$langs;
172  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
173  if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
174 
175  // Load traductions files requiredby by page
176  $outputlangs->loadLangs(array("main", "interventions", "dict", "companies"));
177 
178  if ($conf->ficheinter->dir_output)
179  {
180  $object->fetch_thirdparty();
181 
182  // Definition of $dir and $file
183  if ($object->specimen)
184  {
185  $dir = $conf->ficheinter->dir_output;
186  $file = $dir . "/SPECIMEN.pdf";
187  }
188  else
189  {
190  $objectref = dol_sanitizeFileName($object->ref);
191  $dir = $conf->ficheinter->dir_output . "/" . $objectref;
192  $file = $dir . "/" . $objectref . ".pdf";
193  }
194 
195  if (! file_exists($dir))
196  {
197  if (dol_mkdir($dir) < 0)
198  {
199  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
200  return 0;
201  }
202  }
203 
204  if (file_exists($dir))
205  {
206  // Add pdfgeneration hook
207  if (! is_object($hookmanager))
208  {
209  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
210  $hookmanager=new HookManager($this->db);
211  }
212 
213  $hookmanager->initHooks(array('pdfgeneration'));
214  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
215  global $action;
216  $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
217 
218  $nblignes = count($object->lines);
219 
220  // Create pdf instance
221  $pdf=pdf_getInstance($this->format);
222  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
223  $heightforinfotot = 50; // Height reserved to output the info and total part
224  $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
225  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
226  if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
227  $pdf->SetAutoPageBreak(1,0);
228 
229  if (class_exists('TCPDF'))
230  {
231  $pdf->setPrintHeader(false);
232  $pdf->setPrintFooter(false);
233  }
234  $pdf->SetFont(pdf_getPDFFont($outputlangs));
235  // Set path to the background PDF File
236  if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
237  {
238  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
239  $tplidx = $pdf->importPage(1);
240  }
241 
242  $pdf->Open();
243  $pagenb=0;
244  $pdf->SetDrawColor(128,128,128);
245 
246  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
247  $pdf->SetSubject($outputlangs->transnoentities("InterventionCard"));
248  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
249  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
250  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("InterventionCard"));
251  if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
252 
253  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
254 
255  // New page
256  $pdf->AddPage();
257  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
258  $pagenb++;
259  $this->_pagehead($pdf, $object, 1, $outputlangs);
260  $pdf->SetFont('','', $default_font_size - 1);
261  $pdf->SetTextColor(0,0,0);
262 
263  $tab_top = 90;
264  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
265  $tab_height = 130;
266  $tab_height_newpage = 150;
267 
268  // Affiche notes
269  $notetoshow=empty($object->note_public)?'':$object->note_public;
270  if ($notetoshow)
271  {
272  $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
273  complete_substitutions_array($substitutionarray, $outputlangs, $object);
274  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
275 
276  $tab_top = 88;
277 
278  $pdf->SetFont('','', $default_font_size - 1);
279  $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
280  $nexY = $pdf->GetY();
281  $height_note=$nexY-$tab_top;
282 
283  // Rect prend une longueur en 3eme param
284  $pdf->SetDrawColor(192,192,192);
285  $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
286 
287  $tab_height = $tab_height - $height_note;
288  $tab_top = $nexY+6;
289  }
290  else
291  {
292  $height_note=0;
293  }
294 
295  $iniY = $tab_top + 7;
296  $curY = $tab_top + 7;
297  $nexY = $tab_top + 7;
298 
299  $pdf->SetXY($this->marge_gauche, $tab_top);
300  $pdf->MultiCell(190,5,$outputlangs->transnoentities("Description"),0,'L',0);
301  $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur-$this->marge_droite, $tab_top + 5);
302 
303  $pdf->SetFont('', '', $default_font_size - 1);
304 
305  $pdf->SetXY($this->marge_gauche, $tab_top + 5);
306  $text=$object->description;
307  if ($object->duration > 0)
308  {
309  $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
310  $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
311  }
312  $desc=dol_htmlentitiesbr($text,1);
313  //print $outputlangs->convToOutputCharset($desc); exit;
314 
315  $pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
316  $nexY = $pdf->GetY();
317 
318  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
319 
320  $nblines = count($object->lines);
321 
322  // Loop on each lines
323  for ($i = 0; $i < $nblines; $i++)
324  {
325  $objectligne = $object->lines[$i];
326 
327  $valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id);
328  if ($valide > 0 || $object->specimen)
329  {
330  $curY = $nexY;
331  $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
332  $pdf->SetTextColor(0,0,0);
333 
334  $pdf->setTopMargin($tab_top_newpage);
335  $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
336  $pageposbefore=$pdf->getPage();
337 
338  // Description of product line
339  $curX = $this->posxdesc-1;
340 
341  // Description of product line
342  if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR))
343  {
344  $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true);
345  }
346  else
347  {
348  $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'day',false,$outputlangs,true);
349  }
350 
351  if ($objectligne->duration > 0)
352  {
353  $txt.=" - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration);
354  }
355  $txt='<strong>'.dol_htmlentitiesbr($txt,1,$outputlangs->charset_output).'</strong>';
356  $desc=dol_htmlentitiesbr($objectligne->desc,1);
357 
358  $pdf->startTransaction();
359  $pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt,$desc), 0, 1, 0);
360  $pageposafter=$pdf->getPage();
361  if ($pageposafter > $pageposbefore) // There is a pagebreak
362  {
363  $pdf->rollbackTransaction(true);
364  $pageposafter=$pageposbefore;
365  //print $pageposafter.'-'.$pageposbefore;exit;
366  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
367  $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0);
368  $pageposafter=$pdf->getPage();
369  $posyafter=$pdf->GetY();
370  //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
371  if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
372  {
373  if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
374  {
375  $pdf->AddPage('','',true);
376  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
377  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
378  $pdf->setPage($pageposafter+1);
379  }
380  }
381  }
382  else // No pagebreak
383  {
384  $pdf->commitTransaction();
385  }
386 
387  $nexY = $pdf->GetY();
388  $pageposafter=$pdf->getPage();
389  $pdf->setPage($pageposbefore);
390  $pdf->setTopMargin($this->marge_haute);
391  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
392 
393  // We suppose that a too long description is moved completely on next page
394  if ($pageposafter > $pageposbefore) {
395  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
396  }
397 
398  $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
399 
400  // Detect if some page were added automatically and output _tableau for past pages
401  while ($pagenb < $pageposafter)
402  {
403  $pdf->setPage($pagenb);
404  if ($pagenb == 1)
405  {
406  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
407  }
408  else
409  {
410  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
411  }
412  $this->_pagefoot($pdf,$object,$outputlangs,1);
413  $pagenb++;
414  $pdf->setPage($pagenb);
415  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
416  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
417  }
418  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
419  {
420  if ($pagenb == 1)
421  {
422  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
423  }
424  else
425  {
426  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
427  }
428  $this->_pagefoot($pdf,$object,$outputlangs,1);
429  // New page
430  $pdf->AddPage();
431  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
432  $pagenb++;
433  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
434  }
435  }
436  }
437 
438  // Show square
439  if ($pagenb == 1)
440  {
441  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
442  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
443  }
444  else
445  {
446  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
447  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
448  }
449 
450  $this->_pagefoot($pdf,$object,$outputlangs);
451  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
452 
453  $pdf->Close();
454  $pdf->Output($file,'F');
455 
456  // Add pdfgeneration hook
457  $hookmanager->initHooks(array('pdfgeneration'));
458  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
459  global $action;
460  $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
461 
462  if (! empty($conf->global->MAIN_UMASK))
463  @chmod($file, octdec($conf->global->MAIN_UMASK));
464 
465  $this->result = array('fullpath'=>$file);
466 
467  return 1;
468  }
469  else
470  {
471  $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
472  return 0;
473  }
474  }
475  else
476  {
477  $this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR");
478  return 0;
479  }
480  }
481 
494  function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
495  {
496  global $conf;
497 
498 
499  $default_font_size = pdf_getPDFFontSize($outputlangs);
500 /*
501  $pdf->SetXY($this->marge_gauche, $tab_top);
502  $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
503  $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
504 
505  $pdf->SetFont('','', $default_font_size - 1);
506 
507  $pdf->MultiCell(0, 3, ''); // Set interline to 3
508  $pdf->SetXY($this->marge_gauche, $tab_top + 8);
509  $text=$object->description;
510  if ($object->duration > 0)
511  {
512  $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
513  $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
514  }
515  $desc=dol_htmlentitiesbr($text,1);
516  //print $outputlangs->convToOutputCharset($desc); exit;
517 
518  $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1);
519  $nexY = $pdf->GetY();
520 
521  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
522 
523  $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
524 */
525 
526  // Output Rect
527  $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+1, 0, 0); // Rect prend une longueur en 3eme param et 4eme param
528 
529  if (empty($hidebottom))
530  {
531  $pdf->SetXY(20,230);
532  $pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0);
533 
534  $pdf->SetXY(20,235);
535  $pdf->MultiCell(80,25, '', 1);
536 
537  $pdf->SetXY(110,230);
538  $pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0);
539 
540  $pdf->SetXY(110,235);
541  $pdf->MultiCell(80,25, '', 1);
542  }
543  }
544 
554  function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
555  {
556  global $conf,$langs;
557  $default_font_size = pdf_getPDFFontSize($outputlangs);
558 
559  // Load traductions files requiredby by page
560  $outputlangs->loadLangs(array("main", "dict", "companies", "interventions"));
561 
562  pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
563 
564  //Affiche le filigrane brouillon - Print Draft Watermark
565  if($object->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) )
566  {
567  pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FICHINTER_DRAFT_WATERMARK);
568  }
569 
570  //Prepare la suite
571  $pdf->SetTextColor(0,0,60);
572  $pdf->SetFont('','B', $default_font_size + 3);
573 
574  $posx=$this->page_largeur-$this->marge_droite-100;
575  $posy=$this->marge_haute;
576 
577  $pdf->SetXY($this->marge_gauche,$posy);
578 
579  // Logo
580  $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
581  if ($this->emetteur->logo)
582  {
583  if (is_readable($logo))
584  {
585  $height=pdf_getHeightForLogo($logo);
586  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
587  }
588  else
589  {
590  $pdf->SetTextColor(200,0,0);
591  $pdf->SetFont('','B',$default_font_size - 2);
592  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
593  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
594  }
595  }
596  else
597  {
598  $text=$this->emetteur->name;
599  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
600  }
601 
602  $pdf->SetFont('','B',$default_font_size + 3);
603  $pdf->SetXY($posx,$posy);
604  $pdf->SetTextColor(0,0,60);
605  $title=$outputlangs->transnoentities("InterventionCard");
606  $pdf->MultiCell(100, 4, $title, '', 'R');
607 
608  $pdf->SetFont('','B',$default_font_size + 2);
609 
610  $posy+=5;
611  $pdf->SetXY($posx,$posy);
612  $pdf->SetTextColor(0,0,60);
613  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
614 
615  $posy+=1;
616  $pdf->SetFont('','', $default_font_size);
617 
618  $posy+=4;
619  $pdf->SetXY($posx,$posy);
620  $pdf->SetTextColor(0,0,60);
621  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->datec,"day",false,$outputlangs,true), '', 'R');
622 
623  if ($object->thirdparty->code_client)
624  {
625  $posy+=4;
626  $pdf->SetXY($posx,$posy);
627  $pdf->SetTextColor(0,0,60);
628  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
629  }
630 
631  if ($showaddress)
632  {
633  // Sender properties
634  $carac_emetteur='';
635  // Add internal contact of proposal if defined
636  $arrayidcontact=$object->getIdContact('internal','INTERREPFOLL');
637  if (count($arrayidcontact) > 0)
638  {
639  $object->fetch_user($arrayidcontact[0]);
640  $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
641  }
642 
643  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
644 
645  // Show sender
646  $posy=42;
647  $posx=$this->marge_gauche;
648  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
649  $hautcadre=40;
650 
651  // Show sender frame
652  $pdf->SetTextColor(0,0,0);
653  $pdf->SetFont('','', $default_font_size - 2);
654  $pdf->SetXY($posx,$posy-5);
655  $pdf->SetXY($posx,$posy);
656  $pdf->SetFillColor(230,230,230);
657  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
658 
659  // Show sender name
660  $pdf->SetXY($posx+2,$posy+3);
661  $pdf->SetTextColor(0,0,60);
662  $pdf->SetFont('','B',$default_font_size);
663  $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
664  $posy=$pdf->getY();
665 
666  // Show sender information
667  $pdf->SetFont('','', $default_font_size - 1);
668  $pdf->SetXY($posx+2,$posy);
669  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
670 
671 
672  // If CUSTOMER contact defined, we use it
673  $usecontact=false;
674  $arrayidcontact=$object->getIdContact('external','CUSTOMER');
675  if (count($arrayidcontact) > 0)
676  {
677  $usecontact=true;
678  $result=$object->fetch_contact($arrayidcontact[0]);
679  }
680 
681  //Recipient name
682  // On peut utiliser le nom de la societe du contact
683  if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
684  $thirdparty = $object->contact;
685  } else {
686  $thirdparty = $object->thirdparty;
687  }
688 
689  $carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
690 
691  $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target',$object);
692 
693  // Show recipient
694  $widthrecbox=100;
695  if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
696  $posy=42;
697  $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
698  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
699 
700  // Show recipient frame
701  $pdf->SetTextColor(0,0,0);
702  $pdf->SetFont('','', $default_font_size - 2);
703  $pdf->SetXY($posx+2,$posy-5);
704  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
705  $pdf->SetTextColor(0,0,0);
706 
707  // Show recipient name
708  $pdf->SetXY($posx+2,$posy+3);
709  $pdf->SetFont('','B', $default_font_size);
710  $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
711 
712  $posy = $pdf->getY();
713 
714  // Show recipient information
715  $pdf->SetFont('','', $default_font_size - 1);
716  $pdf->SetXY($posx+2,$posy);
717  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
718  }
719  }
720 
730  function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
731  {
732  global $conf;
733  $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
734  return pdf_pagefoot($pdf,$outputlangs,'FICHINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
735  }
736 }
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
__construct($db)
Constructor.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
Class to build interventions documents with model Soleil.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition: pdf.lib.php:643
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
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
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
$version
Dolibarr version of the loaded document string.
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
Parent class to manage intervention document templates.
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
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_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition: pdf.lib.php:623
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...
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...