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