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