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