150 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
153 global $user, $langs,
$conf, $mysoc, $db, $hookmanager, $nblines;
155 if (!is_object($outputlangs)) {
156 $outputlangs = $langs;
160 $outputlangs->charset_output =
'ISO-8859-1';
164 $outputlangs->loadLangs(array(
"main",
"hrm"));
166 $nblines = count(
$object->lines);
168 if (
$conf->hrm->dir_output) {
172 $dir =
$conf->hrm->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/evaluation';
173 $file = $dir.
"/SPECIMEN.pdf";
177 $dir =
$conf->hrm->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/evaluation'.
"/".$objectref;
178 $file = $dir.
"/".$objectref.
".pdf";
181 if (!file_exists($dir)) {
183 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
188 if (file_exists($dir)) {
190 if (!is_object($hookmanager)) {
191 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
194 $hookmanager->initHooks(array(
'pdfgeneration'));
195 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
197 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
199 $nblines = count(
$object->lines);
204 $heightforinfotot = 0;
206 $heightforfooter = $this->marge_basse + 12;
208 $heightforfooter += 6;
211 $pdf->SetAutoPageBreak(1, 0);
213 if (class_exists(
'TCPDF')) {
214 $pdf->setPrintHeader(
false);
215 $pdf->setPrintFooter(
false);
220 $pagecount = $pdf->setSourceFile(
$conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
221 $tplidx = $pdf->importPage(1);
226 $pdf->SetDrawColor(128, 128, 128);
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"));
234 $pdf->SetCompression(
false);
238 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
242 if (!empty($tplidx)) {
243 $pdf->useTemplate($tplidx);
247 $pdf->SetFont(
'',
'', $default_font_size - 1);
248 $pdf->MultiCell(0, 3,
'');
249 $pdf->SetTextColor(0, 0, 0);
252 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 35 : 10);
254 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
257 if (!empty(
$object->note_public)) {
260 $pdf->SetFont(
'',
'B', $default_font_size);
261 $pdf->MultiCell(190, 4, $outputlangs->transnoentities(
"Notes") .
":", 0,
'L', 0, 0, 12, $tab_top);
263 $pdf->SetFont(
'',
'', $default_font_size - 1);
265 $nexY = $pdf->GetY();
266 $height_note = $nexY - $tab_top;
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');
272 $tab_height -= $height_note;
273 $tab_top = $nexY + 6;
278 $iniY = $tab_top + 7;
279 $nexY = $tab_top + 7;
281 $pdf->setTopMargin($tab_top_newpage);
284 while ($i < $nblines) {
285 $pdf->SetFont(
'',
'', $default_font_size - 2);
286 $pdf->SetTextColor(0, 0, 0);
288 if (empty($showmorebeforepagebreak) && ($i !== ($nblines - 1))) {
289 $pdf->setPageOrientation(
'', 1, $heightforfooter);
291 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
294 $pdf->setTopMargin($tab_top_newpage);
296 $pageposbefore = $pdf->getPage();
298 $pdf->startTransaction();
300 $this->
printLine($pdf,
$object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
304 $pageposafter = $pdf->getPage();
305 if ($pageposafter > $pageposbefore) {
307 $pdf->rollbackTransaction(
true);
309 $pageposafter = $pageposbefore;
310 if (empty($showmorebeforepagebreak)) {
311 $pdf->AddPage(
'',
'',
true);
312 if (!empty($tplidx)) {
313 $pdf->useTemplate($tplidx);
318 $pdf->setPage($pageposafter + 1);
319 $showmorebeforepagebreak = 1;
320 $nexY = $tab_top_newpage;
321 $nexY += ($pdf->getFontSize() * 1.3);
322 $pdf->SetFont(
'',
'', $default_font_size - 2);
323 $pdf->SetTextColor(0, 0, 0);
325 $pdf->setTopMargin($tab_top_newpage);
328 $pdf->setPageOrientation(
'', 1, $heightforfooter);
329 $showmorebeforepagebreak = 0;
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))) {
337 if ($i == ($nblines - 1)) {
339 $pdf->AddPage(
'',
'',
true);
340 if (!empty($tplidx)) {
341 $pdf->useTemplate($tplidx);
346 $pdf->setPage($pageposafter + 1);
352 $showmorebeforepagebreak = 1;
354 $showmorebeforepagebreak = 0;
358 $pdf->commitTransaction();
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);
371 $nexY += ($pdf->getFontSize() * 1.3);
374 while ($pagenb < $pageposafter) {
375 $pdf->setPage($pagenb);
376 $pdf->setPageOrientation(
'', 1, 0);
378 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
380 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
384 $pdf->setPage($pagenb);
385 $pdf->setPageOrientation(
'', 1, 0);
389 if (!empty($tplidx)) {
390 $pdf->useTemplate($tplidx);
393 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
395 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
397 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
402 if (!empty($tplidx)) {
403 $pdf->useTemplate($tplidx);
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;
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;
421 $pdf->SetFont(
'',
'', 10);
426 if (method_exists($pdf,
'AliasNbPages')) {
427 $pdf->AliasNbPages();
432 $pdf->Output($file,
'F');
435 $hookmanager->initHooks(array(
'pdfgeneration'));
436 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
438 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
440 $this->error = $hookmanager->error;
441 $this->errors = $hookmanager->errors;
446 $this->result = array(
'fullpath' => $file);
450 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
454 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"HRM_OUTPUTDIR");
469 protected function printLine(&$pdf,
$object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
472 $objectligne =
$object->lines[$linenumber];
473 $pdf->SetFont(
'',
'', $default_font_size - 1);
474 $pdf->SetTextColor(0, 0, 0);
477 $pdf->SetXY($this->posxresult - 1, $curY);
479 if ($objectligne->rankorder > $objectligne->required_rank) {
481 $pdf->SetFillColor(0, 109, 91);
482 } elseif ($objectligne->rankorder == $objectligne->required_rank) {
484 $pdf->SetFillColor(159, 226, 191);
485 } elseif ($objectligne->rankorder < $objectligne->required_rank) {
487 $pdf->SetFillColor(205, 92, 92);
489 if ($objectligne->rankorder == 0 || $objectligne->required_rank == 0) {
491 $pdf->SetFillColor(255, 255, 255);
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);
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');
502 $pdf->SetXY($this->posxrankemp, $curY);
503 $pdf->MultiCell($this->posxrequiredrank - $this->posxrankemp - 0.8, 4, (($objectligne->rankorder != 0) ? $objectligne->rankorder :
"-"), 0,
'C');
506 $skill =
new Skill($this->db);
507 $skill->fetch($objectligne->fk_skill);
508 $pdf->SetXY($this->posxskill, $curY);
509 $comment = $skill->label;
511 if (!empty($skill->description)) {
512 $comment .=
'<br>' . $outputlangs->trans(
"Description").
': '.$skill->description;
514 $pdf->writeHTMLCell($this->posxrankemp - $this->posxskill - 0.8, 4, $this->posxskill - 1, $curY, $comment, 0, 1);
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');
536 global $user, $langs,
$conf, $mysoc, $db, $hookmanager;
539 $outputlangs->loadLangs(array(
"main",
"trips",
"companies"));
544 $pdf->SetTextColor(0, 0, 60);
545 $pdf->SetFont(
'',
'B', $default_font_size + 3);
547 $posy = $this->marge_haute;
548 $posx = $this->page_largeur - $this->marge_droite - 100;
550 $pdf->SetXY($this->marge_gauche, $posy);
553 $logo =
$conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
554 if ($this->emetteur->logo) {
555 if (is_readable($logo)) {
557 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
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');
565 $text = $this->emetteur->name;
566 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
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');
574 $pdf->SetFont(
'',
'', $default_font_size - 1);
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');
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');
591 $carac_emetteur =
'';
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));
599 include_once DOL_DOCUMENT_ROOT.
'/hrm/class/job.class.php';
602 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
'JobProfile').
' : '.$outputlangs->convToOutputCharset($job->label);
612 $posx = $this->marge_gauche;
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);
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');
654 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
664 $pdf->SetDrawColor(128, 128, 128);
667 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius,
'1234',
'D');
669 if (empty($hidetop)) {
670 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
673 $pdf->SetFont(
'',
'', 8);
676 if (empty($hidetop)) {
677 $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
678 $pdf->MultiCell($this->posxskill - $this->posxpiece - 0.8, 1,
'',
'',
'C');
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');
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');
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');
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');
711 $pdf->SetTextColor(0, 0, 0);