35 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
64 public $update_main_doc_field;
75 public $phpmin = array(7, 0);
81 public $version =
'dolibarr';
92 public $situationinvoice;
108 global $conf, $langs, $mysoc;
111 $langs->loadLangs(array(
"main",
"bills"));
114 $this->
name =
"standard";
115 $this->
description = $langs->trans(
'DocumentModelStandardPDF');
116 $this->update_main_doc_field = 1;
121 $this->page_largeur = $formatarray[
'width'];
122 $this->page_hauteur = $formatarray[
'height'];
123 $this->format = array($this->page_largeur, $this->page_hauteur);
130 $this->emetteur = $mysoc;
131 if (empty($this->emetteur->country_code)) {
132 $this->emetteur->country_code = substr($langs->defaultlang, -2);
136 $this->posxdesc = $this->marge_gauche + 1;
139 $this->tabTitleHeight = 5;
143 $this->tva = array();
144 $this->localtax1 = array();
145 $this->localtax2 = array();
146 $this->atleastoneratenotnull = 0;
147 $this->atleastonediscount = 0;
148 $this->situationinvoice =
false;
164 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
167 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
169 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
171 if (!is_object($outputlangs)) {
172 $outputlangs = $langs;
176 $outputlangs->charset_output =
'ISO-8859-1';
180 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
183 global $outputlangsbis;
184 $outputlangsbis =
new Translate(
'', $conf);
186 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
189 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
197 $realpatharray = array();
198 $this->atleastonephoto =
false;
252 if ($conf->mymodule->dir_output.
'/myobject') {
253 $object->fetch_thirdparty();
256 if ($object->specimen) {
257 $dir = $conf->mymodule->dir_output.
'/myobject';
258 $file = $dir.
"/SPECIMEN.pdf";
261 $dir = $conf->mymodule->dir_output.
'/myobject/'.$objectref;
262 $file = $dir.
"/".$objectref.
".pdf";
264 if (!file_exists($dir)) {
266 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
271 if (file_exists($dir)) {
273 $hookmanager->initHooks(array(
'pdfgeneration'));
274 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
276 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
279 $nblines = (is_array($object->lines) ? count($object->lines) : 0);
284 $pdf->SetAutoPageBreak(1, 0);
286 $heightforinfotot = 50;
287 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
288 $heightforfooter = $this->marge_basse + (
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
290 if (class_exists(
'TCPDF')) {
291 $pdf->setPrintHeader(
false);
292 $pdf->setPrintFooter(
false);
298 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].
'/'.
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
299 $tplidx = $pdf->importPage(1);
304 $pdf->SetDrawColor(128, 128, 128);
306 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
307 $pdf->SetSubject($outputlangs->transnoentities(
"PdfTitle"));
308 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
309 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
310 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
312 $pdf->SetCompression(
false);
316 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
324 'Name' => $this->emetteur->name,
325 'Location' =>
getCountry($this->emetteur->country_code, 0),
326 'Reason' =>
'MYOBJECT',
327 'ContactInfo' => $this->emetteur->email
329 $pdf->setSignature($cert, $cert, $this->emetteur->name,
'', 2, $info);
332 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
336 if (!empty($tplidx)) {
337 $pdf->useTemplate($tplidx);
341 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
342 $pdf->SetFont(
'',
'', $default_font_size - 1);
343 $pdf->MultiCell(0, 3,
'');
344 $pdf->SetTextColor(0, 0, 0);
346 $tab_top = 90 + $top_shift;
347 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
348 $tab_height = 130 - $top_shift;
349 $tab_height_newpage = 150;
351 $tab_height_newpage -= $top_shift;
354 $nexY = $tab_top - 1;
357 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
359 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
360 if (!empty($extranote)) {
364 $pagenb = $pdf->getPage();
368 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
369 $pageposbeforenote = $pagenb;
376 $pdf->startTransaction();
378 $pdf->SetFont(
'',
'', $default_font_size - 1);
379 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
381 $pageposafternote = $pdf->getPage();
382 $posyafter = $pdf->GetY();
384 if ($pageposafternote > $pageposbeforenote) {
385 $pdf->rollbackTransaction(
true);
388 while ($pagenb < $pageposafternote) {
391 if (!empty($tplidx)) {
392 $pdf->useTemplate($tplidx);
395 $this->
_pagehead($pdf, $object, 0, $outputlangs);
398 $pdf->setTopMargin($tab_top_newpage);
400 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
404 $pdf->setPage($pageposbeforenote);
405 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
406 $pdf->SetFont(
'',
'', $default_font_size - 1);
407 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
408 $pageposafternote = $pdf->getPage();
410 $posyafter = $pdf->GetY();
412 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
413 $pdf->AddPage(
'',
'',
true);
416 $pdf->setPage($pageposafternote);
417 $pdf->setTopMargin($tab_top_newpage);
419 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
425 $i = $pageposbeforenote;
426 while ($i < $pageposafternote) {
430 $pdf->SetDrawColor(128, 128, 128);
432 if ($i > $pageposbeforenote) {
433 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
434 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
436 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
437 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
441 $pdf->setPageOrientation(
'', 1, 0);
442 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
448 $pdf->setPage($pageposafternote);
449 if (!empty($tplidx)) {
450 $pdf->useTemplate($tplidx);
453 $this->
_pagehead($pdf, $object, 0, $outputlangs);
455 $height_note = $posyafter - $tab_top_newpage;
456 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
459 $pdf->commitTransaction();
460 $posyafter = $pdf->GetY();
461 $height_note = $posyafter - $tab_top;
462 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
465 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
467 $pdf->AddPage(
'',
'',
true);
470 $pdf->setPage($pageposafternote);
471 if (!empty($tplidx)) {
472 $pdf->useTemplate($tplidx);
475 $this->
_pagehead($pdf, $object, 0, $outputlangs);
478 $posyafter = $tab_top_newpage;
482 $tab_height = $tab_height - $height_note;
483 $tab_top = $posyafter + 6;
492 $pdf->startTransaction();
493 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
494 $pdf->rollbackTransaction(
true);
496 $nexY = $tab_top + $this->tabTitleHeight;
499 $pageposbeforeprintlines = $pdf->getPage();
500 $pagenb = $pageposbeforeprintlines;
501 for ($i = 0; $i < $nblines; $i++) {
503 $pdf->SetFont(
'',
'', $default_font_size - 1);
504 $pdf->SetTextColor(0, 0, 0);
507 $imglinesize = array();
508 if (!empty($realpatharray[$i])) {
512 $pdf->setTopMargin($tab_top_newpage);
513 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
514 $pageposbefore = $pdf->getPage();
516 $showpricebeforepagebreak = 1;
521 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
522 $pdf->AddPage(
'',
'',
true);
523 if (!empty($tplidx)) {
524 $pdf->useTemplate($tplidx);
526 $pdf->setPage($pageposbefore + 1);
528 $curY = $tab_top_newpage;
532 $showpricebeforepagebreak = 1;
534 $showpricebeforepagebreak = 0;
538 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
539 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
541 $posYAfterImage = $curY + $imglinesize[
'height'];
547 $pdf->startTransaction();
549 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
550 $pageposafter = $pdf->getPage();
552 if ($pageposafter > $pageposbefore) {
553 $pdf->rollbackTransaction(
true);
554 $pdf->setPageOrientation(
'', 1, $heightforfooter);
556 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
558 $pageposafter = $pdf->getPage();
559 $posyafter = $pdf->GetY();
561 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
562 if ($i == ($nblines - 1)) {
563 $pdf->AddPage(
'',
'',
true);
564 if (!empty($tplidx)) {
565 $pdf->useTemplate($tplidx);
567 $pdf->setPage($pageposafter + 1);
573 $showpricebeforepagebreak = 1;
575 $showpricebeforepagebreak = 0;
580 $pdf->commitTransaction();
584 $nexY = $pdf->GetY();
585 $pageposafter = $pdf->getPage();
586 $pdf->setPage($pageposbefore);
587 $pdf->setTopMargin($this->marge_haute);
588 $pdf->setPageOrientation(
'', 1, 0);
591 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
592 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
595 $pdf->SetFont(
'',
'', $default_font_size - 1);
602 $nexY = max($pdf->GetY(), $nexY);
606 if (!empty($object->lines[$i]->array_options)) {
607 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
609 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
611 $nexY = max($pdf->GetY(), $nexY);
623 'outputlangs' => $outputlangs,
624 'hidedetails' => $hidedetails
626 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
631 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
632 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
633 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
634 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
636 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
639 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
640 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
642 $tvaligne = $sign * $object->lines[$i]->total_tva;
646 $localtax1ligne = $object->lines[$i]->total_localtax1;
647 $localtax2ligne = $object->lines[$i]->total_localtax2;
648 $localtax1_rate = $object->lines[$i]->localtax1_tx;
649 $localtax2_rate = $object->lines[$i]->localtax2_tx;
650 $localtax1_type = $object->lines[$i]->localtax1_type;
651 $localtax2_type = $object->lines[$i]->localtax2_type;
653 if ($object->remise_percent) {
654 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
656 if ($object->remise_percent) {
657 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
659 if ($object->remise_percent) {
660 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
663 $vatrate = (string) $object->lines[$i]->tva_tx;
666 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
667 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
669 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
670 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
674 if ($localtax1_type && $localtax1ligne != 0) {
675 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
676 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
678 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
681 if ($localtax2_type && $localtax2ligne != 0) {
682 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
683 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
685 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
689 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
692 if (!isset($this->tva[$vatrate])) {
693 $this->tva[$vatrate] = 0;
695 $this->tva[$vatrate] += $tvaligne;
697 $nexY = max($nexY, $posYAfterImage);
700 if (
getDolGlobalInt(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
701 $pdf->setPage($pageposafter);
702 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
704 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
705 $pdf->SetLineStyle(array(
'dash'=>0));
709 while ($pagenb < $pageposafter) {
710 $pdf->setPage($pagenb);
711 if ($pagenb == $pageposbeforeprintlines) {
712 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
714 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
716 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
718 $pdf->setPage($pagenb);
719 $pdf->setPageOrientation(
'', 1, 0);
721 $this->
_pagehead($pdf, $object, 0, $outputlangs);
723 if (!empty($tplidx)) {
724 $pdf->useTemplate($tplidx);
728 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
729 if ($pagenb == $pageposafter) {
730 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
732 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
734 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
737 if (!empty($tplidx)) {
738 $pdf->useTemplate($tplidx);
742 $this->
_pagehead($pdf, $object, 0, $outputlangs);
748 if ($pagenb == $pageposbeforeprintlines) {
749 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
750 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
752 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
753 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
771 $this->
_pagefoot($pdf, $object, $outputlangs);
772 if (method_exists($pdf,
'AliasNbPages')) {
773 $pdf->AliasNbPages();
778 $pdf->Output($file,
'F');
781 $hookmanager->initHooks(array(
'pdfgeneration'));
782 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
784 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
786 $this->error = $hookmanager->error;
787 $this->errors = $hookmanager->errors;
792 $this->result = array(
'fullpath'=>$file);
796 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
800 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
816 return parent::liste_modeles($db, $maxfilenamelength);
834 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis =
null)
844 $currency = !empty($currency) ? $currency : $conf->currency;
848 $pdf->SetTextColor(0, 0, 0);
849 $pdf->SetFont(
'',
'', $default_font_size - 2);
851 if (empty($hidetop)) {
852 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
853 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
854 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
857 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
858 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
862 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
866 $pdf->SetDrawColor(128, 128, 128);
867 $pdf->SetFont(
'',
'', $default_font_size - 1);
870 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
873 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
875 if (empty($hidetop)) {
876 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight);
891 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
893 global $conf, $langs;
896 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
903 if ($object->statut == $object::STATUS_DRAFT &&
getDolGlobalString(
'MYMODULE_DRAFT_WATERMARK')) {
907 $pdf->SetTextColor(0, 0, 60);
908 $pdf->SetFont(
'',
'B', $default_font_size + 3);
912 $posy = $this->marge_haute;
913 $posx = $this->page_largeur - $this->marge_droite - $w;
915 $pdf->SetXY($this->marge_gauche, $posy);
919 if ($this->emetteur->logo) {
920 $logodir = $conf->mycompany->dir_output;
921 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
922 $logodir = $conf->mycompany->multidir_output[$object->entity];
925 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
927 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
929 if (is_readable($logo)) {
931 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
933 $pdf->SetTextColor(200, 0, 0);
934 $pdf->SetFont(
'',
'B', $default_font_size - 2);
935 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
936 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
939 $text = $this->emetteur->name;
940 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
944 $pdf->SetFont(
'',
'B', $default_font_size + 3);
945 $pdf->SetXY($posx, $posy);
946 $pdf->SetTextColor(0, 0, 60);
947 $title = $outputlangs->transnoentities(
"PdfTitle");
948 if (
getDolGlobalInt(
'MAIN_ODT_AS_PDF') && is_object($outputlangsbis)) {
950 $title .= $outputlangsbis->transnoentities(
"PdfTitle");
952 $pdf->MultiCell($w, 3, $title,
'',
'R');
954 $pdf->SetFont(
'',
'B', $default_font_size);
957 $pdf->SetXY($posx, $posy);
958 $pdf->SetTextColor(0, 0, 60);
959 $textref = $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref);
960 if ($object->statut == $object::STATUS_DRAFT) {
961 $pdf->SetTextColor(128, 0, 0);
962 $textref .=
' - '.$outputlangs->transnoentities(
"NotValidated");
964 $pdf->MultiCell($w, 4, $textref,
'',
'R');
967 $pdf->SetFont(
'',
'', $default_font_size - 2);
969 if ($object->ref_client) {
971 $pdf->SetXY($posx, $posy);
972 $pdf->SetTextColor(0, 0, 60);
973 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
977 $object->fetch_projet();
978 if (!empty($object->project->ref)) {
980 $pdf->SetXY($posx, $posy);
981 $pdf->SetTextColor(0, 0, 60);
982 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
987 $object->fetch_projet();
988 if (!empty($object->project->ref)) {
989 $outputlangs->load(
"projects");
991 $pdf->SetXY($posx, $posy);
992 $pdf->SetTextColor(0, 0, 60);
993 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
998 $pdf->SetXY($posx, $posy);
999 $pdf->SetTextColor(0, 0, 60);
1001 $title = $outputlangs->transnoentities(
"Date");
1002 if (
getDolGlobalInt(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1003 $title .=
' - '.$outputlangsbis->transnoentities(
"Date");
1005 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs),
'',
'R');
1007 if ($object->thirdparty->code_client) {
1009 $pdf->SetXY($posx, $posy);
1010 $pdf->SetTextColor(0, 0, 60);
1011 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1016 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1017 if (count($arrayidcontact) > 0) {
1018 $usertmp =
new User($this->db);
1019 $usertmp->fetch($arrayidcontact[0]);
1021 $pdf->SetXY($posx, $posy);
1022 $pdf->SetTextColor(0, 0, 60);
1023 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1031 $current_y = $pdf->getY();
1032 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1033 if ($current_y < $pdf->getY()) {
1034 $top_shift = $pdf->getY() - $current_y;
1039 $carac_emetteur =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1043 $posy += $top_shift;
1044 $posx = $this->marge_gauche;
1046 $posx = $this->page_largeur - $this->marge_droite - 80;
1050 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
1054 $pdf->SetTextColor(0, 0, 0);
1055 $pdf->SetFont(
'',
'', $default_font_size - 2);
1056 $pdf->SetXY($posx, $posy - 5);
1057 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0,
'L');
1058 $pdf->SetXY($posx, $posy);
1059 $pdf->SetFillColor(230, 230, 230);
1060 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1061 $pdf->SetTextColor(0, 0, 60);
1064 $pdf->SetXY($posx + 2, $posy + 3);
1065 $pdf->SetFont(
'',
'B', $default_font_size);
1066 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1067 $posy = $pdf->getY();
1070 $pdf->SetXY($posx + 2, $posy);
1071 $pdf->SetFont(
'',
'', $default_font_size - 1);
1072 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1075 $usecontact =
false;
1076 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
1077 if (count($arrayidcontact) > 0) {
1079 $result = $object->fetch_contact($arrayidcontact[0]);
1083 if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
1084 $thirdparty = $object->contact;
1086 $thirdparty = $object->thirdparty;
1089 if (is_object($thirdparty)) {
1093 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1096 $widthrecbox =
getDolGlobalInt(
'MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
1097 if ($this->page_largeur < 210) {
1101 $posy += $top_shift;
1102 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1104 $posx = $this->marge_gauche;
1108 $pdf->SetTextColor(0, 0, 0);
1109 $pdf->SetFont(
'',
'', $default_font_size - 2);
1110 $pdf->SetXY($posx + 2, $posy - 5);
1111 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo").
":", 0,
'L');
1112 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1115 $pdf->SetXY($posx + 2, $posy + 3);
1116 $pdf->SetFont(
'',
'B', $default_font_size);
1117 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1119 $posy = $pdf->getY();
1122 $pdf->SetFont(
'',
'', $default_font_size - 1);
1123 $pdf->SetXY($posx + 2, $posy);
1124 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1127 $pdf->SetTextColor(0, 0, 0);
1141 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1145 return pdf_pagefoot($pdf, $outputlangs,
'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1158 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1160 global $conf, $hookmanager;
1163 $this->defaultContentsFieldsStyle = array(
1165 'padding' => array(1, 0.5, 1, 0.5),
1169 $this->defaultTitlesFieldsStyle = array(
1171 'padding' => array(0.5, 0, 0.5, 0),
1193 $this->cols[
'desc'] = array(
1198 'textkey' =>
'Designation',
1202 'padding' => array(0.5, 0.5, 0.5, 0.5),
1206 'padding' => array(1, 0.5, 1, 1.5),
1212 $this->cols[
'photo'] = array(
1217 'textkey' =>
'Photo',
1221 'padding' => array(0, 0, 0, 0),
1223 'border-left' =>
false,
1226 if (
getDolGlobalInt(
'MAIN_GENERATE_INVOICES_WITH_PICTURE') && !empty($this->atleastonephoto)) {
1227 $this->cols[
'photo'][
'status'] =
true;
1232 $this->cols[
'vat'] = array(
1239 'border-left' =>
true,
1243 $this->cols[
'vat'][
'status'] =
true;
1247 $this->cols[
'subprice'] = array(
1252 'textkey' =>
'PriceUHT'
1254 'border-left' =>
true,
1258 $this->cols[
'qty'] = array(
1265 'border-left' =>
true,
1269 $this->cols[
'progress'] = array(
1274 'textkey' =>
'Progress'
1276 'border-left' =>
true,
1279 if ($this->situationinvoice) {
1280 $this->cols[
'progress'][
'status'] =
true;
1284 $this->cols[
'unit'] = array(
1291 'border-left' =>
true,
1293 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1294 $this->cols[
'unit'][
'status'] =
true;
1298 $this->cols[
'discount'] = array(
1303 'textkey' =>
'ReductionShort'
1305 'border-left' =>
true,
1307 if ($this->atleastonediscount) {
1308 $this->cols[
'discount'][
'status'] =
true;
1311 $rank = $rank + 1000;
1312 $this->cols[
'totalexcltax'] = array(
1317 'textkey' =>
'TotalHT'
1319 'border-left' =>
true,
1323 if (!empty($object->lines)) {
1324 $line = reset($object->lines);
1328 $parameters = array(
1329 'object' => $object,
1330 'outputlangs' => $outputlangs,
1331 'hidedetails' => $hidedetails,
1332 'hidedesc' => $hidedesc,
1333 'hideref' => $hideref
1336 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
1339 } elseif (empty($reshook)) {
1340 $this->cols = array_replace($this->cols, $hookmanager->resArray);
1342 $this->cols = $hookmanager->resArray;
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
getColumnStatus($colKey)
get column status from column key
printStdColumnContent($pdf, &$curY, $colKey, $columnText='')
print standard column content
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
Print standard column content.
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
getExtrafieldContent($object, $extrafieldKey, $outputlangs=null)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
Parent class for documents models.
Class to manage translations.
Class to manage Dolibarr users.
Class to manage PDF template standard_myobject.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null)
Show top header of page.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='', $outputlangsbis=null)
Show table for lines.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
__construct($db)
Constructor.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
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...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
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_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects 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 formated for output on documents.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
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.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
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.