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