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