dolibarr  17.0.4
pdf_baleine.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) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
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 
70  public $phpmin = array(7, 0);
71 
76  public $version = 'dolibarr';
77 
81  public $page_largeur;
82 
86  public $page_hauteur;
87 
91  public $format;
92 
96  public $marge_gauche;
97 
101  public $marge_droite;
102 
106  public $marge_haute;
107 
111  public $marge_basse;
112 
117  public $emetteur;
118 
124  public function __construct($db)
125  {
126  global $conf, $langs, $mysoc;
127 
128  // Translations
129  $langs->loadLangs(array("main", "projects", "companies"));
130 
131  $this->db = $db;
132  $this->name = "baleine";
133  $this->description = $langs->trans("DocumentModelBaleine");
134  $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
135 
136  // Page size for A4 format
137  $this->type = 'pdf';
138  $formatarray = pdf_getFormat();
139  $this->page_largeur = $formatarray['width'];
140  $this->page_hauteur = $formatarray['height'];
141  $this->format = array($this->page_largeur, $this->page_hauteur);
142  $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
143  $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
144  $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
145  $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
146 
147  $this->option_logo = 1; // Display logo FAC_PDF_LOGO
148  $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
149 
150  // Get source company
151  $this->emetteur = $mysoc;
152  if (!$this->emetteur->country_code) {
153  $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
154  }
155 
156  // Define position of columns
157  $this->posxref = $this->marge_gauche + 1;
158  $this->posxlabel = $this->marge_gauche + 25;
159  $this->posxworkload = $this->marge_gauche + 117;
160  $this->posxprogress = $this->marge_gauche + 137;
161  $this->posxdatestart = $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->posxworkload -= 20;
167  $this->posxprogress -= 20;
168  $this->posxdatestart -= 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 (getDolGlobalString('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 = (!getDolGlobalInt('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  // Loop on each lines
322  for ($i = 0; $i < $nblines; $i++) {
323  $curY = $nexY;
324  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
325  $pdf->SetTextColor(0, 0, 0);
326 
327  $pdf->setTopMargin($tab_top_newpage);
328  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
329  $pageposbefore = $pdf->getPage();
330 
331  // Description of line
332  $ref = $object->lines[$i]->ref;
333  $libelleline = $object->lines[$i]->label;
334  $progress = ($object->lines[$i]->progress ? $object->lines[$i]->progress.'%' : '');
335  $datestart = dol_print_date($object->lines[$i]->date_start, 'day');
336  $dateend = dol_print_date($object->lines[$i]->date_end, 'day');
337  $planned_workload = convertSecondToTime((int) $object->lines[$i]->planned_workload, 'allhourmin');
338 
339  $showpricebeforepagebreak = 1;
340 
341  $pdf->startTransaction();
342  // Label
343  $pdf->SetXY($this->posxlabel, $curY);
344  $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
345  $pageposafter = $pdf->getPage();
346  if ($pageposafter > $pageposbefore) { // There is a pagebreak
347  $pdf->rollbackTransaction(true);
348  $pageposafter = $pageposbefore;
349  //print $pageposafter.'-'.$pageposbefore;exit;
350  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
351  // Label
352  $pdf->SetXY($this->posxlabel, $curY);
353  $posybefore = $pdf->GetY();
354  $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
355  $pageposafter = $pdf->getPage();
356  $posyafter = $pdf->GetY();
357  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
358  if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
359  $pdf->AddPage('', '', true);
360  if (!empty($tplidx)) {
361  $pdf->useTemplate($tplidx);
362  }
363  if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
364  $this->_pagehead($pdf, $object, 0, $outputlangs);
365  }
366  $pdf->setPage($pageposafter + 1);
367  }
368  } else {
369  // We found a page break
370 
371  // Allows data in the first page if description is long enough to break in multiples pages
372  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
373  $showpricebeforepagebreak = 1;
374  } else {
375  $showpricebeforepagebreak = 0;
376  }
377 
378  $forcedesconsamepage = 1;
379  if ($forcedesconsamepage) {
380  $pdf->rollbackTransaction(true);
381  $pageposafter = $pageposbefore;
382  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
383 
384  $pdf->AddPage('', '', true);
385  if (!empty($tplidx)) {
386  $pdf->useTemplate($tplidx);
387  }
388  if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
389  $this->_pagehead($pdf, $object, 0, $outputlangs);
390  }
391  $pdf->setPage($pageposafter + 1);
392  $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
393  $pdf->MultiCell(0, 3, ''); // Set interline to 3
394  $pdf->SetTextColor(0, 0, 0);
395 
396  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
397  $curY = $tab_top_newpage + $heightoftitleline + 1;
398 
399  // Label
400  $pdf->SetXY($this->posxlabel, $curY);
401  $posybefore = $pdf->GetY();
402  $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
403  $pageposafter = $pdf->getPage();
404  $posyafter = $pdf->GetY();
405  }
406  }
407  //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
408  } else // No pagebreak
409  {
410  $pdf->commitTransaction();
411  }
412  $posYAfterDescription = $pdf->GetY();
413 
414  $nexY = $pdf->GetY();
415  $pageposafter = $pdf->getPage();
416  $pdf->setPage($pageposbefore);
417  $pdf->setTopMargin($this->marge_haute);
418  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
419 
420  // We suppose that a too long description is moved completely on next page
421  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
422  //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
423  $pdf->setPage($pageposafter);
424  $curY = $tab_top_newpage + $heightoftitleline + 1;
425  }
426 
427  $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
428 
429  // Ref of task
430  $pdf->SetXY($this->posxref, $curY);
431  $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
432  // Workload
433  $pdf->SetXY($this->posxworkload, $curY);
434  $pdf->SetFont('', '', $default_font_size - 2); // We use a smaller font
435  $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $planned_workload ? $planned_workload : '', 0, 'R');
436  // Progress
437  $pdf->SetXY($this->posxprogress, $curY);
438  $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, $progress, 0, 'R');
439  $pdf->SetFont('', '', $default_font_size - 1); // We restore font
440 
441  // Date start and end
442  $pdf->SetXY($this->posxdatestart, $curY);
443  $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $datestart, 0, 'C');
444  $pdf->SetXY($this->posxdateend, $curY);
445  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $dateend, 0, 'C');
446 
447  // Add line
448  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
449  $pdf->setPage($pageposafter);
450  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
451  //$pdf->SetDrawColor(190,190,200);
452  $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
453  $pdf->SetLineStyle(array('dash'=>0));
454  }
455 
456  $nexY += 2; // Add space between lines
457 
458  // Detect if some page were added automatically and output _tableau for past pages
459  while ($pagenb < $pageposafter) {
460  $pdf->setPage($pagenb);
461  if ($pagenb == 1) {
462  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
463  } else {
464  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
465  }
466  $this->_pagefoot($pdf, $object, $outputlangs, 1);
467  $pagenb++;
468  $pdf->setPage($pagenb);
469  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
470  if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
471  $this->_pagehead($pdf, $object, 0, $outputlangs);
472  }
473  if (!empty($tplidx)) {
474  $pdf->useTemplate($tplidx);
475  }
476  }
477  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
478  if ($pagenb == 1) {
479  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
480  } else {
481  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
482  }
483  $this->_pagefoot($pdf, $object, $outputlangs, 1);
484  // New page
485  $pdf->AddPage();
486  if (!empty($tplidx)) {
487  $pdf->useTemplate($tplidx);
488  }
489  $pagenb++;
490  if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
491  $this->_pagehead($pdf, $object, 0, $outputlangs);
492  }
493  }
494  }
495 
496  // Show square
497  if ($pagenb == 1) {
498  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
499  } else {
500  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
501  }
502  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
503 
504  // Footer of the page
505  $this->_pagefoot($pdf, $object, $outputlangs);
506  if (method_exists($pdf, 'AliasNbPages')) {
507  $pdf->AliasNbPages();
508  }
509 
510  $pdf->Close();
511 
512  $pdf->Output($file, 'F');
513 
514  // Add pdfgeneration hook
515  $hookmanager->initHooks(array('pdfgeneration'));
516  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
517  global $action;
518  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
519  if ($reshook < 0) {
520  $this->error = $hookmanager->error;
521  $this->errors = $hookmanager->errors;
522  }
523 
524  if (!empty($conf->global->MAIN_UMASK)) {
525  @chmod($file, octdec($conf->global->MAIN_UMASK));
526  }
527 
528  $this->result = array('fullpath'=>$file);
529 
530  return 1; // No error
531  } else {
532  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
533  return 0;
534  }
535  } else {
536  $this->error = $langs->transnoentities("ErrorConstantNotDefined", "PROJECT_OUTPUTDIR");
537  return 0;
538  }
539  }
540 
541  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
554  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
555  {
556  global $conf, $mysoc;
557 
558  $heightoftitleline = 10;
559 
560  $default_font_size = pdf_getPDFFontSize($outputlangs);
561 
562  $pdf->SetDrawColor(128, 128, 128);
563 
564  // Draw rect of all tab (title + lines). Rect takes a length in 3rd parameter
565  $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
566 
567  // Line takes a position y in 3rd parameter
568  $pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline);
569 
570  $pdf->SetTextColor(0, 0, 0);
571  $pdf->SetFont('', '', $default_font_size);
572 
573  $pdf->SetXY($this->posxref, $tab_top + 1);
574  $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
575 
576  $pdf->SetXY($this->posxlabel, $tab_top + 1);
577  $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
578 
579  $pdf->SetXY($this->posxworkload, $tab_top + 1);
580  $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
581 
582  $pdf->SetXY($this->posxprogress, $tab_top + 1);
583  $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, '%', 0, 'R');
584 
585  // Date start
586  $pdf->SetXY($this->posxdatestart, $tab_top + 1);
587  $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $outputlangs->trans("Start"), 0, 'C');
588 
589  // Date end
590  $pdf->SetXY($this->posxdateend, $tab_top + 1);
591  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $outputlangs->trans("End"), 0, 'C');
592  }
593 
594  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
604  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
605  {
606  global $langs, $conf, $mysoc;
607 
608  $default_font_size = pdf_getPDFFontSize($outputlangs);
609 
610  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
611 
612  $pdf->SetTextColor(0, 0, 60);
613  $pdf->SetFont('', 'B', $default_font_size + 3);
614 
615  $posx = $this->page_largeur - $this->marge_droite - 100;
616  $posy = $this->marge_haute;
617 
618  $pdf->SetXY($this->marge_gauche, $posy);
619 
620  // Logo
621  $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
622  if ($mysoc->logo) {
623  if (is_readable($logo)) {
624  $height = pdf_getHeightForLogo($logo);
625  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
626  } else {
627  $pdf->SetTextColor(200, 0, 0);
628  $pdf->SetFont('', 'B', $default_font_size - 2);
629  $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
630  $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
631  }
632  } else {
633  $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
634  }
635 
636  $pdf->SetFont('', 'B', $default_font_size + 3);
637  $pdf->SetXY($posx, $posy);
638  $pdf->SetTextColor(0, 0, 60);
639  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
640  $pdf->SetFont('', '', $default_font_size + 2);
641 
642  $posy += 6;
643  $pdf->SetXY($posx, $posy);
644  $pdf->SetTextColor(0, 0, 60);
645  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : ".dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R');
646 
647  if ($object->date_end) {
648  $posy += 6;
649  $pdf->SetXY($posx, $posy);
650  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : ".dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R');
651  }
652 
653  if (is_object($object->thirdparty)) {
654  $posy += 6;
655  $pdf->SetXY($posx, $posy);
656  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : ".$object->thirdparty->getFullName($outputlangs), '', 'R');
657  }
658 
659  $pdf->SetTextColor(0, 0, 60);
660 
661  // Add list of linked objects
662  /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
663  $object->fetchObjectLinked();
664 
665  foreach($object->linkedObjects as $objecttype => $objects)
666  {
667  //var_dump($objects);exit;
668  if ($objecttype == 'commande')
669  {
670  $outputlangs->load('orders');
671  $num=count($objects);
672  for ($i=0;$i<$num;$i++)
673  {
674  $posy+=4;
675  $pdf->SetXY($posx,$posy);
676  $pdf->SetFont('','', $default_font_size - 1);
677  $text=$objects[$i]->ref;
678  if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
679  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
680  }
681  }
682  }
683  */
684  }
685 
686  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
696  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
697  {
698  $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
699  return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
700  }
701 }
Class to manage hooks.
Parent class for projects models.
Class to manage tasks.
Definition: task.class.php:38
Class to manage generation of project document Baleine.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
__construct($db)
Constructor.
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.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
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:238
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).
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...
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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...
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:288
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:84
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:313
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:1001
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:749
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:723
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:265
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:126
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:122
$conf db
API class for accounts.
Definition: inc.php:41