dolibarr  16.0.5
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 <https://www.gnu.org/licenses/>.
22  * or see https://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 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
35 
36 
41 {
45  public $db;
46 
50  public $name;
51 
55  public $description;
56 
60  public $update_main_doc_field;
61 
65  public $type;
66 
71  public $phpmin = array(5, 6);
72 
77  public $version = 'dolibarr';
78 
82  public $page_largeur;
83 
87  public $page_hauteur;
88 
92  public $format;
93 
97  public $marge_gauche;
98 
102  public $marge_droite;
103 
107  public $marge_haute;
108 
112  public $marge_basse;
113 
118  public $emetteur;
119 
125  public function __construct($db)
126  {
127  global $conf, $langs, $mysoc;
128 
129  $this->db = $db;
130  $this->name = 'soleil';
131  $this->description = $langs->trans("DocumentModelStandardPDF");
132  $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
133 
134  // Page size for A4 format
135  $this->type = 'pdf';
136  $formatarray = pdf_getFormat();
137  $this->page_largeur = $formatarray['width'];
138  $this->page_hauteur = $formatarray['height'];
139  $this->format = array($this->page_largeur, $this->page_hauteur);
140  $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
141  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
142  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
143  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
144 
145  $this->option_logo = 1; // Display logo
146  $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION
147  $this->option_modereg = 0; // Display payment mode
148  $this->option_condreg = 0; // Display payment terms
149  $this->option_multilang = 1; // Available in several languages
150  $this->option_draft_watermark = 1; // Support add of a watermark on drafts
151  $this->watermark = '';
152 
153  // Get source company
154  $this->emetteur = $mysoc;
155  if (empty($this->emetteur->country_code)) {
156  $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if not defined
157  }
158 
159  // Define position of columns
160  $this->posxdesc = $this->marge_gauche + 1;
161  }
162 
163  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
175  public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
176  {
177  // phpcs:enable
178  global $user, $langs, $conf, $mysoc, $db, $hookmanager;
179 
180  if (!is_object($outputlangs)) {
181  $outputlangs = $langs;
182  }
183  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
184  if (!empty($conf->global->MAIN_USE_FPDF)) {
185  $outputlangs->charset_output = 'ISO-8859-1';
186  }
187 
188  // Load traductions files required by page
189  $outputlangs->loadLangs(array("main", "interventions", "dict", "companies"));
190 
191  // Show Draft Watermark
192  if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FICHINTER_DRAFT_WATERMARK))) {
193  $this->watermark = $conf->global->FICHINTER_DRAFT_WATERMARK;
194  }
195 
196  if ($conf->ficheinter->dir_output) {
197  $object->fetch_thirdparty();
198 
199  // Definition of $dir and $file
200  if ($object->specimen) {
201  $dir = $conf->ficheinter->dir_output;
202  $file = $dir."/SPECIMEN.pdf";
203  } else {
204  $objectref = dol_sanitizeFileName($object->ref);
205  $dir = $conf->ficheinter->dir_output."/".$objectref;
206  $file = $dir."/".$objectref.".pdf";
207  }
208 
209  if (!file_exists($dir)) {
210  if (dol_mkdir($dir) < 0) {
211  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
212  return 0;
213  }
214  }
215 
216  if (file_exists($dir)) {
217  // Add pdfgeneration hook
218  if (!is_object($hookmanager)) {
219  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
220  $hookmanager = new HookManager($this->db);
221  }
222 
223  $hookmanager->initHooks(array('pdfgeneration'));
224  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
225  global $action;
226  $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
227 
228  $nblines = count($object->lines);
229 
230  // Create pdf instance
231  $pdf = pdf_getInstance($this->format);
232  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
233  $heightforinfotot = 50; // Height reserved to output the info and total part
234  $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
235  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
236  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
237  $heightforfooter += 6;
238  }
239  $pdf->SetAutoPageBreak(1, 0);
240 
241  if (class_exists('TCPDF')) {
242  $pdf->setPrintHeader(false);
243  $pdf->setPrintFooter(false);
244  }
245  $pdf->SetFont(pdf_getPDFFont($outputlangs));
246  // Set path to the background PDF File
247  if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
248  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
249  $tplidx = $pdf->importPage(1);
250  }
251 
252  $pdf->Open();
253  $pagenb = 0;
254  $pdf->SetDrawColor(128, 128, 128);
255 
256  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
257  $pdf->SetSubject($outputlangs->transnoentities("InterventionCard"));
258  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
259  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
260  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("InterventionCard"));
261  if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
262  $pdf->SetCompression(false);
263  }
264 
265  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
266 
267  // New page
268  $pdf->AddPage();
269  if (!empty($tplidx)) {
270  $pdf->useTemplate($tplidx);
271  }
272  $pagenb++;
273  $this->_pagehead($pdf, $object, 1, $outputlangs);
274  $pdf->SetFont('', '', $default_font_size - 1);
275  $pdf->SetTextColor(0, 0, 0);
276 
277  $tab_top = 90;
278  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
279 
280  $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
281 
282  // Display notes
283  $notetoshow = empty($object->note_public) ? '' : $object->note_public;
284  if ($notetoshow) {
285  $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
286  complete_substitutions_array($substitutionarray, $outputlangs, $object);
287  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
288  $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
289 
290  $tab_top = 88;
291 
292  $pdf->SetFont('', '', $default_font_size - 1);
293  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
294  $nexY = $pdf->GetY();
295  $height_note = $nexY - $tab_top;
296 
297  // Rect takes a length in 3rd parameter
298  $pdf->SetDrawColor(192, 192, 192);
299  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
300 
301  $tab_height = $tab_height - $height_note;
302  $tab_top = $nexY + 6;
303  } else {
304  $height_note = 0;
305  }
306 
307  $iniY = $tab_top + 7;
308  $curY = $tab_top + 7;
309  $nexY = $tab_top + 7;
310 
311  $pdf->SetXY($this->marge_gauche, $tab_top);
312  $pdf->MultiCell(190, 5, $outputlangs->transnoentities("Description"), 0, 'L', 0);
313  $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
314 
315  $pdf->SetFont('', '', $default_font_size - 1);
316 
317  $pdf->SetXY($this->marge_gauche, $tab_top + 5);
318  $text = $object->description;
319  if ($object->duration > 0) {
320  $totaltime = convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
321  $text .= ($text ? ' - ' : '').$langs->trans("Total").": ".$totaltime;
322  }
323  $desc = dol_htmlentitiesbr($text, 1);
324  //print $outputlangs->convToOutputCharset($desc); exit;
325 
326  $pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
327  $nexY = $pdf->GetY();
328 
329  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
330 
331  $nblines = count($object->lines);
332 
333  // Loop on each lines
334  for ($i = 0; $i < $nblines; $i++) {
335  $objectligne = $object->lines[$i];
336 
337  $valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id);
338  if ($valide > 0 || $object->specimen) {
339  $curY = $nexY;
340  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
341  $pdf->SetTextColor(0, 0, 0);
342 
343  $pdf->setTopMargin($tab_top_newpage);
344  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
345  $pageposbefore = $pdf->getPage();
346 
347  // Description of product line
348  $curX = $this->posxdesc - 1;
349 
350  // Description of product line
351  if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) {
352  $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true);
353  } else {
354  $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'day', false, $outputlangs, true);
355  }
356 
357  if ($objectligne->duration > 0) {
358  $txt .= " - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration);
359  }
360  $txt = '<strong>'.dol_htmlentitiesbr($txt, 1, $outputlangs->charset_output).'</strong>';
361  $desc = dol_htmlentitiesbr($objectligne->desc, 1);
362 
363  $pdf->startTransaction();
364  $pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt, $desc), 0, 1, 0);
365  $pageposafter = $pdf->getPage();
366  if ($pageposafter > $pageposbefore) { // There is a pagebreak
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($txt, $desc), 0, 1, 0);
372  $pageposafter = $pdf->getPage();
373  $posyafter = $pdf->GetY();
374  //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
375  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
376  if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
377  $pdf->AddPage('', '', true);
378  if (!empty($tplidx)) {
379  $pdf->useTemplate($tplidx);
380  }
381  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
382  $this->_pagehead($pdf, $object, 0, $outputlangs);
383  }
384  $pdf->setPage($pageposafter + 1);
385  }
386  }
387  } else // No pagebreak
388  {
389  $pdf->commitTransaction();
390  }
391 
392  $nexY = $pdf->GetY();
393  $pageposafter = $pdf->getPage();
394  $pdf->setPage($pageposbefore);
395  $pdf->setTopMargin($this->marge_haute);
396  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
397 
398  // We suppose that a too long description is moved completely on next page
399  if ($pageposafter > $pageposbefore) {
400  $pdf->setPage($pageposafter);
401  $curY = $tab_top_newpage;
402  }
403 
404  $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
405 
406  // Detect if some page were added automatically and output _tableau for past pages
407  while ($pagenb < $pageposafter) {
408  $pdf->setPage($pagenb);
409  if ($pagenb == 1) {
410  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
411  } else {
412  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
413  }
414  $this->_pagefoot($pdf, $object, $outputlangs, 1);
415  $pagenb++;
416  $pdf->setPage($pagenb);
417  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
418  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
419  $this->_pagehead($pdf, $object, 0, $outputlangs);
420  }
421  if (!empty($tplidx)) {
422  $pdf->useTemplate($tplidx);
423  }
424  }
425  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
426  if ($pagenb == 1) {
427  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
428  } else {
429  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
430  }
431  $this->_pagefoot($pdf, $object, $outputlangs, 1);
432  // New page
433  $pdf->AddPage();
434  if (!empty($tplidx)) {
435  $pdf->useTemplate($tplidx);
436  }
437  $pagenb++;
438  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
439  $this->_pagehead($pdf, $object, 0, $outputlangs);
440  }
441  }
442  }
443  }
444 
445  // Show square
446  if ($pagenb == 1) {
447  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
448  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
449  } else {
450  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
451  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
452  }
453 
454  $this->_pagefoot($pdf, $object, $outputlangs);
455  if (method_exists($pdf, 'AliasNbPages')) {
456  $pdf->AliasNbPages();
457  }
458 
459  $pdf->Close();
460  $pdf->Output($file, 'F');
461 
462  // Add pdfgeneration hook
463  $hookmanager->initHooks(array('pdfgeneration'));
464  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
465  global $action;
466  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
467  if ($reshook < 0) {
468  $this->error = $hookmanager->error;
469  $this->errors = $hookmanager->errors;
470  }
471 
472  if (!empty($conf->global->MAIN_UMASK)) {
473  @chmod($file, octdec($conf->global->MAIN_UMASK));
474  }
475 
476  $this->result = array('fullpath'=>$file);
477 
478  return 1;
479  } else {
480  $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
481  return 0;
482  }
483  } else {
484  $this->error = $langs->trans("ErrorConstantNotDefined", "FICHEINTER_OUTPUTDIR");
485  return 0;
486  }
487  }
488 
489  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
502  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
503  {
504  global $conf;
505 
506 
507  $default_font_size = pdf_getPDFFontSize($outputlangs);
508  /*
509  $pdf->SetXY($this->marge_gauche, $tab_top);
510  $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
511  $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
512 
513  $pdf->SetFont('','', $default_font_size - 1);
514 
515  $pdf->MultiCell(0, 3, ''); // Set interline to 3
516  $pdf->SetXY($this->marge_gauche, $tab_top + 8);
517  $text=$object->description;
518  if ($object->duration > 0)
519  {
520  $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
521  $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
522  }
523  $desc=dol_htmlentitiesbr($text,1);
524  //print $outputlangs->convToOutputCharset($desc); exit;
525 
526  $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1);
527  $nexY = $pdf->GetY();
528 
529  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
530 
531  $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
532  */
533 
534  // Output Rect
535  $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 1, 0, 0); // Rect takes a length in 3rd parameter and 4th parameter
536 
537  if (empty($hidebottom)) {
538  $pdf->SetXY(20, 230);
539  $pdf->MultiCell(80, 5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"), 0, 'L', 0);
540 
541  $pdf->SetXY(20, 235);
542  $pdf->MultiCell(80, 25, '', 1);
543 
544  $pdf->SetXY(110, 230);
545  $pdf->MultiCell(80, 5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"), 0, 'L', 0);
546 
547  $pdf->SetXY(110, 235);
548  $pdf->MultiCell(80, 25, '', 1);
549  }
550  }
551 
552  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
562  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
563  {
564  global $conf, $langs;
565  $default_font_size = pdf_getPDFFontSize($outputlangs);
566 
567  // Load traductions files required by page
568  $outputlangs->loadLangs(array("main", "dict", "companies", "interventions"));
569 
570  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
571 
572  //Prepare next
573  $pdf->SetTextColor(0, 0, 60);
574  $pdf->SetFont('', 'B', $default_font_size + 3);
575 
576  $posx = $this->page_largeur - $this->marge_droite - 100;
577  $posy = $this->marge_haute;
578 
579  $pdf->SetXY($this->marge_gauche, $posy);
580 
581  // Logo
582  $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
583  if ($this->emetteur->logo) {
584  if (is_readable($logo)) {
585  $height = pdf_getHeightForLogo($logo);
586  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
587  } else {
588  $pdf->SetTextColor(200, 0, 0);
589  $pdf->SetFont('', 'B', $default_font_size - 2);
590  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
591  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
592  }
593  } else {
594  $text = $this->emetteur->name;
595  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
596  }
597 
598  $pdf->SetFont('', 'B', $default_font_size + 3);
599  $pdf->SetXY($posx, $posy);
600  $pdf->SetTextColor(0, 0, 60);
601  $title = $outputlangs->transnoentities("InterventionCard");
602  $pdf->MultiCell(100, 4, $title, '', 'R');
603 
604  $pdf->SetFont('', 'B', $default_font_size + 2);
605 
606  $posy += 5;
607  $pdf->SetXY($posx, $posy);
608  $pdf->SetTextColor(0, 0, 60);
609  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
610 
611  $posy += 1;
612  $pdf->SetFont('', '', $default_font_size);
613 
614  $posy += 4;
615  $pdf->SetXY($posx, $posy);
616  $pdf->SetTextColor(0, 0, 60);
617  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->datec, "day", false, $outputlangs, true), '', 'R');
618 
619  if (!empty($object->ref_client)) {
620  $posy += 4;
621  $pdf->SetXY($posx, $posy);
622  $pdf->SetTextColor(0, 0, 60);
623  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer") . " : " . dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R');
624  }
625 
626 
627  if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && $object->thirdparty->code_client) {
628  $posy += 4;
629  $pdf->SetXY($posx, $posy);
630  $pdf->SetTextColor(0, 0, 60);
631  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
632  }
633 
634  if ($showaddress) {
635  // Sender properties
636  $carac_emetteur = '';
637  // Add internal contact of proposal if defined
638  $arrayidcontact = $object->getIdContact('internal', 'INTERREPFOLL');
639  if (count($arrayidcontact) > 0) {
640  $object->fetch_user($arrayidcontact[0]);
641  $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
642  }
643 
644  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
645 
646  // Show sender
647  $posy = 42;
648  $posx = $this->marge_gauche;
649  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
650  $posx = $this->page_largeur - $this->marge_droite - 80;
651  }
652  $hautcadre = 40;
653 
654  // Show sender frame
655  if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
656  $pdf->SetTextColor(0, 0, 0);
657  $pdf->SetFont('', '', $default_font_size - 2);
658  $pdf->SetXY($posx, $posy - 5);
659  $pdf->SetXY($posx, $posy);
660  $pdf->SetFillColor(230, 230, 230);
661  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
662  }
663 
664  // Show sender name
665  if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
666  $pdf->SetXY($posx + 2, $posy + 3);
667  $pdf->SetTextColor(0, 0, 60);
668  $pdf->SetFont('', 'B', $default_font_size);
669  $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
670  $posy = $pdf->getY();
671  }
672 
673  // Show sender information
674  $pdf->SetFont('', '', $default_font_size - 1);
675  $pdf->SetXY($posx + 2, $posy);
676  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
677 
678 
679  // If CUSTOMER contact defined, we use it
680  $usecontact = false;
681  $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
682  if (count($arrayidcontact) > 0) {
683  $usecontact = true;
684  $result = $object->fetch_contact($arrayidcontact[0]);
685  }
686 
687  // Recipient name
688  if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
689  $thirdparty = $object->contact;
690  } else {
691  $thirdparty = $object->thirdparty;
692  }
693 
694  $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
695 
696  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact) ? $object->contact : ''), $usecontact, 'target', $object);
697 
698  // Show recipient
699  $widthrecbox = 100;
700  if ($this->page_largeur < 210) {
701  $widthrecbox = 84; // To work with US executive format
702  }
703  $posy = 42;
704  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
705  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
706  $posx = $this->marge_gauche;
707  }
708 
709  // Show recipient frame
710  if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
711  $pdf->SetTextColor(0, 0, 0);
712  $pdf->SetFont('', '', $default_font_size - 2);
713  $pdf->SetXY($posx + 2, $posy - 5);
714  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
715  $pdf->SetTextColor(0, 0, 0);
716  }
717 
718  // Show recipient name
719  $pdf->SetXY($posx + 2, $posy + 3);
720  $pdf->SetFont('', 'B', $default_font_size);
721  $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
722 
723  $posy = $pdf->getY();
724 
725  // Show recipient information
726  $pdf->SetFont('', '', $default_font_size - 1);
727  $pdf->SetXY($posx + 2, $posy);
728  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
729  }
730  }
731 
732  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
742  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
743  {
744  global $conf;
745  $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
746  return pdf_pagefoot($pdf, $outputlangs, 'FICHINTER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
747  }
748 }
make_substitutions
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
Definition: functions.lib.php:7839
pdf_soleil\__construct
__construct($db)
Constructor.
Definition: pdf_soleil.modules.php:125
pdf_soleil\write_file
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
Definition: pdf_soleil.modules.php:175
db
$conf db
API class for accounts.
Definition: inc.php:41
pdf_soleil\_tableau
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
Definition: pdf_soleil.modules.php:502
dol_trunc
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
Definition: functions.lib.php:3805
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
description
print *****$script_file(".$version.") pid cd cd cd description as description
Definition: email_expire_services_to_customers.php:83
pdf_getFormat
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:84
pdf_soleil\_pagehead
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
Definition: pdf_soleil.modules.php:562
pdf_getInstance
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:126
pdf_soleil\_pagefoot
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
Definition: pdf_soleil.modules.php:742
pdf_getPDFFont
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:265
name
$conf db name
Definition: repair.php:122
convertSecondToTime
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:236
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
dol_concatdesc
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
Definition: functions.lib.php:7248
ModelePDFFicheinter
Parent class to manage intervention document templates.
Definition: modules_fichinter.php:35
pdfBuildThirdpartyName
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition: pdf.lib.php:386
pdf_pagehead
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:711
pdf_getHeightForLogo
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:313
CommonDocGenerator\printRect
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Definition: commondocgenerator.class.php:977
pdf_soleil
Class to build interventions documents with model Soleil.
Definition: pdf_soleil.modules.php:40
pdf_build_address
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:427
convertBackOfficeMediasLinksToPublicLinks
if(!function_exists('dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
Definition: functions2.lib.php:2711
dol_htmlentitiesbr
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...
Definition: functions.lib.php:6991
pdf_getPDFFontSize
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:288
pdf_getSubstitutionArray
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:737
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6603
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
HookManager
Class to manage hooks.
Definition: hookmanager.class.php:30
complete_substitutions_array
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...
Definition: functions.lib.php:7961
pdf_pagefoot
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition: pdf.lib.php:989