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->getFullName($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);
280 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 35 : 10);
282 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
285 if (!empty(
$object->note_public)) {
288 $pdf->SetFont(
'',
'B', $default_font_size);
289 $pdf->MultiCell(190, 4, $outputlangs->transnoentities(
"Notes") .
":", 0,
'L',
false, 0, 12, $tab_top);
291 $pdf->SetFont(
'',
'', $default_font_size - 1);
293 $nexY = $pdf->GetY();
294 $height_note = $nexY - $tab_top;
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');
300 $tab_height -= $height_note;
301 $tab_top = $nexY + 6;
306 $iniY = $tab_top + 7;
307 $nexY = $tab_top + 7;
309 $showmorebeforepagebreak = 0;
311 $pdf->setTopMargin($tab_top_newpage);
314 while ($i < $nblines) {
315 $pdf->SetFont(
'',
'', $default_font_size - 2);
316 $pdf->SetTextColor(0, 0, 0);
318 if (empty($showmorebeforepagebreak) && ($i !== ($nblines - 1))) {
319 $pdf->setPageOrientation(
'',
true, $heightforfooter);
321 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
324 $pdf->setTopMargin($tab_top_newpage);
326 $pageposbefore = $pdf->getPage();
328 $pdf->startTransaction();
331 $this->
printLine($pdf,
$object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
334 $pageposafter = $pdf->getPage();
335 if ($pageposafter > $pageposbefore) {
337 $pdf->rollbackTransaction(
true);
339 $pageposafter = $pageposbefore;
340 if (empty($showmorebeforepagebreak)) {
341 $pdf->AddPage(
'',
'',
true);
342 if (!empty($tplidx)) {
343 $pdf->useTemplate($tplidx);
348 $pdf->setPage($pageposafter + 1);
349 $showmorebeforepagebreak = 1;
350 $nexY = $tab_top_newpage;
351 $nexY += ($pdf->getFontSize() * 1.3);
352 $pdf->SetFont(
'',
'', $default_font_size - 2);
353 $pdf->SetTextColor(0, 0, 0);
355 $pdf->setTopMargin($tab_top_newpage);
358 $pdf->setPageOrientation(
'',
true, $heightforfooter);
359 $showmorebeforepagebreak = 0;
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))) {
367 if ($i == ($nblines - 1)) {
369 $pdf->AddPage(
'',
'',
true);
370 if (!empty($tplidx)) {
371 $pdf->useTemplate($tplidx);
376 $pdf->setPage($pageposafter + 1);
382 $showmorebeforepagebreak = 1;
384 $showmorebeforepagebreak = 0;
388 $pdf->commitTransaction();
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);
401 $nexY += ($pdf->getFontSize() * 1.3);
404 while ($pagenb < $pageposafter) {
405 $pdf->setPage($pagenb);
406 $pdf->setPageOrientation(
'',
true, 0);
408 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
410 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
414 $pdf->setPage($pagenb);
415 $pdf->setPageOrientation(
'',
true, 0);
419 if (!empty($tplidx)) {
420 $pdf->useTemplate($tplidx);
423 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
425 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
427 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
432 if (!empty($tplidx)) {
433 $pdf->useTemplate($tplidx);
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;
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;
451 $pdf->SetFont(
'',
'', 10);
456 if (method_exists($pdf,
'AliasNbPages')) {
457 $pdf->AliasNbPages();
462 $pdf->Output($file,
'F');
465 $hookmanager->initHooks(array(
'pdfgeneration'));
466 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
468 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
469 $this->warnings = $hookmanager->warnings;
471 $this->error = $hookmanager->error;
472 $this->errors = $hookmanager->errors;
479 $this->result = array(
'fullpath' => $file);
483 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
487 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"HRM_OUTPUTDIR");
502 protected function printLine(&$pdf,
$object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
504 $objectligne =
$object->lines[$linenumber];
505 $pdf->SetFont(
'',
'', $default_font_size - 1);
506 $pdf->SetTextColor(0, 0, 0);
509 $rankemptoshow =
"-";
510 if ($objectligne->rankorder > 0) {
511 $rankemptoshow = (string) $objectligne->rankorder;
512 } elseif ($objectligne->rankorder < 0) {
513 $rankemptoshow = $outputlangs->transnoentitiesnoconv(
"NA");
515 $pdf->SetXY($this->posxrankemp, $curY);
516 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 0.8, 4, $rankemptoshow, 0,
'C');
519 $rankexpectedtoshow =
"-";
520 if ($objectligne->required_rank > 0) {
521 if ($objectligne->rankorder != 0) {
522 $rankexpectedtoshow = $objectligne->required_rank;
524 } elseif ($objectligne->required_rank < 0) {
525 $rankexpectedtoshow = $outputlangs->transnoentitiesnoconv(
"NA");
527 $pdf->SetXY($this->posxrequiredrank, $curY);
528 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 0.8, 4, $rankexpectedtoshow, 0,
'C');
531 $pdf->SetXY($this->posxresult - 1, $curY);
533 if ($objectligne->required_rank < 0) {
534 $pdf->SetFillColor(255, 255, 255);
535 } elseif ($objectligne->rankorder > $objectligne->required_rank) {
537 $pdf->SetFillColor(20, 129, 111);
538 } elseif ($objectligne->rankorder == $objectligne->required_rank) {
540 $pdf->SetFillColor(169, 236, 201);
541 } elseif ($objectligne->rankorder < $objectligne->required_rank) {
543 $pdf->SetFillColor(205, 92, 92);
545 if ($objectligne->rankorder <= 0 || $objectligne->required_rank == 0) {
547 $pdf->SetFillColor(240, 240, 240);
550 if ($objectligne->required_rank < 0) {
551 if ($objectligne->rankorder > 0) {
552 $result = $objectligne->rankorder;
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;
559 $pdf->MultiCell($this->posxresult - 210 - 0.8 - 4, 4, $result, 0,
'C',
true);
564 $skill =
new Skill($this->db);
565 $skill->fetch($objectligne->fk_skill);
566 $pdf->SetXY($this->posxskill, $curY);
567 $comment = $skill->label;
569 if (!empty($skill->description)) {
570 $comment .=
'<br>' . $outputlangs->trans(
"Description").
': '.$skill->description;
572 $pdf->writeHTMLCell($this->posxrankemp - $this->posxskill - 0.8, 4, $this->posxskill - 1, $curY, $comment, 0, 1);
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');
592 global $user, $langs, $conf,
$mysoc, $db, $hookmanager;
595 $outputlangs->loadLangs(array(
"main",
"trips",
"companies"));
600 $pdf->SetTextColor(0, 0, 60);
601 $pdf->SetFont(
'',
'B', $default_font_size + 3);
603 $posy = $this->marge_haute;
604 $posx = $this->page_largeur - $this->marge_droite - 100;
606 $pdf->SetXY($this->marge_gauche, $posy);
609 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
610 if ($this->emetteur->logo) {
611 if (is_readable($logo)) {
613 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
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');
621 $text = $this->emetteur->name;
622 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
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');
630 $pdf->SetFont(
'',
'', $default_font_size - 1);
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');
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');
647 $carac_emetteur =
'';
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));
655 include_once DOL_DOCUMENT_ROOT.
'/hrm/class/job.class.php';
658 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
'JobProfile').
' : '.$outputlangs->convToOutputCharset($job->label);
668 $posx = $this->marge_gauche;
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);
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');
710 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
720 $pdf->SetDrawColor(128, 128, 128);
723 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius,
'1234',
'D');
725 if (empty($hidetop)) {
726 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
729 $pdf->SetFont(
'',
'', 8);
732 if (empty($hidetop)) {
733 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
734 $pdf->MultiCell($this->posxskill - $this->posxpiece - 0.8, 1,
'',
'',
'C');
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');
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');
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');
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');
767 $pdf->SetTextColor(0, 0, 0);