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