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