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