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