dolibarr 19.0.3
pdf_standard.modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
4 * Copyright (C) 2016-2023 Philippe Grand <philippe.grand@atoo-net.com>
5 * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
6 * Copyright (C) 2018 Francis Appels <francis.appels@z-application.com>
7 * Copyright (C) 2019 Markus Welters <markus@welters.de>
8 * Copyright (C) 2019 Rafael Ingenleuf <ingenleuf@welters.de>
9 * Copyright (C) 2020 Marc Guenneugues <marc.guenneugues@simicar.fr>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 * or see https://www.gnu.org/
24 */
25
32require_once DOL_DOCUMENT_ROOT.'/core/modules/hrm/modules_evaluation.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
36
41{
45 public $db;
46
50 public $name;
51
55 public $description;
56
60 public $update_main_doc_field;
61
65 public $type;
66
71 public $version = 'dolibarr';
72
73 public $posxpiece;
74 public $posxskill;
75 public $posxrankemp;
76 public $posxrequiredrank;
77 public $posxresult;
78 public $postotalht;
79 public $posxnotes;
80
81
87 public function __construct($db)
88 {
89 global $conf, $langs, $mysoc, $user;
90 // Translations
91 $langs->loadLangs(array("main", "hrm"));
92
93 $this->db = $db;
94 $this->name = "standard";
95 $this->description = $langs->trans('PDFStandardHrmEvaluation');
96 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
97
98 // Page size for A4 format
99 $this->type = 'pdf';
100 $formatarray = pdf_getFormat();
101 $this->page_largeur = $formatarray['width'];
102 $this->page_hauteur = $formatarray['height'];
103 $this->format = array($this->page_largeur, $this->page_hauteur);
104 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
105 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
106 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
107 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
108
109 $this->option_logo = 1; // Display logo
110 $this->option_draft_watermark = 1; // Support add of a watermark on drafts
111
112 // Get source company
113 $this->emetteur = $mysoc;
114
115 // Define position of columns
116 $this->posxnotes = $this->marge_gauche + 1;
117
118 $this->posxpiece = $this->marge_gauche + 1;
119 $this->posxskill = $this->marge_gauche + 8;
120 $this->posxrankemp = 129;
121 $this->posxrequiredrank = 157;
122 $this->posxresult = 185;
123
124 if ($this->page_largeur < 210) { // To work with US executive format
125 $this->posxrankemp -= 20;
126 $this->posxrequiredrank -= 20;
127 $this->posxresult -= 20;
128 }
129 }
130
131 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
143 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
144 {
145 // phpcs:enable
146 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
147
148 if (!is_object($outputlangs)) {
149 $outputlangs = $langs;
150 }
151 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
152 if (getDolGlobalString('MAIN_USE_FPDF')) {
153 $outputlangs->charset_output = 'ISO-8859-1';
154 }
155
156 // Load traductions files required by page
157 $outputlangs->loadLangs(array("main", "hrm"));
158
159 $nblines = count($object->lines);
160
161 if ($conf->hrm->dir_output) {
162 // Definition of $dir and $file
163 if ($object->specimen) {
164 //$dir = $conf->hrm->dir_output;
165 $dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1].'/evaluation';
166 $file = $dir."/SPECIMEN.pdf";
167 } else {
168 $objectref = dol_sanitizeFileName($object->ref);
169 //$dir = $conf->hrm->dir_output."/".$objectref;
170 $dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1].'/evaluation'."/".$objectref;
171 $file = $dir."/".$objectref.".pdf";
172 }
173
174 if (!file_exists($dir)) {
175 if (dol_mkdir($dir) < 0) {
176 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
177 return 0;
178 }
179 }
180
181 if (file_exists($dir)) {
182 // Add pdfgeneration hook
183 if (!is_object($hookmanager)) {
184 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
185 $hookmanager = new HookManager($this->db);
186 }
187 $hookmanager->initHooks(array('pdfgeneration'));
188 $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
189 global $action;
190 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
191 // Set nblines with the new command lines content after hook
192 $nblines = count($object->lines);
193
194 // Create pdf instance
195 $pdf = pdf_getInstance($this->format);
196 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
197 $heightforinfotot = 0; // Height reserved to output the info and total part
198 $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
199 $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin)
200 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
201 $heightforfooter += 6;
202 }
203
204 $pdf->SetAutoPageBreak(1, 0);
205
206 if (class_exists('TCPDF')) {
207 $pdf->setPrintHeader(false);
208 $pdf->setPrintFooter(false);
209 }
210 $pdf->SetFont(pdf_getPDFFont($outputlangs));
211 // Set path to the background PDF File
212 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
213 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
214 $tplidx = $pdf->importPage(1);
215 }
216
217 $pdf->Open();
218 $pagenb = 0;
219 $pdf->SetDrawColor(128, 128, 128);
220
221 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
222 $pdf->SetSubject($outputlangs->transnoentities("Evaluation"));
223 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
224 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
225 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Evaluation"));
226 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
227 $pdf->SetCompression(false);
228 }
229
230 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
231
232 // New page
233 $pdf->AddPage();
234 if (!empty($tplidx)) {
235 $pdf->useTemplate($tplidx);
236 }
237 $pagenb++;
238 $this->_pagehead($pdf, $object, 1, $outputlangs);
239 $pdf->SetFont('', '', $default_font_size - 1);
240 $pdf->MultiCell(0, 3, ''); // Set interline to 3
241 $pdf->SetTextColor(0, 0, 0);
242
243 $tab_top = 65;
244 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 35 : 10);
245
246 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
247
248 // Show notes
249 if (!empty($object->note_public)) {
250 $tab_top = 65;
251
252 $pdf->SetFont('', 'B', $default_font_size);
253 $pdf->MultiCell(190, 4, $outputlangs->transnoentities("Notes") . ":", 0, 'L', 0, '', 12, $tab_top);
254 $tab_top +=4;
255 $pdf->SetFont('', '', $default_font_size - 1);
256 $pdf->writeHTMLCell(190, 3, $this->posxnotes + 1, $tab_top + 1, dol_htmlentitiesbr($object->note_public), 0, 1);
257 $nexY = $pdf->GetY();
258 $height_note = $nexY - $tab_top;
259
260 // Rect takes a length in 3rd parameter
261 $pdf->SetDrawColor(192, 192, 192);
262 $pdf->Rect($this->marge_gauche, $tab_top - 1 - 4, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1 + 6);
263
264 $tab_height = $tab_height - $height_note;
265 $tab_top = $nexY + 6;
266 } else {
267 $height_note = 0;
268 }
269
270 $iniY = $tab_top + 7;
271 $initialY = $tab_top + 7;
272 $nexY = $tab_top + 7;
273
274 $pdf->setTopMargin($tab_top_newpage);
275 // Loop on each lines
276 $i = 0;
277 while ($i < $nblines) {
278 $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
279 $pdf->SetTextColor(0, 0, 0);
280
281 if (empty($showmorebeforepagebreak) && ($i !== ($nblines - 1))) {
282 $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
283 } else {
284 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
285 }
286
287 $pdf->setTopMargin($tab_top_newpage);
288
289 $pageposbefore = $pdf->getPage();
290 $curY = $nexY;
291 $pdf->startTransaction();
292
293 $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
294
295
296
297 $pageposafter = $pdf->getPage();
298 if ($pageposafter > $pageposbefore) {
299 // There is a pagebreak
300 $pdf->rollbackTransaction(true);
301
302 $pageposafter = $pageposbefore;
303 if (empty($showmorebeforepagebreak)) {
304 $pdf->AddPage('', '', true);
305 if (!empty($tplidx)) {
306 $pdf->useTemplate($tplidx);
307 }
308 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
309 $this->_pagehead($pdf, $object, 0, $outputlangs);
310 }
311 $pdf->setPage($pageposafter + 1);
312 $showmorebeforepagebreak = 1;
313 $nexY = $tab_top_newpage;
314 $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines
315 $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
316 $pdf->SetTextColor(0, 0, 0);
317
318 $pdf->setTopMargin($tab_top_newpage);
319 continue;
320 } else {
321 $pdf->setPageOrientation('', 1, $heightforfooter);
322 $showmorebeforepagebreak = 0;
323 }
324
325 $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
326 $pageposafter = $pdf->getPage();
327 $posyafter = $pdf->GetY();
328 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
329 // There is no space left for total+free text
330 if ($i == ($nblines - 1)) {
331 // No more lines, and no space left to show total, so we create a new page
332 $pdf->AddPage('', '', true);
333 if (!empty($tplidx)) {
334 $pdf->useTemplate($tplidx);
335 }
336 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
337 $this->_pagehead($pdf, $object, 0, $outputlangs);
338 }
339 $pdf->setPage($pageposafter + 1);
340 }
341 } else {
342 // We found a page break
343 // Allows data in the first page if description is long enough to break in multiples pages
344 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
345 $showmorebeforepagebreak = 1;
346 } else {
347 $showmorebeforepagebreak = 0;
348 }
349 }
350 } else { // No pagebreak
351 $pdf->commitTransaction();
352 }
353 $i++;
354
355 //nexY
356 $nexY = $pdf->GetY();
357 $pdf->line($this->marge_gauche, $nexY + 2, $this->page_largeur - $this->marge_droite, $nexY + 2);
358 $pageposafter = $pdf->getPage();
359 $pdf->setPage($pageposbefore);
360 $pdf->setTopMargin($this->marge_haute);
361 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
362
363
364 $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines
365
366 // Detect if some page were added automatically and output _tableau for past pages
367 while ($pagenb < $pageposafter) {
368 $pdf->setPage($pagenb);
369 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
370 if ($pagenb == 1) {
371 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
372 } else {
373 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
374 }
375 $this->_pagefoot($pdf, $object, $outputlangs, 1);
376 $pagenb++;
377 $pdf->setPage($pagenb);
378 $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
379 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
380 $this->_pagehead($pdf, $object, 0, $outputlangs);
381 }
382 if (!empty($tplidx)) {
383 $pdf->useTemplate($tplidx);
384 }
385 }
386 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
387 if ($pagenb == 1) {
388 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
389 } else {
390 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
391 }
392 $this->_pagefoot($pdf, $object, $outputlangs, 1);
393 // New page
394 $pdf->AddPage();
395 if (!empty($tplidx)) {
396 $pdf->useTemplate($tplidx);
397 }
398 $pagenb++;
399 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
400 $this->_pagehead($pdf, $object, 0, $outputlangs);
401 }
402 }
403 }
404
405 // Show square
406 if ($pagenb == 1) {
407 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
408 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
409 } else {
410 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
411 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
412 }
413
414 $pdf->SetFont('', '', 10);
415
416
417 // Page footer
418 $this->_pagefoot($pdf, $object, $outputlangs);
419 if (method_exists($pdf, 'AliasNbPages')) {
420 $pdf->AliasNbPages();
421 }
422
423 $pdf->Close();
424
425 $pdf->Output($file, 'F');
426
427 // Add pdfgeneration hook
428 $hookmanager->initHooks(array('pdfgeneration'));
429 $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
430 global $action;
431 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
432 if ($reshook < 0) {
433 $this->error = $hookmanager->error;
434 $this->errors = $hookmanager->errors;
435 }
436
437 dolChmod($file);
438
439 $this->result = array('fullpath'=>$file);
440
441 return 1; // No error
442 } else {
443 $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
444 return 0;
445 }
446 } else {
447 $this->error = $langs->trans("ErrorConstantNotDefined", "HRM_OUTPUTDIR");
448 return 0;
449 }
450 }
451
462 protected function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
463 {
464 global $conf;
465 $objectligne = $object->lines[$linenumber];
466 $pdf->SetFont('', '', $default_font_size - 1);
467 $pdf->SetTextColor(0, 0, 0);
468
469 // Result
470 $pdf->SetXY($this->posxresult - 1, $curY);
471
472 if ($objectligne->rankorder > $objectligne->required_rank) {
473 // Teal Green
474 $pdf->SetFillColor(0, 109, 91);
475 } elseif ($objectligne->rankorder == $objectligne->required_rank) {
476 // Seafoam Green
477 $pdf->SetFillColor(159, 226, 191);
478 } elseif ($objectligne->rankorder < $objectligne->required_rank) {
479 // red
480 $pdf->SetFillColor(205, 92, 92);
481 }
482 if ($objectligne->rankorder == 0 || $objectligne->required_rank == 0) {
483 // No fill color
484 $pdf->SetFillColor(255, 255, 255);
485 }
486 $result = (($objectligne->required_rank != 0 && $objectligne->rankorder != 0) ? $objectligne->rankorder . "/" . $objectligne->required_rank : "-");
487 $pdf->MultiCell($this->posxresult - 210 - 0.8 - 4, 4, $result, 0, 'C', 1);
488
489
490 // required Rank
491 $pdf->SetXY($this->posxrequiredrank, $curY);
492 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 0.8, 4, (($objectligne->required_rank != 0 && $objectligne->rankorder != 0) ? $objectligne->required_rank : "-"), 0, 'C');
493
494 // Rank Employee
495 $pdf->SetXY($this->posxrankemp, $curY);
496 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 0.8, 4, (($objectligne->rankorder != 0) ? $objectligne->rankorder : "-"), 0, 'C');
497
498 // Skill
499 $skill = new Skill($this->db);
500 $skill->fetch($objectligne->fk_skill);
501 $pdf->SetXY($this->posxskill, $curY);
502 $comment = $skill->label;
503
504 if (!empty($skill->description)) {
505 $comment .= '<br>' . $outputlangs->trans("Description").': '.$skill->description;
506 }
507 $pdf->writeHTMLCell($this->posxrankemp - $this->posxskill - 0.8, 4, $this->posxskill - 1, $curY, $comment, 0, 1);
508
509
510
511 // Line num
512 $pdf->SetXY($this->posxpiece, $curY);
513 $pdf->writeHTMLCell($this->posxskill - $this->posxpiece - 0.8, 3, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1, 0, 0, 'C');
514 }
515
516 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
526 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
527 {
528 // global $conf, $langs, $hookmanager;
529 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
530
531 // Load traductions files required by page
532 $outputlangs->loadLangs(array("main", "trips", "companies"));
533
534 $default_font_size = pdf_getPDFFontSize($outputlangs);
535
536
537 $pdf->SetTextColor(0, 0, 60);
538 $pdf->SetFont('', 'B', $default_font_size + 3);
539
540 $posy = $this->marge_haute;
541 $posx = $this->page_largeur - $this->marge_droite - 100;
542
543 $pdf->SetXY($this->marge_gauche, $posy);
544
545 // Logo
546 $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
547 if ($this->emetteur->logo) {
548 if (is_readable($logo)) {
549 $height = pdf_getHeightForLogo($logo);
550 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
551 } else {
552 $pdf->SetTextColor(200, 0, 0);
553 $pdf->SetFont('', 'B', $default_font_size - 2);
554 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
555 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
556 }
557 } else {
558 $text = $this->emetteur->name;
559 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
560 }
561
562 $pdf->SetFont('', 'B', $default_font_size + 4);
563 $pdf->SetXY($posx, $posy);
564 $pdf->SetTextColor(0, 0, 60);
565 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $outputlangs->transnoentities("Eval"), 0, 'R');
566
567 $pdf->SetFont('', '', $default_font_size - 1);
568
569 // Ref complete
570 $posy += 8;
571 $pdf->SetXY($posx, $posy);
572 $pdf->SetTextColor(0, 0, 60);
573 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R');
574
575 // Date evaluation
576 $posy += 5;
577 $pdf->SetXY($posx, $posy);
578 $pdf->SetTextColor(0, 0, 60);
579 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateEval")." : ".dol_print_date($object->date_eval, "day", false, $outputlangs), '', 'R');
580
581
582 if ($showaddress) {
583 // Sender properties
584 $carac_emetteur = '';
585
586 // employee informations
587 $employee = new User($this->db);
588 $employee->fetch($object->fk_user);
589 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities('Employee').' : '.$outputlangs->convToOutputCharset(ucfirst($employee->firstname) . ' ' . strtoupper($employee->lastname));
590
591 // Position
592 $job = new Job($db);
593 $job->fetch($object->fk_job);
594 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities('JobProfile').' : '.$outputlangs->convToOutputCharset($job->label);
595
596 /*$carac_emetteur .= "\n";
597 if ($object->description) {
598 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($object->description);
599 }*/
600
601
602 // Show sender
603 $posy = 40;
604 $posx = $this->marge_gauche;
605 $hautcadre = 20;
606 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
607 $posx = 118;
608 }
609
610 // Show sender frame
611 /*$pdf->SetTextColor(0, 0, 0);
612 $pdf->SetFont('', 'B', $default_font_size - 2);
613 $pdf->SetXY($posx, $posy - 5);
614 $pdf->MultiCell(190, 5, $outputlangs->transnoentities("Informations"), '', 'L');*/
615 $pdf->SetXY($posx, $posy);
616 $pdf->SetFillColor(224, 224, 224);
617 $pdf->MultiCell(190, $hautcadre, "", 0, 'R', 1);
618 $pdf->SetTextColor(0, 0, 60);
619
620 // Show sender information
621 $pdf->SetXY($posx + 2, $posy + 3);
622 $pdf->SetFont('', 'B', $default_font_size);
623 $pdf->MultiCell(190, 4, $outputlangs->convToOutputCharset($object->label), 0, 'L');
624 $pdf->SetXY($posx + 2, $posy + 8);
625 $pdf->SetFont('', '', $default_font_size - 1);
626 $pdf->MultiCell(190, 4, $carac_emetteur, 0, 'L');
627 }
628 }
629
630 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
644 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
645 {
646 global $conf;
647
648 // Force to disable hidetop and hidebottom
649 $hidebottom = 0;
650 if ($hidetop) {
651 $hidetop = -1;
652 }
653
654 $pdf->SetDrawColor(128, 128, 128);
655
656 // Rect takes a length in 3rd parameter
657 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
658 // line prend une position y en 3eme param
659 if (empty($hidetop)) {
660 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
661 }
662
663 $pdf->SetFont('', '', 8);
664
665 // Line no
666 if (empty($hidetop)) {
667 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
668 $pdf->MultiCell($this->posxskill - $this->posxpiece - 0.8, 1, '', '', 'C');
669 }
670
671 // Skill
672 $pdf->line($this->posxskill - 1, $tab_top, $this->posxskill - 1, $tab_top + $tab_height);
673 if (empty($hidetop)) {
674 $pdf->SetXY($this->posxskill - 1, $tab_top + 1);
675 $pdf->MultiCell($this->posxrankemp - $this->posxskill - 0.8, 1, $outputlangs->transnoentities("Skill"), '', 'L');
676 }
677
678 // Employee Rank
679 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
680 $pdf->line($this->posxrankemp - 1, $tab_top, $this->posxrankemp - 1, $tab_top + $tab_height);
681 if (empty($hidetop)) {
682 $pdf->SetXY($this->posxrankemp - 0.8, $tab_top + 1);
683 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 1, 2, $outputlangs->transnoentities("EmployeeRankShort"), '', 'C');
684 }
685 }
686
687 // Required Rank
688 $pdf->line($this->posxrequiredrank - 1, $tab_top, $this->posxrequiredrank - 1, $tab_top + $tab_height);
689 if (empty($hidetop)) {
690 $pdf->SetXY($this->posxrequiredrank - 0.8, $tab_top + 1);
691 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 1, 2, $outputlangs->transnoentities("RequiredRankShort"), '', 'C');
692 }
693
694 // Result
695 $pdf->line($this->posxresult - 1, $tab_top, $this->posxresult - 1, $tab_top + $tab_height);
696 if (empty($hidetop)) {
697 $pdf->SetXY($this->posxresult - 0.8, $tab_top + 1);
698 $pdf->MultiCell($this->postotalht - $this->posxresult - 1, 2, $outputlangs->transnoentities("Result"), '', 'C');
699 }
700
701 $pdf->SetTextColor(0, 0, 0);
702 }
703
704
705
706 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
716 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
717 {
718 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
719 return pdf_pagefoot($pdf, $outputlangs, '', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
720 }
721}
Class to manage hooks.
Class for Job.
Definition job.class.php:37
Parent class for documents models.
Class for Skill.
Class to manage Dolibarr users.
Class to generate expense report based on standard model.
__construct($db)
Constructor.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails=0)
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
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.
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.
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_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:266
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