dolibarr 21.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 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 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
155 public function write_file($object, $outputlangs, $srctemplatepath = '')
156 {
157 // phpcs:enable
158 global $conf, $hookmanager, $langs, $user;
159
160 if (!is_object($outputlangs)) {
161 $outputlangs = $langs;
162 }
163 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
164 if (getDolGlobalString('MAIN_USE_FPDF')) {
165 $outputlangs->charset_output = 'ISO-8859-1';
166 }
167
168 // Load traductions files required by page
169 $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
170
171 if ($conf->project->multidir_output[$object->entity]) {
172 //$nblines = count($object->lines); // This is set later with array of tasks
173
174 $objectref = dol_sanitizeFileName($object->ref);
175 $dir = $conf->project->multidir_output[$object->entity];
176 if (!preg_match('/specimen/i', $objectref)) {
177 $dir .= "/".$objectref;
178 }
179 $file = $dir."/".$objectref.".pdf";
180
181 if (!file_exists($dir)) {
182 if (dol_mkdir($dir) < 0) {
183 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
184 return 0;
185 }
186 }
187
188 if (file_exists($dir)) {
189 // Add pdfgeneration hook
190 if (!is_object($hookmanager)) {
191 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
192 $hookmanager = new HookManager($this->db);
193 }
194 $hookmanager->initHooks(array('pdfgeneration'));
195 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
196 global $action;
197 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
198
199 // Create pdf instance
200 $pdf = pdf_getInstance($this->format);
201 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
202 $pdf->SetAutoPageBreak(1, 0);
203
204 $heightforinfotot = 40; // Height reserved to output the info and total part
205 $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
206 $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
207 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
208 $heightforfooter += 6;
209 }
210
211 if (class_exists('TCPDF')) {
212 $pdf->setPrintHeader(false);
213 $pdf->setPrintFooter(false);
214 }
215 $pdf->SetFont(pdf_getPDFFont($outputlangs));
216 // Set path to the background PDF File
217 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
218 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
219 $tplidx = $pdf->importPage(1);
220 }
221
222 // Complete object by loading several other information
223 $task = new Task($this->db);
224 $tasksarray = $task->getTasksArray(null, null, $object->id);
225
226 if (!$object->id > 0) { // Special case when used with object = specimen, we may return all lines
227 $tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
228 }
229
230 $object->lines = $tasksarray;
231 $nblines = count($object->lines);
232
233 $pdf->Open();
234 $pagenb = 0;
235 $pdf->SetDrawColor(128, 128, 128);
236
237 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
238 $pdf->SetSubject($outputlangs->transnoentities("Project"));
239 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
240 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
241 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
242 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
243 $pdf->SetCompression(false);
244 }
245
246 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
247 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
248
249 // New page
250 $pdf->AddPage();
251 if (!empty($tplidx)) {
252 $pdf->useTemplate($tplidx);
253 }
254 $pagenb++;
255 $this->_pagehead($pdf, $object, 1, $outputlangs);
256 $pdf->SetFont('', '', $default_font_size - 1);
257 $pdf->MultiCell(0, 3, ''); // Set interline to 3
258 $pdf->SetTextColor(0, 0, 0);
259
260 $tab_top = 50;
261 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
262
263 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
264
265 // Show public note
266 $notetoshow = empty($object->note_public) ? '' : $object->note_public;
267 if ($notetoshow) {
268 $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
269 complete_substitutions_array($substitutionarray, $outputlangs, $object);
270 $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
271 $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
272
273 $tab_top -= 2;
274
275 $pdf->SetFont('', '', $default_font_size - 1);
276 $pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($notetoshow), 0, 1);
277 $nexY = $pdf->GetY();
278 $height_note = $nexY - $tab_top;
279
280 // Rect takes a length in 3rd parameter
281 $pdf->SetDrawColor(192, 192, 192);
282 $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');
283
284 $tab_height -= $height_note;
285 $tab_top = $nexY + 6;
286 } else {
287 $height_note = 0;
288 }
289
290 $heightoftitleline = 10;
291 $iniY = $tab_top + $heightoftitleline + 1;
292 $curY = $tab_top + $heightoftitleline + 1;
293 $nexY = $tab_top + $heightoftitleline + 1;
294
295 // Loop on each lines
296 for ($i = 0; $i < $nblines; $i++) {
297 $curY = $nexY;
298 $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
299 $pdf->SetTextColor(0, 0, 0);
300
301 $pdf->setTopMargin($tab_top_newpage);
302 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
303 $pageposbefore = $pdf->getPage();
304
305 // Description of line
306 $ref = $object->lines[$i]->ref;
307 $libelleline = $object->lines[$i]->label;
308 $progress = ($object->lines[$i]->progress ? $object->lines[$i]->progress.'%' : '');
309 $datestart = dol_print_date($object->lines[$i]->date_start, 'day');
310 $dateend = dol_print_date($object->lines[$i]->date_end, 'day');
311 $planned_workload = convertSecondToTime((int) $object->lines[$i]->planned_workload, 'allhourmin');
312
313 $showpricebeforepagebreak = 1;
314
315 $pdf->startTransaction();
316 // Label
317 $pdf->SetXY($this->posxlabel, $curY);
318 $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
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 // Label
326 $pdf->SetXY($this->posxlabel, $curY);
327 $posybefore = $pdf->GetY();
328 $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
329 $pageposafter = $pdf->getPage();
330 $posyafter = $pdf->GetY();
331 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
332 if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
333 $pdf->AddPage('', '', true);
334 if (!empty($tplidx)) {
335 $pdf->useTemplate($tplidx);
336 }
337 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
338 $this->_pagehead($pdf, $object, 0, $outputlangs);
339 }
340 $pdf->setPage($pageposafter + 1);
341 }
342 } else {
343 // We found a page break
344
345 // Allows data in the first page if description is long enough to break in multiples pages
346 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
347 $showpricebeforepagebreak = 1;
348 } else {
349 $showpricebeforepagebreak = 0;
350 }
351
352 $forcedesconsamepage = 1;
353 if ($forcedesconsamepage) {
354 $pdf->rollbackTransaction(true);
355 $pageposafter = $pageposbefore;
356 $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
357
358 $pdf->AddPage('', '', true);
359 if (!empty($tplidx)) {
360 $pdf->useTemplate($tplidx);
361 }
362 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
363 $this->_pagehead($pdf, $object, 0, $outputlangs);
364 }
365 $pdf->setPage($pageposafter + 1);
366 $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par default
367 $pdf->MultiCell(0, 3, ''); // Set interline to 3
368 $pdf->SetTextColor(0, 0, 0);
369
370 $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
371 $curY = $tab_top_newpage + $heightoftitleline + 1;
372
373 // Label
374 $pdf->SetXY($this->posxlabel, $curY);
375 $posybefore = $pdf->GetY();
376 $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
377 $pageposafter = $pdf->getPage();
378 $posyafter = $pdf->GetY();
379 }
380 }
381 //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
382 } else { // No pagebreak
383 $pdf->commitTransaction();
384 }
385 $posYAfterDescription = $pdf->GetY();
386
387 $nexY = $pdf->GetY();
388 $pageposafter = $pdf->getPage();
389 $pdf->setPage($pageposbefore);
390 $pdf->setTopMargin($this->marge_haute);
391 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
392
393 // We suppose that a too long description is moved completely on next page
394 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
395 //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
396 $pdf->setPage($pageposafter);
397 $curY = $tab_top_newpage + $heightoftitleline + 1;
398 }
399
400 $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
401
402 // Ref of task
403 $pdf->SetXY($this->posxref, $curY);
404 $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
405 // Workload
406 $pdf->SetXY($this->posxworkload, $curY);
407 $pdf->SetFont('', '', $default_font_size - 2); // We use a smaller font
408 $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $planned_workload ? $planned_workload : '', 0, 'R');
409 // Progress
410 $pdf->SetXY($this->posxprogress, $curY);
411 $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, $progress, 0, 'R');
412 $pdf->SetFont('', '', $default_font_size - 1); // We restore font
413
414 // Date start and end
415 $pdf->SetXY($this->posxdatestart, $curY);
416 $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $datestart, 0, 'C');
417 $pdf->SetXY($this->posxdateend, $curY);
418 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $dateend, 0, 'C');
419
420 // Add line
421 if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
422 $pdf->setPage($pageposafter);
423 $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
424 //$pdf->SetDrawColor(190,190,200);
425 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
426 $pdf->SetLineStyle(array('dash' => 0));
427 }
428
429 $nexY += 2; // Add space between lines
430
431 // Detect if some page were added automatically and output _tableau for past pages
432 while ($pagenb < $pageposafter) {
433 $pdf->setPage($pagenb);
434 if ($pagenb == 1) {
435 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
436 } else {
437 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
438 }
439 $this->_pagefoot($pdf, $object, $outputlangs, 1);
440 $pagenb++;
441 $pdf->setPage($pagenb);
442 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
443 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
444 $this->_pagehead($pdf, $object, 0, $outputlangs);
445 }
446 if (!empty($tplidx)) {
447 $pdf->useTemplate($tplidx);
448 }
449 }
450 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { // @phan-suppress-current-line PhanUndeclaredProperty
451 if ($pagenb == 1) {
452 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
453 } else {
454 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
455 }
456 $this->_pagefoot($pdf, $object, $outputlangs, 1);
457 // New page
458 $pdf->AddPage();
459 if (!empty($tplidx)) {
460 $pdf->useTemplate($tplidx);
461 }
462 $pagenb++;
463 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
464 $this->_pagehead($pdf, $object, 0, $outputlangs);
465 }
466 }
467 }
468
469 // Show square
470 if ($pagenb == 1) {
471 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
472 } else {
473 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
474 }
475 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
476
477 // Footer of the page
478 $this->_pagefoot($pdf, $object, $outputlangs);
479 if (method_exists($pdf, 'AliasNbPages')) {
480 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
481 }
482
483 $pdf->Close();
484
485 $pdf->Output($file, 'F');
486
487 // Add pdfgeneration hook
488 $hookmanager->initHooks(array('pdfgeneration'));
489 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
490 global $action;
491 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
492 if ($reshook < 0) {
493 $this->error = $hookmanager->error;
494 $this->errors = $hookmanager->errors;
495 }
496
497 dolChmod($file);
498
499 $this->result = array('fullpath' => $file);
500
501 return 1; // No error
502 } else {
503 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
504 return 0;
505 }
506 } else {
507 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "PROJECT_OUTPUTDIR");
508 return 0;
509 }
510 }
511
512 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
525 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
526 {
527 global $conf, $mysoc;
528
529 $heightoftitleline = 10;
530
531 $default_font_size = pdf_getPDFFontSize($outputlangs);
532
533 $pdf->SetDrawColor(128, 128, 128);
534
535 // Draw rect of all tab (title + lines). Rect takes a length in 3rd parameter
536 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, '1234', 'D');
537
538 // Line takes a position y in 3rd parameter
539 $pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline);
540
541 $pdf->SetTextColor(0, 0, 0);
542 $pdf->SetFont('', '', $default_font_size);
543
544 $pdf->SetXY($this->posxref, $tab_top + 1);
545 $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
546
547 $pdf->SetXY($this->posxlabel, $tab_top + 1);
548 $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
549
550 $pdf->SetXY($this->posxworkload, $tab_top + 1);
551 $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
552
553 $pdf->SetXY($this->posxprogress, $tab_top + 1);
554 $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, '%', 0, 'R');
555
556 // Date start
557 $pdf->SetXY($this->posxdatestart, $tab_top + 1);
558 $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $outputlangs->trans("Start"), 0, 'C');
559
560 // Date end
561 $pdf->SetXY($this->posxdateend, $tab_top + 1);
562 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $outputlangs->trans("End"), 0, 'C');
563 }
564
565 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
575 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
576 {
577 global $langs, $conf, $mysoc;
578
579 $default_font_size = pdf_getPDFFontSize($outputlangs);
580
581 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
582
583 $pdf->SetTextColor(0, 0, 60);
584 $pdf->SetFont('', 'B', $default_font_size + 3);
585
586 $posx = $this->page_largeur - $this->marge_droite - 100;
587 $posy = $this->marge_haute;
588
589 $pdf->SetXY($this->marge_gauche, $posy);
590
591 // Logo
592 $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
593 if ($mysoc->logo) {
594 if (is_readable($logo)) {
595 $height = pdf_getHeightForLogo($logo);
596 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
597 } else {
598 $pdf->SetTextColor(200, 0, 0);
599 $pdf->SetFont('', 'B', $default_font_size - 2);
600 $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
601 $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
602 }
603 } else {
604 $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
605 }
606
607 $pdf->SetFont('', 'B', $default_font_size + 3);
608 $pdf->SetXY($posx, $posy);
609 $pdf->SetTextColor(0, 0, 60);
610 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
611 $pdf->SetFont('', '', $default_font_size + 2);
612
613 $posy += 6;
614 $pdf->SetXY($posx, $posy);
615 $pdf->SetTextColor(0, 0, 60);
616 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : ".dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R');
617
618 if ($object->date_end) {
619 $posy += 6;
620 $pdf->SetXY($posx, $posy);
621 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : ".dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R');
622 }
623
624 if (is_object($object->thirdparty)) {
625 $posy += 6;
626 $pdf->SetXY($posx, $posy);
627 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : ".$object->thirdparty->getFullName($outputlangs), '', 'R');
628 }
629
630 $pdf->SetTextColor(0, 0, 60);
631
632 // Add list of linked objects
633 /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
634 $object->fetchObjectLinked();
635
636 foreach($object->linkedObjects as $objecttype => $objects)
637 {
638 //var_dump($objects);exit;
639 if ($objecttype == 'commande')
640 {
641 $outputlangs->load('orders');
642 $num=count($objects);
643 for ($i=0;$i<$num;$i++)
644 {
645 $posy+=4;
646 $pdf->SetXY($posx,$posy);
647 $pdf->SetFont('','', $default_font_size - 1);
648 $text=$objects[$i]->ref;
649 if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
650 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
651 }
652 }
653 }
654 */
655
656 return 0;
657 }
658
659 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
669 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
670 {
671 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
672 return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
673 }
674}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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='')
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.
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:244
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).
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_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)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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_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
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:149
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:152