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