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