dolibarr  13.0.2
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 {
44  public $phpmin = array(5, 6);
45 
50  public $version = 'dolibarr';
51 
56  public $emetteur;
57 
63  public function __construct($db)
64  {
65  global $conf, $langs, $mysoc;
66 
67  // Translations
68  $langs->loadLangs(array("main", "projects", "companies"));
69 
70  $this->db = $db;
71  $this->name = "timespent";
72  $this->description = $langs->trans("DocumentModelTimeSpent");
73 
74  // Page size for A4 format
75  $this->type = 'pdf';
76  $formatarray = pdf_getFormat();
77  $this->page_largeur = $formatarray['width'];
78  $this->page_hauteur = $formatarray['height'];
79  $this->format = array($this->page_largeur, $this->page_hauteur);
80  $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
81  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
82  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
83  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
84 
85  $this->option_logo = 1; // Display logo FAC_PDF_LOGO
86  $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
87  $this->option_codeproduitservice = 1; // Display product-service code
88 
89  // Get source company
90  $this->emetteur = $mysoc;
91  if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
92 
93  // Define position of columns
94  $this->posxref = $this->marge_gauche + 1;
95  $this->posxlabel = $this->marge_gauche + 25;
96  $this->posxworkload = $this->marge_gauche + 100;
97  $this->posxtimespent = $this->marge_gauche + 120;
98  //$this->posxprogress=$this->marge_gauche+140;
99  $this->posxuser = $this->marge_gauche + 147;
100  //$this->posxdateend = $this->marge_gauche + 169;
101  if ($this->page_largeur < 210) // To work with US executive format
102  {
103  $this->posxref -= 20;
104  $this->posxlabel -= 20;
105  $this->posxtimespent -= 20;
106  //$this->posxprogress-=20;
107  $this->posxuser -= 20;
108  //$this->posxdateend -= 20;
109  }
110  }
111 
112 
113  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
121  public function write_file($object, $outputlangs)
122  {
123  // phpcs:enable
124  global $conf, $hookmanager, $langs, $user;
125 
126  if (!is_object($outputlangs)) $outputlangs = $langs;
127  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
128  if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
129 
130  // Load traductions files required by page
131  $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
132 
133  if ($conf->projet->dir_output)
134  {
135  //$nblines = count($object->lines); // This is set later with array of tasks
136 
137  $objectref = dol_sanitizeFileName($object->ref);
138  $dir = $conf->projet->dir_output;
139  if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
140  $file = $dir."/".$objectref.".pdf";
141 
142  if (!file_exists($dir))
143  {
144  if (dol_mkdir($dir) < 0)
145  {
146  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
147  return 0;
148  }
149  }
150 
151  if (file_exists($dir))
152  {
153  // Add pdfgeneration hook
154  if (!is_object($hookmanager))
155  {
156  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
157  $hookmanager = new HookManager($this->db);
158  }
159  $hookmanager->initHooks(array('pdfgeneration'));
160  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
161  global $action;
162  $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
163 
164  // Create pdf instance
165  $pdf = pdf_getInstance($this->format);
166  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
167  $pdf->SetAutoPageBreak(1, 0);
168 
169  $heightforinfotot = 40; // Height reserved to output the info and total part
170  $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
171  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
172  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;
173 
174  if (class_exists('TCPDF'))
175  {
176  $pdf->setPrintHeader(false);
177  $pdf->setPrintFooter(false);
178  }
179  $pdf->SetFont(pdf_getPDFFont($outputlangs));
180  // Set path to the background PDF File
181  if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
182  {
183  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
184  $tplidx = $pdf->importPage(1);
185  }
186 
187  // Complete object by loading several other informations
188  $task = new Task($this->db);
189  $tasksarray = $task->getTasksArray(0, 0, $object->id);
190 
191  if (!$object->id > 0) // Special case when used with object = specimen, we may return all lines
192  {
193  $tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
194  }
195 
196  $object->lines = $tasksarray;
197  $nblines = count($object->lines);
198 
199  $pdf->Open();
200  $pagenb = 0;
201  $pdf->SetDrawColor(128, 128, 128);
202 
203  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
204  $pdf->SetSubject($outputlangs->transnoentities("Project"));
205  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
206  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
207  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
208  if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
209 
210  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
211 
212  // New page
213  $pdf->AddPage();
214  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
215  $pagenb++;
216  $this->_pagehead($pdf, $object, 1, $outputlangs);
217  $pdf->SetFont('', '', $default_font_size - 1);
218  $pdf->MultiCell(0, 3, ''); // Set interline to 3
219  $pdf->SetTextColor(0, 0, 0);
220 
221  $tab_top = 50;
222  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
223  $tab_height = 170;
224  $tab_height_newpage = 190;
225 
226  // Show public note
227  $notetoshow = empty($object->note_public) ? '' : $object->note_public;
228  if ($notetoshow)
229  {
230  $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
231  complete_substitutions_array($substitutionarray, $outputlangs, $object);
232  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
233  $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
234 
235  $tab_top -= 2;
236 
237  $pdf->SetFont('', '', $default_font_size - 1);
238  $pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($notetoshow), 0, 1);
239  $nexY = $pdf->GetY();
240  $height_note = $nexY - $tab_top;
241 
242  // Rect takes a length in 3rd parameter
243  $pdf->SetDrawColor(192, 192, 192);
244  $pdf->Rect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2);
245 
246  $tab_height = $tab_height - $height_note;
247  $tab_top = $nexY + 6;
248  } else {
249  $height_note = 0;
250  }
251 
252  $heightoftitleline = 10;
253  $iniY = $tab_top + $heightoftitleline + 1;
254  $curY = $tab_top + $heightoftitleline + 1;
255  $nexY = $tab_top + $heightoftitleline + 1;
256 
257  $tmpuser = new User($this->db);
258 
259  // TODO We should loop on record of times spent grouped by user instead of lines of tasks
260 
261  // Loop on each lines
262  for ($i = 0; $i < $nblines; $i++)
263  {
264  $curY = $nexY;
265  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
266  $pdf->SetTextColor(0, 0, 0);
267 
268  $pdf->setTopMargin($tab_top_newpage);
269  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
270  $pageposbefore = $pdf->getPage();
271 
272  // Description of line
273  $ref = $object->lines[$i]->ref;
274  $libelleline = $object->lines[$i]->label;
275  //$progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
276  $datestart = dol_print_date($object->lines[$i]->date_start, 'day');
277  $dateend = dol_print_date($object->lines[$i]->date_end, 'day');
278  $duration = convertSecondToTime((int) $object->lines[$i]->duration, 'allhourmin');
279 
280  $showpricebeforepagebreak = 1;
281 
282  $pdf->startTransaction();
283  // Label
284  $pdf->SetXY($this->posxlabel, $curY);
285  $pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
286  $pageposafter = $pdf->getPage();
287  if ($pageposafter > $pageposbefore) // There is a pagebreak
288  {
289  $pdf->rollbackTransaction(true);
290  $pageposafter = $pageposbefore;
291  //print $pageposafter.'-'.$pageposbefore;exit;
292  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
293  // Label
294  $pdf->SetXY($this->posxlabel, $curY);
295  $posybefore = $pdf->GetY();
296  $pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
297  $pageposafter = $pdf->getPage();
298  $posyafter = $pdf->GetY();
299  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
300  {
301  if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
302  {
303  $pdf->AddPage('', '', true);
304  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
305  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
306  $pdf->setPage($pageposafter + 1);
307  }
308  } else {
309  // We found a page break
310 
311  // Allows data in the first page if description is long enough to break in multiples pages
312  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
313  $showpricebeforepagebreak = 1;
314  else $showpricebeforepagebreak = 0;
315 
316  $forcedesconsamepage = 1;
317  if ($forcedesconsamepage)
318  {
319  $pdf->rollbackTransaction(true);
320  $pageposafter = $pageposbefore;
321  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
322 
323  $pdf->AddPage('', '', true);
324  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
325  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
326  $pdf->setPage($pageposafter + 1);
327  $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
328  $pdf->MultiCell(0, 3, ''); // Set interline to 3
329  $pdf->SetTextColor(0, 0, 0);
330 
331  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
332  $curY = $tab_top_newpage + $heightoftitleline + 1;
333 
334  // Label
335  $pdf->SetXY($this->posxlabel, $curY);
336  $posybefore = $pdf->GetY();
337  $pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338  $pageposafter = $pdf->getPage();
339  $posyafter = $pdf->GetY();
340  }
341  }
342  //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
343  } else // No pagebreak
344  {
345  $pdf->commitTransaction();
346  }
347  $posYAfterDescription = $pdf->GetY();
348 
349  $nexY = $pdf->GetY();
350  $pageposafter = $pdf->getPage();
351  $pdf->setPage($pageposbefore);
352  $pdf->setTopMargin($this->marge_haute);
353  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
354 
355  // We suppose that a too long description is moved completely on next page
356  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
357  //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
358  $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
359  }
360 
361  $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
362 
363  // Ref of task
364  $pdf->SetXY($this->posxref, $curY);
365  $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
366  // timespent
367  $pdf->SetXY($this->posxtimespent, $curY);
368  $pdf->MultiCell($this->posxuser - $this->posxtimespent, 3, $duration ? $duration : '', 0, 'R');
369  // Progress
370  //$pdf->SetXY($this->posxprogress, $curY);
371  //$pdf->MultiCell($this->posxuser-$this->posxprogress, 3, $progress, 0, 'R');
372 
373  // User spending time
374  /*var_dump($object->lines[$i]);exit;
375  $tmpuser->fetch($object->lines[$i]->fk_user);
376  $pdf->SetXY($this->posxuser, $curY);
377  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxuser, 3, $tmpuser->getFullName($outputlangs, 0, -1, 20), 0, 'C');
378  */
379 
380  // Add line
381  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
382  {
383  $pdf->setPage($pageposafter);
384  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
385  //$pdf->SetDrawColor(190,190,200);
386  $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
387  $pdf->SetLineStyle(array('dash'=>0));
388  }
389 
390  $nexY += 2; // Add space between lines
391 
392  // Detect if some page were added automatically and output _tableau for past pages
393  while ($pagenb < $pageposafter)
394  {
395  $pdf->setPage($pagenb);
396  if ($pagenb == 1)
397  {
398  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
399  } else {
400  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
401  }
402  $this->_pagefoot($pdf, $object, $outputlangs, 1);
403  $pagenb++;
404  $pdf->setPage($pagenb);
405  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
406  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
407  }
408  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
409  {
410  if ($pagenb == 1)
411  {
412  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
413  } else {
414  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
415  }
416  $this->_pagefoot($pdf, $object, $outputlangs, 1);
417  // New page
418  $pdf->AddPage();
419  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
420  $pagenb++;
421  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
422  }
423  }
424 
425  // Show square
426  if ($pagenb == 1)
427  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
428  else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
429  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
430 
431  // Footer of the page
432  $this->_pagefoot($pdf, $object, $outputlangs);
433  if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
434 
435  $pdf->Close();
436 
437  $pdf->Output($file, 'F');
438 
439  // Add pdfgeneration hook
440  $hookmanager->initHooks(array('pdfgeneration'));
441  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
442  global $action;
443  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
444  if ($reshook < 0)
445  {
446  $this->error = $hookmanager->error;
447  $this->errors = $hookmanager->errors;
448  }
449 
450  if (!empty($conf->global->MAIN_UMASK))
451  @chmod($file, octdec($conf->global->MAIN_UMASK));
452 
453  $this->result = array('fullpath'=>$file);
454 
455  return 1; // No error
456  } else {
457  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
458  return 0;
459  }
460  } else {
461  $this->error = $langs->transnoentities("ErrorConstantNotDefined", "PROJECT_OUTPUTDIR");
462  return 0;
463  }
464  }
465 
466  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
479  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
480  {
481  global $conf, $mysoc;
482 
483  $heightoftitleline = 10;
484 
485  $default_font_size = pdf_getPDFFontSize($outputlangs);
486 
487  $pdf->SetDrawColor(128, 128, 128);
488 
489  // Draw rect of all tab (title + lines). Rect takes a length in 3rd parameter
490  $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
491 
492  // Line takes a position y in 3rd parameter
493  $pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline);
494 
495  $pdf->SetTextColor(0, 0, 0);
496  $pdf->SetFont('', '', $default_font_size);
497 
498  $pdf->SetXY($this->posxref, $tab_top + 1);
499  $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
500 
501  $pdf->SetXY($this->posxlabel, $tab_top + 1);
502  $pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
503 
504  $pdf->SetXY($this->posxtimespent, $tab_top + 1);
505  $pdf->MultiCell($this->posxuser - $this->posxtimespent, 3, $outputlangs->transnoentities("TimeSpent"), 0, 'R');
506 
507  //$pdf->SetXY($this->posxprogress, $tab_top+1);
508  //$pdf->MultiCell($this->posxuser - $this->posxprogress, 3, '%', 0, 'R');
509 
510  $pdf->SetXY($this->posxuser, $tab_top + 1);
511  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxuser, 3, '', 0, 'C');
512  }
513 
514  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
524  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
525  {
526  global $langs, $conf, $mysoc;
527 
528  $default_font_size = pdf_getPDFFontSize($outputlangs);
529 
530  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
531 
532  $pdf->SetTextColor(0, 0, 60);
533  $pdf->SetFont('', 'B', $default_font_size + 3);
534 
535  $posx = $this->page_largeur - $this->marge_droite - 100;
536  $posy = $this->marge_haute;
537 
538  $pdf->SetXY($this->marge_gauche, $posy);
539 
540  // Logo
541  $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
542  if ($mysoc->logo)
543  {
544  if (is_readable($logo))
545  {
546  $height = pdf_getHeightForLogo($logo);
547  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
548  } else {
549  $pdf->SetTextColor(200, 0, 0);
550  $pdf->SetFont('', 'B', $default_font_size - 2);
551  $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
552  $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
553  }
554  } else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
555 
556  $pdf->SetFont('', 'B', $default_font_size + 3);
557  $pdf->SetXY($posx, $posy);
558  $pdf->SetTextColor(0, 0, 60);
559  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
560  $pdf->SetFont('', '', $default_font_size + 2);
561 
562  $posy += 6;
563  $pdf->SetXY($posx, $posy);
564  $pdf->SetTextColor(0, 0, 60);
565  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : ".dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R');
566 
567  $posy += 6;
568  $pdf->SetXY($posx, $posy);
569  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : ".dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R');
570 
571  if (is_object($object->thirdparty))
572  {
573  $posy += 6;
574  $pdf->SetXY($posx, $posy);
575  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : ".$object->thirdparty->getFullName($outputlangs), '', 'R');
576  }
577 
578  $pdf->SetTextColor(0, 0, 60);
579 
580  // Add list of linked objects
581  /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
582  $object->fetchObjectLinked();
583 
584  foreach($object->linkedObjects as $objecttype => $objects)
585  {
586  var_dump($objects);exit;
587  if ($objecttype == 'commande')
588  {
589  $outputlangs->load('orders');
590  $num=count($objects);
591  for ($i=0;$i<$num;$i++)
592  {
593  $posy+=4;
594  $pdf->SetXY($posx,$posy);
595  $pdf->SetFont('','', $default_font_size - 1);
596  $text=$objects[$i]->ref;
597  if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
598  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
599  }
600  }
601  }
602  */
603  }
604 
605  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
615  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
616  {
617  global $conf;
618  $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
619  return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
620  }
621 }
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:45
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:620
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:750
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:245
Class to manage Dolibarr users.
Definition: user.class.php:44
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...
Class to manage generation of project document Timespent.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:222
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
$conf db
API class for accounts.
Definition: inc.php:54
__construct($db)
Constructor.
Class to manage hooks.
Parent class for projects models.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
Definition: pdf.lib.php:887
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
write_file($object, $outputlangs)
Function to build pdf project onto disk.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:270
convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
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:643
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
Definition: pdf.lib.php:88
Class to manage tasks.
Definition: task.class.php:35
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=&gt;newva...
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
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:180
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 &quot;subst...