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