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