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