dolibarr 24.0.0-beta
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-2026 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, $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 $entity = isset($object->entity) ? $object->entity : 1;
199 $basedir = empty($conf->hrm->multidir_output[$entity]) ? $conf->hrm->dir_output : $conf->hrm->multidir_output[$entity];
200 if ($object->specimen) {
201 $dir = $basedir.'/evaluation';
202 $file = $dir."/SPECIMEN.pdf";
203 } else {
204 $objectref = dol_sanitizeFileName($object->ref);
205 $dir = $basedir.'/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->getAnonymisableFullName($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((string) $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 $this->warnings = $hookmanager->warnings;
470 if ($reshook < 0) {
471 $this->error = $hookmanager->error;
472 $this->errors = $hookmanager->errors;
473 dolChmod($file);
474 return -1;
475 }
476
477 dolChmod($file);
478
479 $this->result = array('fullpath' => $file);
480
481 return 1; // No error
482 } else {
483 $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
484 return 0;
485 }
486 } else {
487 $this->error = $langs->trans("ErrorConstantNotDefined", "HRM_OUTPUTDIR");
488 return 0;
489 }
490 }
491
502 protected function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
503 {
504 $objectligne = $object->lines[$linenumber];
505 $pdf->SetFont('', '', $default_font_size - 1);
506 $pdf->SetTextColor(0, 0, 0);
507
508 // Rank of employee
509 $rankemptoshow = "-";
510 if ($objectligne->rankorder > 0) {
511 $rankemptoshow = (string) $objectligne->rankorder;
512 } elseif ($objectligne->rankorder < 0) {
513 $rankemptoshow = $outputlangs->transnoentitiesnoconv("NA");
514 }
515 $pdf->SetXY($this->posxrankemp, $curY);
516 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 0.8, 4, $rankemptoshow, 0, 'C');
517
518 // Expected required Rank
519 $rankexpectedtoshow = "-";
520 if ($objectligne->required_rank > 0) {
521 if ($objectligne->rankorder != 0) {
522 $rankexpectedtoshow = $objectligne->required_rank;
523 }
524 } elseif ($objectligne->required_rank < 0) {
525 $rankexpectedtoshow = $outputlangs->transnoentitiesnoconv("NA");
526 }
527 $pdf->SetXY($this->posxrequiredrank, $curY);
528 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 0.8, 4, $rankexpectedtoshow, 0, 'C');
529
530 // Result
531 $pdf->SetXY($this->posxresult - 1, $curY);
532
533 if ($objectligne->required_rank < 0) { // NA
534 $pdf->SetFillColor(255, 255, 255);
535 } elseif ($objectligne->rankorder > $objectligne->required_rank) { // Higher than expected
536 // Teal Green
537 $pdf->SetFillColor(20, 129, 111);
538 } elseif ($objectligne->rankorder == $objectligne->required_rank) { // Same than expected
539 // Seafoam Green
540 $pdf->SetFillColor(169, 236, 201);
541 } elseif ($objectligne->rankorder < $objectligne->required_rank) { // Lower than expected
542 // Red
543 $pdf->SetFillColor(205, 92, 92);
544 }
545 if ($objectligne->rankorder <= 0 || $objectligne->required_rank == 0) {
546 // No fill color
547 $pdf->SetFillColor(240, 240, 240);
548 }
549 $result = "-";
550 if ($objectligne->required_rank < 0) {
551 if ($objectligne->rankorder > 0) {
552 $result = $objectligne->rankorder;
553 }
554 } elseif ($objectligne->rankorder < 0) {
555 $result = $outputlangs->transnoentitiesnoconv("NA");
556 } elseif ($objectligne->required_rank != 0 && $objectligne->rankorder != 0) {
557 $result = $objectligne->rankorder . "/" . $objectligne->required_rank;
558 }
559 $pdf->MultiCell($this->posxresult - 210 - 0.8 - 4, 4, $result, 0, 'C', true);
560
561 // The next fields can be on several lines so we output them at end so the pos on next line will work correctly
562
563 // Skill
564 $skill = new Skill($this->db);
565 $skill->fetch($objectligne->fk_skill);
566 $pdf->SetXY($this->posxskill, $curY);
567 $comment = $skill->label;
568
569 if (!empty($skill->description)) {
570 $comment .= '<br>' . $outputlangs->trans("Description").': '.$skill->description;
571 }
572 $pdf->writeHTMLCell($this->posxrankemp - $this->posxskill - 0.8, 4, $this->posxskill - 1, $curY, $comment, 0, 1);
573
574 // Line num
575 $pdf->SetXY($this->posxpiece, $curY);
576 $pdf->writeHTMLCell($this->posxskill - $this->posxpiece - 0.8, 3, $this->posxpiece - 1, $curY, (string) ($linenumber + 1), 0, 1, false, false, 'C');
577 }
578
579 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
589 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
590 {
591 // global $conf, $langs, $hookmanager;
592 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
593
594 // Load traductions files required by page
595 $outputlangs->loadLangs(array("main", "trips", "companies"));
596
597 $default_font_size = pdf_getPDFFontSize($outputlangs);
598
599
600 $pdf->SetTextColor(0, 0, 60);
601 $pdf->SetFont('', 'B', $default_font_size + 3);
602
603 $posy = $this->marge_haute;
604 $posx = $this->page_largeur - $this->marge_droite - 100;
605
606 $pdf->SetXY($this->marge_gauche, $posy);
607
608 // Logo
609 $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
610 if ($this->emetteur->logo) {
611 if (is_readable($logo)) {
612 $height = pdf_getHeightForLogo($logo);
613 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
614 } else {
615 $pdf->SetTextColor(200, 0, 0);
616 $pdf->SetFont('', 'B', $default_font_size - 2);
617 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
618 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
619 }
620 } else {
621 $text = $this->emetteur->name;
622 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
623 }
624
625 $pdf->SetFont('', 'B', $default_font_size + 4);
626 $pdf->SetXY($posx, $posy);
627 $pdf->SetTextColor(0, 0, 60);
628 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $outputlangs->transnoentities("Eval"), 0, 'R');
629
630 $pdf->SetFont('', '', $default_font_size - 1);
631
632 // Ref complete
633 $posy += 8;
634 $pdf->SetXY($posx, $posy);
635 $pdf->SetTextColor(0, 0, 60);
636 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R');
637
638 // Date evaluation
639 $posy += 5;
640 $pdf->SetXY($posx, $posy);
641 $pdf->SetTextColor(0, 0, 60);
642 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateEval")." : ".dol_print_date($object->date_eval, "day", false, $outputlangs), '', 'R');
643
644
645 if ($showaddress) {
646 // Sender properties
647 $carac_emetteur = '';
648
649 // employee information
650 $employee = new User($this->db);
651 $employee->fetch($object->fk_user);
652 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities('Employee').' : '.$outputlangs->convToOutputCharset(ucfirst($employee->firstname) . ' ' . strtoupper($employee->lastname));
653
654 // Position
655 include_once DOL_DOCUMENT_ROOT.'/hrm/class/job.class.php';
656 $job = new Job($db);
657 $job->fetch($object->fk_job);
658 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities('JobProfile').' : '.$outputlangs->convToOutputCharset($job->label);
659
660 /*$carac_emetteur .= "\n";
661 if ($object->description) {
662 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($object->description);
663 }*/
664
665
666 // Show sender
667 $posy = 40;
668 $posx = $this->marge_gauche;
669 $hautcadre = 20;
670 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
671 $posx = 118;
672 }
673
674 // Show sender frame
675 /*$pdf->SetTextColor(0, 0, 0);
676 $pdf->SetFont('', 'B', $default_font_size - 2);
677 $pdf->SetXY($posx, $posy - 5);
678 $pdf->MultiCell(190, 5, $outputlangs->transnoentities("Information"), '', 'L');*/
679 $pdf->SetXY($posx, $posy);
680 $pdf->SetFillColor(224, 224, 224);
681 $pdf->RoundedRect($posx, $posy, 190, $hautcadre, $this->corner_radius, '1234', 'F');
682 $pdf->SetTextColor(0, 0, 60);
683
684 // Show sender information
685 $pdf->SetXY($posx + 2, $posy + 3);
686 $pdf->SetFont('', 'B', $default_font_size);
687 $pdf->MultiCell(190, 4, $outputlangs->convToOutputCharset($object->label), 0, 'L');
688 $pdf->SetXY($posx + 2, $posy + 8);
689 $pdf->SetFont('', '', $default_font_size - 1);
690 $pdf->MultiCell(190, 4, $carac_emetteur, 0, 'L');
691 }
692
693 return 0;
694 }
695
696 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
710 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
711 {
712 global $conf;
713
714 // Force to disable hidetop and hidebottom
715 $hidebottom = 0;
716 if ($hidetop) {
717 $hidetop = -1;
718 }
719
720 $pdf->SetDrawColor(128, 128, 128);
721
722 // Rect takes a length in 3rd parameter
723 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, '1234', 'D');
724 // line prend une position y en 3eme param
725 if (empty($hidetop)) {
726 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
727 }
728
729 $pdf->SetFont('', '', 8);
730
731 // Line no
732 if (empty($hidetop)) {
733 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
734 $pdf->MultiCell($this->posxskill - $this->posxpiece - 0.8, 1, '', '', 'C');
735 }
736
737 // Skill
738 $pdf->line($this->posxskill - 1, $tab_top, $this->posxskill - 1, $tab_top + $tab_height);
739 if (empty($hidetop)) {
740 $pdf->SetXY($this->posxskill - 1, $tab_top + 1);
741 $pdf->MultiCell($this->posxrankemp - $this->posxskill - 0.8, 1, $outputlangs->transnoentities("Skill"), '', 'L');
742 }
743
744 // Employee Rank
745 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
746 $pdf->line($this->posxrankemp - 1, $tab_top, $this->posxrankemp - 1, $tab_top + $tab_height);
747 if (empty($hidetop)) {
748 $pdf->SetXY($this->posxrankemp - 0.8, $tab_top + 1);
749 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 1, 2, $outputlangs->transnoentities("EmployeeRankShort"), '', 'C');
750 }
751 }
752
753 // Required Rank
754 $pdf->line($this->posxrequiredrank - 1, $tab_top, $this->posxrequiredrank - 1, $tab_top + $tab_height);
755 if (empty($hidetop)) {
756 $pdf->SetXY($this->posxrequiredrank - 0.8, $tab_top + 1);
757 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 1, 2, $outputlangs->transnoentities("RequiredRankShort"), '', 'C');
758 }
759
760 // Result
761 $pdf->line($this->posxresult - 1, $tab_top, $this->posxresult - 1, $tab_top + $tab_height);
762 if (empty($hidetop)) {
763 $pdf->SetXY($this->posxresult - 0.8, $tab_top + 1);
764 $pdf->MultiCell($this->postotalht - $this->posxresult - 1, 2, $outputlangs->transnoentities("Result"), '', 'C');
765 }
766
767 $pdf->SetTextColor(0, 0, 0);
768 }
769
770
771
772 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
782 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
783 {
784 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
785 return pdf_pagefoot($pdf, $outputlangs, '', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
786 }
787}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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.
global $mysoc
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(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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, $decorate=0)
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...
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)
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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:294
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:317
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:1421
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:273
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
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133