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