dolibarr 22.0.5
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-2025 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-2025 MDW <mdeweerd@users.noreply.github.com>
11 * Copyright (C) 2024 Nick Fragoulis
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 * or see https://www.gnu.org/
26 */
27
34require_once DOL_DOCUMENT_ROOT.'/core/modules/hrm/modules_evaluation.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38
43{
47 public $db;
48
52 public $name;
53
57 public $description;
58
62 public $update_main_doc_field;
63
67 public $type;
68
73 public $version = 'dolibarr';
74
78 public $posxpiece;
79
83 public $posxskill;
84
88 public $posxrankemp;
89
93 public $posxrequiredrank;
94
98 public $posxresult;
99
103 public $postotalht;
104
108 public $posxnotes;
109
110
116 public function __construct($db)
117 {
118 global $langs, $mysoc;
119
120 // Translations
121 $langs->loadLangs(array("main", "hrm"));
122
123 $this->db = $db;
124 $this->name = "standard";
125 $this->description = $langs->trans('PDFStandardHrmEvaluation');
126 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
127
128 // Page size for A4 format
129 $this->type = 'pdf';
130 $formatarray = pdf_getFormat();
131 $this->page_largeur = $formatarray['width'];
132 $this->page_hauteur = $formatarray['height'];
133 $this->format = array($this->page_largeur, $this->page_hauteur);
134 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
135 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
136 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
137 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
138 $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0);
139 $this->option_logo = 1; // Display logo
140 $this->option_draft_watermark = 1; // Support add of a watermark on drafts
141
142 // Define position of columns
143 $this->posxnotes = $this->marge_gauche + 1;
144
145 $this->posxpiece = $this->marge_gauche + 1;
146 $this->posxskill = $this->marge_gauche + 8;
147 $this->posxrankemp = 129;
148 $this->posxrequiredrank = 157;
149 $this->posxresult = 185;
150
151 if ($this->page_largeur < 210) { // To work with US executive format
152 $this->posxrankemp -= 20;
153 $this->posxrequiredrank -= 20;
154 $this->posxresult -= 20;
155 }
156
157 if ($mysoc === null) {
158 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
159 return;
160 }
161
162 // Get source company
163 $this->emetteur = $mysoc;
164 }
165
166 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
178 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
179 {
180 // phpcs:enable
181 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
182
183 if (!is_object($outputlangs)) {
184 $outputlangs = $langs;
185 }
186 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
187 if (getDolGlobalString('MAIN_USE_FPDF')) {
188 $outputlangs->charset_output = 'ISO-8859-1';
189 }
190
191 // Load traductions files required by page
192 $outputlangs->loadLangs(array("main", "hrm"));
193
194 $nblines = count($object->lines);
195
196 if ($conf->hrm->dir_output) {
197 // Definition of $dir and $file
198 if ($object->specimen) {
199 //$dir = $conf->hrm->dir_output;
200 $dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1].'/evaluation';
201 $file = $dir."/SPECIMEN.pdf";
202 } else {
203 $objectref = dol_sanitizeFileName($object->ref);
204 //$dir = $conf->hrm->dir_output."/".$objectref;
205 $dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1].'/evaluation'."/".$objectref;
206 $file = $dir."/".$objectref.".pdf";
207 }
208
209 if (!file_exists($dir)) {
210 if (dol_mkdir($dir) < 0) {
211 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
212 return 0;
213 }
214 }
215
216 if (file_exists($dir)) {
217 // Add pdfgeneration hook
218 if (!is_object($hookmanager)) {
219 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
220 $hookmanager = new HookManager($this->db);
221 }
222 $hookmanager->initHooks(array('pdfgeneration'));
223 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
224 global $action;
225 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
226 // Set nblines with the new command lines content after hook
227 $nblines = count($object->lines);
228
229 // Create pdf instance
230 $pdf = pdf_getInstance($this->format);
231 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
232 $heightforinfotot = 0; // Height reserved to output the info and total part
233 $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
234 $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin)
235 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
236 $heightforfooter += 6;
237 }
238
239 $pdf->setAutoPageBreak(true, 0);
240
241 if (class_exists('TCPDF')) {
242 $pdf->setPrintHeader(false);
243 $pdf->setPrintFooter(false);
244 }
245 $pdf->SetFont(pdf_getPDFFont($outputlangs));
246 // Set path to the background PDF File
247 if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
248 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
249 $tplidx = $pdf->importPage(1);
250 }
251
252 $pdf->Open();
253 $pagenb = 0;
254 $pdf->SetDrawColor(128, 128, 128);
255
256 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
257 $pdf->SetSubject($outputlangs->transnoentities("Evaluation"));
258 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
259 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
260 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Evaluation"));
261 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
262 $pdf->SetCompression(false);
263 }
264
265 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
266 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
267
268 // New page
269 $pdf->AddPage();
270 if (!empty($tplidx)) {
271 $pdf->useTemplate($tplidx);
272 }
273 $pagenb++;
274 $this->_pagehead($pdf, $object, 1, $outputlangs);
275 $pdf->SetFont('', '', $default_font_size - 1);
276 $pdf->MultiCell(0, 3, ''); // Set interline to 3
277 $pdf->SetTextColor(0, 0, 0);
278
279 $tab_top = 65;
280 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 35 : 10);
281
282 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
283
284 // Show notes
285 if (!empty($object->note_public)) {
286 $tab_top = 65;
287
288 $pdf->SetFont('', 'B', $default_font_size);
289 $pdf->MultiCell(190, 4, $outputlangs->transnoentities("Notes") . ":", 0, 'L', false, 0, 12, $tab_top);
290 $tab_top += 4;
291 $pdf->SetFont('', '', $default_font_size - 1);
292 $pdf->writeHTMLCell(190, 3, $this->posxnotes + 1, $tab_top + 1, dol_htmlentitiesbr($object->note_public), 0, 1);
293 $nexY = $pdf->GetY();
294 $height_note = $nexY - $tab_top;
295
296 // Rect takes a length in 3rd parameter
297 $pdf->SetDrawColor(192, 192, 192);
298 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1 - 4, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1 + 6, $this->corner_radius, '1234', 'D');
299
300 $tab_height -= $height_note;
301 $tab_top = $nexY + 6;
302 } else {
303 $height_note = 0;
304 }
305
306 $iniY = $tab_top + 7;
307 $nexY = $tab_top + 7;
308
309 $showmorebeforepagebreak = 0;
310
311 $pdf->setTopMargin($tab_top_newpage);
312 // Loop on each lines
313 $i = 0;
314 while ($i < $nblines) {
315 $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
316 $pdf->SetTextColor(0, 0, 0);
317
318 if (empty($showmorebeforepagebreak) && ($i !== ($nblines - 1))) {
319 $pdf->setPageOrientation('', true, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
320 } else {
321 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
322 }
323
324 $pdf->setTopMargin($tab_top_newpage);
325
326 $pageposbefore = $pdf->getPage();
327 $curY = $nexY;
328 $pdf->startTransaction();
329
330 // Shod fields of line
331 $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
332
333
334 $pageposafter = $pdf->getPage();
335 if ($pageposafter > $pageposbefore) {
336 // There is a pagebreak
337 $pdf->rollbackTransaction(true);
338
339 $pageposafter = $pageposbefore;
340 if (empty($showmorebeforepagebreak)) {
341 $pdf->AddPage('', '', true);
342 if (!empty($tplidx)) {
343 $pdf->useTemplate($tplidx);
344 }
345 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
346 $this->_pagehead($pdf, $object, 0, $outputlangs);
347 }
348 $pdf->setPage($pageposafter + 1);
349 $showmorebeforepagebreak = 1;
350 $nexY = $tab_top_newpage;
351 $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines
352 $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
353 $pdf->SetTextColor(0, 0, 0);
354
355 $pdf->setTopMargin($tab_top_newpage);
356 continue;
357 } else {
358 $pdf->setPageOrientation('', true, $heightforfooter);
359 $showmorebeforepagebreak = 0;
360 }
361
362 $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
363 $pageposafter = $pdf->getPage();
364 $posyafter = $pdf->GetY();
365 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
366 // There is no space left for total+free text
367 if ($i == ($nblines - 1)) {
368 // No more lines, and no space left to show total, so we create a new page
369 $pdf->AddPage('', '', true);
370 if (!empty($tplidx)) {
371 $pdf->useTemplate($tplidx);
372 }
373 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
374 $this->_pagehead($pdf, $object, 0, $outputlangs);
375 }
376 $pdf->setPage($pageposafter + 1);
377 }
378 } else {
379 // We found a page break
380 // Allows data in the first page if description is long enough to break in multiples pages
381 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
382 $showmorebeforepagebreak = 1;
383 } else {
384 $showmorebeforepagebreak = 0;
385 }
386 }
387 } else { // No pagebreak
388 $pdf->commitTransaction();
389 }
390 $i++;
391
392 //nexY
393 $nexY = $pdf->GetY();
394 $pdf->line($this->marge_gauche, $nexY + 2, $this->page_largeur - $this->marge_droite, $nexY + 2);
395 $pageposafter = $pdf->getPage();
396 $pdf->setPage($pageposbefore);
397 $pdf->setTopMargin($this->marge_haute);
398 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
399
400
401 $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines
402
403 // Detect if some page were added automatically and output _tableau for past pages
404 while ($pagenb < $pageposafter) {
405 $pdf->setPage($pagenb);
406 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
407 if ($pagenb == 1) {
408 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
409 } else {
410 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
411 }
412 $this->_pagefoot($pdf, $object, $outputlangs, 1);
413 $pagenb++;
414 $pdf->setPage($pagenb);
415 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
416 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
417 $this->_pagehead($pdf, $object, 0, $outputlangs);
418 }
419 if (!empty($tplidx)) {
420 $pdf->useTemplate($tplidx);
421 }
422 }
423 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { // @phan-suppress-current-line PhanUndeclaredProperty
424 if ($pagenb == 1) {
425 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
426 } else {
427 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
428 }
429 $this->_pagefoot($pdf, $object, $outputlangs, 1);
430 // New page
431 $pdf->AddPage();
432 if (!empty($tplidx)) {
433 $pdf->useTemplate($tplidx);
434 }
435 $pagenb++;
436 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
437 $this->_pagehead($pdf, $object, 0, $outputlangs);
438 }
439 }
440 }
441
442 // Show square
443 if ($pagenb == 1) {
444 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
445 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
446 } else {
447 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
448 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
449 }
450
451 $pdf->SetFont('', '', 10);
452
453
454 // Page footer
455 $this->_pagefoot($pdf, $object, $outputlangs);
456 if (method_exists($pdf, 'AliasNbPages')) {
457 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
458 }
459
460 $pdf->Close();
461
462 $pdf->Output($file, 'F');
463
464 // Add pdfgeneration hook
465 $hookmanager->initHooks(array('pdfgeneration'));
466 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
467 global $action;
468 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
469 if ($reshook < 0) {
470 $this->error = $hookmanager->error;
471 $this->errors = $hookmanager->errors;
472 }
473
474 dolChmod($file);
475
476 $this->result = array('fullpath' => $file);
477
478 return 1; // No error
479 } else {
480 $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
481 return 0;
482 }
483 } else {
484 $this->error = $langs->trans("ErrorConstantNotDefined", "HRM_OUTPUTDIR");
485 return 0;
486 }
487 }
488
499 protected function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
500 {
501 $objectligne = $object->lines[$linenumber];
502 $pdf->SetFont('', '', $default_font_size - 1);
503 $pdf->SetTextColor(0, 0, 0);
504
505 // Rank of employee
506 $rankemptoshow = "-";
507 if ($objectligne->rankorder > 0) {
508 $rankemptoshow = (string) $objectligne->rankorder;
509 } elseif ($objectligne->rankorder < 0) {
510 $rankemptoshow = $outputlangs->transnoentitiesnoconv("NA");
511 }
512 $pdf->SetXY($this->posxrankemp, $curY);
513 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 0.8, 4, $rankemptoshow, 0, 'C');
514
515 // Expected required Rank
516 $rankexpectedtoshow = "-";
517 if ($objectligne->required_rank > 0) {
518 if ($objectligne->rankorder != 0) {
519 $rankexpectedtoshow = $objectligne->required_rank;
520 }
521 } elseif ($objectligne->required_rank < 0) {
522 $rankexpectedtoshow = $outputlangs->transnoentitiesnoconv("NA");
523 }
524 $pdf->SetXY($this->posxrequiredrank, $curY);
525 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 0.8, 4, $rankexpectedtoshow, 0, 'C');
526
527 // Result
528 $pdf->SetXY($this->posxresult - 1, $curY);
529
530 if ($objectligne->required_rank < 0) { // NA
531 $pdf->SetFillColor(255, 255, 255);
532 } elseif ($objectligne->rankorder > $objectligne->required_rank) { // Higher than expected
533 // Teal Green
534 $pdf->SetFillColor(20, 129, 111);
535 } elseif ($objectligne->rankorder == $objectligne->required_rank) { // Same than expected
536 // Seafoam Green
537 $pdf->SetFillColor(169, 236, 201);
538 } elseif ($objectligne->rankorder < $objectligne->required_rank) { // Lower than expected
539 // Red
540 $pdf->SetFillColor(205, 92, 92);
541 }
542 if ($objectligne->rankorder <= 0 || $objectligne->required_rank == 0) {
543 // No fill color
544 $pdf->SetFillColor(240, 240, 240);
545 }
546 $result = "-";
547 if ($objectligne->required_rank < 0) {
548 if ($objectligne->rankorder > 0) {
549 $result = $objectligne->rankorder;
550 }
551 } elseif ($objectligne->rankorder < 0) {
552 $result = $outputlangs->transnoentitiesnoconv("NA");
553 } elseif ($objectligne->required_rank != 0 && $objectligne->rankorder != 0) {
554 $result = $objectligne->rankorder . "/" . $objectligne->required_rank;
555 }
556 $pdf->MultiCell($this->posxresult - 210 - 0.8 - 4, 4, $result, 0, 'C', true);
557
558 // The next fields can be on several lines so we output them at end so the pos on next line will work correctly
559
560 // Skill
561 $skill = new Skill($this->db);
562 $skill->fetch($objectligne->fk_skill);
563 $pdf->SetXY($this->posxskill, $curY);
564 $comment = $skill->label;
565
566 if (!empty($skill->description)) {
567 $comment .= '<br>' . $outputlangs->trans("Description").': '.$skill->description;
568 }
569 $pdf->writeHTMLCell($this->posxrankemp - $this->posxskill - 0.8, 4, $this->posxskill - 1, $curY, $comment, 0, 1);
570
571 // Line num
572 $pdf->SetXY($this->posxpiece, $curY);
573 $pdf->writeHTMLCell($this->posxskill - $this->posxpiece - 0.8, 3, $this->posxpiece - 1, $curY, (string) ($linenumber + 1), 0, 1, false, false, 'C');
574 }
575
576 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
586 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
587 {
588 // global $conf, $langs, $hookmanager;
589 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
590
591 // Load traductions files required by page
592 $outputlangs->loadLangs(array("main", "trips", "companies"));
593
594 $default_font_size = pdf_getPDFFontSize($outputlangs);
595
596
597 $pdf->SetTextColor(0, 0, 60);
598 $pdf->SetFont('', 'B', $default_font_size + 3);
599
600 $posy = $this->marge_haute;
601 $posx = $this->page_largeur - $this->marge_droite - 100;
602
603 $pdf->SetXY($this->marge_gauche, $posy);
604
605 // Logo
606 $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
607 if ($this->emetteur->logo) {
608 if (is_readable($logo)) {
609 $height = pdf_getHeightForLogo($logo);
610 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
611 } else {
612 $pdf->SetTextColor(200, 0, 0);
613 $pdf->SetFont('', 'B', $default_font_size - 2);
614 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
615 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
616 }
617 } else {
618 $text = $this->emetteur->name;
619 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
620 }
621
622 $pdf->SetFont('', 'B', $default_font_size + 4);
623 $pdf->SetXY($posx, $posy);
624 $pdf->SetTextColor(0, 0, 60);
625 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $outputlangs->transnoentities("Eval"), 0, 'R');
626
627 $pdf->SetFont('', '', $default_font_size - 1);
628
629 // Ref complete
630 $posy += 8;
631 $pdf->SetXY($posx, $posy);
632 $pdf->SetTextColor(0, 0, 60);
633 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R');
634
635 // Date evaluation
636 $posy += 5;
637 $pdf->SetXY($posx, $posy);
638 $pdf->SetTextColor(0, 0, 60);
639 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateEval")." : ".dol_print_date($object->date_eval, "day", false, $outputlangs), '', 'R');
640
641
642 if ($showaddress) {
643 // Sender properties
644 $carac_emetteur = '';
645
646 // employee information
647 $employee = new User($this->db);
648 $employee->fetch($object->fk_user);
649 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities('Employee').' : '.$outputlangs->convToOutputCharset(ucfirst($employee->firstname) . ' ' . strtoupper($employee->lastname));
650
651 // Position
652 include_once DOL_DOCUMENT_ROOT.'/hrm/class/job.class.php';
653 $job = new Job($db);
654 $job->fetch($object->fk_job);
655 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities('JobProfile').' : '.$outputlangs->convToOutputCharset($job->label);
656
657 /*$carac_emetteur .= "\n";
658 if ($object->description) {
659 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($object->description);
660 }*/
661
662
663 // Show sender
664 $posy = 40;
665 $posx = $this->marge_gauche;
666 $hautcadre = 20;
667 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
668 $posx = 118;
669 }
670
671 // Show sender frame
672 /*$pdf->SetTextColor(0, 0, 0);
673 $pdf->SetFont('', 'B', $default_font_size - 2);
674 $pdf->SetXY($posx, $posy - 5);
675 $pdf->MultiCell(190, 5, $outputlangs->transnoentities("Information"), '', 'L');*/
676 $pdf->SetXY($posx, $posy);
677 $pdf->SetFillColor(224, 224, 224);
678 $pdf->RoundedRect($posx, $posy, 190, $hautcadre, $this->corner_radius, '1234', 'F');
679 $pdf->SetTextColor(0, 0, 60);
680
681 // Show sender information
682 $pdf->SetXY($posx + 2, $posy + 3);
683 $pdf->SetFont('', 'B', $default_font_size);
684 $pdf->MultiCell(190, 4, $outputlangs->convToOutputCharset($object->label), 0, 'L');
685 $pdf->SetXY($posx + 2, $posy + 8);
686 $pdf->SetFont('', '', $default_font_size - 1);
687 $pdf->MultiCell(190, 4, $carac_emetteur, 0, 'L');
688 }
689
690 return 0;
691 }
692
693 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
707 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
708 {
709 global $conf;
710
711 // Force to disable hidetop and hidebottom
712 $hidebottom = 0;
713 if ($hidetop) {
714 $hidetop = -1;
715 }
716
717 $pdf->SetDrawColor(128, 128, 128);
718
719 // Rect takes a length in 3rd parameter
720 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, '1234', 'D');
721 // line prend une position y en 3eme param
722 if (empty($hidetop)) {
723 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
724 }
725
726 $pdf->SetFont('', '', 8);
727
728 // Line no
729 if (empty($hidetop)) {
730 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
731 $pdf->MultiCell($this->posxskill - $this->posxpiece - 0.8, 1, '', '', 'C');
732 }
733
734 // Skill
735 $pdf->line($this->posxskill - 1, $tab_top, $this->posxskill - 1, $tab_top + $tab_height);
736 if (empty($hidetop)) {
737 $pdf->SetXY($this->posxskill - 1, $tab_top + 1);
738 $pdf->MultiCell($this->posxrankemp - $this->posxskill - 0.8, 1, $outputlangs->transnoentities("Skill"), '', 'L');
739 }
740
741 // Employee Rank
742 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
743 $pdf->line($this->posxrankemp - 1, $tab_top, $this->posxrankemp - 1, $tab_top + $tab_height);
744 if (empty($hidetop)) {
745 $pdf->SetXY($this->posxrankemp - 0.8, $tab_top + 1);
746 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 1, 2, $outputlangs->transnoentities("EmployeeRankShort"), '', 'C');
747 }
748 }
749
750 // Required Rank
751 $pdf->line($this->posxrequiredrank - 1, $tab_top, $this->posxrequiredrank - 1, $tab_top + $tab_height);
752 if (empty($hidetop)) {
753 $pdf->SetXY($this->posxrequiredrank - 0.8, $tab_top + 1);
754 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 1, 2, $outputlangs->transnoentities("RequiredRankShort"), '', 'C');
755 }
756
757 // Result
758 $pdf->line($this->posxresult - 1, $tab_top, $this->posxresult - 1, $tab_top + $tab_height);
759 if (empty($hidetop)) {
760 $pdf->SetXY($this->posxresult - 0.8, $tab_top + 1);
761 $pdf->MultiCell($this->postotalht - $this->posxresult - 1, 2, $outputlangs->transnoentities("Result"), '', 'C');
762 }
763
764 $pdf->SetTextColor(0, 0, 0);
765 }
766
767
768
769 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
779 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
780 {
781 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
782 return pdf_pagefoot($pdf, $outputlangs, '', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
783 }
784}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
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.
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
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_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...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:87
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:289
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:1047
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:129
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:158
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:161