dolibarr  7.0.0-beta
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@capnetworks.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 {
41  var $db;
42  var $name;
43  var $description;
44  var $type;
45 
46  var $phpmin = array(4,3,0); // Minimum version of PHP required by module
47  var $version = 'dolibarr';
48 
49  var $page_largeur;
50  var $page_hauteur;
51  var $format;
52  var $marge_gauche;
53  var $marge_droite;
54  var $marge_haute;
55  var $marge_basse;
56 
62  function __construct($db)
63  {
64  global $conf,$langs,$mysoc;
65 
66  $this->db = $db;
67  $this->name = 'soleil';
68  $this->description = $langs->trans("DocumentModelStandardPDF");
69 
70  // Dimension page pour format A4
71  $this->type = 'pdf';
72  $formatarray=pdf_getFormat();
73  $this->page_largeur = $formatarray['width'];
74  $this->page_hauteur = $formatarray['height'];
75  $this->format = array($this->page_largeur,$this->page_hauteur);
76  $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
77  $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
78  $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
79  $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
80 
81  $this->option_logo = 1; // Affiche logo
82  $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION
83  $this->option_modereg = 0; // Affiche mode reglement
84  $this->option_condreg = 0; // Affiche conditions reglement
85  $this->option_codeproduitservice = 0; // Affiche code produit-service
86  $this->option_multilang = 1; // Dispo en plusieurs langues
87  $this->option_draft_watermark = 1; //Support add of a watermark on drafts
88 
89  // Get source company
90  $this->emetteur=$mysoc;
91  if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if not defined
92 
93  // Define position of columns
94  $this->posxdesc=$this->marge_gauche+1;
95  }
96 
108  function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
109  {
110  global $user,$langs,$conf,$mysoc,$db,$hookmanager;
111 
112  if (! is_object($outputlangs)) $outputlangs=$langs;
113  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
114  if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
115 
116  $outputlangs->load("main");
117  $outputlangs->load("dict");
118  $outputlangs->load("companies");
119  $outputlangs->load("interventions");
120 
121  if ($conf->ficheinter->dir_output)
122  {
123  $object->fetch_thirdparty();
124 
125  // Definition of $dir and $file
126  if ($object->specimen)
127  {
128  $dir = $conf->ficheinter->dir_output;
129  $file = $dir . "/SPECIMEN.pdf";
130  }
131  else
132  {
133  $objectref = dol_sanitizeFileName($object->ref);
134  $dir = $conf->ficheinter->dir_output . "/" . $objectref;
135  $file = $dir . "/" . $objectref . ".pdf";
136  }
137 
138  if (! file_exists($dir))
139  {
140  if (dol_mkdir($dir) < 0)
141  {
142  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
143  return 0;
144  }
145  }
146 
147  if (file_exists($dir))
148  {
149  // Add pdfgeneration hook
150  if (! is_object($hookmanager))
151  {
152  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
153  $hookmanager=new HookManager($this->db);
154  }
155 
156  $hookmanager->initHooks(array('pdfgeneration'));
157  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
158  global $action;
159  $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
160 
161  $nblignes = count($object->lines);
162 
163  // Create pdf instance
164  $pdf=pdf_getInstance($this->format);
165  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
166  $heightforinfotot = 50; // Height reserved to output the info and total part
167  $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
168  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
169  $pdf->SetAutoPageBreak(1,0);
170 
171  if (class_exists('TCPDF'))
172  {
173  $pdf->setPrintHeader(false);
174  $pdf->setPrintFooter(false);
175  }
176  $pdf->SetFont(pdf_getPDFFont($outputlangs));
177  // Set path to the background PDF File
178  if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
179  {
180  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
181  $tplidx = $pdf->importPage(1);
182  }
183 
184  $pdf->Open();
185  $pagenb=0;
186  $pdf->SetDrawColor(128,128,128);
187 
188  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
189  $pdf->SetSubject($outputlangs->transnoentities("InterventionCard"));
190  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
191  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
192  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("InterventionCard"));
193  if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
194 
195  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
196 
197  // New page
198  $pdf->AddPage();
199  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
200  $pagenb++;
201  $this->_pagehead($pdf, $object, 1, $outputlangs);
202  $pdf->SetFont('','', $default_font_size - 1);
203  $pdf->SetTextColor(0,0,0);
204 
205  $tab_top = 90;
206  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
207  $tab_height = 130;
208  $tab_height_newpage = 150;
209 
210  // Affiche notes
211  $notetoshow=empty($object->note_public)?'':$object->note_public;
212  if ($notetoshow)
213  {
214  $tab_top = 88;
215 
216  $pdf->SetFont('','', $default_font_size - 1);
217  $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
218  $nexY = $pdf->GetY();
219  $height_note=$nexY-$tab_top;
220 
221  // Rect prend une longueur en 3eme param
222  $pdf->SetDrawColor(192,192,192);
223  $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
224 
225  $tab_height = $tab_height - $height_note;
226  $tab_top = $nexY+6;
227  }
228  else
229  {
230  $height_note=0;
231  }
232 
233  $iniY = $tab_top + 7;
234  $curY = $tab_top + 7;
235  $nexY = $tab_top + 7;
236 
237  $pdf->SetXY($this->marge_gauche, $tab_top);
238  $pdf->MultiCell(190,5,$outputlangs->transnoentities("Description"),0,'L',0);
239  $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur-$this->marge_droite, $tab_top + 5);
240 
241  $pdf->SetFont('', '', $default_font_size - 1);
242 
243  $pdf->SetXY($this->marge_gauche, $tab_top + 5);
244  $text=$object->description;
245  if ($object->duration > 0)
246  {
247  $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
248  $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
249  }
250  $desc=dol_htmlentitiesbr($text,1);
251  //print $outputlangs->convToOutputCharset($desc); exit;
252 
253  $pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
254  $nexY = $pdf->GetY();
255 
256  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
257 
258  $nblines = count($object->lines);
259 
260  // Loop on each lines
261  for ($i = 0; $i < $nblines; $i++)
262  {
263  $objectligne = $object->lines[$i];
264 
265  $valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id);
266  if ($valide > 0 || $object->specimen)
267  {
268  $curY = $nexY;
269  $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
270  $pdf->SetTextColor(0,0,0);
271 
272  $pdf->setTopMargin($tab_top_newpage);
273  $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
274  $pageposbefore=$pdf->getPage();
275 
276  // Description of product line
277  $curX = $this->posxdesc-1;
278 
279  // Description of product line
280  if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR))
281  {
282  $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true);
283  }
284  else
285  {
286  $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'day',false,$outputlangs,true);
287  }
288 
289  if ($objectligne->duration > 0)
290  {
291  $txt.=" - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration);
292  }
293  $txt='<strong>'.dol_htmlentitiesbr($txt,1,$outputlangs->charset_output).'</strong>';
294  $desc=dol_htmlentitiesbr($objectligne->desc,1);
295 
296  $pdf->startTransaction();
297  $pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt,$desc), 0, 1, 0);
298  $pageposafter=$pdf->getPage();
299  if ($pageposafter > $pageposbefore) // There is a pagebreak
300  {
301  $pdf->rollbackTransaction(true);
302  $pageposafter=$pageposbefore;
303  //print $pageposafter.'-'.$pageposbefore;exit;
304  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
305  $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0);
306  $pageposafter=$pdf->getPage();
307  $posyafter=$pdf->GetY();
308  //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
309  if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
310  {
311  if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
312  {
313  $pdf->AddPage('','',true);
314  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
315  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
316  $pdf->setPage($pageposafter+1);
317  }
318  }
319  }
320  else // No pagebreak
321  {
322  $pdf->commitTransaction();
323  }
324 
325  $nexY = $pdf->GetY();
326  $pageposafter=$pdf->getPage();
327  $pdf->setPage($pageposbefore);
328  $pdf->setTopMargin($this->marge_haute);
329  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
330 
331  // We suppose that a too long description is moved completely on next page
332  if ($pageposafter > $pageposbefore) {
333  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
334  }
335 
336  $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
337 
338  // Detect if some page were added automatically and output _tableau for past pages
339  while ($pagenb < $pageposafter)
340  {
341  $pdf->setPage($pagenb);
342  if ($pagenb == 1)
343  {
344  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
345  }
346  else
347  {
348  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
349  }
350  $this->_pagefoot($pdf,$object,$outputlangs,1);
351  $pagenb++;
352  $pdf->setPage($pagenb);
353  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
354  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
355  }
356  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
357  {
358  if ($pagenb == 1)
359  {
360  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
361  }
362  else
363  {
364  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
365  }
366  $this->_pagefoot($pdf,$object,$outputlangs,1);
367  // New page
368  $pdf->AddPage();
369  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
370  $pagenb++;
371  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
372  }
373  }
374  }
375 
376  // Show square
377  if ($pagenb == 1)
378  {
379  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
380  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
381  }
382  else
383  {
384  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
385  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
386  }
387 
388  $this->_pagefoot($pdf,$object,$outputlangs);
389  if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
390 
391  $pdf->Close();
392  $pdf->Output($file,'F');
393 
394  // Add pdfgeneration hook
395  $hookmanager->initHooks(array('pdfgeneration'));
396  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
397  global $action;
398  $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
399 
400  if (! empty($conf->global->MAIN_UMASK))
401  @chmod($file, octdec($conf->global->MAIN_UMASK));
402 
403  $this->result = array('fullpath'=>$file);
404 
405  return 1;
406  }
407  else
408  {
409  $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
410  return 0;
411  }
412  }
413  else
414  {
415  $this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR");
416  return 0;
417  }
418  }
419 
432  function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
433  {
434  global $conf;
435 
436 
437  $default_font_size = pdf_getPDFFontSize($outputlangs);
438 /*
439  $pdf->SetXY($this->marge_gauche, $tab_top);
440  $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
441  $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
442 
443  $pdf->SetFont('','', $default_font_size - 1);
444 
445  $pdf->MultiCell(0, 3, ''); // Set interline to 3
446  $pdf->SetXY($this->marge_gauche, $tab_top + 8);
447  $text=$object->description;
448  if ($object->duration > 0)
449  {
450  $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
451  $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
452  }
453  $desc=dol_htmlentitiesbr($text,1);
454  //print $outputlangs->convToOutputCharset($desc); exit;
455 
456  $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1);
457  $nexY = $pdf->GetY();
458 
459  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
460 
461  $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
462 */
463 
464  // Output Rect
465  $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
466 
467  if (empty($hidebottom))
468  {
469  $pdf->SetXY(20,230);
470  $pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0);
471 
472  $pdf->SetXY(20,235);
473  $pdf->MultiCell(80,25, '', 1);
474 
475  $pdf->SetXY(110,230);
476  $pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0);
477 
478  $pdf->SetXY(110,235);
479  $pdf->MultiCell(80,25, '', 1);
480  }
481  }
482 
492  function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
493  {
494  global $conf,$langs;
495  $default_font_size = pdf_getPDFFontSize($outputlangs);
496 
497  $outputlangs->load("main");
498  $outputlangs->load("dict");
499  $outputlangs->load("companies");
500  $outputlangs->load("interventions");
501 
502  pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
503 
504  //Affiche le filigrane brouillon - Print Draft Watermark
505  if($object->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) )
506  {
507  pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FICHINTER_DRAFT_WATERMARK);
508  }
509 
510  //Prepare la suite
511  $pdf->SetTextColor(0,0,60);
512  $pdf->SetFont('','B', $default_font_size + 3);
513 
514  $posx=$this->page_largeur-$this->marge_droite-100;
515  $posy=$this->marge_haute;
516 
517  $pdf->SetXY($this->marge_gauche,$posy);
518 
519  // Logo
520  $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
521  if ($this->emetteur->logo)
522  {
523  if (is_readable($logo))
524  {
525  $height=pdf_getHeightForLogo($logo);
526  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
527  }
528  else
529  {
530  $pdf->SetTextColor(200,0,0);
531  $pdf->SetFont('','B',$default_font_size - 2);
532  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
533  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
534  }
535  }
536  else
537  {
538  $text=$this->emetteur->name;
539  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
540  }
541 
542  $pdf->SetFont('','B',$default_font_size + 3);
543  $pdf->SetXY($posx,$posy);
544  $pdf->SetTextColor(0,0,60);
545  $title=$outputlangs->transnoentities("InterventionCard");
546  $pdf->MultiCell(100, 4, $title, '', 'R');
547 
548  $pdf->SetFont('','B',$default_font_size + 2);
549 
550  $posy+=5;
551  $pdf->SetXY($posx,$posy);
552  $pdf->SetTextColor(0,0,60);
553  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
554 
555  $posy+=1;
556  $pdf->SetFont('','', $default_font_size);
557 
558  $posy+=4;
559  $pdf->SetXY($posx,$posy);
560  $pdf->SetTextColor(0,0,60);
561  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->datec,"day",false,$outputlangs,true), '', 'R');
562 
563  if ($object->thirdparty->code_client)
564  {
565  $posy+=4;
566  $pdf->SetXY($posx,$posy);
567  $pdf->SetTextColor(0,0,60);
568  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
569  }
570 
571  if ($showaddress)
572  {
573  // Sender properties
574  $carac_emetteur='';
575  // Add internal contact of proposal if defined
576  $arrayidcontact=$object->getIdContact('internal','INTERREPFOLL');
577  if (count($arrayidcontact) > 0)
578  {
579  $object->fetch_user($arrayidcontact[0]);
580  $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
581  }
582 
583  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
584 
585  // Show sender
586  $posy=42;
587  $posx=$this->marge_gauche;
588  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
589  $hautcadre=40;
590 
591  // Show sender frame
592  $pdf->SetTextColor(0,0,0);
593  $pdf->SetFont('','', $default_font_size - 2);
594  $pdf->SetXY($posx,$posy-5);
595  $pdf->SetXY($posx,$posy);
596  $pdf->SetFillColor(230,230,230);
597  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
598 
599  // Show sender name
600  $pdf->SetXY($posx+2,$posy+3);
601  $pdf->SetTextColor(0,0,60);
602  $pdf->SetFont('','B',$default_font_size);
603  $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
604  $posy=$pdf->getY();
605 
606  // Show sender information
607  $pdf->SetFont('','', $default_font_size - 1);
608  $pdf->SetXY($posx+2,$posy);
609  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
610 
611 
612  // If CUSTOMER contact defined, we use it
613  $usecontact=false;
614  $arrayidcontact=$object->getIdContact('external','CUSTOMER');
615  if (count($arrayidcontact) > 0)
616  {
617  $usecontact=true;
618  $result=$object->fetch_contact($arrayidcontact[0]);
619  }
620 
621  //Recipient name
622  // On peut utiliser le nom de la societe du contact
623  if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
624  $thirdparty = $object->contact;
625  } else {
626  $thirdparty = $object->thirdparty;
627  }
628 
629  $carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
630 
631  $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target',$object);
632 
633  // Show recipient
634  $widthrecbox=100;
635  if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
636  $posy=42;
637  $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
638  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
639 
640  // Show recipient frame
641  $pdf->SetTextColor(0,0,0);
642  $pdf->SetFont('','', $default_font_size - 2);
643  $pdf->SetXY($posx+2,$posy-5);
644  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
645  $pdf->SetTextColor(0,0,0);
646 
647  // Show recipient name
648  $pdf->SetXY($posx+2,$posy+3);
649  $pdf->SetFont('','B', $default_font_size);
650  $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
651 
652  $posy = $pdf->getY();
653 
654  // Show recipient information
655  $pdf->SetFont('','', $default_font_size - 1);
656  $pdf->SetXY($posx+2,$posy);
657  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
658  }
659  }
660 
670  function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
671  {
672  global $conf;
673  $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
674  return pdf_pagefoot($pdf,$outputlangs,'FICHINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
675  }
676 
677 }
678 
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:171
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
__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:623
_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:384
</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.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:256
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:233
dol_concatdesc($text1, $text2, $forxml=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
Class to manage hooks.
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:852
Parent class to manage intervention document templates.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
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:277
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
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...
type
Definition: viewcat.php:283