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