31 require_once DOL_DOCUMENT_ROOT.
'/core/modules/fichinter/modules_fichinter.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
61 public $update_main_doc_field;
72 public $version =
'dolibarr';
82 global $langs, $mysoc;
85 $this->
name =
'soleil';
86 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
87 $this->update_main_doc_field = 1;
92 $this->page_largeur = $formatarray[
'width'];
93 $this->page_hauteur = $formatarray[
'height'];
94 $this->format = array($this->page_largeur, $this->page_hauteur);
100 $this->option_logo = 1;
101 $this->option_tva = 0;
102 $this->option_modereg = 0;
103 $this->option_condreg = 0;
104 $this->option_multilang = 1;
105 $this->option_draft_watermark = 1;
106 $this->watermark =
'';
109 $this->emetteur = $mysoc;
110 if (empty($this->emetteur->country_code)) {
111 $this->emetteur->country_code = substr($langs->defaultlang, -2);
115 $this->posxdesc = $this->marge_gauche + 1;
130 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
133 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
135 if (!is_object($outputlangs)) {
136 $outputlangs = $langs;
140 $outputlangs->charset_output =
'ISO-8859-1';
144 $outputlangs->loadLangs(array(
"main",
"interventions",
"dict",
"companies"));
151 if ($conf->ficheinter->dir_output) {
156 $dir = $conf->ficheinter->dir_output;
157 $file = $dir.
"/SPECIMEN.pdf";
160 $dir = $conf->ficheinter->dir_output.
"/".$objectref;
161 $file = $dir.
"/".$objectref.
".pdf";
164 if (!file_exists($dir)) {
166 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
171 if (file_exists($dir)) {
173 if (!is_object($hookmanager)) {
174 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
178 $hookmanager->initHooks(array(
'pdfgeneration'));
179 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
181 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
183 $nblines = count(
$object->lines);
188 $heightforinfotot = 50;
189 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
190 $heightforfooter = $this->marge_basse + 8;
192 $heightforfooter += 6;
194 $pdf->SetAutoPageBreak(1, 0);
196 if (class_exists(
'TCPDF')) {
197 $pdf->setPrintHeader(
false);
198 $pdf->setPrintFooter(
false);
203 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
204 $tplidx = $pdf->importPage(1);
209 $pdf->SetDrawColor(128, 128, 128);
211 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
212 $pdf->SetSubject($outputlangs->transnoentities(
"InterventionCard"));
213 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
214 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
215 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"InterventionCard"));
217 $pdf->SetCompression(
false);
221 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
225 if (!empty($tplidx)) {
226 $pdf->useTemplate($tplidx);
230 $pdf->SetFont(
'',
'', $default_font_size - 1);
231 $pdf->SetTextColor(0, 0, 0);
234 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
236 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
239 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
248 $pdf->SetFont(
'',
'', $default_font_size - 1);
249 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
250 $nexY = $pdf->GetY();
251 $height_note = $nexY - $tab_top;
254 $pdf->SetDrawColor(192, 192, 192);
255 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
257 $tab_height = $tab_height - $height_note;
258 $tab_top = $nexY + 6;
263 $iniY = $tab_top + 7;
264 $curY = $tab_top + 7;
265 $nexY = $tab_top + 7;
267 $pdf->SetXY($this->marge_gauche, $tab_top);
268 $pdf->MultiCell(190, 5, $outputlangs->transnoentities(
"Description"), 0,
'L', 0);
269 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
271 $pdf->SetFont(
'',
'', $default_font_size - 1);
273 $pdf->SetXY($this->marge_gauche, $tab_top + 5);
277 $text .= ($text ?
' - ' :
'').$langs->trans(
"Total").
": ".$totaltime;
282 $pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
283 $nexY = $pdf->GetY();
285 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
287 $nblines = count(
$object->lines);
290 for ($i = 0; $i < $nblines; $i++) {
291 $objectligne =
$object->lines[$i];
293 $valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id);
294 if ($valide > 0 ||
$object->specimen) {
296 $pdf->SetFont(
'',
'', $default_font_size - 1);
297 $pdf->SetTextColor(0, 0, 0);
299 $pdf->setTopMargin($tab_top_newpage);
300 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
301 $pageposbefore = $pdf->getPage();
304 $curX = $this->posxdesc - 1;
308 $txt = $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date($objectligne->datei,
'dayhour',
false, $outputlangs,
true);
310 $txt = $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date($objectligne->datei,
'day',
false, $outputlangs,
true);
313 if ($objectligne->duration > 0) {
314 $txt .=
" - ".$outputlangs->transnoentities(
"Duration").
" : ".
convertSecondToTime($objectligne->duration);
316 $txt =
'<strong>'.dol_htmlentitiesbr($txt, 1, $outputlangs->charset_output).
'</strong>';
319 $pdf->startTransaction();
320 $pdf->writeHTMLCell(0, 0, $curX, $curY + 1,
dol_concatdesc($txt, $desc), 0, 1, 0);
321 $pageposafter = $pdf->getPage();
322 if ($pageposafter > $pageposbefore) {
323 $pdf->rollbackTransaction(
true);
324 $pageposafter = $pageposbefore;
326 $pdf->setPageOrientation(
'', 1, $heightforfooter);
327 $pdf->writeHTMLCell(0, 0, $curX, $curY,
dol_concatdesc($txt, $desc), 0, 1, 0);
328 $pageposafter = $pdf->getPage();
329 $posyafter = $pdf->GetY();
331 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
332 if ($i == ($nblines - 1)) {
333 $pdf->AddPage(
'',
'',
true);
334 if (!empty($tplidx)) {
335 $pdf->useTemplate($tplidx);
340 $pdf->setPage($pageposafter + 1);
344 $pdf->commitTransaction();
347 $nexY = $pdf->GetY();
348 $pageposafter = $pdf->getPage();
349 $pdf->setPage($pageposbefore);
350 $pdf->setTopMargin($this->marge_haute);
351 $pdf->setPageOrientation(
'', 1, 0);
354 if ($pageposafter > $pageposbefore) {
355 $pdf->setPage($pageposafter);
356 $curY = $tab_top_newpage;
359 $pdf->SetFont(
'',
'', $default_font_size - 1);
362 while ($pagenb < $pageposafter) {
363 $pdf->setPage($pagenb);
365 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object);
367 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object);
371 $pdf->setPage($pagenb);
372 $pdf->setPageOrientation(
'', 1, 0);
376 if (!empty($tplidx)) {
377 $pdf->useTemplate($tplidx);
380 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
382 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object);
384 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object);
389 if (!empty($tplidx)) {
390 $pdf->useTemplate($tplidx);
402 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object);
403 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
405 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object);
406 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
410 if (method_exists($pdf,
'AliasNbPages')) {
411 $pdf->AliasNbPages();
415 $pdf->Output($file,
'F');
418 $hookmanager->initHooks(array(
'pdfgeneration'));
419 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
421 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
423 $this->error = $hookmanager->error;
424 $this->errors = $hookmanager->errors;
429 $this->result = array(
'fullpath' => $file);
433 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
437 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"FICHEINTER_OUTPUTDIR");
456 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, FichInter
$object =
null)
489 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 1, 0, 0);
491 if (empty($hidebottom)) {
494 $arrayidcontact =
$object->getIdContact(
'internal',
'INTERVENING');
495 if (count($arrayidcontact) > 0) {
496 $object->fetch_user($arrayidcontact[0]);
497 $employee_name =
$object->user->getFullName($outputlangs);
501 $pdf->SetXY(20, 230);
502 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"NameAndSignatureOfInternalContact"), 0,
'L', 0);
504 $pdf->SetXY(20, 235);
505 $pdf->MultiCell(80, 25, $employee_name, 1,
'L');
507 $pdf->SetXY(110, 230);
508 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"NameAndSignatureOfExternalContact"), 0,
'L', 0);
510 $pdf->SetXY(110, 235);
511 $pdf->MultiCell(80, 25,
'', 1);
527 global $conf, $langs;
532 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"interventions"));
537 $pdf->SetTextColor(0, 0, 60);
538 $pdf->SetFont(
'',
'B', $default_font_size + 3);
540 $posx = $this->page_largeur - $this->marge_droite - 100;
541 $posy = $this->marge_haute;
543 $pdf->SetXY($this->marge_gauche, $posy);
546 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
547 if ($this->emetteur->logo) {
548 if (is_readable($logo)) {
550 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
552 $pdf->SetTextColor(200, 0, 0);
553 $pdf->SetFont(
'',
'B', $default_font_size - 2);
554 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
555 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
558 $text = $this->emetteur->name;
559 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
562 $pdf->SetFont(
'',
'B', $default_font_size + 3);
563 $pdf->SetXY($posx, $posy);
564 $pdf->SetTextColor(0, 0, 60);
565 $title = $outputlangs->transnoentities(
"InterventionCard");
566 $pdf->MultiCell(100, 4, $title,
'',
'R');
568 $pdf->SetFont(
'',
'B', $default_font_size + 2);
571 $pdf->SetXY($posx, $posy);
572 $pdf->SetTextColor(0, 0, 60);
573 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset(
$object->ref),
'',
'R');
576 $pdf->SetFont(
'',
'', $default_font_size);
579 $pdf->SetXY($posx, $posy);
580 $pdf->SetTextColor(0, 0, 60);
581 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->datec,
"day",
false, $outputlangs,
true),
'',
'R');
583 if (!empty(
$object->ref_client)) {
585 $pdf->SetXY($posx, $posy);
586 $pdf->SetTextColor(0, 0, 60);
587 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer") .
" : " .
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_client), 65),
'',
'R');
593 $pdf->SetXY($posx, $posy);
594 $pdf->SetTextColor(0, 0, 60);
595 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
600 $carac_emetteur =
'';
602 $arrayidcontact =
$object->getIdContact(
'internal',
'INTERREPFOLL');
603 if (count($arrayidcontact) > 0) {
604 $object->fetch_user($arrayidcontact[0]);
605 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
606 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
608 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
612 $carac_emetteur .=
"\n";
619 $posx = $this->marge_gauche;
621 $posx = $this->page_largeur - $this->marge_droite - 80;
627 $pdf->SetTextColor(0, 0, 0);
628 $pdf->SetFont(
'',
'', $default_font_size - 2);
629 $pdf->SetXY($posx, $posy - 5);
630 $pdf->SetXY($posx, $posy);
631 $pdf->SetFillColor(230, 230, 230);
632 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
637 $pdf->SetXY($posx + 2, $posy + 3);
638 $pdf->SetTextColor(0, 0, 60);
639 $pdf->SetFont(
'',
'B', $default_font_size);
640 $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
641 $posy = $pdf->getY();
645 $pdf->SetFont(
'',
'', $default_font_size - 1);
646 $pdf->SetXY($posx + 2, $posy);
647 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
652 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
653 if (count($arrayidcontact) > 0) {
655 $result =
$object->fetch_contact($arrayidcontact[0]);
659 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
660 $thirdparty =
$object->contact;
662 $thirdparty =
$object->thirdparty;
671 if ($this->page_largeur < 210) {
675 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
677 $posx = $this->marge_gauche;
682 $pdf->SetTextColor(0, 0, 0);
683 $pdf->SetFont(
'',
'', $default_font_size - 2);
684 $pdf->SetXY($posx + 2, $posy - 5);
685 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
686 $pdf->SetTextColor(0, 0, 0);
690 $pdf->SetXY($posx + 2, $posy + 3);
691 $pdf->SetFont(
'',
'B', $default_font_size);
692 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0,
'L');
694 $posy = $pdf->getY();
697 $pdf->SetFont(
'',
'', $default_font_size - 1);
698 $pdf->SetXY($posx + 2, $posy);
699 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
717 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
718 return pdf_pagefoot($pdf, $outputlangs,
'FICHINTER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur,
$object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Parent class to manage intervention document templates.
Class to build interventions documents with model Soleil.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, FichInter $object=null)
Show table for lines.
__construct($db)
Constructor.
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!function_exists('dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.