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