dolibarr 23.0.3
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 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2024 Nick Fragoulis
12 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <https://www.gnu.org/licenses/>.
26 * or see https://www.gnu.org/
27 */
28
34require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
39
40
45{
49 public $db;
50
54 public $name;
55
59 public $description;
60
64 public $update_main_doc_field;
65
69 public $type;
70
75 public $version = 'dolibarr';
76
77
83 public function __construct($db)
84 {
85 global $langs, $mysoc;
86
87 $this->db = $db;
88 $this->name = 'soleil';
89 $this->description = $langs->trans("DocumentModelStandardPDF");
90 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
91
92 // Page size for A4 format
93 $this->type = 'pdf';
94 $formatarray = pdf_getFormat();
95 $this->page_largeur = $formatarray['width'];
96 $this->page_hauteur = $formatarray['height'];
97 $this->format = array($this->page_largeur, $this->page_hauteur);
98 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
99 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
100 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
101 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
102 $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0);
103 $this->option_logo = 1; // Display logo
104 $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION
105 $this->option_modereg = 0; // Display payment mode
106 $this->option_condreg = 0; // Display payment terms
107 $this->option_multilang = 1; // Available in several languages
108 $this->option_draft_watermark = 1; // Support add of a watermark on drafts
109 $this->watermark = '';
110
111 // Define position of columns
112 $this->posxdesc = $this->marge_gauche + 1;
113
114 if ($mysoc === null) {
115 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
116 return;
117 }
118
119 // Get source company
120 $this->emetteur = $mysoc;
121 if (empty($this->emetteur->country_code)) {
122 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if not defined
123 }
124 }
125
126 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
138 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
139 {
140 // phpcs:enable
141 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
142
143 if (!is_object($outputlangs)) {
144 $outputlangs = $langs;
145 }
146 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
147 if (getDolGlobalString('MAIN_USE_FPDF')) {
148 $outputlangs->charset_output = 'ISO-8859-1';
149 }
150
151 // Load traductions files required by page
152 $outputlangs->loadLangs(array("main", "interventions", "dict", "companies", "compta"));
153
154 // Show Draft Watermark
155 if ($object->status == $object::STATUS_DRAFT && (getDolGlobalString('FICHINTER_DRAFT_WATERMARK'))) {
156 $this->watermark = getDolGlobalString('FICHINTER_DRAFT_WATERMARK');
157 }
158
159 if ($conf->ficheinter->dir_output) {
160 $object->fetch_thirdparty();
161
162 // Definition of $dir and $file
163 if ($object->specimen) {
164 $dir = $conf->ficheinter->dir_output;
165 $file = $dir."/SPECIMEN.pdf";
166 } else {
167 $objectref = dol_sanitizeFileName($object->ref);
168 $dir = $conf->ficheinter->dir_output."/".$objectref;
169 $file = $dir."/".$objectref.".pdf";
170 }
171
172 if (!file_exists($dir)) {
173 if (dol_mkdir($dir) < 0) {
174 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
175 return 0;
176 }
177 }
178
179 if (file_exists($dir)) {
180 // Add pdfgeneration hook
181 if (!is_object($hookmanager)) {
182 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
183 $hookmanager = new HookManager($this->db);
184 }
185
186 $hookmanager->initHooks(array('pdfgeneration'));
187 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
188 global $action;
189 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
190
191 $nblines = count($object->lines);
192
193 // Create pdf instance
194 $pdf = pdf_getInstance($this->format);
195 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
196 $heightforinfotot = 50; // Height reserved to output the info and total part
197 $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
198 $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
199 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
200 $heightforfooter += 6;
201 }
202 $pdf->setAutoPageBreak(true, 0);
203
204 if (class_exists('TCPDF')) {
205 $pdf->setPrintHeader(false);
206 $pdf->setPrintFooter(false);
207 }
208 $pdf->SetFont(pdf_getPDFFont($outputlangs));
209 // Set path to the background PDF File
210 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
211 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
212 $tplidx = $pdf->importPage(1);
213 }
214
215 $pdf->Open();
216 $pagenb = 0;
217 $pdf->SetDrawColor(128, 128, 128);
218
219 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
220 $pdf->SetSubject($outputlangs->transnoentities("InterventionCard"));
221 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
222 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
223 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("InterventionCard"));
224 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
225 $pdf->SetCompression(false);
226 }
227
228 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
229 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
230
231 // New page
232 $pdf->AddPage();
233 if (!empty($tplidx)) {
234 $pdf->useTemplate($tplidx);
235 }
236 $pagenb++;
237 $this->_pagehead($pdf, $object, 1, $outputlangs);
238 $pdf->SetFont('', '', $default_font_size - 1);
239 $pdf->SetTextColor(0, 0, 0);
240
241 $tab_top = 90;
242 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
243
244 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
245
246 // Display notes
247 $notetoshow = empty($object->note_public) ? '' : $object->note_public;
248 if ($notetoshow) {
249 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
250 complete_substitutions_array($substitutionarray, $outputlangs, $object);
251 $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
252 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
253
254 $tab_top = 88;
255
256 $pdf->SetFont('', '', $default_font_size - 1);
257 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
258 $nexY = $pdf->GetY();
259 $height_note = $nexY - $tab_top;
260
261 // Rect takes a length in 3rd parameter
262 $pdf->SetDrawColor(192, 192, 192);
263 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D');
264
265 $tab_height -= $height_note;
266 $tab_top = $nexY + 6;
267 } else {
268 $height_note = 0;
269 }
270
271 $iniY = $tab_top + 7;
272 $curY = $tab_top + 7;
273 $nexY = $tab_top + 7;
274
275 $pdf->SetXY($this->marge_gauche, $tab_top);
276 $pdf->MultiCell(190, 5, $outputlangs->transnoentities("Description"), 0, 'L', false);
277 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
278
279 $pdf->SetFont('', '', $default_font_size - 1);
280
281 $pdf->SetXY($this->marge_gauche, $tab_top + 5);
282 $text = $object->description;
283 if ($object->duration > 0) {
284 $totaltime = convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
285 $text .= ($text ? ' - ' : '').$langs->trans("Total").": ".$totaltime;
286 }
287 $desc = dol_htmlentitiesbr($text, 1);
288 //print $outputlangs->convToOutputCharset($desc); exit;
289
290 $pdf->writeHTMLCell(180, 3, $this->posxdesc - 1, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
291 $nexY = $pdf->GetY();
292
293 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
294
295 $nblines = count($object->lines);
296
297 // Loop on each lines
298 for ($i = 0; $i < $nblines; $i++) {
299 $objectligne = $object->lines[$i];
300
301 $valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id);
302 if ($valide > 0 || $object->specimen) {
303 $curY = $nexY;
304 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
305 $pdf->SetTextColor(0, 0, 0);
306
307 $pdf->setTopMargin($tab_top_newpage);
308 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
309 $pageposbefore = $pdf->getPage();
310
311 // Description of product line
312 $curX = $this->posxdesc - 1;
313
314 // Description of product line
315 if (!getDolGlobalString('FICHINTER_DATE_WITHOUT_HOUR')) {
316 $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true);
317 } else {
318 $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'day', false, $outputlangs, true);
319 }
320
321 if ($objectligne->duration > 0) {
322 $txt .= " - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration);
323 }
324 $txt = '<strong>'.dol_htmlentitiesbr($txt, 1, $outputlangs->charset_output).'</strong>';
325 $desc = dol_htmlentitiesbr($objectligne->desc, 1);
326
327 $pdf->startTransaction();
328 $pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt, $desc), 0, 1, false);
329 $pageposafter = $pdf->getPage();
330 if ($pageposafter > $pageposbefore) { // There is a pagebreak
331 $pdf->rollbackTransaction(true);
332 $pageposafter = $pageposbefore;
333 //print $pageposafter.'-'.$pageposbefore;exit;
334 $pdf->setPageOrientation('', true, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
335 $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt, $desc), 0, 1, false);
336 $pageposafter = $pdf->getPage();
337 $posyafter = $pdf->GetY();
338 //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
339 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
340 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
341 $pdf->AddPage('', '', true);
342 if (!empty($tplidx)) {
343 $pdf->useTemplate($tplidx);
344 }
345 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
346 $this->_pagehead($pdf, $object, 0, $outputlangs);
347 }
348 $pdf->setPage($pageposafter + 1);
349 }
350 }
351 } else { // No pagebreak
352 $pdf->commitTransaction();
353 }
354
355 $nexY = $pdf->GetY();
356 $pageposafter = $pdf->getPage();
357 $pdf->setPage($pageposbefore);
358 $pdf->setTopMargin($this->marge_haute);
359 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
360
361 // We suppose that a too long description is moved completely on next page
362 if ($pageposafter > $pageposbefore) {
363 $pdf->setPage($pageposafter);
364 $curY = $tab_top_newpage;
365 }
366
367 $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
368
369 // Detect if some page were added automatically and output _tableau for past pages
370 while ($pagenb < $pageposafter) {
371 $pdf->setPage($pagenb);
372 if ($pagenb == 1) {
373 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
374 } else {
375 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
376 }
377 $this->_pagefoot($pdf, $object, $outputlangs, 1);
378 $pagenb++;
379 $pdf->setPage($pagenb);
380 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
381 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
382 $this->_pagehead($pdf, $object, 0, $outputlangs);
383 }
384 if (!empty($tplidx)) {
385 $pdf->useTemplate($tplidx);
386 }
387 }
388 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { // @phan-suppress-current-line PhanUndeclaredProperty
389 if ($pagenb == 1) {
390 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
391 } else {
392 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
393 }
394 $this->_pagefoot($pdf, $object, $outputlangs, 1);
395 // New page
396 $pdf->AddPage();
397 if (!empty($tplidx)) {
398 $pdf->useTemplate($tplidx);
399 }
400 $pagenb++;
401 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
402 $this->_pagehead($pdf, $object, 0, $outputlangs);
403 }
404 }
405 }
406 }
407
408 // Show square
409 if ($pagenb == 1) {
410 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object);
411 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
412 } else {
413 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object);
414 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
415 }
416
417 $this->_pagefoot($pdf, $object, $outputlangs);
418 if (method_exists($pdf, 'AliasNbPages')) {
419 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
420 }
421
422 $pdf->Close();
423 $pdf->Output($file, 'F');
424
425 // Add pdfgeneration hook
426 $hookmanager->initHooks(array('pdfgeneration'));
427 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
428 global $action;
429 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
430 $this->warnings = $hookmanager->warnings;
431 if ($reshook < 0) {
432 $this->error = $hookmanager->error;
433 $this->errors = $hookmanager->errors;
434 dolChmod($file);
435 return -1;
436 }
437
438 dolChmod($file);
439
440 $this->result = array('fullpath' => $file);
441
442 return 1;
443 } else {
444 $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
445 return 0;
446 }
447 } else {
448 $this->error = $langs->trans("ErrorConstantNotDefined", "FICHEINTER_OUTPUTDIR");
449 return 0;
450 }
451 }
452
453 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
467 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object = null)
468 {
469 global $conf;
470
471
472 $default_font_size = pdf_getPDFFontSize($outputlangs);
473 /*
474 $pdf->SetXY($this->marge_gauche, $tab_top);
475 $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
476 $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
477
478 $pdf->SetFont('','', $default_font_size - 1);
479
480 $pdf->MultiCell(0, 3, ''); // Set interline to 3
481 $pdf->SetXY($this->marge_gauche, $tab_top + 8);
482 $text=$object->description;
483 if ($object->duration > 0)
484 {
485 $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
486 $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
487 }
488 $desc=dol_htmlentitiesbr($text,1);
489 //print $outputlangs->convToOutputCharset($desc); exit;
490
491 $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1);
492 $nexY = $pdf->GetY();
493
494 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
495
496 $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
497 */
498
499 // Output Rect
500 $this->printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 1, $this->corner_radius, 0, 0, 'D'); // Rect takes a length in 3rd parameter and 4th parameter
501
502 if (empty($hidebottom)) {
503 $employee_name = '';
504 if (!empty($object)) {
505 $arrayidcontact = $object->getIdContact('internal', 'INTERVENING');
506 if (count($arrayidcontact) > 0) {
507 $object->fetch_user($arrayidcontact[0]);
508 $employee_name = $object->user->getFullName($outputlangs);
509 }
510 }
511
512 $pdf->SetXY(20, 230);
513 $pdf->MultiCell(80, 5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"), 0, 'L', false);
514
515 $pdf->SetXY(20, 235);
516 $pdf->MultiCell(80, 25, $employee_name, 1, 'L');
517
518 $pdf->SetXY(110, 230);
519 $pdf->MultiCell(80, 5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"), 0, 'L', false);
520
521 $pdf->SetXY(110, 235);
522 $pdf->MultiCell(80, 25, '', 1);
523 }
524 }
525
526 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
536 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
537 {
538 global $conf, $langs;
539
540 $default_font_size = pdf_getPDFFontSize($outputlangs);
541
542 // Load traductions files required by page
543 $outputlangs->loadLangs(array("main", "dict", "companies", "interventions"));
544
545 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
546
547 //Prepare next
548 $pdf->SetTextColor(0, 0, 60);
549 $pdf->SetFont('', 'B', $default_font_size + 3);
550
551 $posx = $this->page_largeur - $this->marge_droite - 100;
552 $posy = $this->marge_haute;
553
554 $pdf->SetXY($this->marge_gauche, $posy);
555
556 // Logo
557 $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
558 if ($this->emetteur->logo) {
559 if (is_readable($logo)) {
560 $height = pdf_getHeightForLogo($logo);
561 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
562 } else {
563 $pdf->SetTextColor(200, 0, 0);
564 $pdf->SetFont('', 'B', $default_font_size - 2);
565 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
566 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
567 }
568 } else {
569 $text = $this->emetteur->name;
570 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
571 }
572
573 $pdf->SetFont('', 'B', $default_font_size + 3);
574 $pdf->SetXY($posx, $posy);
575 $pdf->SetTextColor(0, 0, 60);
576 $title = $outputlangs->transnoentities("InterventionCard");
577 $pdf->MultiCell(100, 4, $title, '', 'R');
578
579 $pdf->SetFont('', 'B', $default_font_size + 2);
580
581 $posy += 5;
582 $pdf->SetXY($posx, $posy);
583 $pdf->SetTextColor(0, 0, 60);
584 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
585
586 $posy += 1;
587 $pdf->SetFont('', '', $default_font_size);
588
589 $posy += 4;
590 $pdf->SetXY($posx, $posy);
591 $pdf->SetTextColor(0, 0, 60);
592 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->datec, "day", false, $outputlangs, true), '', 'R');
593
594 if (!empty($object->ref_client)) {
595 $posy += 4;
596 $pdf->SetXY($posx, $posy);
597 $pdf->SetTextColor(0, 0, 60);
598 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer") . " : " . dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R');
599 }
600
601
602 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
603 $posy += 4;
604 $pdf->SetXY($posx, $posy);
605 $pdf->SetTextColor(0, 0, 60);
606 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
607 }
608
609 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_ACCOUNTING_CODE') && $object->thirdparty->code_compta_client) {
610 $posy += 4;
611 $pdf->SetXY($posx, $posy);
612 $pdf->SetTextColor(0, 0, 60);
613 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerAccountancyCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_compta_client), '', 'R');
614 }
615
616 if ($showaddress) {
617 // Sender properties
618 $carac_emetteur = '';
619 // Add internal contact of object if defined
620 $arrayidcontact = $object->getIdContact('internal', 'INTERREPFOLL');
621 if (count($arrayidcontact) > 0) {
622 $object->fetch_user($arrayidcontact[0]);
623 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
624 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
625 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
626 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
627 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
628 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
629 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
630 $carac_emetteur .= "\n";
631 }
632
633 $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
634
635 // Show sender
636 $posy = 42;
637 $posx = $this->marge_gauche;
638 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
639 $posx = $this->page_largeur - $this->marge_droite - 80;
640 }
641 $hautcadre = 40;
642
643 // Show sender frame
644 if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
645 $pdf->SetTextColor(0, 0, 0);
646 $pdf->SetFont('', '', $default_font_size - 2);
647 $pdf->SetXY($posx, $posy - 5);
648 $pdf->SetXY($posx, $posy);
649 $pdf->SetFillColor(230, 230, 230);
650 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F');
651 }
652
653 // Show sender name
654 if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
655 $pdf->SetXY($posx + 2, $posy + 3);
656 $pdf->SetTextColor(0, 0, 60);
657 $pdf->SetFont('', 'B', $default_font_size);
658 $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
659 $posy = $pdf->getY();
660 }
661
662 // Show sender information
663 $pdf->SetFont('', '', $default_font_size - 1);
664 $pdf->SetXY($posx + 2, $posy);
665 $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
666
667
668 // If CUSTOMER contact defined, we use it
669 $usecontact = false;
670 $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
671 if (count($arrayidcontact) > 0) {
672 $usecontact = true;
673 $result = $object->fetch_contact($arrayidcontact[0]);
674 }
675
676 // Recipient name
677 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
678 $thirdparty = $object->contact;
679 } else {
680 $thirdparty = $object->thirdparty;
681 }
682
683 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
684
685 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact) ? $object->contact : ''), ($usecontact ? 1 : 0), 'target', $object);
686
687 // Show recipient
688 $widthrecbox = 100;
689 if ($this->page_largeur < 210) {
690 $widthrecbox = 84; // To work with US executive format
691 }
692 $posy = 42;
693 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
694 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
695 $posx = $this->marge_gauche;
696 }
697
698 // Show recipient frame
699 if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
700 $pdf->SetTextColor(0, 0, 0);
701 $pdf->SetFont('', '', $default_font_size - 2);
702 $pdf->SetXY($posx + 2, $posy - 5);
703 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
704 $pdf->SetTextColor(0, 0, 0);
705 }
706
707 // Show recipient name
708 $pdf->SetXY($posx + 2, $posy + 3);
709 $pdf->SetFont('', 'B', $default_font_size);
710 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
711
712 $posy = $pdf->getY();
713
714 // Show recipient information
715 $pdf->SetFont('', '', $default_font_size - 1);
716 $pdf->SetXY($posx + 2, $posy);
717 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
718 }
719
720 return 0;
721 }
722
723 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
733 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
734 {
735 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
736 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);
737 }
738}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
printRoundedRect($pdf, $x, $y, $w, $h, $r, $hidetop=0, $hidebottom=0, $style='D')
Print a rounded rectangle on the 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, $object=null)
Show table for lines.
__construct($db)
Constructor.
global $mysoc
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:247
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...
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a 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_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:87
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:289
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:312
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:1110
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:742
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:268
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
Definition pdf.lib.php:433
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:824
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:129
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:388
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:125
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:128