dolibarr  13.0.2
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 {
45  public $phpmin = array(5, 6);
46 
51  public $version = 'dolibarr';
52 
57  public $emetteur;
58 
64  public function __construct($db)
65  {
66  global $conf, $langs, $mysoc;
67 
68  // Translations
69  $langs->loadLangs(array("main", "projects", "companies"));
70 
71  $this->db = $db;
72  $this->name = "baleine";
73  $this->description = $langs->trans("DocumentModelBaleine");
74 
75  // Page size for A4 format
76  $this->type = 'pdf';
77  $formatarray = pdf_getFormat();
78  $this->page_largeur = $formatarray['width'];
79  $this->page_hauteur = $formatarray['height'];
80  $this->format = array($this->page_largeur, $this->page_hauteur);
81  $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
82  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
83  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
84  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
85 
86  $this->option_logo = 1; // Display logo FAC_PDF_LOGO
87  $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
88  $this->option_codeproduitservice = 1; // Display product-service code
89 
90  // Get source company
91  $this->emetteur = $mysoc;
92  if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
93 
94  // Define position of columns
95  $this->posxref = $this->marge_gauche + 1;
96  $this->posxlabel = $this->marge_gauche + 25;
97  $this->posxworkload = $this->marge_gauche + 117;
98  $this->posxprogress = $this->marge_gauche + 137;
99  $this->posxdatestart = $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->posxworkload -= 20;
106  $this->posxprogress -= 20;
107  $this->posxdatestart -= 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  // Loop on each lines
258  for ($i = 0; $i < $nblines; $i++)
259  {
260  $curY = $nexY;
261  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
262  $pdf->SetTextColor(0, 0, 0);
263 
264  $pdf->setTopMargin($tab_top_newpage);
265  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
266  $pageposbefore = $pdf->getPage();
267 
268  // Description of line
269  $ref = $object->lines[$i]->ref;
270  $libelleline = $object->lines[$i]->label;
271  $progress = ($object->lines[$i]->progress ? $object->lines[$i]->progress.'%' : '');
272  $datestart = dol_print_date($object->lines[$i]->date_start, 'day');
273  $dateend = dol_print_date($object->lines[$i]->date_end, 'day');
274  $planned_workload = convertSecondToTime((int) $object->lines[$i]->planned_workload, 'allhourmin');
275 
276  $showpricebeforepagebreak = 1;
277 
278  $pdf->startTransaction();
279  // Label
280  $pdf->SetXY($this->posxlabel, $curY);
281  $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
282  $pageposafter = $pdf->getPage();
283  if ($pageposafter > $pageposbefore) // There is a pagebreak
284  {
285  $pdf->rollbackTransaction(true);
286  $pageposafter = $pageposbefore;
287  //print $pageposafter.'-'.$pageposbefore;exit;
288  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
289  // Label
290  $pdf->SetXY($this->posxlabel, $curY);
291  $posybefore = $pdf->GetY();
292  $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
293  $pageposafter = $pdf->getPage();
294  $posyafter = $pdf->GetY();
295  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
296  {
297  if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
298  {
299  $pdf->AddPage('', '', true);
300  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
301  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
302  $pdf->setPage($pageposafter + 1);
303  }
304  } else {
305  // We found a page break
306 
307  // Allows data in the first page if description is long enough to break in multiples pages
308  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
309  $showpricebeforepagebreak = 1;
310  else $showpricebeforepagebreak = 0;
311 
312  $forcedesconsamepage = 1;
313  if ($forcedesconsamepage)
314  {
315  $pdf->rollbackTransaction(true);
316  $pageposafter = $pageposbefore;
317  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
318 
319  $pdf->AddPage('', '', true);
320  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
321  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
322  $pdf->setPage($pageposafter + 1);
323  $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
324  $pdf->MultiCell(0, 3, ''); // Set interline to 3
325  $pdf->SetTextColor(0, 0, 0);
326 
327  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
328  $curY = $tab_top_newpage + $heightoftitleline + 1;
329 
330  // Label
331  $pdf->SetXY($this->posxlabel, $curY);
332  $posybefore = $pdf->GetY();
333  $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
334  $pageposafter = $pdf->getPage();
335  $posyafter = $pdf->GetY();
336  }
337  }
338  //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
339  } else // No pagebreak
340  {
341  $pdf->commitTransaction();
342  }
343  $posYAfterDescription = $pdf->GetY();
344 
345  $nexY = $pdf->GetY();
346  $pageposafter = $pdf->getPage();
347  $pdf->setPage($pageposbefore);
348  $pdf->setTopMargin($this->marge_haute);
349  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
350 
351  // We suppose that a too long description is moved completely on next page
352  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
353  //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
354  $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
355  }
356 
357  $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
358 
359  // Ref of task
360  $pdf->SetXY($this->posxref, $curY);
361  $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
362  // Workload
363  $pdf->SetXY($this->posxworkload, $curY);
364  $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $planned_workload ? $planned_workload : '', 0, 'R');
365  // Progress
366  $pdf->SetXY($this->posxprogress, $curY);
367  $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, $progress, 0, 'R');
368 
369  // Date start and end
370  $pdf->SetXY($this->posxdatestart, $curY);
371  $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $datestart, 0, 'C');
372  $pdf->SetXY($this->posxdateend, $curY);
373  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $dateend, 0, 'C');
374 
375  // Add line
376  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
377  {
378  $pdf->setPage($pageposafter);
379  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
380  //$pdf->SetDrawColor(190,190,200);
381  $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
382  $pdf->SetLineStyle(array('dash'=>0));
383  }
384 
385  $nexY += 2; // Add space between lines
386 
387  // Detect if some page were added automatically and output _tableau for past pages
388  while ($pagenb < $pageposafter)
389  {
390  $pdf->setPage($pagenb);
391  if ($pagenb == 1)
392  {
393  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
394  } else {
395  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
396  }
397  $this->_pagefoot($pdf, $object, $outputlangs, 1);
398  $pagenb++;
399  $pdf->setPage($pagenb);
400  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
401  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
402  }
403  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
404  {
405  if ($pagenb == 1)
406  {
407  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
408  } else {
409  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
410  }
411  $this->_pagefoot($pdf, $object, $outputlangs, 1);
412  // New page
413  $pdf->AddPage();
414  if (!empty($tplidx)) $pdf->useTemplate($tplidx);
415  $pagenb++;
416  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
417  }
418  }
419 
420  // Show square
421  if ($pagenb == 1)
422  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
423  else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
424  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
425 
426  // Footer of the page
427  $this->_pagefoot($pdf, $object, $outputlangs);
428  if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
429 
430  $pdf->Close();
431 
432  $pdf->Output($file, 'F');
433 
434  // Add pdfgeneration hook
435  $hookmanager->initHooks(array('pdfgeneration'));
436  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
437  global $action;
438  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
439  if ($reshook < 0)
440  {
441  $this->error = $hookmanager->error;
442  $this->errors = $hookmanager->errors;
443  }
444 
445  if (!empty($conf->global->MAIN_UMASK))
446  @chmod($file, octdec($conf->global->MAIN_UMASK));
447 
448  $this->result = array('fullpath'=>$file);
449 
450  return 1; // No error
451  } else {
452  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
453  return 0;
454  }
455  } else {
456  $this->error = $langs->transnoentities("ErrorConstantNotDefined", "PROJECT_OUTPUTDIR");
457  return 0;
458  }
459  }
460 
461  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
474  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
475  {
476  global $conf, $mysoc;
477 
478  $heightoftitleline = 10;
479 
480  $default_font_size = pdf_getPDFFontSize($outputlangs);
481 
482  $pdf->SetDrawColor(128, 128, 128);
483 
484  // Draw rect of all tab (title + lines). Rect takes a length in 3rd parameter
485  $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
486 
487  // Line takes a position y in 3rd parameter
488  $pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline);
489 
490  $pdf->SetTextColor(0, 0, 0);
491  $pdf->SetFont('', '', $default_font_size);
492 
493  $pdf->SetXY($this->posxref, $tab_top + 1);
494  $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
495 
496  $pdf->SetXY($this->posxlabel, $tab_top + 1);
497  $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
498 
499  $pdf->SetXY($this->posxworkload, $tab_top + 1);
500  $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
501 
502  $pdf->SetXY($this->posxprogress, $tab_top + 1);
503  $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, '%', 0, 'R');
504 
505  // Date start
506  $pdf->SetXY($this->posxdatestart, $tab_top + 1);
507  $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $outputlangs->trans("Start"), 0, 'C');
508 
509  // Date end
510  $pdf->SetXY($this->posxdateend, $tab_top + 1);
511  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $outputlangs->trans("End"), 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
write_file($object, $outputlangs)
Function to build pdf project onto disk.
__construct($db)
Constructor.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:245
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...
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
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
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
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).
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=&gt;newva...
Class to manage generation of project document Baleine.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
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...
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.