178 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
181 global $user, $langs,
$conf,
$mysoc, $hookmanager, $nblines;
183 if (!is_object($outputlangs)) {
184 $outputlangs = $langs;
188 $outputlangs->charset_output =
'ISO-8859-1';
192 $outputlangs->loadLangs(array(
"main",
"hrm"));
194 $nblines = count(
$object->lines);
196 if (
$conf->hrm->dir_output) {
199 $basedir = empty(
$conf->hrm->multidir_output[$entity]) ?
$conf->hrm->dir_output :
$conf->hrm->multidir_output[$entity];
201 $dir = $basedir.
'/evaluation';
202 $file = $dir.
"/SPECIMEN.pdf";
205 $dir = $basedir.
'/evaluation'.
"/".$objectref;
206 $file = $dir.
"/".$objectref.
".pdf";
209 if (!file_exists($dir)) {
211 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
216 if (file_exists($dir)) {
218 if (!is_object($hookmanager)) {
219 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
222 $hookmanager->initHooks(array(
'pdfgeneration'));
223 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
225 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
227 $nblines = count(
$object->lines);
232 $heightforinfotot = 0;
234 $heightforfooter = $this->marge_basse + 12;
236 $heightforfooter += 6;
239 $pdf->setAutoPageBreak(
true, 0);
241 if (class_exists(
'TCPDF')) {
242 $pdf->setPrintHeader(
false);
243 $pdf->setPrintFooter(
false);
248 $pagecount = $pdf->setSourceFile(
$conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
249 $tplidx = $pdf->importPage(1);
254 $pdf->SetDrawColor(128, 128, 128);
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"));
262 $pdf->SetCompression(
false);
266 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
270 if (!empty($tplidx)) {
271 $pdf->useTemplate($tplidx);
275 $pdf->SetFont(
'',
'', $default_font_size - 1);
276 $pdf->MultiCell(0, 3,
'');
277 $pdf->SetTextColor(0, 0, 0);
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);
283 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
286 if (!empty(
$object->note_public)) {
287 $tab_top = $top_margin;
289 $pdf->SetFont(
'',
'B', $default_font_size);
290 $pdf->MultiCell(190, 4, $outputlangs->transnoentities(
"Notes") .
":", 0,
'L',
false, 0, 12, $tab_top);
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;
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');
301 $tab_height -= $height_note;
302 $tab_top = $nexY + 6;
307 $iniY = $tab_top + 7;
308 $nexY = $tab_top + 7;
310 $showmorebeforepagebreak = 0;
312 $pdf->setTopMargin($tab_top_newpage);
315 while ($i < $nblines) {
316 $pdf->SetFont(
'',
'', $default_font_size - 2);
317 $pdf->SetTextColor(0, 0, 0);
319 if (empty($showmorebeforepagebreak) && ($i !== ($nblines - 1))) {
320 $pdf->setPageOrientation(
'',
true, $heightforfooter);
322 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
325 $pdf->setTopMargin($tab_top_newpage);
327 $pageposbefore = $pdf->getPage();
329 $pdf->startTransaction();
332 $this->
printLine($pdf,
$object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
335 $pageposafter = $pdf->getPage();
336 if ($pageposafter > $pageposbefore) {
338 $pdf->rollbackTransaction(
true);
340 $pageposafter = $pageposbefore;
341 if (empty($showmorebeforepagebreak)) {
342 $pdf->AddPage(
'',
'',
true);
343 if (!empty($tplidx)) {
344 $pdf->useTemplate($tplidx);
349 $pdf->setPage($pageposafter + 1);
350 $showmorebeforepagebreak = 1;
351 $nexY = $tab_top_newpage;
352 $nexY += ($pdf->getFontSize() * 1.3);
353 $pdf->SetFont(
'',
'', $default_font_size - 2);
354 $pdf->SetTextColor(0, 0, 0);
356 $pdf->setTopMargin($tab_top_newpage);
359 $pdf->setPageOrientation(
'',
true, $heightforfooter);
360 $showmorebeforepagebreak = 0;
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))) {
368 if ($i == ($nblines - 1)) {
370 $pdf->AddPage(
'',
'',
true);
371 if (!empty($tplidx)) {
372 $pdf->useTemplate($tplidx);
377 $pdf->setPage($pageposafter + 1);
383 $showmorebeforepagebreak = 1;
385 $showmorebeforepagebreak = 0;
389 $pdf->commitTransaction();
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);
402 $nexY += ($pdf->getFontSize() * 1.3);
405 while ($pagenb < $pageposafter) {
406 $pdf->setPage($pagenb);
407 $pdf->setPageOrientation(
'',
true, 0);
409 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
411 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
415 $pdf->setPage($pagenb);
416 $pdf->setPageOrientation(
'',
true, 0);
420 if (!empty($tplidx)) {
421 $pdf->useTemplate($tplidx);
424 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
426 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
428 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
433 if (!empty($tplidx)) {
434 $pdf->useTemplate($tplidx);
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;
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;
452 $pdf->SetFont(
'',
'', 10);
457 if (method_exists($pdf,
'AliasNbPages')) {
458 $pdf->AliasNbPages();
463 $pdf->Output($file,
'F');
466 $hookmanager->initHooks(array(
'pdfgeneration'));
467 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
469 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
470 $this->warnings = $hookmanager->warnings;
472 $this->error = $hookmanager->error;
473 $this->errors = $hookmanager->errors;
480 $this->result = array(
'fullpath' => $file);
484 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
488 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"HRM_OUTPUTDIR");
503 protected function printLine($pdf,
$object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
505 $objectligne =
$object->lines[$linenumber];
506 $pdf->SetFont(
'',
'', $default_font_size - 1);
507 $pdf->SetTextColor(0, 0, 0);
510 $rankemptoshow =
"-";
511 if ($objectligne->rankorder > 0) {
512 $rankemptoshow = (
string) $objectligne->rankorder;
513 } elseif ($objectligne->rankorder < 0) {
514 $rankemptoshow = $outputlangs->transnoentitiesnoconv(
"NA");
516 $pdf->SetXY($this->posxrankemp, $curY);
517 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 0.8, 4, $rankemptoshow, 0,
'C');
520 $rankexpectedtoshow =
"-";
521 if ($objectligne->required_rank > 0) {
522 if ($objectligne->rankorder != 0) {
523 $rankexpectedtoshow = $objectligne->required_rank;
525 } elseif ($objectligne->required_rank < 0) {
526 $rankexpectedtoshow = $outputlangs->transnoentitiesnoconv(
"NA");
528 $pdf->SetXY($this->posxrequiredrank, $curY);
529 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 0.8, 4, $rankexpectedtoshow, 0,
'C');
532 $pdf->SetXY($this->posxresult - 1, $curY);
534 if ($objectligne->required_rank < 0) {
535 $pdf->SetFillColor(255, 255, 255);
536 } elseif ($objectligne->rankorder > $objectligne->required_rank) {
538 $pdf->SetFillColor(20, 129, 111);
539 } elseif ($objectligne->rankorder == $objectligne->required_rank) {
541 $pdf->SetFillColor(169, 236, 201);
542 } elseif ($objectligne->rankorder < $objectligne->required_rank) {
544 $pdf->SetFillColor(205, 92, 92);
546 if ($objectligne->rankorder <= 0 || $objectligne->required_rank == 0) {
548 $pdf->SetFillColor(240, 240, 240);
551 if ($objectligne->required_rank < 0) {
552 if ($objectligne->rankorder > 0) {
553 $result = $objectligne->rankorder;
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;
560 $pdf->MultiCell($this->posxresult - 210 - 0.8 - 4, 4, $result, 0,
'C',
true);
565 $skill =
new Skill($this->db);
566 $skill->fetch($objectligne->fk_skill);
567 $pdf->SetXY($this->posxskill, $curY);
568 $comment = $skill->label;
570 if (!empty($skill->description)) {
571 $comment .=
'<br>' . $outputlangs->trans(
"Description").
': '.$skill->description;
573 $pdf->writeHTMLCell($this->posxrankemp - $this->posxskill - 0.8, 4, $this->posxskill - 1, $curY, $comment, 0, 1);
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');
593 global $user, $langs,
$conf,
$mysoc, $db, $hookmanager;
596 $outputlangs->loadLangs(array(
"main",
"trips",
"companies"));
601 $pdf->SetTextColor(0, 0, 60);
602 $pdf->SetFont(
'',
'B', $default_font_size + 3);
604 $posy = $this->marge_haute;
605 $posx = $this->page_largeur - $this->marge_droite - 100;
607 $pdf->SetXY($this->marge_gauche, $posy);
610 $logo =
$conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
611 if ($this->emetteur->logo) {
612 if (is_readable($logo)) {
614 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
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');
622 $text = $this->emetteur->name;
623 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
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');
631 $pdf->SetFont(
'',
'', $default_font_size - 1);
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');
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');
648 $carac_emetteur =
'';
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));
656 include_once DOL_DOCUMENT_ROOT.
'/hrm/class/job.class.php';
659 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
'JobProfile').
' : '.$outputlangs->convToOutputCharset($job->label);
668 $posy = $this->marge_haute + 30;
669 $posx = $this->marge_gauche;
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);
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');
711 protected function _tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
721 $pdf->SetDrawColor(128, 128, 128);
724 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius,
'1234',
'D');
726 if (empty($hidetop)) {
727 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
730 $pdf->SetFont(
'',
'', 8);
733 if (empty($hidetop)) {
734 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
735 $pdf->MultiCell($this->posxskill - $this->posxpiece - 0.8, 1,
'',
'',
'C');
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');
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');
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');
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');
768 $pdf->SetTextColor(0, 0, 0);