dolibarr 21.0.0-alpha
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 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024 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->statut == $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(1, 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', 0);
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, 10, $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('', 1, $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, 0);
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('', 1, $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, 0);
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('', 1, 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('', 1, 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 if ($reshook < 0) {
431 $this->error = $hookmanager->error;
432 $this->errors = $hookmanager->errors;
433 }
434
435 dolChmod($file);
436
437 $this->result = array('fullpath' => $file);
438
439 return 1;
440 } else {
441 $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
442 return 0;
443 }
444 } else {
445 $this->error = $langs->trans("ErrorConstantNotDefined", "FICHEINTER_OUTPUTDIR");
446 return 0;
447 }
448 }
449
450 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
464 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object = null)
465 {
466 global $conf;
467
468
469 $default_font_size = pdf_getPDFFontSize($outputlangs);
470 /*
471 $pdf->SetXY($this->marge_gauche, $tab_top);
472 $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
473 $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
474
475 $pdf->SetFont('','', $default_font_size - 1);
476
477 $pdf->MultiCell(0, 3, ''); // Set interline to 3
478 $pdf->SetXY($this->marge_gauche, $tab_top + 8);
479 $text=$object->description;
480 if ($object->duration > 0)
481 {
482 $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
483 $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
484 }
485 $desc=dol_htmlentitiesbr($text,1);
486 //print $outputlangs->convToOutputCharset($desc); exit;
487
488 $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1);
489 $nexY = $pdf->GetY();
490
491 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
492
493 $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
494 */
495
496 // Output Rect
497 $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
498
499 if (empty($hidebottom)) {
500 $employee_name = '';
501 if (!empty($object)) {
502 $arrayidcontact = $object->getIdContact('internal', 'INTERVENING');
503 if (count($arrayidcontact) > 0) {
504 $object->fetch_user($arrayidcontact[0]);
505 $employee_name = $object->user->getFullName($outputlangs);
506 }
507 }
508
509 $pdf->SetXY(20, 230);
510 $pdf->MultiCell(80, 5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"), 0, 'L', 0);
511
512 $pdf->SetXY(20, 235);
513 $pdf->MultiCell(80, 25, $employee_name, 1, 'L');
514
515 $pdf->SetXY(110, 230);
516 $pdf->MultiCell(80, 5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"), 0, 'L', 0);
517
518 $pdf->SetXY(110, 235);
519 $pdf->MultiCell(80, 25, '', 1);
520 }
521 }
522
523 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
533 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
534 {
535 global $conf, $langs;
536
537 $default_font_size = pdf_getPDFFontSize($outputlangs);
538
539 // Load traductions files required by page
540 $outputlangs->loadLangs(array("main", "dict", "companies", "interventions"));
541
542 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
543
544 //Prepare next
545 $pdf->SetTextColor(0, 0, 60);
546 $pdf->SetFont('', 'B', $default_font_size + 3);
547
548 $posx = $this->page_largeur - $this->marge_droite - 100;
549 $posy = $this->marge_haute;
550
551 $pdf->SetXY($this->marge_gauche, $posy);
552
553 // Logo
554 $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
555 if ($this->emetteur->logo) {
556 if (is_readable($logo)) {
557 $height = pdf_getHeightForLogo($logo);
558 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
559 } else {
560 $pdf->SetTextColor(200, 0, 0);
561 $pdf->SetFont('', 'B', $default_font_size - 2);
562 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
563 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
564 }
565 } else {
566 $text = $this->emetteur->name;
567 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
568 }
569
570 $pdf->SetFont('', 'B', $default_font_size + 3);
571 $pdf->SetXY($posx, $posy);
572 $pdf->SetTextColor(0, 0, 60);
573 $title = $outputlangs->transnoentities("InterventionCard");
574 $pdf->MultiCell(100, 4, $title, '', 'R');
575
576 $pdf->SetFont('', 'B', $default_font_size + 2);
577
578 $posy += 5;
579 $pdf->SetXY($posx, $posy);
580 $pdf->SetTextColor(0, 0, 60);
581 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
582
583 $posy += 1;
584 $pdf->SetFont('', '', $default_font_size);
585
586 $posy += 4;
587 $pdf->SetXY($posx, $posy);
588 $pdf->SetTextColor(0, 0, 60);
589 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->datec, "day", false, $outputlangs, true), '', 'R');
590
591 if (!empty($object->ref_client)) {
592 $posy += 4;
593 $pdf->SetXY($posx, $posy);
594 $pdf->SetTextColor(0, 0, 60);
595 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer") . " : " . dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R');
596 }
597
598
599 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
600 $posy += 4;
601 $pdf->SetXY($posx, $posy);
602 $pdf->SetTextColor(0, 0, 60);
603 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
604 }
605
606 if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_ACCOUNTING_CODE') && $object->thirdparty->code_compta_client) {
607 $posy += 4;
608 $pdf->SetXY($posx, $posy);
609 $pdf->SetTextColor(0, 0, 60);
610 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerAccountancyCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_compta_client), '', 'R');
611 }
612
613 if ($showaddress) {
614 // Sender properties
615 $carac_emetteur = '';
616 // Add internal contact of object if defined
617 $arrayidcontact = $object->getIdContact('internal', 'INTERREPFOLL');
618 if (count($arrayidcontact) > 0) {
619 $object->fetch_user($arrayidcontact[0]);
620 $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
621 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
622 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
623 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
624 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
625 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
626 $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
627 $carac_emetteur .= "\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 (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
636 $posx = $this->page_largeur - $this->marge_droite - 80;
637 }
638 $hautcadre = 40;
639
640 // Show sender frame
641 if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
642 $pdf->SetTextColor(0, 0, 0);
643 $pdf->SetFont('', '', $default_font_size - 2);
644 $pdf->SetXY($posx, $posy - 5);
645 $pdf->SetXY($posx, $posy);
646 $pdf->SetFillColor(230, 230, 230);
647 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius, '1234', 'F');
648 }
649
650 // Show sender name
651 if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
652 $pdf->SetXY($posx + 2, $posy + 3);
653 $pdf->SetTextColor(0, 0, 60);
654 $pdf->SetFont('', 'B', $default_font_size);
655 $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
656 $posy = $pdf->getY();
657 }
658
659 // Show sender information
660 $pdf->SetFont('', '', $default_font_size - 1);
661 $pdf->SetXY($posx + 2, $posy);
662 $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
663
664
665 // If CUSTOMER contact defined, we use it
666 $usecontact = false;
667 $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
668 if (count($arrayidcontact) > 0) {
669 $usecontact = true;
670 $result = $object->fetch_contact($arrayidcontact[0]);
671 }
672
673 // Recipient name
674 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
675 $thirdparty = $object->contact;
676 } else {
677 $thirdparty = $object->thirdparty;
678 }
679
680 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
681
682 $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact) ? $object->contact : ''), ($usecontact ? 1 : 0), 'target', $object);
683
684 // Show recipient
685 $widthrecbox = 100;
686 if ($this->page_largeur < 210) {
687 $widthrecbox = 84; // To work with US executive format
688 }
689 $posy = 42;
690 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
691 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
692 $posx = $this->marge_gauche;
693 }
694
695 // Show recipient frame
696 if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
697 $pdf->SetTextColor(0, 0, 0);
698 $pdf->SetFont('', '', $default_font_size - 2);
699 $pdf->SetXY($posx + 2, $posy - 5);
700 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D');
701 $pdf->SetTextColor(0, 0, 0);
702 }
703
704 // Show recipient name
705 $pdf->SetXY($posx + 2, $posy + 3);
706 $pdf->SetFont('', 'B', $default_font_size);
707 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
708
709 $posy = $pdf->getY();
710
711 // Show recipient information
712 $pdf->SetFont('', '', $default_font_size - 1);
713 $pdf->SetXY($posx + 2, $posy);
714 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
715 }
716
717 return 0;
718 }
719
720 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
730 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
731 {
732 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
733 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);
734 }
735}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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.
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:242
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.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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 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:86
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:288
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:313
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:1027
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:729
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:265
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:434
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:765
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:128
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
Definition pdf.lib.php:386
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:137
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140