178 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
181 global $user, $langs,
$conf, $mysoc, $db, $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) {
200 $dir =
$conf->hrm->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/evaluation';
201 $file = $dir.
"/SPECIMEN.pdf";
205 $dir =
$conf->hrm->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/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);
470 $this->error = $hookmanager->error;
471 $this->errors = $hookmanager->errors;
476 $this->result = array(
'fullpath' => $file);
480 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
484 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"HRM_OUTPUTDIR");
499 protected function printLine(&$pdf,
$object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
501 $objectligne =
$object->lines[$linenumber];
502 $pdf->SetFont(
'',
'', $default_font_size - 1);
503 $pdf->SetTextColor(0, 0, 0);
506 $rankemptoshow =
"-";
507 if ($objectligne->rankorder > 0) {
508 $rankemptoshow = (string) $objectligne->rankorder;
509 } elseif ($objectligne->rankorder < 0) {
510 $rankemptoshow = $outputlangs->transnoentitiesnoconv(
"NA");
512 $pdf->SetXY($this->posxrankemp, $curY);
513 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 0.8, 4, $rankemptoshow, 0,
'C');
516 $rankexpectedtoshow =
"-";
517 if ($objectligne->required_rank > 0) {
518 if ($objectligne->rankorder != 0) {
519 $rankexpectedtoshow = $objectligne->required_rank;
521 } elseif ($objectligne->required_rank < 0) {
522 $rankexpectedtoshow = $outputlangs->transnoentitiesnoconv(
"NA");
524 $pdf->SetXY($this->posxrequiredrank, $curY);
525 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 0.8, 4, $rankexpectedtoshow, 0,
'C');
528 $pdf->SetXY($this->posxresult - 1, $curY);
530 if ($objectligne->required_rank < 0) {
531 $pdf->SetFillColor(255, 255, 255);
532 } elseif ($objectligne->rankorder > $objectligne->required_rank) {
534 $pdf->SetFillColor(20, 129, 111);
535 } elseif ($objectligne->rankorder == $objectligne->required_rank) {
537 $pdf->SetFillColor(169, 236, 201);
538 } elseif ($objectligne->rankorder < $objectligne->required_rank) {
540 $pdf->SetFillColor(205, 92, 92);
542 if ($objectligne->rankorder <= 0 || $objectligne->required_rank == 0) {
544 $pdf->SetFillColor(240, 240, 240);
547 if ($objectligne->required_rank < 0) {
548 if ($objectligne->rankorder > 0) {
549 $result = $objectligne->rankorder;
551 } elseif ($objectligne->rankorder < 0) {
552 $result = $outputlangs->transnoentitiesnoconv(
"NA");
553 } elseif ($objectligne->required_rank != 0 && $objectligne->rankorder != 0) {
554 $result = $objectligne->rankorder .
"/" . $objectligne->required_rank;
556 $pdf->MultiCell($this->posxresult - 210 - 0.8 - 4, 4, $result, 0,
'C',
true);
561 $skill =
new Skill($this->db);
562 $skill->fetch($objectligne->fk_skill);
563 $pdf->SetXY($this->posxskill, $curY);
564 $comment = $skill->label;
566 if (!empty($skill->description)) {
567 $comment .=
'<br>' . $outputlangs->trans(
"Description").
': '.$skill->description;
569 $pdf->writeHTMLCell($this->posxrankemp - $this->posxskill - 0.8, 4, $this->posxskill - 1, $curY, $comment, 0, 1);
572 $pdf->SetXY($this->posxpiece, $curY);
573 $pdf->writeHTMLCell($this->posxskill - $this->posxpiece - 0.8, 3, $this->posxpiece - 1, $curY, (
string) ($linenumber + 1), 0, 1,
false,
false,
'C');
589 global $user, $langs,
$conf, $mysoc, $db, $hookmanager;
592 $outputlangs->loadLangs(array(
"main",
"trips",
"companies"));
597 $pdf->SetTextColor(0, 0, 60);
598 $pdf->SetFont(
'',
'B', $default_font_size + 3);
600 $posy = $this->marge_haute;
601 $posx = $this->page_largeur - $this->marge_droite - 100;
603 $pdf->SetXY($this->marge_gauche, $posy);
606 $logo =
$conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
607 if ($this->emetteur->logo) {
608 if (is_readable($logo)) {
610 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
612 $pdf->SetTextColor(200, 0, 0);
613 $pdf->SetFont(
'',
'B', $default_font_size - 2);
614 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
615 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
618 $text = $this->emetteur->name;
619 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
622 $pdf->SetFont(
'',
'B', $default_font_size + 4);
623 $pdf->SetXY($posx, $posy);
624 $pdf->SetTextColor(0, 0, 60);
625 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $outputlangs->transnoentities(
"Eval"), 0,
'R');
627 $pdf->SetFont(
'',
'', $default_font_size - 1);
631 $pdf->SetXY($posx, $posy);
632 $pdf->SetTextColor(0, 0, 60);
633 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"Ref").
" : ".
$object->ref,
'',
'R');
637 $pdf->SetXY($posx, $posy);
638 $pdf->SetTextColor(0, 0, 60);
639 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"DateEval").
" : ".
dol_print_date(
$object->date_eval,
"day",
false, $outputlangs),
'',
'R');
644 $carac_emetteur =
'';
647 $employee =
new User($this->db);
648 $employee->fetch(
$object->fk_user);
649 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
'Employee').
' : '.$outputlangs->convToOutputCharset(ucfirst($employee->firstname) .
' ' . strtoupper($employee->lastname));
652 include_once DOL_DOCUMENT_ROOT.
'/hrm/class/job.class.php';
655 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
'JobProfile').
' : '.$outputlangs->convToOutputCharset($job->label);
665 $posx = $this->marge_gauche;
676 $pdf->SetXY($posx, $posy);
677 $pdf->SetFillColor(224, 224, 224);
678 $pdf->RoundedRect($posx, $posy, 190, $hautcadre, $this->corner_radius,
'1234',
'F');
679 $pdf->SetTextColor(0, 0, 60);
682 $pdf->SetXY($posx + 2, $posy + 3);
683 $pdf->SetFont(
'',
'B', $default_font_size);
684 $pdf->MultiCell(190, 4, $outputlangs->convToOutputCharset(
$object->label), 0,
'L');
685 $pdf->SetXY($posx + 2, $posy + 8);
686 $pdf->SetFont(
'',
'', $default_font_size - 1);
687 $pdf->MultiCell(190, 4, $carac_emetteur, 0,
'L');
707 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
717 $pdf->SetDrawColor(128, 128, 128);
720 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius,
'1234',
'D');
722 if (empty($hidetop)) {
723 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
726 $pdf->SetFont(
'',
'', 8);
729 if (empty($hidetop)) {
730 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
731 $pdf->MultiCell($this->posxskill - $this->posxpiece - 0.8, 1,
'',
'',
'C');
735 $pdf->line($this->posxskill - 1, $tab_top, $this->posxskill - 1, $tab_top + $tab_height);
736 if (empty($hidetop)) {
737 $pdf->SetXY($this->posxskill - 1, $tab_top + 1);
738 $pdf->MultiCell($this->posxrankemp - $this->posxskill - 0.8, 1, $outputlangs->transnoentities(
"Skill"),
'',
'L');
743 $pdf->line($this->posxrankemp - 1, $tab_top, $this->posxrankemp - 1, $tab_top + $tab_height);
744 if (empty($hidetop)) {
745 $pdf->SetXY($this->posxrankemp - 0.8, $tab_top + 1);
746 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 1, 2, $outputlangs->transnoentities(
"EmployeeRankShort"),
'',
'C');
751 $pdf->line($this->posxrequiredrank - 1, $tab_top, $this->posxrequiredrank - 1, $tab_top + $tab_height);
752 if (empty($hidetop)) {
753 $pdf->SetXY($this->posxrequiredrank - 0.8, $tab_top + 1);
754 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 1, 2, $outputlangs->transnoentities(
"RequiredRankShort"),
'',
'C');
758 $pdf->line($this->posxresult - 1, $tab_top, $this->posxresult - 1, $tab_top + $tab_height);
759 if (empty($hidetop)) {
760 $pdf->SetXY($this->posxresult - 0.8, $tab_top + 1);
761 $pdf->MultiCell($this->postotalht - $this->posxresult - 1, 2, $outputlangs->transnoentities(
"Result"),
'',
'C');
764 $pdf->SetTextColor(0, 0, 0);