dolibarr 24.0.0-beta
pdf_baleine.modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2024 Nick Fragoulis
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 * or see https://www.gnu.org/
21 */
22
29require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
30require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
31require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
36
37
43{
47 public $db;
48
52 public $name;
53
57 public $description;
58
62 public $update_main_doc_field;
63
67 public $type;
68
72 public $posxdatestart;
73
77 public $posxdateend;
78
83 public $version = 'dolibarr';
84
85
91 public function __construct($db)
92 {
93 global $langs, $mysoc;
94
95 // Translations
96 $langs->loadLangs(array("main", "projects", "companies"));
97
98 $this->db = $db;
99 $this->name = "baleine";
100 $this->description = $langs->trans("DocumentModelBaleine");
101 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
102
103 // Page size for A4 format
104 $this->type = 'pdf';
105 $formatarray = pdf_getFormat();
106 $this->page_largeur = $formatarray['width'];
107 $this->page_hauteur = $formatarray['height'];
108 $this->format = array($this->page_largeur, $this->page_hauteur);
109 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
110 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
111 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
112 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
113 $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0);
114 $this->option_logo = 1; // Display logo FAC_PDF_LOGO
115 $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
116
117 // Define position of columns
118 $this->posxref = $this->marge_gauche + 1;
119 $this->posxlabel = $this->marge_gauche + 25;
120 $this->posxworkload = $this->marge_gauche + 117;
121 $this->posxprogress = $this->marge_gauche + 137;
122 $this->posxdatestart = $this->marge_gauche + 147;
123 $this->posxdateend = $this->marge_gauche + 169;
124 if ($this->page_largeur < 210) { // To work with US executive format
125 $this->posxref -= 20;
126 $this->posxlabel -= 20;
127 $this->posxworkload -= 20;
128 $this->posxprogress -= 20;
129 $this->posxdatestart -= 20;
130 $this->posxdateend -= 20;
131 }
132
133 if ($mysoc === null) {
134 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
135 return;
136 }
137
138 // Get source company
139 $this->emetteur = $mysoc;
140 if (!$this->emetteur->country_code) {
141 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
142 }
143 }
144
145
146 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
158 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
159 {
160 // phpcs:enable
161 global $conf, $hookmanager, $langs, $user;
162
163 if (!is_object($outputlangs)) {
164 $outputlangs = $langs;
165 }
166 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
167 if (getDolGlobalString('MAIN_USE_FPDF')) {
168 $outputlangs->charset_output = 'ISO-8859-1';
169 }
170
171 // Load traductions files required by page
172 $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
173
174 if ($conf->project->multidir_output[$object->entity ?? $conf->entity]) {
175 //$nblines = count($object->lines); // This is set later with array of tasks
176
177 $objectref = dol_sanitizeFileName($object->ref);
178 $dir = $conf->project->multidir_output[$object->entity ?? $conf->entity];
179 if (!preg_match('/specimen/i', $objectref)) {
180 $dir .= "/".$objectref;
181 }
182 $file = $dir."/".$objectref.".pdf";
183
184 if (!file_exists($dir)) {
185 if (dol_mkdir($dir) < 0) {
186 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
187 return 0;
188 }
189 }
190
191 if (file_exists($dir)) {
192 // Add pdfgeneration hook
193 if (!is_object($hookmanager)) {
194 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
195 $hookmanager = new HookManager($this->db);
196 }
197 $hookmanager->initHooks(array('pdfgeneration'));
198 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
199 global $action;
200 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
201
202 // Create pdf instance
203 $pdf = pdf_getInstance($this->format);
204 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
205 $pdf->setAutoPageBreak(true, 0);
206
207 $heightforinfotot = 40; // Height reserved to output the info and total part
208 $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
209 $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
210 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
211 $heightforfooter += 6;
212 }
213
214 if (class_exists('TCPDF')) {
215 $pdf->setPrintHeader(false);
216 $pdf->setPrintFooter(false);
217 }
218 $pdf->SetFont(pdf_getPDFFont($outputlangs));
219 // Set path to the background PDF File
220 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
221 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
222 $tplidx = $pdf->importPage(1);
223 }
224
225 // Complete object by loading several other information
226 $task = new Task($this->db);
227 $tasksarray = $task->getTasksArray(null, null, $object->id);
228
229 if (!$object->id > 0) { // Special case when used with object = specimen, we may return all lines
230 $tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
231 }
232
233 $object->lines = $tasksarray;
234 $nblines = count($object->lines);
235
236 $pdf->Open();
237 $pagenb = 0;
238 $pdf->SetDrawColor(128, 128, 128);
239
240 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
241 $pdf->SetSubject($outputlangs->transnoentities("Project"));
242 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
243 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)));
244 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
245 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
246 $pdf->SetCompression(false);
247 }
248
249 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
250 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
251
252 // New page
253 $pdf->AddPage();
254 if (!empty($tplidx)) {
255 $pdf->useTemplate($tplidx);
256 }
257 $pagenb++;
258 $this->_pagehead($pdf, $object, 1, $outputlangs);
259 $pdf->SetFont('', '', $default_font_size - 1);
260 $pdf->MultiCell(0, 3, ''); // Set interline to 3
261 $pdf->SetTextColor(0, 0, 0);
262
263 $tab_top = 50;
264 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
265
266 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
267
268 // Show public note
269 $notetoshow = empty($object->note_public) ? '' : $object->note_public;
270 if ($notetoshow) {
271 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
272 complete_substitutions_array($substitutionarray, $outputlangs, $object);
273 $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
274 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
275
276 $tab_top -= 2;
277
278 $pdf->SetFont('', '', $default_font_size - 1);
279 $pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($notetoshow), 0, 1);
280 $nexY = $pdf->GetY();
281 $height_note = $nexY - $tab_top;
282
283 // Rect takes a length in 3rd parameter
284 $pdf->SetDrawColor(192, 192, 192);
285 $pdf->RoundedRect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius, '1234', 'D');
286
287 $tab_height -= $height_note;
288 $tab_top = $nexY + 6;
289 } else {
290 $height_note = 0;
291 }
292
293 $heightoftitleline = 10;
294 $iniY = $tab_top + $heightoftitleline + 1;
295 $curY = $tab_top + $heightoftitleline + 1;
296 $nexY = $tab_top + $heightoftitleline + 1;
297
298 // Loop on each lines
299 for ($i = 0; $i < $nblines; $i++) {
300 $curY = $nexY;
301 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
302 $pdf->SetTextColor(0, 0, 0);
303
304 $pdf->setTopMargin($tab_top_newpage);
305 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
306 $pageposbefore = $pdf->getPage();
307
308 // Description of line
309 $ref = $object->lines[$i]->ref;
310 $libelleline = $object->lines[$i]->label;
311 $progress = ($object->lines[$i]->progress ? $object->lines[$i]->progress.'%' : '');
312 $datestart = dol_print_date($object->lines[$i]->date_start, 'day');
313 $dateend = dol_print_date($object->lines[$i]->date_end, 'day');
314 $planned_workload = convertSecondToTime((int) $object->lines[$i]->planned_workload, 'allhourmin');
315
316 $showpricebeforepagebreak = 1;
317
318 $pdf->startTransaction();
319 // Label
320 $pdf->SetXY($this->posxlabel, $curY);
321 $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
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('', true, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
328 // Label
329 $pdf->SetXY($this->posxlabel, $curY);
330 $posybefore = $pdf->GetY();
331 $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
332 $pageposafter = $pdf->getPage();
333 $posyafter = $pdf->GetY();
334 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
335 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
336 $pdf->AddPage('', '', true);
337 if (!empty($tplidx)) {
338 $pdf->useTemplate($tplidx);
339 }
340 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
341 $this->_pagehead($pdf, $object, 0, $outputlangs);
342 }
343 $pdf->setPage($pageposafter + 1);
344 }
345 } else {
346 // We found a page break
347
348 // Allows data in the first page if description is long enough to break in multiples pages
349 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
350 $showpricebeforepagebreak = 1;
351 } else {
352 $showpricebeforepagebreak = 0;
353 }
354
355 $forcedesconsamepage = 1;
356 if ($forcedesconsamepage) {
357 $pdf->rollbackTransaction(true);
358 $pageposafter = $pageposbefore;
359 $pdf->setPageOrientation('', true, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
360
361 $pdf->AddPage('', '', true);
362 if (!empty($tplidx)) {
363 $pdf->useTemplate($tplidx);
364 }
365 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
366 $this->_pagehead($pdf, $object, 0, $outputlangs);
367 }
368 $pdf->setPage($pageposafter + 1);
369 $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par default
370 $pdf->MultiCell(0, 3, ''); // Set interline to 3
371 $pdf->SetTextColor(0, 0, 0);
372
373 $pdf->setPageOrientation('', true, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
374 $curY = $tab_top_newpage + $heightoftitleline + 1;
375
376 // Label
377 $pdf->SetXY($this->posxlabel, $curY);
378 $posybefore = $pdf->GetY();
379 $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
380 $pageposafter = $pdf->getPage();
381 $posyafter = $pdf->GetY();
382 }
383 }
384 //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
385 } else { // No pagebreak
386 $pdf->commitTransaction();
387 }
388 $posYAfterDescription = $pdf->GetY();
389
390 $nexY = $pdf->GetY();
391 $pageposafter = $pdf->getPage();
392 $pdf->setPage($pageposbefore);
393 $pdf->setTopMargin($this->marge_haute);
394 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
395
396 // We suppose that a too long description is moved completely on next page
397 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
398 //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
399 $pdf->setPage($pageposafter);
400 $curY = $tab_top_newpage + $heightoftitleline + 1;
401 }
402
403 $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
404
405 // Ref of task
406 $pdf->SetXY($this->posxref, $curY);
407 $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
408 // Workload
409 $pdf->SetXY($this->posxworkload, $curY);
410 $pdf->SetFont('', '', $default_font_size - 2); // We use a smaller font
411 $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $planned_workload ? $planned_workload : '', 0, 'R');
412 // Progress
413 $pdf->SetXY($this->posxprogress, $curY);
414 $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, $progress, 0, 'R');
415 $pdf->SetFont('', '', $default_font_size - 1); // We restore font
416
417 // Date start and end
418 $pdf->SetXY($this->posxdatestart, $curY);
419 $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $datestart, 0, 'C');
420 $pdf->SetXY($this->posxdateend, $curY);
421 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $dateend, 0, 'C');
422
423 // Add line
424 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
425 $pdf->setPage($pageposafter);
426 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
427 //$pdf->SetDrawColor(190,190,200);
428 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
429 $pdf->SetLineStyle(array('dash' => 0));
430 }
431
432 $nexY += 2; // Add space between lines
433
434 // Detect if some page were added automatically and output _tableau for past pages
435 while ($pagenb < $pageposafter) {
436 $pdf->setPage($pagenb);
437 if ($pagenb == 1) {
438 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
439 } else {
440 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
441 }
442 $this->_pagefoot($pdf, $object, $outputlangs, 1);
443 $pagenb++;
444 $pdf->setPage($pagenb);
445 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
446 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
447 $this->_pagehead($pdf, $object, 0, $outputlangs);
448 }
449 if (!empty($tplidx)) {
450 $pdf->useTemplate($tplidx);
451 }
452 }
453 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { // @phan-suppress-current-line PhanUndeclaredProperty
454 if ($pagenb == 1) {
455 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
456 } else {
457 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
458 }
459 $this->_pagefoot($pdf, $object, $outputlangs, 1);
460 // New page
461 $pdf->AddPage();
462 if (!empty($tplidx)) {
463 $pdf->useTemplate($tplidx);
464 }
465 $pagenb++;
466 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
467 $this->_pagehead($pdf, $object, 0, $outputlangs);
468 }
469 }
470 }
471
472 // Show square
473 if ($pagenb == 1) {
474 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
475 } else {
476 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
477 }
478 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
479
480 // Footer of the page
481 $this->_pagefoot($pdf, $object, $outputlangs);
482 if (method_exists($pdf, 'AliasNbPages')) {
483 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
484 }
485
486 $pdf->Close();
487
488 $pdf->Output($file, 'F');
489
490 // Add pdfgeneration hook
491 $hookmanager->initHooks(array('pdfgeneration'));
492 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
493 global $action;
494 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
495 $this->warnings = $hookmanager->warnings;
496 if ($reshook < 0) {
497 $this->error = $hookmanager->error;
498 $this->errors = $hookmanager->errors;
499 dolChmod($file);
500 return -1;
501 }
502
503 dolChmod($file);
504
505 $this->result = array('fullpath' => $file);
506
507 return 1; // No error
508 } else {
509 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
510 return 0;
511 }
512 } else {
513 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "PROJECT_OUTPUTDIR");
514 return 0;
515 }
516 }
517
518 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
531 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
532 {
533 $heightoftitleline = 10;
534
535 $default_font_size = pdf_getPDFFontSize($outputlangs);
536
537 $pdf->SetDrawColor(128, 128, 128);
538
539 // Draw rect of all tab (title + lines). Rect takes a length in 3rd parameter
540 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, '1234', 'D');
541
542 // Line takes a position y in 3rd parameter
543 $pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline);
544
545 $pdf->SetTextColor(0, 0, 0);
546 $pdf->SetFont('', '', $default_font_size);
547
548 $pdf->SetXY($this->posxref, $tab_top + 1);
549 $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
550
551 $pdf->SetXY($this->posxlabel, $tab_top + 1);
552 $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
553
554 $pdf->SetFont('', '', $default_font_size - 1);
555
556 $pdf->SetXY($this->posxworkload, $tab_top + 1);
557 $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
558
559 $pdf->SetXY($this->posxprogress, $tab_top + 1);
560 $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, '%', 0, 'R');
561
562 // Date start
563 $pdf->SetXY($this->posxdatestart, $tab_top + 1);
564 $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $outputlangs->transnoentities("DateStart"), 0, 'C');
565
566 // Date end
567 $pdf->SetXY($this->posxdateend, $tab_top + 1);
568 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $outputlangs->transnoentities("DateEnd"), 0, 'C');
569 }
570
571 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
581 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
582 {
583 global $langs, $conf, $mysoc;
584
585 $default_font_size = pdf_getPDFFontSize($outputlangs);
586
587 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
588
589 $pdf->SetTextColor(0, 0, 60);
590 $pdf->SetFont('', 'B', $default_font_size + 3);
591
592 $posx = $this->page_largeur - $this->marge_droite - 100;
593 $posy = $this->marge_haute;
594
595 $pdf->SetXY($this->marge_gauche, $posy);
596
597 // Logo
598 $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
599 if ($mysoc->logo) {
600 if (is_readable($logo)) {
601 $height = pdf_getHeightForLogo($logo);
602 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
603 } else {
604 $pdf->SetTextColor(200, 0, 0);
605 $pdf->SetFont('', 'B', $default_font_size - 2);
606 $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
607 $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
608 }
609 } else {
610 $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
611 }
612
613 $pdf->SetFont('', 'B', $default_font_size + 3);
614 $pdf->SetXY($posx, $posy);
615 $pdf->SetTextColor(0, 0, 60);
616 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
617 $pdf->SetFont('', '', $default_font_size + 2);
618
619 $posy += 6;
620 $pdf->SetXY($posx, $posy);
621 $pdf->SetTextColor(0, 0, 60);
622 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : ".dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R');
623
624 if ($object->date_end) {
625 $posy += 6;
626 $pdf->SetXY($posx, $posy);
627 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : ".dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R');
628 }
629
630 if (is_object($object->thirdparty)) {
631 $posy += 6;
632 $pdf->SetXY($posx, $posy);
633 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : ".$object->thirdparty->getFullName($outputlangs), '', 'R');
634 }
635
636 $pdf->SetTextColor(0, 0, 60);
637
638 // Add list of linked objects
639 /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
640 $object->fetchObjectLinked();
641
642 foreach($object->linkedObjects as $objecttype => $objects)
643 {
644 //var_dump($objects);exit;
645 if ($objecttype == 'commande')
646 {
647 $outputlangs->load('orders');
648 $num=count($objects);
649 for ($i=0;$i<$num;$i++)
650 {
651 $posy+=4;
652 $pdf->SetXY($posx,$posy);
653 $pdf->SetFont('','', $default_font_size - 1);
654 $text=$objects[$i]->ref;
655 if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
656 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
657 }
658 }
659 }
660 */
661
662 return 0;
663 }
664
665 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
675 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
676 {
677 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
678 return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
679 }
680}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage hooks.
Parent class for projects models.
Class to manage tasks.
Class to manage generation of project document Baleine.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
__construct($db)
Constructor.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf project onto disk.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
global $mysoc
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
Definition date.lib.php:248
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(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!function_exists( 'dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:87
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:294
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:317
pdf_pagehead($pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:747
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:1421
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:273
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:1135
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:129
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133