144 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
147 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
149 if (!is_object($outputlangs)) {
150 $outputlangs = $langs;
154 $outputlangs->charset_output =
'ISO-8859-1';
158 $outputlangs->loadLangs(array(
"main",
"hrm"));
160 $nblines = count(
$object->lines);
162 if ($conf->hrm->dir_output) {
166 $dir = $conf->hrm->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/evaluation';
167 $file = $dir.
"/SPECIMEN.pdf";
171 $dir = $conf->hrm->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/evaluation'.
"/".$objectref;
172 $file = $dir.
"/".$objectref.
".pdf";
175 if (!file_exists($dir)) {
177 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
182 if (file_exists($dir)) {
184 if (!is_object($hookmanager)) {
185 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
188 $hookmanager->initHooks(array(
'pdfgeneration'));
189 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
191 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
193 $nblines = count(
$object->lines);
198 $heightforinfotot = 0;
200 $heightforfooter = $this->marge_basse + 12;
202 $heightforfooter += 6;
205 $pdf->SetAutoPageBreak(1, 0);
207 if (class_exists(
'TCPDF')) {
208 $pdf->setPrintHeader(
false);
209 $pdf->setPrintFooter(
false);
214 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
215 $tplidx = $pdf->importPage(1);
220 $pdf->SetDrawColor(128, 128, 128);
222 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
223 $pdf->SetSubject($outputlangs->transnoentities(
"Evaluation"));
224 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
225 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
226 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Evaluation"));
228 $pdf->SetCompression(
false);
232 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
236 if (!empty($tplidx)) {
237 $pdf->useTemplate($tplidx);
241 $pdf->SetFont(
'',
'', $default_font_size - 1);
242 $pdf->MultiCell(0, 3,
'');
243 $pdf->SetTextColor(0, 0, 0);
246 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 35 : 10);
248 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
251 if (!empty(
$object->note_public)) {
254 $pdf->SetFont(
'',
'B', $default_font_size);
255 $pdf->MultiCell(190, 4, $outputlangs->transnoentities(
"Notes") .
":", 0,
'L', 0, 0, 12, $tab_top);
257 $pdf->SetFont(
'',
'', $default_font_size - 1);
259 $nexY = $pdf->GetY();
260 $height_note = $nexY - $tab_top;
263 $pdf->SetDrawColor(192, 192, 192);
264 $pdf->Rect($this->marge_gauche, $tab_top - 1 - 4, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1 + 6);
266 $tab_height -= $height_note;
267 $tab_top = $nexY + 6;
272 $iniY = $tab_top + 7;
273 $nexY = $tab_top + 7;
275 $pdf->setTopMargin($tab_top_newpage);
278 while ($i < $nblines) {
279 $pdf->SetFont(
'',
'', $default_font_size - 2);
280 $pdf->SetTextColor(0, 0, 0);
282 if (empty($showmorebeforepagebreak) && ($i !== ($nblines - 1))) {
283 $pdf->setPageOrientation(
'', 1, $heightforfooter);
285 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
288 $pdf->setTopMargin($tab_top_newpage);
290 $pageposbefore = $pdf->getPage();
292 $pdf->startTransaction();
294 $this->
printLine($pdf,
$object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
298 $pageposafter = $pdf->getPage();
299 if ($pageposafter > $pageposbefore) {
301 $pdf->rollbackTransaction(
true);
303 $pageposafter = $pageposbefore;
304 if (empty($showmorebeforepagebreak)) {
305 $pdf->AddPage(
'',
'',
true);
306 if (!empty($tplidx)) {
307 $pdf->useTemplate($tplidx);
312 $pdf->setPage($pageposafter + 1);
313 $showmorebeforepagebreak = 1;
314 $nexY = $tab_top_newpage;
315 $nexY += ($pdf->getFontSize() * 1.3);
316 $pdf->SetFont(
'',
'', $default_font_size - 2);
317 $pdf->SetTextColor(0, 0, 0);
319 $pdf->setTopMargin($tab_top_newpage);
322 $pdf->setPageOrientation(
'', 1, $heightforfooter);
323 $showmorebeforepagebreak = 0;
326 $this->
printLine($pdf,
$object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
327 $pageposafter = $pdf->getPage();
328 $posyafter = $pdf->GetY();
329 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
331 if ($i == ($nblines - 1)) {
333 $pdf->AddPage(
'',
'',
true);
334 if (!empty($tplidx)) {
335 $pdf->useTemplate($tplidx);
340 $pdf->setPage($pageposafter + 1);
346 $showmorebeforepagebreak = 1;
348 $showmorebeforepagebreak = 0;
352 $pdf->commitTransaction();
357 $nexY = $pdf->GetY();
358 $pdf->line($this->marge_gauche, $nexY + 2, $this->page_largeur - $this->marge_droite, $nexY + 2);
359 $pageposafter = $pdf->getPage();
360 $pdf->setPage($pageposbefore);
361 $pdf->setTopMargin($this->marge_haute);
362 $pdf->setPageOrientation(
'', 1, 0);
365 $nexY += ($pdf->getFontSize() * 1.3);
368 while ($pagenb < $pageposafter) {
369 $pdf->setPage($pagenb);
370 $pdf->setPageOrientation(
'', 1, 0);
372 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
374 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
378 $pdf->setPage($pagenb);
379 $pdf->setPageOrientation(
'', 1, 0);
383 if (!empty($tplidx)) {
384 $pdf->useTemplate($tplidx);
387 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
389 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
391 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
396 if (!empty($tplidx)) {
397 $pdf->useTemplate($tplidx);
408 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
409 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
411 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
412 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
415 $pdf->SetFont(
'',
'', 10);
420 if (method_exists($pdf,
'AliasNbPages')) {
421 $pdf->AliasNbPages();
426 $pdf->Output($file,
'F');
429 $hookmanager->initHooks(array(
'pdfgeneration'));
430 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
432 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
434 $this->error = $hookmanager->error;
435 $this->errors = $hookmanager->errors;
440 $this->result = array(
'fullpath' => $file);
444 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
448 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"HRM_OUTPUTDIR");
463 protected function printLine(&$pdf,
$object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
466 $objectligne =
$object->lines[$linenumber];
467 $pdf->SetFont(
'',
'', $default_font_size - 1);
468 $pdf->SetTextColor(0, 0, 0);
471 $pdf->SetXY($this->posxresult - 1, $curY);
473 if ($objectligne->rankorder > $objectligne->required_rank) {
475 $pdf->SetFillColor(0, 109, 91);
476 } elseif ($objectligne->rankorder == $objectligne->required_rank) {
478 $pdf->SetFillColor(159, 226, 191);
479 } elseif ($objectligne->rankorder < $objectligne->required_rank) {
481 $pdf->SetFillColor(205, 92, 92);
483 if ($objectligne->rankorder == 0 || $objectligne->required_rank == 0) {
485 $pdf->SetFillColor(255, 255, 255);
487 $result = (($objectligne->required_rank != 0 && $objectligne->rankorder != 0) ? $objectligne->rankorder .
"/" . $objectligne->required_rank :
"-");
488 $pdf->MultiCell($this->posxresult - 210 - 0.8 - 4, 4, $result, 0,
'C', 1);
492 $pdf->SetXY($this->posxrequiredrank, $curY);
493 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 0.8, 4, (($objectligne->required_rank != 0 && $objectligne->rankorder != 0) ? $objectligne->required_rank :
"-"), 0,
'C');
496 $pdf->SetXY($this->posxrankemp, $curY);
497 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 0.8, 4, (($objectligne->rankorder != 0) ? $objectligne->rankorder :
"-"), 0,
'C');
500 $skill =
new Skill($this->db);
501 $skill->fetch($objectligne->fk_skill);
502 $pdf->SetXY($this->posxskill, $curY);
503 $comment = $skill->label;
505 if (!empty($skill->description)) {
506 $comment .=
'<br>' . $outputlangs->trans(
"Description").
': '.$skill->description;
508 $pdf->writeHTMLCell($this->posxrankemp - $this->posxskill - 0.8, 4, $this->posxskill - 1, $curY, $comment, 0, 1);
513 $pdf->SetXY($this->posxpiece, $curY);
514 $pdf->writeHTMLCell($this->posxskill - $this->posxpiece - 0.8, 3, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1, 0, 0,
'C');
530 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
533 $outputlangs->loadLangs(array(
"main",
"trips",
"companies"));
538 $pdf->SetTextColor(0, 0, 60);
539 $pdf->SetFont(
'',
'B', $default_font_size + 3);
541 $posy = $this->marge_haute;
542 $posx = $this->page_largeur - $this->marge_droite - 100;
544 $pdf->SetXY($this->marge_gauche, $posy);
547 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
548 if ($this->emetteur->logo) {
549 if (is_readable($logo)) {
551 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
553 $pdf->SetTextColor(200, 0, 0);
554 $pdf->SetFont(
'',
'B', $default_font_size - 2);
555 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
556 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
559 $text = $this->emetteur->name;
560 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
563 $pdf->SetFont(
'',
'B', $default_font_size + 4);
564 $pdf->SetXY($posx, $posy);
565 $pdf->SetTextColor(0, 0, 60);
566 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $outputlangs->transnoentities(
"Eval"), 0,
'R');
568 $pdf->SetFont(
'',
'', $default_font_size - 1);
572 $pdf->SetXY($posx, $posy);
573 $pdf->SetTextColor(0, 0, 60);
574 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"Ref").
" : ".
$object->ref,
'',
'R');
578 $pdf->SetXY($posx, $posy);
579 $pdf->SetTextColor(0, 0, 60);
580 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities(
"DateEval").
" : ".
dol_print_date(
$object->date_eval,
"day",
false, $outputlangs),
'',
'R');
585 $carac_emetteur =
'';
588 $employee =
new User($this->db);
589 $employee->fetch(
$object->fk_user);
590 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
'Employee').
' : '.$outputlangs->convToOutputCharset(ucfirst($employee->firstname) .
' ' . strtoupper($employee->lastname));
593 include_once DOL_DOCUMENT_ROOT.
'/hrm/class/job.class.php';
596 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
'JobProfile').
' : '.$outputlangs->convToOutputCharset($job->label);
606 $posx = $this->marge_gauche;
617 $pdf->SetXY($posx, $posy);
618 $pdf->SetFillColor(224, 224, 224);
619 $pdf->MultiCell(190, $hautcadre,
"", 0,
'R', 1);
620 $pdf->SetTextColor(0, 0, 60);
623 $pdf->SetXY($posx + 2, $posy + 3);
624 $pdf->SetFont(
'',
'B', $default_font_size);
625 $pdf->MultiCell(190, 4, $outputlangs->convToOutputCharset(
$object->label), 0,
'L');
626 $pdf->SetXY($posx + 2, $posy + 8);
627 $pdf->SetFont(
'',
'', $default_font_size - 1);
628 $pdf->MultiCell(190, 4, $carac_emetteur, 0,
'L');
648 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
658 $pdf->SetDrawColor(128, 128, 128);
661 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
663 if (empty($hidetop)) {
664 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
667 $pdf->SetFont(
'',
'', 8);
670 if (empty($hidetop)) {
671 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
672 $pdf->MultiCell($this->posxskill - $this->posxpiece - 0.8, 1,
'',
'',
'C');
676 $pdf->line($this->posxskill - 1, $tab_top, $this->posxskill - 1, $tab_top + $tab_height);
677 if (empty($hidetop)) {
678 $pdf->SetXY($this->posxskill - 1, $tab_top + 1);
679 $pdf->MultiCell($this->posxrankemp - $this->posxskill - 0.8, 1, $outputlangs->transnoentities(
"Skill"),
'',
'L');
684 $pdf->line($this->posxrankemp - 1, $tab_top, $this->posxrankemp - 1, $tab_top + $tab_height);
685 if (empty($hidetop)) {
686 $pdf->SetXY($this->posxrankemp - 0.8, $tab_top + 1);
687 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 1, 2, $outputlangs->transnoentities(
"EmployeeRankShort"),
'',
'C');
692 $pdf->line($this->posxrequiredrank - 1, $tab_top, $this->posxrequiredrank - 1, $tab_top + $tab_height);
693 if (empty($hidetop)) {
694 $pdf->SetXY($this->posxrequiredrank - 0.8, $tab_top + 1);
695 $pdf->MultiCell($this->posxresult - $this->posxrequiredrank - 1, 2, $outputlangs->transnoentities(
"RequiredRankShort"),
'',
'C');
699 $pdf->line($this->posxresult - 1, $tab_top, $this->posxresult - 1, $tab_top + $tab_height);
700 if (empty($hidetop)) {
701 $pdf->SetXY($this->posxresult - 0.8, $tab_top + 1);
702 $pdf->MultiCell($this->postotalht - $this->posxresult - 1, 2, $outputlangs->transnoentities(
"Result"),
'',
'C');
705 $pdf->SetTextColor(0, 0, 0);