36 require_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
37 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
66 public $update_main_doc_field;
77 public $phpmin = array(7, 0);
83 public $version =
'dolibarr';
103 public $marge_gauche;
108 public $marge_droite;
124 public $heightforinfotot;
129 public $heightforfreetext;
134 public $heightforfooter;
144 public $tab_top_newpage;
155 public $situationinvoice;
166 public $categoryOfOperation = -1;
176 global $conf, $langs, $mysoc;
179 $langs->loadLangs(array(
"main",
"bills"));
182 $this->
name =
"sponge";
183 $this->
description = $langs->trans(
'PDFSpongeDescription');
184 $this->update_main_doc_field = 1;
189 $this->page_largeur = $formatarray[
'width'];
190 $this->page_hauteur = $formatarray[
'height'];
191 $this->format = array($this->page_largeur, $this->page_hauteur);
197 $this->option_logo = 1;
198 $this->option_tva = 1;
199 $this->option_modereg = 1;
200 $this->option_condreg = 1;
201 $this->option_multilang = 1;
202 $this->option_escompte = 1;
203 $this->option_credit_note = 1;
204 $this->option_freetext = 1;
205 $this->option_draft_watermark = 1;
206 $this->watermark =
'';
209 $this->emetteur = $mysoc;
210 if (empty($this->emetteur->country_code)) {
211 $this->emetteur->country_code = substr($langs->defaultlang, -2);
215 $this->posxdesc = $this->marge_gauche + 1;
218 $this->tabTitleHeight = 5;
222 $this->tva = array();
223 $this->tva_array = array();
224 $this->localtax1 = array();
225 $this->localtax2 = array();
226 $this->atleastoneratenotnull = 0;
227 $this->atleastonediscount = 0;
228 $this->situationinvoice =
false;
244 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
247 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
249 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
251 if (!is_object($outputlangs)) {
252 $outputlangs = $langs;
255 if (!empty($conf->global->MAIN_USE_FPDF)) {
256 $outputlangs->charset_output =
'ISO-8859-1';
260 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
262 global $outputlangsbis;
263 $outputlangsbis =
null;
264 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
265 $outputlangsbis =
new Translate(
'', $conf);
266 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
267 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
271 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) {
272 $this->watermark = $conf->global->FACTURE_DRAFT_WATERMARK;
275 $nblines = count($object->lines);
278 if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
279 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
283 $realpatharray = array();
284 $this->atleastonephoto =
false;
285 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) {
288 for ($i = 0; $i < $nblines; $i++) {
289 if (empty($object->lines[$i]->fk_product)) {
293 $objphoto->fetch($object->lines[$i]->fk_product);
296 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
297 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
299 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
300 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
304 foreach ($pdir as $midir) {
306 if ($conf->entity != $objphoto->entity) {
307 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
309 $dir = $conf->product->dir_output.
'/'.$midir;
312 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
314 if ($obj[
'photo_vignette']) {
315 $filename = $obj[
'photo_vignette'];
317 $filename = $obj[
'photo'];
320 $filename = $obj[
'photo'];
323 $realpath = $dir.$filename;
325 $this->atleastonephoto =
true;
330 if ($realpath && $arephoto) {
331 $realpatharray[$i] = $realpath;
338 if ($conf->facture->multidir_output[$conf->entity]) {
339 $object->fetch_thirdparty();
341 $deja_regle = $object->getSommePaiement((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
342 $amount_credit_notes_included = $object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
343 $amount_deposits_included = $object->getSumDepositsUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
346 if ($object->specimen) {
347 $dir = $conf->facture->multidir_output[$conf->entity];
348 $file = $dir.
"/SPECIMEN.pdf";
351 $dir = $conf->facture->multidir_output[$object->entity].
"/".$objectref;
352 $file = $dir.
"/".$objectref.
".pdf";
354 if (!file_exists($dir)) {
356 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
361 if (file_exists($dir)) {
363 if (!is_object($hookmanager)) {
364 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
367 $hookmanager->initHooks(array(
'pdfgeneration'));
368 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
370 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
373 $nblines = count($object->lines);
374 $nbpayments = count($object->getListOfPayments());
379 $pdf->SetAutoPageBreak(1, 0);
381 $this->heightforinfotot = 50 + (4 * $nbpayments);
382 $this->heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
383 $this->heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22);
385 if (class_exists(
'TCPDF')) {
386 $pdf->setPrintHeader(
false);
387 $pdf->setPrintFooter(
false);
392 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
393 $logodir = $conf->mycompany->dir_output;
394 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
395 $logodir = $conf->mycompany->multidir_output[$object->entity];
397 $pagecount = $pdf->setSourceFile($logodir.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
398 $tplidx = $pdf->importPage(1);
403 $pdf->SetDrawColor(128, 128, 128);
405 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
406 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
407 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
408 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
409 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
411 $pdf->SetCompression(
false);
415 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
416 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
419 $cert = empty($conf->global->CERTIFICATE_CRT) ?
'' : $conf->global->CERTIFICATE_CRT;
422 $certprivate = empty($conf->global->CERTIFICATE_CRT_PRIVATE) ?
'' : $conf->global->CERTIFICATE_CRT_PRIVATE;
427 'Name' => $this->emetteur->name,
428 'Location' =>
getCountry($this->emetteur->country_code, 0),
429 'Reason' =>
'INVOICE',
430 'ContactInfo' => $this->emetteur->email
432 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
435 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
439 $categoryOfOperation = 0;
442 for ($i = 0; $i < $nblines; $i++) {
443 if ($object->lines[$i]->remise_percent) {
444 $this->atleastonediscount++;
448 $lineProductType = $object->lines[$i]->product_type;
454 if ($nbProduct > 0 && $nbService > 0) {
456 $categoryOfOperation = 2;
460 if ($categoryOfOperation <= 0) {
462 if ($nbProduct == 0 && $nbService > 0) {
463 $categoryOfOperation = 1;
466 $this->categoryOfOperation = $categoryOfOperation;
469 if ($object->situation_cycle_ref) {
470 $this->situationinvoice =
true;
475 if (!empty($tplidx)) {
476 $pdf->useTemplate($tplidx);
481 $pagehead = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
482 $top_shift = $pagehead[
'top_shift'];
483 $shipp_shift = $pagehead[
'shipp_shift'];
484 $pdf->SetFont(
'',
'', $default_font_size - 1);
485 $pdf->MultiCell(0, 3,
'');
486 $pdf->SetTextColor(0, 0, 0);
491 $this->tab_top = 90 + $top_shift + $shipp_shift;
492 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
495 $extra_under_address_shift = 0;
497 if (!empty($conf->global->INVOICE_ADD_ZATCA_QR_CODE)) {
498 $qrcodestring = $object->buildZATCAQRString();
499 } elseif (!empty($conf->global->INVOICE_ADD_SWISS_QR_CODE)) {
500 $qrcodestring = $object->buildSwitzerlandQRString();
503 $qrcodecolor = array(
'25',
'25',
'25');
508 'fgcolor' => $qrcodecolor,
513 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
514 $extra_under_address_shift += 25;
522 'outputlangs' => $outputlangs,
523 'hidedetails' => $hidedetails
525 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
526 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
527 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_header_shift'];
530 $this->tab_top += $extra_under_address_shift;
531 $this->tab_top_newpage += 0;
535 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext;
537 $nexY = $this->tab_top - 1;
540 $height_incoterms = 0;
542 $desc_incoterms = $object->getIncotermsForPDF();
543 if ($desc_incoterms) {
546 $pdf->SetFont(
'',
'', $default_font_size - 1);
547 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
548 $nexY = max($pdf->GetY(), $nexY);
549 $height_incoterms = $nexY - $this->tab_top;
552 $pdf->SetDrawColor(192, 192, 192);
553 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
555 $this->tab_top = $nexY + 6;
556 $height_incoterms += 4;
561 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
562 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
564 if (is_object($object->thirdparty)) {
565 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
566 $salerepobj =
new User($this->
db);
567 $salerepobj->fetch($salereparray[0][
'id']);
568 if (!empty($salerepobj->signature)) {
569 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
575 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
576 if (!empty($extranote)) {
580 $pagenb = $pdf->getPage();
584 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
585 $pageposbeforenote = $pagenb;
592 $pdf->startTransaction();
594 $pdf->SetFont(
'',
'', $default_font_size - 1);
595 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
597 $pageposafternote = $pdf->getPage();
598 $posyafter = $pdf->GetY();
600 if ($pageposafternote > $pageposbeforenote) {
601 $pdf->rollbackTransaction(
true);
604 while ($pagenb < $pageposafternote) {
607 if (!empty($tplidx)) {
608 $pdf->useTemplate($tplidx);
611 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
614 $pdf->setTopMargin($this->tab_top_newpage);
616 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
620 $pdf->setPage($pageposbeforenote);
621 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
622 $pdf->SetFont(
'',
'', $default_font_size - 1);
623 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
624 $pageposafternote = $pdf->getPage();
626 $posyafter = $pdf->GetY();
628 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
629 $pdf->AddPage(
'',
'',
true);
632 $pdf->setPage($pageposafternote);
633 $pdf->setTopMargin($this->tab_top_newpage);
635 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
641 $i = $pageposbeforenote;
642 while ($i < $pageposafternote) {
646 $pdf->SetDrawColor(128, 128, 128);
648 if ($i > $pageposbeforenote) {
649 $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
650 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
652 $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
653 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
657 $pdf->setPageOrientation(
'', 1, 0);
658 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
664 $pdf->setPage($pageposafternote);
665 if (!empty($tplidx)) {
666 $pdf->useTemplate($tplidx);
669 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
671 $height_note = $posyafter - $this->tab_top_newpage;
672 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
675 $pdf->commitTransaction();
676 $posyafter = $pdf->GetY();
677 $height_note = $posyafter - $this->tab_top;
678 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
681 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
683 $pdf->AddPage(
'',
'',
true);
686 $pdf->setPage($pageposafternote);
687 if (!empty($tplidx)) {
688 $pdf->useTemplate($tplidx);
691 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
694 $posyafter = $this->tab_top_newpage;
698 $tab_height = $tab_height - $height_note;
699 $this->tab_top = $posyafter + 6;
708 $pdf->startTransaction();
709 $this->
pdfTabTitles($pdf, $this->tab_top, $tab_height, $outputlangs, $hidetop);
710 $pdf->rollbackTransaction(
true);
712 $nexY = $this->tab_top + $this->tabTitleHeight;
715 $pageposbeforeprintlines = $pdf->getPage();
716 $pagenb = $pageposbeforeprintlines;
717 for ($i = 0; $i < $nblines; $i++) {
719 $pdf->SetFont(
'',
'', $default_font_size - 1);
720 $pdf->SetTextColor(0, 0, 0);
723 $imglinesize = array();
724 if (!empty($realpatharray[$i])) {
728 $pdf->setTopMargin($this->tab_top_newpage);
729 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot);
730 $pageposbefore = $pdf->getPage();
732 $showpricebeforepagebreak = 1;
734 $posYAfterDescription = 0;
738 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
739 $pdf->AddPage(
'',
'',
true);
740 if (!empty($tplidx)) {
741 $pdf->useTemplate($tplidx);
743 $pdf->setPage($pageposbefore + 1);
745 $curY = $this->tab_top_newpage;
748 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
749 $showpricebeforepagebreak = 1;
751 $showpricebeforepagebreak = 0;
755 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
756 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
758 $posYAfterImage = $curY + $imglinesize[
'height'];
764 $pdf->startTransaction();
766 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
767 $pageposafter = $pdf->getPage();
769 if ($pageposafter > $pageposbefore) {
770 $pdf->rollbackTransaction(
true);
771 $pageposafter = $pageposbefore;
772 $pdf->setPageOrientation(
'', 1, $this->heightforfooter);
774 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
776 $pageposafter = $pdf->getPage();
777 $posyafter = $pdf->GetY();
779 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
780 if ($i == ($nblines - 1)) {
781 $pdf->AddPage(
'',
'',
true);
782 if (!empty($tplidx)) {
783 $pdf->useTemplate($tplidx);
785 $pdf->setPage($pageposafter + 1);
790 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
791 $showpricebeforepagebreak = 1;
793 $showpricebeforepagebreak = 0;
798 $pdf->commitTransaction();
800 $posYAfterDescription = $pdf->GetY();
803 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
805 $pageposafter = $pdf->getPage();
806 $pdf->setPage($pageposbefore);
807 $pdf->setTopMargin($this->marge_haute);
808 $pdf->setPageOrientation(
'', 1, 0);
811 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
812 $pdf->setPage($pageposafter);
813 $curY = $this->tab_top_newpage;
816 $pdf->SetFont(
'',
'', $default_font_size - 1);
822 $nexY = max($pdf->GetY(), $nexY);
829 $nexY = max($pdf->GetY(), $nexY);
837 $nexY = max($pdf->GetY(), $nexY);
844 $nexY = max($pdf->GetY(), $nexY);
849 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
851 $nexY = max($pdf->GetY(), $nexY);
855 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
858 $nexY = max($pdf->GetY(), $nexY);
865 $nexY = max($pdf->GetY(), $nexY);
872 $nexY = max($pdf->GetY(), $nexY);
876 if (!empty($object->lines[$i]->array_options)) {
877 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
879 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
881 $nexY = max($pdf->GetY(), $nexY);
893 'outputlangs' => $outputlangs,
894 'hidedetails' => $hidedetails
896 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
900 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
904 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
905 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
906 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
907 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
909 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
912 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
913 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
915 $tvaligne = $sign * $object->lines[$i]->total_tva;
919 $localtax1ligne = $object->lines[$i]->total_localtax1;
920 $localtax2ligne = $object->lines[$i]->total_localtax2;
921 $localtax1_rate = $object->lines[$i]->localtax1_tx;
922 $localtax2_rate = $object->lines[$i]->localtax2_tx;
923 $localtax1_type = $object->lines[$i]->localtax1_type;
924 $localtax2_type = $object->lines[$i]->localtax2_type;
926 if ($object->remise_percent) {
927 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
929 if ($object->remise_percent) {
930 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
932 if ($object->remise_percent) {
933 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
936 $vatrate = (string) $object->lines[$i]->tva_tx;
939 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
940 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
942 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
943 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
947 if ($localtax1_type && $localtax1ligne != 0) {
948 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
950 if ($localtax2_type && $localtax2ligne != 0) {
951 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
954 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
959 if (!isset($this->tva[$vatrate])) {
960 $this->tva[$vatrate] = 0;
962 $this->tva[$vatrate] += $tvaligne;
963 $vatcode = $object->lines[$i]->vat_src_code;
964 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
965 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
967 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
969 $nexY = max($nexY, $posYAfterImage);
972 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
973 $pdf->setPage($pageposafter);
974 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
976 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
977 $pdf->SetLineStyle(array(
'dash'=>0));
981 while ($pagenb < $pageposafter) {
982 $pdf->setPage($pagenb);
983 if ($pagenb == $pageposbeforeprintlines) {
984 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
986 $this->
_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
988 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
990 $pdf->setPage($pagenb);
991 $pdf->setPageOrientation(
'', 1, 0);
993 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
995 if (!empty($tplidx)) {
996 $pdf->useTemplate($tplidx);
1000 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
1001 if ($pagenb == $pageposafter) {
1002 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
1004 $this->
_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
1006 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
1009 if (!empty($tplidx)) {
1010 $pdf->useTemplate($tplidx);
1014 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1020 if ($pagenb == $pageposbeforeprintlines) {
1021 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
1022 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
1024 $this->
_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
1025 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
1029 $posy = $this->
drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
1032 $posy = $this->
drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1035 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) {
1040 $this->
_pagefoot($pdf, $object, $outputlangs);
1041 if (method_exists($pdf,
'AliasNbPages')) {
1042 $pdf->AliasNbPages();
1047 $pdf->Output($file,
'F');
1050 $hookmanager->initHooks(array(
'pdfgeneration'));
1051 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
1053 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1055 $this->error = $hookmanager->error;
1056 $this->errors = $hookmanager->errors;
1059 if (!empty($conf->global->MAIN_UMASK)) {
1060 @chmod($file, octdec($conf->global->MAIN_UMASK));
1063 $this->result = array(
'fullpath'=>$file);
1067 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1071 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1091 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1096 $tab3_top = $posy + 8;
1099 if ($this->page_largeur < 210) {
1105 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1106 if ($object->type == 2) {
1107 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1110 $pdf->SetFont(
'',
'', $default_font_size - 3);
1111 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1112 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1114 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1116 $pdf->SetFont(
'',
'', $default_font_size - 4);
1117 $pdf->SetXY($tab3_posx, $tab3_top);
1118 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1119 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1120 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1121 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1122 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1123 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1124 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1126 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1130 $pdf->SetFont(
'',
'', $default_font_size - 4);
1134 $sql =
"SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,";
1135 $sql .=
" re.description, re.fk_facture_source,";
1136 $sql .=
" f.type, f.datef";
1137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1138 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int) $object->id);
1141 $num = $this->
db->num_rows(
$resql);
1146 $obj = $this->
db->fetch_object(
$resql);
1148 if ($obj->type == 2) {
1149 $text = $outputlangs->transnoentities(
"CreditNote");
1150 } elseif ($obj->type == 3) {
1151 $text = $outputlangs->transnoentities(
"Deposit");
1152 } elseif ($obj->type == 0) {
1153 $text = $outputlangs->transnoentities(
"ExcessReceived");
1155 $text = $outputlangs->transnoentities(
"UnknownType");
1158 $invoice->fetch($obj->fk_facture_source);
1160 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1161 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1162 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1163 $pdf->MultiCell(20, 3,
price((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1164 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1165 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1166 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1167 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1169 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1174 $this->error = $this->
db->lasterror();
1180 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1182 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1183 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1184 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
1186 $sql .=
" ORDER BY p.datep";
1190 $num = $this->
db->num_rows(
$resql);
1194 $row = $this->
db->fetch_object(
$resql);
1196 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1197 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1198 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1199 $pdf->MultiCell(20, 3,
price($sign * ((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1200 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1201 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1203 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1204 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1205 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1207 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1212 return $tab3_top + $y + 3;
1214 $this->error = $this->
db->lasterror();
1230 protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
1232 global $conf, $mysoc;
1236 $pdf->SetFont(
'',
'', $default_font_size - 1);
1239 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1240 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1241 $pdf->SetXY($this->marge_gauche, $posy);
1242 if ($mysoc->forme_juridique_code == 92) {
1243 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1245 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1248 $posy = $pdf->GetY() + 4;
1253 if ($this->page_largeur < 210) {
1258 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
1259 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1260 $pdf->SetXY($this->marge_gauche, $posy);
1261 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1262 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1264 $pdf->SetFont(
'',
'', $default_font_size - 2);
1265 $pdf->SetXY($posxval, $posy);
1266 $lib_condition_paiement = $outputlangs->transnoentities(
"PaymentCondition".$object->cond_reglement_code) != (
'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities(
"PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
1267 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1268 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1270 $posy = $pdf->GetY() + 3;
1274 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1275 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1276 $pdf->SetXY($this->marge_gauche, $posy);
1277 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1278 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1280 $pdf->SetFont(
'',
'', $default_font_size - 2);
1281 $pdf->SetXY($posxval, $posy);
1282 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1283 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1285 $posy = $pdf->GetY() + 3;
1288 if ($object->type != 2) {
1290 if (empty($object->mode_reglement_code)
1291 && empty($conf->global->FACTURE_CHQ_NUMBER)
1293 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1294 } elseif (($object->mode_reglement_code ==
'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
1295 || ($object->mode_reglement_code ==
'VIR' && !
getDolGlobalInt(
'FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
1297 $outputlangs->load(
"errors");
1299 $pdf->SetXY($this->marge_gauche, $posy);
1300 $pdf->SetTextColor(200, 0, 0);
1301 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1302 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1303 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1304 $pdf->SetTextColor(0, 0, 0);
1306 $posy = $pdf->GetY() + 1;
1310 if (!empty($object->mode_reglement_code)
1311 && $object->mode_reglement_code !=
'CHQ'
1312 && $object->mode_reglement_code !=
'VIR') {
1313 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1314 $pdf->SetXY($this->marge_gauche, $posy);
1315 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1316 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1318 $pdf->SetFont(
'',
'', $default_font_size - 2);
1319 $pdf->SetXY($posxval, $posy);
1320 $lib_mode_reg = $outputlangs->transnoentities(
"PaymentType".$object->mode_reglement_code) != (
'PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities(
"PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
1323 if ($object->mode_reglement_code ==
"PRE") {
1324 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1326 $bac->fetch(0, $object->thirdparty->id);
1327 $iban= $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1328 $lib_mode_reg .= $outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1331 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1333 $posy = $pdf->GetY();
1339 if ($this->emetteur->country_code ==
'FR') {
1340 if (isset($conf->global->TAX_MODE) && $conf->global->TAX_MODE == 1) {
1341 $pdf->SetXY($this->marge_gauche, $posy);
1342 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1344 $posy = $pdf->GetY() + 1;
1349 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CB' || $object->mode_reglement_code ==
'VAD') {
1350 $useonlinepayment = 0;
1351 if (!empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)) {
1353 $useonlinepayment++;
1356 $useonlinepayment++;
1359 $useonlinepayment++;
1365 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1368 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1369 $servicename = $langs->transnoentities(
'Online');
1370 $paiement_url = getOnlinePaymentUrl(
'',
'invoice', $object->ref,
'',
'',
'');
1371 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1373 $pdf->SetXY($this->marge_gauche, $posy);
1374 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1376 $posy = $pdf->GetY() + 1;
1381 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1383 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
1384 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1386 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
1388 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1390 $pdf->SetXY($this->marge_gauche, $posy);
1391 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1392 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1393 $posy = $pdf->GetY() + 1;
1395 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1396 $pdf->SetXY($this->marge_gauche, $posy);
1397 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1398 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1399 $posy = $pdf->GetY() + 2;
1402 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1403 $pdf->SetXY($this->marge_gauche, $posy);
1404 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1405 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1406 $posy = $pdf->GetY() + 1;
1408 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1409 $pdf->SetXY($this->marge_gauche, $posy);
1410 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1411 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1412 $posy = $pdf->GetY() + 2;
1419 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1420 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1421 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1422 if ($object->fk_bank > 0) {
1423 $bankid = $object->fk_bank;
1426 $account->fetch($bankid);
1428 $curx = $this->marge_gauche;
1431 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1453 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
1455 global $conf, $mysoc, $hookmanager;
1458 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1466 if (is_object($outputlangsbis)) {
1467 $pdf->SetFont(
'',
'', $default_font_size - 2);
1469 $pdf->SetFont(
'',
'', $default_font_size - 1);
1475 if ($this->page_largeur < 210) {
1479 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1485 $parameters = array(
1486 'object' => &$object,
1487 'outputlangs' => $outputlangs,
1489 $hookmanager->executeHooks(
'beforePercentCalculation', $parameters, $this);
1494 foreach ($object->lines as $line) {
1495 $percent += $line->situation_percent;
1500 $avancementGlobal = $percent / $i;
1502 $avancementGlobal = 0;
1505 $object->fetchPreviousNextSituationInvoice();
1506 $TPreviousIncoice = $object->tab_previous_situation_invoice;
1509 $total_a_payer_ttc = 0;
1510 foreach ($TPreviousIncoice as &$fac) {
1511 $total_a_payer += $fac->total_ht;
1512 $total_a_payer_ttc += $fac->total_ttc;
1514 $total_a_payer += $object->total_ht;
1515 $total_a_payer_ttc += $object->total_ttc;
1517 if (!empty($avancementGlobal)) {
1518 $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
1519 $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
1522 $total_a_payer_ttc = 0;
1526 if (!empty($TPreviousIncoice)) {
1527 $pdf->setY($tab2_top);
1528 $posy = $pdf->GetY();
1530 foreach ($TPreviousIncoice as &$fac) {
1531 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1532 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
1535 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1536 $pdf->setY($this->tab_top_newpage);
1538 $pdf->setY($this->marge_haute);
1540 $posy = $pdf->GetY();
1545 $pdf->SetFillColor(255, 255, 255);
1546 $pdf->SetXY($col1x, $posy);
1547 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $fac->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1549 $pdf->SetXY($col2x, $posy);
1553 $facSign = $fac->total_ht >= 0 ?
'+' :
'';
1556 $displayAmount =
' '.$facSign.
' '.
price($fac->total_ht, 0, $outputlangs);
1558 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1567 $pdf->SetFillColor(255, 255, 255);
1568 $pdf->SetXY($col1x, $posy);
1569 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $object->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1571 $pdf->SetXY($col2x, $posy);
1574 $facSign = $object->total_ht >= 0 ?
'+' :
'';
1577 if ($fac->type === facture::TYPE_CREDIT_NOTE) {
1582 $displayAmount =
' '.$facSign.
' '.
price($object->total_ht, 0, $outputlangs);
1583 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1588 $pdf->SetFont(
'',
'', $default_font_size - 1);
1589 $pdf->SetFillColor(255, 255, 255);
1590 $pdf->SetXY($col1x, $posy);
1591 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"SituationTotalProgress", $avancementGlobal), 0,
'L', 1);
1593 $pdf->SetXY($col2x, $posy);
1594 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0,
'R', 1);
1595 $pdf->SetFont(
'',
'', $default_font_size - 2);
1599 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1602 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1603 $pdf->setY($this->tab_top_newpage);
1605 $pdf->setY($this->marge_haute);
1608 $posy = $pdf->GetY();
1619 $total_ht = (
isModEnabled(
"multicurrency") && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1622 $total_line_remise = 0;
1623 foreach ($object->lines as $i => $line) {
1626 if ($line->total_ht < 0) {
1627 $total_line_remise += -$line->total_ht;
1630 if ($total_line_remise > 0) {
1631 if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
1632 $pdf->SetFillColor(255, 255, 255);
1633 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1634 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1635 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1636 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1641 if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
1642 $pdf->SetFillColor(255, 255, 255);
1643 $pdf->SetXY($col1x, $tab2_top);
1644 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1645 $pdf->SetXY($col2x, $tab2_top);
1646 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1653 $pdf->SetFillColor(255, 255, 255);
1654 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1655 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ?
"TotalHT" :
"Total").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ?
"TotalHT" :
"Total") :
''), 0,
'L', 1);
1657 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1658 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1659 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1662 $pdf->SetFillColor(248, 248, 248);
1664 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1666 $this->atleastoneratenotnull = 0;
1667 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
1668 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1669 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
1677 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1678 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1682 foreach ($localtax_rate as $tvakey => $tvaval) {
1687 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1690 if (preg_match(
'/\*/', $tvakey)) {
1691 $tvakey = str_replace(
'*',
'', $tvakey);
1692 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1695 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1697 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1698 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1700 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1701 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1709 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1710 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1714 foreach ($localtax_rate as $tvakey => $tvaval) {
1719 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1722 if (preg_match(
'/\*/', $tvakey)) {
1723 $tvakey = str_replace(
'*',
'', $tvakey);
1724 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1726 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1728 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1729 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1731 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1732 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1739 if (
getDolGlobalInt(
'INVOICE_USE_SITUATION') == 1 && $object->situation_cycle_ref && $object->situation_counter > 1) {
1741 foreach ($this->tva as $tvakey => $tvaval) {
1742 $sum_pdf_tva += $tvaval;
1745 if ($sum_pdf_tva != $object->total_tva) {
1746 if (!empty($sum_pdf_tva)) {
1747 $coef_fix_tva = $object->total_tva / $sum_pdf_tva;
1753 foreach ($this->tva as $tvakey => $tvaval) {
1754 $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1756 foreach ($this->tva_array as $tvakey => $tvaval) {
1757 $this->tva_array[$tvakey][
'amount'] = $tvaval[
'amount'] * $coef_fix_tva;
1763 foreach ($this->tva_array as $tvakey => $tvaval) {
1765 $this->atleastoneratenotnull++;
1768 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1771 if (preg_match(
'/\*/', $tvakey)) {
1772 $tvakey = str_replace(
'*',
'', $tvakey);
1773 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1775 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1778 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1780 $totalvat .= ($tvaval[
'vatcode'] ? $tvaval[
'vatcode'] :
vatrate($tvaval[
'vatrate'], 1)).$tvacompl;
1782 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1784 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1786 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1787 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1794 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1795 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1799 foreach ($localtax_rate as $tvakey => $tvaval) {
1804 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1807 if (preg_match(
'/\*/', $tvakey)) {
1808 $tvakey = str_replace(
'*',
'', $tvakey);
1809 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1811 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1813 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1815 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1816 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1817 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1825 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1826 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1830 foreach ($localtax_rate as $tvakey => $tvaval) {
1836 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1839 if (preg_match(
'/\*/', $tvakey)) {
1840 $tvakey = str_replace(
'*',
'', $tvakey);
1841 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1843 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1846 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1847 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1849 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1850 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1857 if (
price2num($object->revenuestamp) != 0) {
1859 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1860 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1862 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1863 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $object->revenuestamp), $useborder,
'R', 1);
1868 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1869 $pdf->SetTextColor(0, 0, 60);
1870 $pdf->SetFillColor(224, 224, 224);
1871 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1873 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1874 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1878 if ($object->displayRetainedWarranty()) {
1879 $pdf->SetTextColor(40, 40, 40);
1880 $pdf->SetFillColor(255, 255, 255);
1882 $retainedWarranty = $object->getRetainedWarrantyAmount();
1883 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1887 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1888 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date($object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1890 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1891 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1895 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1897 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.$object->retained_warranty.
'%)';
1898 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date($object->retained_warranty_date_limit,
'day')) :
'';
1900 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1901 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1902 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1907 $pdf->SetTextColor(0, 0, 0);
1909 $creditnoteamount = $object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1910 $depositsamount = $object->getSumDepositsUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1912 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1913 if (!empty($object->paye)) {
1917 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) {
1920 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1921 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"Paid") :
''), 0,
'L', 0);
1922 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1923 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1926 if ($creditnoteamount) {
1927 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1928 $labeltouse .= (is_object($outputlangsbis) ? (
' / '.($outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities(
"CreditNotes")) :
'');
1930 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1931 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1932 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1933 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1952 $pdf->SetTextColor(0, 0, 60);
1953 $pdf->SetFillColor(224, 224, 224);
1954 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1955 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1956 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1957 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1959 $pdf->SetFont(
'',
'', $default_font_size - 1);
1960 $pdf->SetTextColor(0, 0, 0);
1964 return ($tab2_top + ($tab2_hl * $index));
1978 return parent::liste_modeles($db, $maxfilenamelength);
1996 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis =
null)
2006 $currency = !empty($currency) ? $currency : $conf->currency;
2010 $pdf->SetTextColor(0, 0, 0);
2011 $pdf->SetFont(
'',
'', $default_font_size - 2);
2013 if (empty($hidetop)) {
2015 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
2016 $categoryOfOperations = $outputlangs->transnoentities(
"MentionCategoryOfOperations") .
' : ' . $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
2017 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
2018 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
2021 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
2022 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
2023 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
2026 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
2027 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
2030 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
2031 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight,
'F',
null, explode(
',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
2035 $pdf->SetDrawColor(128, 128, 128);
2036 $pdf->SetFont(
'',
'', $default_font_size - 1);
2039 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
2042 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
2044 if (empty($hidetop)) {
2045 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight);
2060 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
2062 global $conf, $langs;
2064 $ltrdirection =
'L';
2065 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
2068 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2074 $pdf->SetTextColor(0, 0, 60);
2075 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2079 $posy = $this->marge_haute;
2080 $posx = $this->page_largeur - $this->marge_droite - $w;
2082 $pdf->SetXY($this->marge_gauche, $posy);
2086 if ($this->emetteur->logo) {
2087 $logodir = $conf->mycompany->dir_output;
2088 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
2089 $logodir = $conf->mycompany->multidir_output[$object->entity];
2092 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2094 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2096 if (is_readable($logo)) {
2098 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2100 $pdf->SetTextColor(200, 0, 0);
2101 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2102 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2103 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2106 $text = $this->emetteur->name;
2107 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2111 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2112 $pdf->SetXY($posx, $posy);
2113 $pdf->SetTextColor(0, 0, 60);
2114 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2115 if ($object->type == 1) {
2116 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2118 if ($object->type == 2) {
2119 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2121 if ($object->type == 3) {
2122 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2124 if ($object->type == 4) {
2125 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2127 if ($this->situationinvoice) {
2128 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
2130 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
2132 if ($object->type == 0) {
2133 if ($this->situationinvoice) {
2134 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2136 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2137 } elseif ($object->type == 1) {
2138 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2139 } elseif ($object->type == 2) {
2140 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2141 } elseif ($object->type == 3) {
2142 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2143 } elseif ($object->type == 4) {
2144 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2147 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
2148 if ($object->statut == $object::STATUS_DRAFT) {
2149 $pdf->SetTextColor(128, 0, 0);
2150 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2153 $pdf->MultiCell($w, 3, $title,
'',
'R');
2155 $pdf->SetFont(
'',
'B', $default_font_size);
2169 $pdf->SetFont(
'',
'', $default_font_size - 2);
2171 if ($object->ref_client) {
2173 $pdf->SetXY($posx, $posy);
2174 $pdf->SetTextColor(0, 0, 60);
2175 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65),
'',
'R');
2178 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
2179 $object->fetch_projet();
2180 if (!empty($object->project->ref)) {
2182 $pdf->SetXY($posx, $posy);
2183 $pdf->SetTextColor(0, 0, 60);
2184 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
2188 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
2189 $object->fetch_projet();
2190 if (!empty($object->project->ref)) {
2191 $outputlangs->load(
"projects");
2193 $pdf->SetXY($posx, $posy);
2194 $pdf->SetTextColor(0, 0, 60);
2195 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
2199 $objectidnext = $object->getIdReplacingInvoice(
'validated');
2200 if ($object->type == 0 && $objectidnext) {
2201 $objectreplacing =
new Facture($this->
db);
2202 $objectreplacing->fetch($objectidnext);
2205 $pdf->SetXY($posx, $posy);
2206 $pdf->SetTextColor(0, 0, 60);
2207 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2209 if ($object->type == 1) {
2210 $objectreplaced =
new Facture($this->
db);
2211 $objectreplaced->fetch($object->fk_facture_source);
2214 $pdf->SetXY($posx, $posy);
2215 $pdf->SetTextColor(0, 0, 60);
2216 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2218 if ($object->type == 2 && !empty($object->fk_facture_source)) {
2219 $objectreplaced =
new Facture($this->
db);
2220 $objectreplaced->fetch($object->fk_facture_source);
2223 $pdf->SetXY($posx, $posy);
2224 $pdf->SetTextColor(0, 0, 60);
2225 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2229 $pdf->SetXY($posx, $posy);
2230 $pdf->SetTextColor(0, 0, 60);
2232 $title = $outputlangs->transnoentities(
"DateInvoice");
2233 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
2234 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2236 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2238 if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) {
2240 $pdf->SetXY($posx, $posy);
2241 $pdf->SetTextColor(0, 0, 60);
2242 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date($object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2245 if ($object->type != 2) {
2247 $pdf->SetXY($posx, $posy);
2248 $pdf->SetTextColor(0, 0, 60);
2249 $title = $outputlangs->transnoentities(
"DateDue");
2250 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
2251 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2253 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2256 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && $object->thirdparty->code_client) {
2258 $pdf->SetXY($posx, $posy);
2259 $pdf->SetTextColor(0, 0, 60);
2260 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
2264 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
2265 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
2266 if (count($arrayidcontact) > 0) {
2267 $usertmp =
new User($this->
db);
2268 $usertmp->fetch($arrayidcontact[0]);
2270 $pdf->SetXY($posx, $posy);
2271 $pdf->SetTextColor(0, 0, 60);
2272 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2281 $current_y = $pdf->getY();
2282 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
2283 if ($current_y < $pdf->getY()) {
2284 $top_shift = $pdf->getY() - $current_y;
2289 $carac_emetteur =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
2292 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
2293 $posy += $top_shift;
2294 $posx = $this->marge_gauche;
2295 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
2296 $posx = $this->page_largeur - $this->marge_droite - 80;
2299 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
2300 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
2303 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
2304 $pdf->SetTextColor(0, 0, 0);
2305 $pdf->SetFont(
'',
'', $default_font_size - 2);
2306 $pdf->SetXY($posx, $posy - 5);
2307 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2308 $pdf->SetXY($posx, $posy);
2309 $pdf->SetFillColor(230, 230, 230);
2310 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2311 $pdf->SetTextColor(0, 0, 60);
2315 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
2316 $pdf->SetXY($posx + 2, $posy + 3);
2317 $pdf->SetFont(
'',
'B', $default_font_size);
2318 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2319 $posy = $pdf->getY();
2323 $pdf->SetXY($posx + 2, $posy);
2324 $pdf->SetFont(
'',
'', $default_font_size - 1);
2325 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2328 $usecontact =
false;
2329 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
2330 if (count($arrayidcontact) > 0) {
2332 $result = $object->fetch_contact($arrayidcontact[0]);
2336 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
2337 $thirdparty = $object->contact;
2339 $thirdparty = $object->thirdparty;
2345 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
2348 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
2349 if ($this->page_largeur < 210) {
2352 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
2353 $posy += $top_shift;
2354 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2355 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
2356 $posx = $this->marge_gauche;
2360 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
2361 $pdf->SetTextColor(0, 0, 0);
2362 $pdf->SetFont(
'',
'', $default_font_size - 2);
2363 $pdf->SetXY($posx + 2, $posy - 5);
2364 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2365 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2369 $pdf->SetXY($posx + 2, $posy + 3);
2370 $pdf->SetFont(
'',
'B', $default_font_size);
2371 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2373 $posy = $pdf->getY();
2376 $pdf->SetFont(
'',
'', $default_font_size - 1);
2377 $pdf->SetXY($posx + 2, $posy);
2378 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2382 $idaddressshipping = $object->getIdContact(
'external',
'SHIPPING');
2384 if (!empty($idaddressshipping)) {
2385 $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
2386 $object->fetch_thirdparty($object->contact->fk_soc);
2388 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact,
'target', $object);
2391 $carac_client_shipping=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'target', $object);
2393 if (!empty($carac_client_shipping) && (isset($object->contact->socid) && $object->contact->socid != $object->socid)) {
2394 $posy += $hautcadre;
2397 $pdf->SetXY($posx + 2, $posy - 5);
2398 $pdf->SetFont(
'',
'', $default_font_size - 2);
2399 $pdf->MultiCell($widthrecbox,
'', $langs->trans(
'ShippingTo'), 0,
'L', 0);
2400 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2403 $pdf->SetXY($posx + 2, $posy + 3);
2404 $pdf->SetFont(
'',
'B', $default_font_size);
2405 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2407 $posy = $pdf->getY();
2410 $pdf->SetXY($posx+2, $posy);
2411 $pdf->SetFont(
'',
'', $default_font_size - 1);
2412 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2413 $shipp_shift += $hautcadre;
2418 $pdf->SetTextColor(0, 0, 0);
2420 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);
2434 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
2436 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
2437 return pdf_pagefoot($pdf, $outputlangs,
'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
2450 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2452 global $conf, $hookmanager;
2455 $this->defaultContentsFieldsStyle = array(
2457 'padding' => array(1, 0.5, 1, 0.5),
2461 $this->defaultTitlesFieldsStyle = array(
2463 'padding' => array(0.5, 0, 0.5, 0),
2485 $this->cols[
'desc'] = array(
2490 'textkey' =>
'Designation',
2494 'padding' => array(0.5, 0.5, 0.5, 0.5),
2498 'padding' => array(1, 0.5, 1, 1.5),
2504 $this->cols[
'photo'] = array(
2506 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
2509 'textkey' =>
'Photo',
2513 'padding' => array(0, 0, 0, 0),
2515 'border-left' =>
false,
2518 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto)) {
2519 $this->cols[
'photo'][
'status'] =
true;
2524 $this->cols[
'vat'] = array(
2531 'border-left' =>
true,
2534 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
2535 $this->cols[
'vat'][
'status'] =
true;
2539 $this->cols[
'subprice'] = array(
2544 'textkey' =>
'PriceUHT'
2546 'border-left' =>
true,
2551 $nblines = count($object->lines);
2552 for ($i = 0; $i < $nblines; $i++) {
2554 $tmpwidth = max($tmpwidth, $tmpwidth2);
2556 if ($tmpwidth > 10) {
2557 $this->cols[
'subprice'][
'width'] += (2 * ($tmpwidth - 10));
2561 $this->cols[
'qty'] = array(
2568 'border-left' =>
true,
2572 $this->cols[
'progress'] = array(
2577 'textkey' =>
'Progress'
2579 'border-left' =>
true,
2582 if ($this->situationinvoice) {
2583 $this->cols[
'progress'][
'status'] =
true;
2587 $this->cols[
'unit'] = array(
2594 'border-left' =>
true,
2597 $this->cols[
'unit'][
'status'] =
true;
2601 $this->cols[
'discount'] = array(
2606 'textkey' =>
'ReductionShort'
2608 'border-left' =>
true,
2610 if ($this->atleastonediscount) {
2611 $this->cols[
'discount'][
'status'] =
true;
2614 $rank = $rank + 1000;
2615 $this->cols[
'totalexcltax'] = array(
2618 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ?
true :
false,
2620 'textkey' =>
'TotalHT'
2622 'border-left' =>
true,
2625 $rank = $rank + 1010;
2626 $this->cols[
'totalincltax'] = array(
2629 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ?
false :
true,
2631 'textkey' =>
'TotalTTC'
2633 'border-left' =>
true,
2637 if (!empty($object->lines)) {
2638 $line = reset($object->lines);
2642 $parameters = array(
2643 'object' => $object,
2644 'outputlangs' => $outputlangs,
2645 'hidedetails' => $hidedetails,
2646 'hidedesc' => $hidedesc,
2647 'hideref' => $hideref
2650 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
2653 } elseif (empty($reshook)) {
2654 $this->cols = array_replace($this->cols, $hookmanager->resArray);
2656 $this->cols = $hookmanager->resArray;
Class to manage bank accounts.
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.
Class to manage bank accounts description of third parties.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
Parent class of invoice document generators.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage translations.
Class to manage Dolibarr users.
Class to manage PDF invoice template sponge.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
__construct($db)
Constructor.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
Show total to pay.
drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
Show payments table.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='', $outputlangsbis=null)
Show table for lines.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null)
Show top header of page.
drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
Show miscellaneous information (payment mode, payment term, ...)
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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...
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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...
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
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)
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
div float
Buy price without taxes.
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails=0)
Return line total amount discount.
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_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.
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_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
pdf_getlineprogress($object, $i, $outputlangs, $hidedetails=0, $hookmanager=null)
Return line percent.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
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_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations 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_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
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.
$conf db
API class for accounts.