dolibarr 25.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-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-2026 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 $top_margin = 55 + $this->marge_haute;
280 $tab_top = $top_margin;
281 $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? $top_margin + 32 : $top_margin);
282
283 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
284
285 // Show notes
286 if (!empty($object->note_public)) {
287 $tab_top = $top_margin;
288
289 $pdf->SetFont('', 'B', $default_font_size);
290 $pdf->MultiCell(190, 4, $outputlangs->transnoentities("Notes") . ":", 0, 'L', false, 0, 12, $tab_top);
291 $tab_top += 4;
292 $pdf->SetFont('', '', $default_font_size - 1);
293 $pdf->writeHTMLCell(190, 3, $this->posxnotes + 1, $tab_top + 1, dol_htmlentitiesbr((string) $object->note_public), 0, 1);
294 $nexY = $pdf->GetY();
295 $height_note = $nexY - $tab_top;
296
297 // Rect takes a length in 3rd parameter
298 $pdf->SetDrawColor(192, 192, 192);
299 $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');
300
301 $tab_height -= $height_note;
302 $tab_top = $nexY + 6;
303 } else {
304 $height_note = 0;
305 }
306
307 $iniY = $tab_top + 7;
308 $nexY = $tab_top + 7;
309
310 $showmorebeforepagebreak = 0;
311
312 $pdf->setTopMargin($tab_top_newpage);
313 // Loop on each lines
314 $i = 0;
315 while ($i < $nblines) {
316 $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
317 $pdf->SetTextColor(0, 0, 0);
318
319 if (empty($showmorebeforepagebreak) && ($i !== ($nblines - 1))) {
320 $pdf->setPageOrientation('', true, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
321 } else {
322 $pdf->setPageOrientation('', true, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
323 }
324
325 $pdf->setTopMargin($tab_top_newpage);
326
327 $pageposbefore = $pdf->getPage();
328 $curY = $nexY;
329 $pdf->startTransaction();
330
331 // Shod fields of line
332 $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
333
334
335 $pageposafter = $pdf->getPage();
336 if ($pageposafter > $pageposbefore) {
337 // There is a pagebreak
338 $pdf->rollbackTransaction(true);
339
340 $pageposafter = $pageposbefore;
341 if (empty($showmorebeforepagebreak)) {
342 $pdf->AddPage('', '', true);
343 if (!empty($tplidx)) {
344 $pdf->useTemplate($tplidx);
345 }
346 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
347 $this->_pagehead($pdf, $object, 0, $outputlangs);
348 }
349 $pdf->setPage($pageposafter + 1);
350 $showmorebeforepagebreak = 1;
351 $nexY = $tab_top_newpage;
352 $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines
353 $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
354 $pdf->SetTextColor(0, 0, 0);
355
356 $pdf->setTopMargin($tab_top_newpage);
357 continue;
358 } else {
359 $pdf->setPageOrientation('', true, $heightforfooter);
360 $showmorebeforepagebreak = 0;
361 }
362
363 $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
364 $pageposafter = $pdf->getPage();
365 $posyafter = $pdf->GetY();
366 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
367 // There is no space left for total+free text
368 if ($i == ($nblines - 1)) {
369 // No more lines, and no space left to show total, so we create a new page
370 $pdf->AddPage('', '', true);
371 if (!empty($tplidx)) {
372 $pdf->useTemplate($tplidx);
373 }
374 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
375 $this->_pagehead($pdf, $object, 0, $outputlangs);
376 }
377 $pdf->setPage($pageposafter + 1);
378 }
379 } else {
380 // We found a page break
381 // Allows data in the first page if description is long enough to break in multiples pages
382 if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
383 $showmorebeforepagebreak = 1;
384 } else {
385 $showmorebeforepagebreak = 0;
386 }
387 }
388 } else { // No pagebreak
389 $pdf->commitTransaction();
390 }
391 $i++;
392
393 //nexY
394 $nexY = $pdf->GetY();
395 $pdf->line($this->marge_gauche, $nexY + 2, $this->page_largeur - $this->marge_droite, $nexY + 2);
396 $pageposafter = $pdf->getPage();
397 $pdf->setPage($pageposbefore);
398 $pdf->setTopMargin($this->marge_haute);
399 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
400
401
402 $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines
403
404 // Detect if some page were added automatically and output _tableau for past pages
405 while ($pagenb < $pageposafter) {
406 $pdf->setPage($pagenb);
407 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
408 if ($pagenb == 1) {
409 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
410 } else {
411 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
412 }
413 $this->_pagefoot($pdf, $object, $outputlangs, 1);
414 $pagenb++;
415 $pdf->setPage($pagenb);
416 $pdf->setPageOrientation('', true, 0); // The only function to edit the bottom margin of current page to set it.
417 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
418 $this->_pagehead($pdf, $object, 0, $outputlangs);
419 }
420 if (!empty($tplidx)) {
421 $pdf->useTemplate($tplidx);
422 }
423 }
424 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { // @phan-suppress-current-line PhanUndeclaredProperty
425 if ($pagenb == 1) {
426 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
427 } else {
428 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
429 }
430 $this->_pagefoot($pdf, $object, $outputlangs, 1);
431 // New page
432 $pdf->AddPage();
433 if (!empty($tplidx)) {
434 $pdf->useTemplate($tplidx);
435 }
436 $pagenb++;
437 if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
438 $this->_pagehead($pdf, $object, 0, $outputlangs);
439 }
440 }
441 }
442
443 // Show square
444 if ($pagenb == 1) {
445 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
446 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
447 } else {
448 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
449 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
450 }
451
452 $pdf->SetFont('', '', 10);
453
454
455 // Page footer
456 $this->_pagefoot($pdf, $object, $outputlangs);
457 if (method_exists($pdf, 'AliasNbPages')) {
458 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
459 }
460
461 $pdf->Close();
462
463 $pdf->Output($file, 'F');
464
465 // Add pdfgeneration hook
466 $hookmanager->initHooks(array('pdfgeneration'));
467 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
468 global $action;
469 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
470 $this->warnings = $hookmanager->warnings;
471 if ($reshook < 0) {
472 $this->error = $hookmanager->error;
473 $this->errors = $hookmanager->errors;
474 dolChmod($file);
475 return -1;
476 }
477
478 dolChmod($file);
479
480 $this->result = array('fullpath' => $file);
481
482 return 1; // No error
483 } else {
484 $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
485 return 0;
486 }
487 } else {
488 $this->error = $langs->trans("ErrorConstantNotDefined", "HRM_OUTPUTDIR");
489 return 0;
490 }
491 }
492
503 protected function printLine($pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
504 {
505 $objectligne = $object->lines[$linenumber];
506 $pdf->SetFont('', '', $default_font_size - 1);
507 $pdf->SetTextColor(0, 0, 0);
508
509 // Rank of employee
510 $rankemptoshow = "-";
511 if ($objectligne->rankorder > 0) {
512 $rankemptoshow = (string) $objectligne->rankorder;
513 } elseif ($objectligne->rankorder < 0) {
514 $rankemptoshow = $outputlangs->transnoentitiesnoconv("NA");
515 }
516 $pdf->SetXY($this->posxrankemp, $curY);
517 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 0.8, 4, $rankemptoshow, 0, 'C');
518
519 // Expected required Rank
520 $rankexpectedtoshow = "-";
521 if ($objectligne->required_rank > 0) {
522 if ($objectligne->rankorder != 0) {
523 $rankexpectedtoshow = $objectligne->required_rank;
524 }
525 } elseif ($objectligne->required_rank < 0) {
526 $rankexpectedtoshow = $outputlangs->transnoentitiesnoconv("NA");
527 }
528 $pdf->SetXY($this->posxrequiredrank, $curY);
529 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 0.8, 4, $rankexpectedtoshow, 0, 'C');
530
531 // Result
532 $pdf->SetXY($this->posxresult - 1, $curY);
533
534 if ($objectligne->required_rank < 0) { // NA
535 $pdf->SetFillColor(255, 255, 255);
536 } elseif ($objectligne->rankorder > $objectligne->required_rank) { // Higher than expected
537 // Teal Green
538 $pdf->SetFillColor(20, 129, 111);
539 } elseif ($objectligne->rankorder == $objectligne->required_rank) { // Same than expected
540 // Seafoam Green
541 $pdf->SetFillColor(169, 236, 201);
542 } elseif ($objectligne->rankorder < $objectligne->required_rank) { // Lower than expected
543 // Red
544 $pdf->SetFillColor(205, 92, 92);
545 }
546 if ($objectligne->rankorder <= 0 || $objectligne->required_rank == 0) {
547 // No fill color
548 $pdf->SetFillColor(240, 240, 240);
549 }
550 $result = "-";
551 if ($objectligne->required_rank < 0) {
552 if ($objectligne->rankorder > 0) {
553 $result = $objectligne->rankorder;
554 }
555 } elseif ($objectligne->rankorder < 0) {
556 $result = $outputlangs->transnoentitiesnoconv("NA");
557 } elseif ($objectligne->required_rank != 0 && $objectligne->rankorder != 0) {
558 $result = $objectligne->rankorder . "/" . $objectligne->required_rank;
559 }
560 $pdf->MultiCell($this->posxresult - 210 - 0.8 - 4, 4, $result, 0, 'C', true);
561
562 // The next fields can be on several lines so we output them at end so the pos on next line will work correctly
563
564 // Skill
565 $skill = new Skill($this->db);
566 $skill->fetch($objectligne->fk_skill);
567 $pdf->SetXY($this->posxskill, $curY);
568 $comment = $skill->label;
569
570 if (!empty($skill->description)) {
571 $comment .= '<br>' . $outputlangs->trans("Description").': '.$skill->description;
572 }
573 $pdf->writeHTMLCell($this->posxrankemp - $this->posxskill - 0.8, 4, $this->posxskill - 1, $curY, $comment, 0, 1);
574
575 // Line num
576 $pdf->SetXY($this->posxpiece, $curY);
577 $pdf->writeHTMLCell($this->posxskill - $this->posxpiece - 0.8, 3, $this->posxpiece - 1, $curY, (string) ($linenumber + 1), 0, 1, false, false, 'C');
578 }
579
580 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
590 protected function _pagehead($pdf, $object, $showaddress, $outputlangs)
591 {
592 // global $conf, $langs, $hookmanager;
593 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
594
595 // Load traductions files required by page
596 $outputlangs->loadLangs(array("main", "trips", "companies"));
597
598 $default_font_size = pdf_getPDFFontSize($outputlangs);
599
600
601 $pdf->SetTextColor(0, 0, 60);
602 $pdf->SetFont('', 'B', $default_font_size + 3);
603
604 $posy = $this->marge_haute;
605 $posx = $this->page_largeur - $this->marge_droite - 100;
606
607 $pdf->SetXY($this->marge_gauche, $posy);
608
609 // Logo
610 $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
611 if ($this->emetteur->logo) {
612 if (is_readable($logo)) {
613 $height = pdf_getHeightForLogo($logo);
614 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
615 } else {
616 $pdf->SetTextColor(200, 0, 0);
617 $pdf->SetFont('', 'B', $default_font_size - 2);
618 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
619 $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
620 }
621 } else {
622 $text = $this->emetteur->name;
623 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
624 }
625
626 $pdf->SetFont('', 'B', $default_font_size + 4);
627 $pdf->SetXY($posx, $posy);
628 $pdf->SetTextColor(0, 0, 60);
629 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $outputlangs->transnoentities("Eval"), 0, 'R');
630
631 $pdf->SetFont('', '', $default_font_size - 1);
632
633 // Ref complete
634 $posy += 8;
635 $pdf->SetXY($posx, $posy);
636 $pdf->SetTextColor(0, 0, 60);
637 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R');
638
639 // Date evaluation
640 $posy += 5;
641 $pdf->SetXY($posx, $posy);
642 $pdf->SetTextColor(0, 0, 60);
643 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateEval")." : ".dol_print_date($object->date_eval, "day", false, $outputlangs), '', 'R');
644
645
646 if ($showaddress) {
647 // Sender properties
648 $carac_emetteur = '';
649
650 // employee information
651 $employee = new User($this->db);
652 $employee->fetch($object->fk_user);
653 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities('Employee').' : '.$outputlangs->convToOutputCharset(ucfirst($employee->firstname) . ' ' . strtoupper($employee->lastname));
654
655 // Position
656 include_once DOL_DOCUMENT_ROOT.'/hrm/class/job.class.php';
657 $job = new Job($db);
658 $job->fetch($object->fk_job);
659 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities('JobProfile').' : '.$outputlangs->convToOutputCharset($job->label);
660
661 /*$carac_emetteur .= "\n";
662 if ($object->description) {
663 $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($object->description);
664 }*/
665
666
667 // Show sender
668 $posy = $this->marge_haute + 30;
669 $posx = $this->marge_gauche;
670 $hautcadre = 20;
671 if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
672 $posx = 118;
673 }
674
675 // Show sender frame
676 /*$pdf->SetTextColor(0, 0, 0);
677 $pdf->SetFont('', 'B', $default_font_size - 2);
678 $pdf->SetXY($posx, $posy - 5);
679 $pdf->MultiCell(190, 5, $outputlangs->transnoentities("Information"), '', 'L');*/
680 $pdf->SetXY($posx, $posy);
681 $pdf->SetFillColor(224, 224, 224);
682 $pdf->RoundedRect($posx, $posy, 190, $hautcadre, $this->corner_radius, '1234', 'F');
683 $pdf->SetTextColor(0, 0, 60);
684
685 // Show sender information
686 $pdf->SetXY($posx + 2, $posy + 3);
687 $pdf->SetFont('', 'B', $default_font_size);
688 $pdf->MultiCell(190, 4, $outputlangs->convToOutputCharset($object->label), 0, 'L');
689 $pdf->SetXY($posx + 2, $posy + 8);
690 $pdf->SetFont('', '', $default_font_size - 1);
691 $pdf->MultiCell(190, 4, $carac_emetteur, 0, 'L');
692 }
693
694 return 0;
695 }
696
697 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
711 protected function _tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
712 {
713 global $conf;
714
715 // Force to disable hidetop and hidebottom
716 $hidebottom = 0;
717 if ($hidetop) {
718 $hidetop = -1;
719 }
720
721 $pdf->SetDrawColor(128, 128, 128);
722
723 // Rect takes a length in 3rd parameter
724 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, '1234', 'D');
725 // line prend une position y en 3eme param
726 if (empty($hidetop)) {
727 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
728 }
729
730 $pdf->SetFont('', '', 8);
731
732 // Line no
733 if (empty($hidetop)) {
734 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
735 $pdf->MultiCell($this->posxskill - $this->posxpiece - 0.8, 1, '', '', 'C');
736 }
737
738 // Skill
739 $pdf->line($this->posxskill - 1, $tab_top, $this->posxskill - 1, $tab_top + $tab_height);
740 if (empty($hidetop)) {
741 $pdf->SetXY($this->posxskill - 1, $tab_top + 1);
742 $pdf->MultiCell($this->posxrankemp - $this->posxskill - 0.8, 1, $outputlangs->transnoentities("Skill"), '', 'L');
743 }
744
745 // Employee Rank
746 if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
747 $pdf->line($this->posxrankemp - 1, $tab_top, $this->posxrankemp - 1, $tab_top + $tab_height);
748 if (empty($hidetop)) {
749 $pdf->SetXY($this->posxrankemp - 0.8, $tab_top + 1);
750 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 1, 2, $outputlangs->transnoentities("EmployeeRankShort"), '', 'C');
751 }
752 }
753
754 // Required Rank
755 $pdf->line($this->posxrequiredrank - 1, $tab_top, $this->posxrequiredrank - 1, $tab_top + $tab_height);
756 if (empty($hidetop)) {
757 $pdf->SetXY($this->posxrequiredrank - 0.8, $tab_top + 1);
758 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 1, 2, $outputlangs->transnoentities("RequiredRankShort"), '', 'C');
759 }
760
761 // Result
762 $pdf->line($this->posxresult - 1, $tab_top, $this->posxresult - 1, $tab_top + $tab_height);
763 if (empty($hidetop)) {
764 $pdf->SetXY($this->posxresult - 0.8, $tab_top + 1);
765 $pdf->MultiCell($this->postotalht - $this->posxresult - 1, 2, $outputlangs->transnoentities("Result"), '', 'C');
766 }
767
768 $pdf->SetTextColor(0, 0, 0);
769 }
770
771
772
773 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
783 protected function _pagefoot($pdf, $object, $outputlangs, $hidefreetext = 0)
784 {
785 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
786 return pdf_pagefoot($pdf, $outputlangs, '', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
787 }
788}
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.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_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)
_pagefoot($pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_pagehead($pdf, $object, $showaddress, $outputlangs)
Show top header of page.
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:1423
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