dolibarr  13.0.2
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 $type;
61 
66  public $phpmin = array(5, 6);
67 
72  public $version = 'dolibarr';
73 
77  public $page_largeur;
78 
82  public $page_hauteur;
83 
87  public $format;
88 
92  public $marge_gauche;
93 
97  public $marge_droite;
98 
102  public $marge_haute;
103 
107  public $marge_basse;
108 
113  public $emetteur;
114 
120  public function __construct($db)
121  {
122  global $conf, $langs, $mysoc;
123 
124  $this->db = $db;
125  $this->name = 'soleil';
126  $this->description = $langs->trans("DocumentModelStandardPDF");
127 
128  // Page size for A4 format
129  $this->type = 'pdf';
130  $formatarray = pdf_getFormat();
131  $this->page_largeur = $formatarray['width'];
132  $this->page_hauteur = $formatarray['height'];
133  $this->format = array($this->page_largeur, $this->page_hauteur);
134  $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
135  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
136  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
137  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
138 
139  $this->option_logo = 1; // Display logo
140  $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION
141  $this->option_modereg = 0; // Display payment mode
142  $this->option_condreg = 0; // Display payment terms
143  $this->option_codeproduitservice = 0; // Display product-service code
144  $this->option_multilang = 1; // Available in several languages
145  $this->option_draft_watermark = 1; // Support add of a watermark on drafts
146 
147  // Get source company
148  $this->emetteur = $mysoc;
149  if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if not defined
150 
151  // Define position of columns
152  $this->posxdesc = $this->marge_gauche + 1;
153  }
154 
155  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
167  public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
168  {
169  // phpcs:enable
170  global $user, $langs, $conf, $mysoc, $db, $hookmanager;
171 
172  if (!is_object($outputlangs)) $outputlangs = $langs;
173  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
174  if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
175 
176  // Load traductions files required by page
177  $outputlangs->loadLangs(array("main", "interventions", "dict", "companies"));
178 
179  if ($conf->ficheinter->dir_output)
180  {
181  $object->fetch_thirdparty();
182 
183  // Definition of $dir and $file
184  if ($object->specimen)
185  {
186  $dir = $conf->ficheinter->dir_output;
187  $file = $dir."/SPECIMEN.pdf";
188  } else {
189  $objectref = dol_sanitizeFileName($object->ref);
190  $dir = $conf->ficheinter->dir_output."/".$objectref;
191  $file = $dir."/".$objectref.".pdf";
192  }
193 
194  if (!file_exists($dir))
195  {
196  if (dol_mkdir($dir) < 0)
197  {
198  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
199  return 0;
200  }
201  }
202 
203  if (file_exists($dir))
204  {
205  // Add pdfgeneration hook
206  if (!is_object($hookmanager))
207  {
208  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
209  $hookmanager = new HookManager($this->db);
210  }
211 
212  $hookmanager->initHooks(array('pdfgeneration'));
213  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
214  global $action;
215  $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
216 
217  $nblines = count($object->lines);
218 
219  // Create pdf instance
220  $pdf = pdf_getInstance($this->format);
221  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
222  $heightforinfotot = 50; // Height reserved to output the info and total part
223  $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
224  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
225  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;
226  $pdf->SetAutoPageBreak(1, 0);
227 
228  if (class_exists('TCPDF'))
229  {
230  $pdf->setPrintHeader(false);
231  $pdf->setPrintFooter(false);
232  }
233  $pdf->SetFont(pdf_getPDFFont($outputlangs));
234  // Set path to the background PDF File
235  if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
236  {
237  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
238  $tplidx = $pdf->importPage(1);
239  }
240 
241  $pdf->Open();
242  $pagenb = 0;
243  $pdf->SetDrawColor(128, 128, 128);
244 
245  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
246  $pdf->SetSubject($outputlangs->transnoentities("InterventionCard"));
247  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
248  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
249  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("InterventionCard"));
250  if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
251 
252  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
253 
254  // New page
255  $pdf->AddPage();
256  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
257  $pagenb++;
258  $this->_pagehead($pdf, $object, 1, $outputlangs);
259  $pdf->SetFont('', '', $default_font_size - 1);
260  $pdf->SetTextColor(0, 0, 0);
261 
262  $tab_top = 90;
263  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
264  $tab_height = 130;
265  $tab_height_newpage = 150;
266 
267  // Display notes
268  $notetoshow = empty($object->note_public) ? '' : $object->note_public;
269  if ($notetoshow)
270  {
271  $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
272  complete_substitutions_array($substitutionarray, $outputlangs, $object);
273  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
274  $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
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 takes a length in 3rd parameter
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  } else {
290  $height_note = 0;
291  }
292 
293  $iniY = $tab_top + 7;
294  $curY = $tab_top + 7;
295  $nexY = $tab_top + 7;
296 
297  $pdf->SetXY($this->marge_gauche, $tab_top);
298  $pdf->MultiCell(190, 5, $outputlangs->transnoentities("Description"), 0, 'L', 0);
299  $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
300 
301  $pdf->SetFont('', '', $default_font_size - 1);
302 
303  $pdf->SetXY($this->marge_gauche, $tab_top + 5);
304  $text = $object->description;
305  if ($object->duration > 0)
306  {
307  $totaltime = convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
308  $text .= ($text ? ' - ' : '').$langs->trans("Total").": ".$totaltime;
309  }
310  $desc = dol_htmlentitiesbr($text, 1);
311  //print $outputlangs->convToOutputCharset($desc); exit;
312 
313  $pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
314  $nexY = $pdf->GetY();
315 
316  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
317 
318  $nblines = count($object->lines);
319 
320  // Loop on each lines
321  for ($i = 0; $i < $nblines; $i++)
322  {
323  $objectligne = $object->lines[$i];
324 
325  $valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id);
326  if ($valide > 0 || $object->specimen)
327  {
328  $curY = $nexY;
329  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
330  $pdf->SetTextColor(0, 0, 0);
331 
332  $pdf->setTopMargin($tab_top_newpage);
333  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
334  $pageposbefore = $pdf->getPage();
335 
336  // Description of product line
337  $curX = $this->posxdesc - 1;
338 
339  // Description of product line
340  if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) {
341  $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true);
342  } else {
343  $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'day', false, $outputlangs, true);
344  }
345 
346  if ($objectligne->duration > 0)
347  {
348  $txt .= " - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration);
349  }
350  $txt = '<strong>'.dol_htmlentitiesbr($txt, 1, $outputlangs->charset_output).'</strong>';
351  $desc = dol_htmlentitiesbr($objectligne->desc, 1);
352 
353  $pdf->startTransaction();
354  $pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt, $desc), 0, 1, 0);
355  $pageposafter = $pdf->getPage();
356  if ($pageposafter > $pageposbefore) // There is a pagebreak
357  {
358  $pdf->rollbackTransaction(true);
359  $pageposafter = $pageposbefore;
360  //print $pageposafter.'-'.$pageposbefore;exit;
361  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
362  $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt, $desc), 0, 1, 0);
363  $pageposafter = $pdf->getPage();
364  $posyafter = $pdf->GetY();
365  //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
366  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
367  {
368  if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
369  {
370  $pdf->AddPage('', '', true);
371  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
372  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
373  $pdf->setPage($pageposafter + 1);
374  }
375  }
376  } else // No pagebreak
377  {
378  $pdf->commitTransaction();
379  }
380 
381  $nexY = $pdf->GetY();
382  $pageposafter = $pdf->getPage();
383  $pdf->setPage($pageposbefore);
384  $pdf->setTopMargin($this->marge_haute);
385  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
386 
387  // We suppose that a too long description is moved completely on next page
388  if ($pageposafter > $pageposbefore) {
389  $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
390  }
391 
392  $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
393 
394  // Detect if some page were added automatically and output _tableau for past pages
395  while ($pagenb < $pageposafter)
396  {
397  $pdf->setPage($pagenb);
398  if ($pagenb == 1)
399  {
400  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
401  } else {
402  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
403  }
404  $this->_pagefoot($pdf, $object, $outputlangs, 1);
405  $pagenb++;
406  $pdf->setPage($pagenb);
407  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
408  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
409  }
410  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
411  {
412  if ($pagenb == 1)
413  {
414  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
415  } else {
416  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
417  }
418  $this->_pagefoot($pdf, $object, $outputlangs, 1);
419  // New page
420  $pdf->AddPage();
421  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
422  $pagenb++;
423  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
424  }
425  }
426  }
427 
428  // Show square
429  if ($pagenb == 1)
430  {
431  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
432  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
433  } else {
434  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
435  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
436  }
437 
438  $this->_pagefoot($pdf, $object, $outputlangs);
439  if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
440 
441  $pdf->Close();
442  $pdf->Output($file, 'F');
443 
444  // Add pdfgeneration hook
445  $hookmanager->initHooks(array('pdfgeneration'));
446  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
447  global $action;
448  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
449  if ($reshook < 0)
450  {
451  $this->error = $hookmanager->error;
452  $this->errors = $hookmanager->errors;
453  }
454 
455  if (!empty($conf->global->MAIN_UMASK))
456  @chmod($file, octdec($conf->global->MAIN_UMASK));
457 
458  $this->result = array('fullpath'=>$file);
459 
460  return 1;
461  } else {
462  $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
463  return 0;
464  }
465  } else {
466  $this->error = $langs->trans("ErrorConstantNotDefined", "FICHEINTER_OUTPUTDIR");
467  return 0;
468  }
469  }
470 
471  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
484  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
485  {
486  global $conf;
487 
488 
489  $default_font_size = pdf_getPDFFontSize($outputlangs);
490  /*
491  $pdf->SetXY($this->marge_gauche, $tab_top);
492  $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
493  $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
494 
495  $pdf->SetFont('','', $default_font_size - 1);
496 
497  $pdf->MultiCell(0, 3, ''); // Set interline to 3
498  $pdf->SetXY($this->marge_gauche, $tab_top + 8);
499  $text=$object->description;
500  if ($object->duration > 0)
501  {
502  $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
503  $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
504  }
505  $desc=dol_htmlentitiesbr($text,1);
506  //print $outputlangs->convToOutputCharset($desc); exit;
507 
508  $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1);
509  $nexY = $pdf->GetY();
510 
511  $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
512 
513  $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
514  */
515 
516  // Output Rect
517  $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
518 
519  if (empty($hidebottom))
520  {
521  $pdf->SetXY(20, 230);
522  $pdf->MultiCell(66, 5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"), 0, 'L', 0);
523 
524  $pdf->SetXY(20, 235);
525  $pdf->MultiCell(80, 25, '', 1);
526 
527  $pdf->SetXY(110, 230);
528  $pdf->MultiCell(80, 5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"), 0, 'L', 0);
529 
530  $pdf->SetXY(110, 235);
531  $pdf->MultiCell(80, 25, '', 1);
532  }
533  }
534 
535  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
545  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
546  {
547  global $conf, $langs;
548  $default_font_size = pdf_getPDFFontSize($outputlangs);
549 
550  // Load traductions files required by page
551  $outputlangs->loadLangs(array("main", "dict", "companies", "interventions"));
552 
553  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
554 
555  //Affiche le filigrane brouillon - Print Draft Watermark
556  if ($object->statut == 0 && (!empty($conf->global->FICHINTER_DRAFT_WATERMARK)))
557  {
558  pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FICHINTER_DRAFT_WATERMARK);
559  }
560 
561  //Prepare next
562  $pdf->SetTextColor(0, 0, 60);
563  $pdf->SetFont('', 'B', $default_font_size + 3);
564 
565  $posx = $this->page_largeur - $this->marge_droite - 100;
566  $posy = $this->marge_haute;
567 
568  $pdf->SetXY($this->marge_gauche, $posy);
569 
570  // Logo
571  $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
572  if ($this->emetteur->logo)
573  {
574  if (is_readable($logo))
575  {
576  $height = pdf_getHeightForLogo($logo);
577  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
578  } else {
579  $pdf->SetTextColor(200, 0, 0);
580  $pdf->SetFont('', 'B', $default_font_size - 2);
581  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
582  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
583  }
584  } else {
585  $text = $this->emetteur->name;
586  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
587  }
588 
589  $pdf->SetFont('', 'B', $default_font_size + 3);
590  $pdf->SetXY($posx, $posy);
591  $pdf->SetTextColor(0, 0, 60);
592  $title = $outputlangs->transnoentities("InterventionCard");
593  $pdf->MultiCell(100, 4, $title, '', 'R');
594 
595  $pdf->SetFont('', 'B', $default_font_size + 2);
596 
597  $posy += 5;
598  $pdf->SetXY($posx, $posy);
599  $pdf->SetTextColor(0, 0, 60);
600  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
601 
602  $posy += 1;
603  $pdf->SetFont('', '', $default_font_size);
604 
605  $posy += 4;
606  $pdf->SetXY($posx, $posy);
607  $pdf->SetTextColor(0, 0, 60);
608  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->datec, "day", false, $outputlangs, true), '', 'R');
609 
610  if ($object->thirdparty->code_client)
611  {
612  $posy += 4;
613  $pdf->SetXY($posx, $posy);
614  $pdf->SetTextColor(0, 0, 60);
615  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
616  }
617 
618  if ($showaddress)
619  {
620  // Sender properties
621  $carac_emetteur = '';
622  // Add internal contact of proposal if defined
623  $arrayidcontact = $object->getIdContact('internal', 'INTERREPFOLL');
624  if (count($arrayidcontact) > 0)
625  {
626  $object->fetch_user($arrayidcontact[0]);
627  $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
628  }
629 
630  $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
631 
632  // Show sender
633  $posy = 42;
634  $posx = $this->marge_gauche;
635  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
636  $hautcadre = 40;
637 
638  // Show sender frame
639  $pdf->SetTextColor(0, 0, 0);
640  $pdf->SetFont('', '', $default_font_size - 2);
641  $pdf->SetXY($posx, $posy - 5);
642  $pdf->SetXY($posx, $posy);
643  $pdf->SetFillColor(230, 230, 230);
644  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
645 
646  // Show sender name
647  $pdf->SetXY($posx + 2, $posy + 3);
648  $pdf->SetTextColor(0, 0, 60);
649  $pdf->SetFont('', 'B', $default_font_size);
650  $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
651  $posy = $pdf->getY();
652 
653  // Show sender information
654  $pdf->SetFont('', '', $default_font_size - 1);
655  $pdf->SetXY($posx + 2, $posy);
656  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
657 
658 
659  // If CUSTOMER contact defined, we use it
660  $usecontact = false;
661  $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
662  if (count($arrayidcontact) > 0)
663  {
664  $usecontact = true;
665  $result = $object->fetch_contact($arrayidcontact[0]);
666  }
667 
668  // Recipient name
669  if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
670  $thirdparty = $object->contact;
671  } else {
672  $thirdparty = $object->thirdparty;
673  }
674 
675  $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
676 
677  $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact) ? $object->contact : ''), $usecontact, 'target', $object);
678 
679  // Show recipient
680  $widthrecbox = 100;
681  if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
682  $posy = 42;
683  $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
684  if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
685 
686  // Show recipient frame
687  $pdf->SetTextColor(0, 0, 0);
688  $pdf->SetFont('', '', $default_font_size - 2);
689  $pdf->SetXY($posx + 2, $posy - 5);
690  $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
691  $pdf->SetTextColor(0, 0, 0);
692 
693  // Show recipient name
694  $pdf->SetXY($posx + 2, $posy + 3);
695  $pdf->SetFont('', 'B', $default_font_size);
696  $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
697 
698  $posy = $pdf->getY();
699 
700  // Show recipient information
701  $pdf->SetFont('', '', $default_font_size - 1);
702  $pdf->SetXY($posx + 2, $posy);
703  $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
704  }
705  }
706 
707  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
717  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
718  {
719  global $conf;
720  $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
721  return pdf_pagefoot($pdf, $outputlangs, 'FICHINTER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
722  }
723 }
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:45
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition: pdf.lib.php:342
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:620
__construct($db)
Constructor.
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:663
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</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:750
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:245
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
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...
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:222
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
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...
$conf db
API class for accounts.
Definition: inc.php:54
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:887
Parent class to manage intervention document templates.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
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:270
convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
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:643
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
Definition: pdf.lib.php:88
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:376
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=&gt;newva...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
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
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 &quot;subst...