dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
17  * or see http://www.gnu.org/
18  */
19 
27 require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
28 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
33 
34 
40 {
44  public $db;
45 
49  public $name;
50 
54  public $description;
55 
59  public $type;
60 
65  public $phpmin = array(5, 4);
66 
71  public $version = 'dolibarr';
72 
76  public $page_largeur;
77 
81  public $page_hauteur;
82 
86  public $format;
87 
91  public $marge_gauche;
92 
96  public $marge_droite;
97 
101  public $marge_haute;
102 
106  public $marge_basse;
107 
112  public $emetteur;
113 
119  function __construct($db)
120  {
121  global $conf,$langs,$mysoc;
122 
123  // Translations
124  $langs->loadLangs(array("main", "projects", "companies"));
125 
126  $this->db = $db;
127  $this->name = "baleine";
128  $this->description = $langs->trans("DocumentModelBaleine");
129 
130  // Dimension page pour format A4
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=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
137  $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
138  $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
139  $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
140 
141  $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
142  $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
143  $this->option_codeproduitservice = 1; // Affiche code produit-service
144 
145  // Recupere emmetteur
146  $this->emetteur=$mysoc;
147  if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined
148 
149  // Defini position des colonnes
150  $this->posxref=$this->marge_gauche+1;
151  $this->posxlabel=$this->marge_gauche+25;
152  $this->posxworkload=$this->marge_gauche+120;
153  $this->posxprogress=$this->marge_gauche+140;
154  $this->posxdatestart=$this->marge_gauche+152;
155  $this->posxdateend=$this->marge_gauche+170;
156  if ($this->page_largeur < 210) // To work with US executive format
157  {
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.NotCamelCaps
176  function write_file($object,$outputlangs)
177  {
178  // phpcs:enable
179  global $conf, $hookmanager, $langs, $user;
180 
181  if (! is_object($outputlangs)) $outputlangs=$langs;
182  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
183  if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
184 
185  // Load traductions files requiredby by page
186  $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
187 
188  if ($conf->projet->dir_output)
189  {
190  //$nblignes = count($object->lines); // This is set later with array of tasks
191 
192  $objectref = dol_sanitizeFileName($object->ref);
193  $dir = $conf->projet->dir_output;
194  if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
195  $file = $dir . "/" . $objectref . ".pdf";
196 
197  if (! file_exists($dir))
198  {
199  if (dol_mkdir($dir) < 0)
200  {
201  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
202  return 0;
203  }
204  }
205 
206  if (file_exists($dir))
207  {
208  // Add pdfgeneration hook
209  if (! is_object($hookmanager))
210  {
211  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
212  $hookmanager=new HookManager($this->db);
213  }
214  $hookmanager->initHooks(array('pdfgeneration'));
215  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
216  global $action;
217  $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
218 
219  // Create pdf instance
220  $pdf=pdf_getInstance($this->format);
221  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
222  $pdf->SetAutoPageBreak(1,0);
223 
224  $heightforinfotot = 40; // Height reserved to output the info and total part
225  $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
226  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
227  if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
228 
229  if (class_exists('TCPDF'))
230  {
231  $pdf->setPrintHeader(false);
232  $pdf->setPrintFooter(false);
233  }
234  $pdf->SetFont(pdf_getPDFFont($outputlangs));
235  // Set path to the background PDF File
236  if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
237  {
238  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
239  $tplidx = $pdf->importPage(1);
240  }
241 
242  // Complete object by loading several other informations
243  $task = new Task($this->db);
244  $tasksarray = $task->getTasksArray(0,0,$object->id);
245 
246  if (! $object->id > 0) // Special case when used with object = specimen, we may return all lines
247  {
248  $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
249  }
250 
251  $object->lines=$tasksarray;
252  $nblignes=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 (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
264 
265  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
266 
267  // New page
268  $pdf->AddPage();
269  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
270  $pagenb++;
271  $this->_pagehead($pdf, $object, 1, $outputlangs);
272  $pdf->SetFont('','', $default_font_size - 1);
273  $pdf->MultiCell(0, 3, ''); // Set interline to 3
274  $pdf->SetTextColor(0,0,0);
275 
276  $tab_top = 50;
277  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
278  $tab_height = 170;
279  $tab_height_newpage = 190;
280 
281  // Show public note
282  $notetoshow=empty($object->note_public)?'':$object->note_public;
283  if ($notetoshow)
284  {
285  $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
286  complete_substitutions_array($substitutionarray, $outputlangs, $object);
287  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
288 
289  $tab_top -= 2;
290 
291  $pdf->SetFont('','', $default_font_size - 1);
292  $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
293  $nexY = $pdf->GetY();
294  $height_note=$nexY-$tab_top;
295 
296  // Rect prend une longueur en 3eme param
297  $pdf->SetDrawColor(192,192,192);
298  $pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2);
299 
300  $tab_height = $tab_height - $height_note;
301  $tab_top = $nexY+6;
302  }
303  else
304  {
305  $height_note=0;
306  }
307 
308  $heightoftitleline = 10;
309  $iniY = $tab_top + $heightoftitleline + 1;
310  $curY = $tab_top + $heightoftitleline + 1;
311  $nexY = $tab_top + $heightoftitleline + 1;
312 
313  // Loop on each lines
314  for ($i = 0 ; $i < $nblignes ; $i++)
315  {
316  $curY = $nexY;
317  $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
318  $pdf->SetTextColor(0,0,0);
319 
320  $pdf->setTopMargin($tab_top_newpage);
321  $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
322  $pageposbefore=$pdf->getPage();
323 
324  // Description of line
325  $ref=$object->lines[$i]->ref;
326  $libelleline=$object->lines[$i]->label;
327  $progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
328  $datestart=dol_print_date($object->lines[$i]->date_start,'day');
329  $dateend=dol_print_date($object->lines[$i]->date_end,'day');
330  $planned_workload=convertSecondToTime((int) $object->lines[$i]->planned_workload,'allhourmin');
331 
332  $showpricebeforepagebreak=1;
333 
334  $pdf->startTransaction();
335  // Label
336  $pdf->SetXY($this->posxlabel, $curY);
337  $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
338  $pageposafter=$pdf->getPage();
339  if ($pageposafter > $pageposbefore) // There is a pagebreak
340  {
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  {
353  if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
354  {
355  $pdf->AddPage('','',true);
356  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
357  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
358  $pdf->setPage($pageposafter+1);
359  }
360  }
361  else
362  {
363  // We found a page break
364  $showpricebeforepagebreak=0;
365  $forcedesconsamepage=1;
366  if ($forcedesconsamepage)
367  {
368  $pdf->rollbackTransaction(true);
369  $pageposafter=$pageposbefore;
370  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
371 
372  $pdf->AddPage('','',true);
373  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
374  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
375  $pdf->setPage($pageposafter+1);
376  $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
377  $pdf->MultiCell(0, 3, ''); // Set interline to 3
378  $pdf->SetTextColor(0,0,0);
379 
380  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
381  $curY = $tab_top_newpage + $heightoftitleline + 1;
382 
383  // Label
384  $pdf->SetXY($this->posxlabel, $curY);
385  $posybefore=$pdf->GetY();
386  $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
387  $pageposafter=$pdf->getPage();
388  $posyafter=$pdf->GetY();
389  }
390  }
391  //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
392  }
393  else // No pagebreak
394  {
395  $pdf->commitTransaction();
396  }
397  $posYAfterDescription=$pdf->GetY();
398 
399  $nexY = $pdf->GetY();
400  $pageposafter=$pdf->getPage();
401  $pdf->setPage($pageposbefore);
402  $pdf->setTopMargin($this->marge_haute);
403  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
404 
405  // We suppose that a too long description is moved completely on next page
406  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
407  //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
408  $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
409  }
410 
411  $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
412 
413  // Ref of task
414  $pdf->SetXY($this->posxref, $curY);
415  $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
416  // Workload
417  $pdf->SetXY($this->posxworkload, $curY);
418  $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload?$planned_workload:'', 0, 'R');
419  // Progress
420  $pdf->SetXY($this->posxprogress, $curY);
421  $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
422  // Date
423  $pdf->SetXY($this->posxdatestart, $curY);
424  $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
425  $pdf->SetXY($this->posxdateend, $curY);
426  $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
427 
428  // Add line
429  if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
430  {
431  $pdf->setPage($pageposafter);
432  $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
433  //$pdf->SetDrawColor(190,190,200);
434  $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
435  $pdf->SetLineStyle(array('dash'=>0));
436  }
437 
438  $nexY+=2; // Passe espace entre les lignes
439 
440  // Detect if some page were added automatically and output _tableau for past pages
441  while ($pagenb < $pageposafter)
442  {
443  $pdf->setPage($pagenb);
444  if ($pagenb == 1)
445  {
446  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
447  }
448  else
449  {
450  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
451  }
452  $this->_pagefoot($pdf,$object,$outputlangs,1);
453  $pagenb++;
454  $pdf->setPage($pagenb);
455  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
456  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
457  }
458  if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
459  {
460  if ($pagenb == 1)
461  {
462  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
463  }
464  else
465  {
466  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
467  }
468  $this->_pagefoot($pdf,$object,$outputlangs,1);
469  // New page
470  $pdf->AddPage();
471  if (! empty($tplidx)) $pdf->useTemplate($tplidx);
472  $pagenb++;
473  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
474  }
475  }
476 
477  // Show square
478  if ($pagenb == 1)
479  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
480  else
481  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
482  $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
483 
484  // Pied de page
485  $this->_pagefoot($pdf, $object, $outputlangs);
486  if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
487 
488  $pdf->Close();
489 
490  $pdf->Output($file, 'F');
491 
492  // Add pdfgeneration hook
493  $hookmanager->initHooks(array('pdfgeneration'));
494  $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
495  global $action;
496  $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
497 
498  if (! empty($conf->global->MAIN_UMASK))
499  @chmod($file, octdec($conf->global->MAIN_UMASK));
500 
501  $this->result = array('fullpath'=>$file);
502 
503  return 1; // Pas d'erreur
504  }
505  else
506  {
507  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
508  return 0;
509  }
510  }
511  else
512  {
513  $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
514  return 0;
515  }
516  }
517 
518 
531  function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
532  {
533  global $conf,$mysoc;
534 
535  $heightoftitleline = 10;
536 
537  $default_font_size = pdf_getPDFFontSize($outputlangs);
538 
539  $pdf->SetDrawColor(128,128,128);
540 
541  // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
542  $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
543 
544  // line prend une position y en 3eme param
545  $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
546 
547  $pdf->SetTextColor(0,0,0);
548  $pdf->SetFont('','', $default_font_size);
549 
550  $pdf->SetXY($this->posxref, $tab_top+1);
551  $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
552 
553  $pdf->SetXY($this->posxlabel, $tab_top+1);
554  $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
555 
556  $pdf->SetXY($this->posxworkload, $tab_top+1);
557  $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
558 
559  $pdf->SetXY($this->posxprogress, $tab_top+1);
560  $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
561 
562  $pdf->SetXY($this->posxdatestart, $tab_top+1);
563  $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C');
564 
565  $pdf->SetXY($this->posxdateend, $tab_top+1);
566  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
567  }
568 
578  function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
579  {
580  global $langs,$conf,$mysoc;
581 
582  $default_font_size = pdf_getPDFFontSize($outputlangs);
583 
584  pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
585 
586  $pdf->SetTextColor(0,0,60);
587  $pdf->SetFont('','B', $default_font_size + 3);
588 
589  $posx=$this->page_largeur-$this->marge_droite-100;
590  $posy=$this->marge_haute;
591 
592  $pdf->SetXY($this->marge_gauche,$posy);
593 
594  // Logo
595  $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
596  if ($mysoc->logo)
597  {
598  if (is_readable($logo))
599  {
600  $height=pdf_getHeightForLogo($logo);
601  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
602  }
603  else
604  {
605  $pdf->SetTextColor(200,0,0);
606  $pdf->SetFont('','B', $default_font_size - 2);
607  $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
608  $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
609  }
610  }
611  else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
612 
613  $pdf->SetFont('','B', $default_font_size + 3);
614  $pdf->SetXY($posx,$posy);
615  $pdf->SetTextColor(0,0,60);
616  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
617  $pdf->SetFont('','', $default_font_size + 2);
618 
619  $posy+=6;
620  $pdf->SetXY($posx,$posy);
621  $pdf->SetTextColor(0,0,60);
622  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
623 
624  $posy+=6;
625  $pdf->SetXY($posx,$posy);
626  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
627 
628  if (is_object($object->thirdparty))
629  {
630  $posy+=6;
631  $pdf->SetXY($posx,$posy);
632  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
633  }
634 
635  $pdf->SetTextColor(0,0,60);
636 
637  // Add list of linked objects
638  /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
639  $object->fetchObjectLinked();
640 
641  foreach($object->linkedObjects as $objecttype => $objects)
642  {
643  var_dump($objects);exit;
644  if ($objecttype == 'commande')
645  {
646  $outputlangs->load('orders');
647  $num=count($objects);
648  for ($i=0;$i<$num;$i++)
649  {
650  $posy+=4;
651  $pdf->SetXY($posx,$posy);
652  $pdf->SetFont('','', $default_font_size - 1);
653  $text=$objects[$i]->ref;
654  if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
655  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
656  }
657  }
658  }
659  */
660  }
661 
671  function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
672  {
673  global $conf;
674  $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
675  return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
676  }
677 }
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
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:82
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:600
</td >< td class="liste_titre" align="right"></td ></tr >< tr class="liste_titre">< input type="checkbox" onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< tr class="oddeven">< td >< input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td >< td >< input type="checkbox" class="check" name="choose'.$i.'"></td >< td class="nowrap"></td >< td >< input type="hidden" name="desc' . $i . '" value="' . dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:573
pdf_getFormat(Translate $outputlangs=null)
Return array with format properties of default PDF format.
Definition: pdf.lib.php:42
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
write_file($object, $outputlangs)
Fonction generant le projet sur le disque.
__construct($db)
Constructor.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:224
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:201
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
Class to manage hooks.
type
Definition: viewcat.php:284
$version
Dolibarr version of the loaded document string.
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:872
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:245
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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:623
Class to manage tasks.
Definition: task.class.php:33
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
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...
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
Class to manage generation of project document Baleine.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
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...
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.