35 require_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
36 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
65 public $update_main_doc_field;
76 public $phpmin = array(7, 0);
82 public $version =
'dolibarr';
102 public $marge_gauche;
107 public $marge_droite;
123 public $heightforinfotot;
128 public $heightforfreetext;
133 public $heightforfooter;
143 public $tab_top_newpage;
154 public $situationinvoice;
165 public $categoryOfOperation = -1;
175 global $conf, $langs, $mysoc;
178 $langs->loadLangs(array(
"main",
"bills"));
181 $this->
name =
"sponge";
182 $this->
description = $langs->trans(
'PDFSpongeDescription');
183 $this->update_main_doc_field = 1;
188 $this->page_largeur = $formatarray[
'width'];
189 $this->page_hauteur = $formatarray[
'height'];
190 $this->format = array($this->page_largeur, $this->page_hauteur);
196 $this->option_logo = 1;
197 $this->option_tva = 1;
198 $this->option_modereg = 1;
199 $this->option_condreg = 1;
200 $this->option_multilang = 1;
201 $this->option_escompte = 1;
202 $this->option_credit_note = 1;
203 $this->option_freetext = 1;
204 $this->option_draft_watermark = 1;
205 $this->watermark =
'';
208 $this->emetteur = $mysoc;
209 if (empty($this->emetteur->country_code)) {
210 $this->emetteur->country_code = substr($langs->defaultlang, -2);
214 $this->posxdesc = $this->marge_gauche + 1;
217 $this->tabTitleHeight = 5;
221 $this->tva = array();
222 $this->tva_array = array();
223 $this->localtax1 = array();
224 $this->localtax2 = array();
225 $this->atleastoneratenotnull = 0;
226 $this->atleastonediscount = 0;
227 $this->situationinvoice =
false;
243 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
246 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
248 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
250 if (!is_object($outputlangs)) {
251 $outputlangs = $langs;
254 if (!empty($conf->global->MAIN_USE_FPDF)) {
255 $outputlangs->charset_output =
'ISO-8859-1';
259 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
261 global $outputlangsbis;
262 $outputlangsbis =
null;
263 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
264 $outputlangsbis =
new Translate(
'', $conf);
265 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
266 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
270 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) {
271 $this->watermark = $conf->global->FACTURE_DRAFT_WATERMARK;
274 $nblines = count($object->lines);
277 if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
278 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
282 $realpatharray = array();
283 $this->atleastonephoto =
false;
284 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) {
287 for ($i = 0; $i < $nblines; $i++) {
288 if (empty($object->lines[$i]->fk_product)) {
292 $objphoto->fetch($object->lines[$i]->fk_product);
295 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
296 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
298 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
299 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
303 foreach ($pdir as $midir) {
305 if ($conf->entity != $objphoto->entity) {
306 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
308 $dir = $conf->product->dir_output.
'/'.$midir;
311 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
313 if ($obj[
'photo_vignette']) {
314 $filename = $obj[
'photo_vignette'];
316 $filename = $obj[
'photo'];
319 $filename = $obj[
'photo'];
322 $realpath = $dir.$filename;
324 $this->atleastonephoto =
true;
329 if ($realpath && $arephoto) {
330 $realpatharray[$i] = $realpath;
337 if ($conf->facture->multidir_output[$conf->entity]) {
338 $object->fetch_thirdparty();
340 $deja_regle = $object->getSommePaiement((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
341 $amount_credit_notes_included = $object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
342 $amount_deposits_included = $object->getSumDepositsUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
345 if ($object->specimen) {
346 $dir = $conf->facture->multidir_output[$conf->entity];
347 $file = $dir.
"/SPECIMEN.pdf";
350 $dir = $conf->facture->multidir_output[$object->entity].
"/".$objectref;
351 $file = $dir.
"/".$objectref.
".pdf";
353 if (!file_exists($dir)) {
355 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
360 if (file_exists($dir)) {
362 if (!is_object($hookmanager)) {
363 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
366 $hookmanager->initHooks(array(
'pdfgeneration'));
367 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
369 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
372 $nblines = count($object->lines);
373 $nbpayments = count($object->getListOfPayments());
378 $pdf->SetAutoPageBreak(1, 0);
380 $this->heightforinfotot = 50 + (4 * $nbpayments);
381 $this->heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
382 $this->heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22);
384 if (class_exists(
'TCPDF')) {
385 $pdf->setPrintHeader(
false);
386 $pdf->setPrintFooter(
false);
391 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
392 $logodir = $conf->mycompany->dir_output;
393 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
394 $logodir = $conf->mycompany->multidir_output[$object->entity];
396 $pagecount = $pdf->setSourceFile($logodir.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
397 $tplidx = $pdf->importPage(1);
402 $pdf->SetDrawColor(128, 128, 128);
404 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
405 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
406 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
407 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
408 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
410 $pdf->SetCompression(
false);
414 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
415 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
418 $cert = empty($conf->global->CERTIFICATE_CRT) ?
'' : $conf->global->CERTIFICATE_CRT;
421 $certprivate = empty($conf->global->CERTIFICATE_CRT_PRIVATE) ?
'' : $conf->global->CERTIFICATE_CRT_PRIVATE;
426 'Name' => $this->emetteur->name,
427 'Location' =>
getCountry($this->emetteur->country_code, 0),
428 'Reason' =>
'INVOICE',
429 'ContactInfo' => $this->emetteur->email
431 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
434 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
438 $categoryOfOperation = 0;
441 for ($i = 0; $i < $nblines; $i++) {
442 if ($object->lines[$i]->remise_percent) {
443 $this->atleastonediscount++;
447 if ($categoryOfOperation < 2) {
448 $lineProductType = $object->lines[$i]->product_type;
454 if ($nbProduct > 0 && $nbService > 0) {
456 $categoryOfOperation = 2;
461 if ($categoryOfOperation <= 0) {
463 if ($nbProduct == 0 && $nbService > 0) {
464 $categoryOfOperation = 1;
467 $this->categoryOfOperation = $categoryOfOperation;
470 if ($object->situation_cycle_ref) {
471 $this->situationinvoice =
true;
476 if (!empty($tplidx)) {
477 $pdf->useTemplate($tplidx);
482 $pagehead = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
483 $top_shift = $pagehead[
'top_shift'];
484 $shipp_shift = $pagehead[
'shipp_shift'];
485 $pdf->SetFont(
'',
'', $default_font_size - 1);
486 $pdf->MultiCell(0, 3,
'');
487 $pdf->SetTextColor(0, 0, 0);
492 $this->tab_top = 90 + $top_shift + $shipp_shift;
493 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
496 $extra_under_address_shift = 0;
498 if (!empty($conf->global->INVOICE_ADD_ZATCA_QR_CODE)) {
499 $qrcodestring = $object->buildZATCAQRString();
500 } elseif (!empty($conf->global->INVOICE_ADD_SWISS_QR_CODE)) {
501 $qrcodestring = $object->buildSwitzerlandQRString();
504 $qrcodecolor = array(
'25',
'25',
'25');
509 'fgcolor' => $qrcodecolor,
514 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
515 $extra_under_address_shift += 25;
523 'outputlangs' => $outputlangs,
524 'hidedetails' => $hidedetails
526 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
527 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
528 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_header_shift'];
531 $this->tab_top += $extra_under_address_shift;
532 $this->tab_top_newpage += 0;
536 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext;
538 $nexY = $this->tab_top - 1;
541 $height_incoterms = 0;
543 $desc_incoterms = $object->getIncotermsForPDF();
544 if ($desc_incoterms) {
547 $pdf->SetFont(
'',
'', $default_font_size - 1);
548 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
549 $nexY = max($pdf->GetY(), $nexY);
550 $height_incoterms = $nexY - $this->tab_top;
553 $pdf->SetDrawColor(192, 192, 192);
554 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
556 $this->tab_top = $nexY + 6;
557 $height_incoterms += 4;
562 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
563 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
565 if (is_object($object->thirdparty)) {
566 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
567 $salerepobj =
new User($this->
db);
568 $salerepobj->fetch($salereparray[0][
'id']);
569 if (!empty($salerepobj->signature)) {
570 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
576 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
577 if (!empty($extranote)) {
581 $pagenb = $pdf->getPage();
585 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
586 $pageposbeforenote = $pagenb;
593 $pdf->startTransaction();
595 $pdf->SetFont(
'',
'', $default_font_size - 1);
596 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
598 $pageposafternote = $pdf->getPage();
599 $posyafter = $pdf->GetY();
601 if ($pageposafternote > $pageposbeforenote) {
602 $pdf->rollbackTransaction(
true);
605 while ($pagenb < $pageposafternote) {
608 if (!empty($tplidx)) {
609 $pdf->useTemplate($tplidx);
612 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
615 $pdf->setTopMargin($this->tab_top_newpage);
617 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
621 $pdf->setPage($pageposbeforenote);
622 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
623 $pdf->SetFont(
'',
'', $default_font_size - 1);
624 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
625 $pageposafternote = $pdf->getPage();
627 $posyafter = $pdf->GetY();
629 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
630 $pdf->AddPage(
'',
'',
true);
633 $pdf->setPage($pageposafternote);
634 $pdf->setTopMargin($this->tab_top_newpage);
636 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
642 $i = $pageposbeforenote;
643 while ($i < $pageposafternote) {
647 $pdf->SetDrawColor(128, 128, 128);
649 if ($i > $pageposbeforenote) {
650 $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
651 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
653 $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
654 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
658 $pdf->setPageOrientation(
'', 1, 0);
659 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
665 $pdf->setPage($pageposafternote);
666 if (!empty($tplidx)) {
667 $pdf->useTemplate($tplidx);
670 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
672 $height_note = $posyafter - $this->tab_top_newpage;
673 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
676 $pdf->commitTransaction();
677 $posyafter = $pdf->GetY();
678 $height_note = $posyafter - $this->tab_top;
679 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
682 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
684 $pdf->AddPage(
'',
'',
true);
687 $pdf->setPage($pageposafternote);
688 if (!empty($tplidx)) {
689 $pdf->useTemplate($tplidx);
692 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
695 $posyafter = $this->tab_top_newpage;
699 $tab_height = $tab_height - $height_note;
700 $this->tab_top = $posyafter + 6;
709 $pdf->startTransaction();
710 $this->
pdfTabTitles($pdf, $this->tab_top, $tab_height, $outputlangs, $hidetop);
711 $pdf->rollbackTransaction(
true);
713 $nexY = $this->tab_top + $this->tabTitleHeight;
716 $pageposbeforeprintlines = $pdf->getPage();
717 $pagenb = $pageposbeforeprintlines;
718 for ($i = 0; $i < $nblines; $i++) {
720 $pdf->SetFont(
'',
'', $default_font_size - 1);
721 $pdf->SetTextColor(0, 0, 0);
724 $imglinesize = array();
725 if (!empty($realpatharray[$i])) {
729 $pdf->setTopMargin($this->tab_top_newpage);
730 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot);
731 $pageposbefore = $pdf->getPage();
733 $showpricebeforepagebreak = 1;
735 $posYAfterDescription = 0;
739 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
740 $pdf->AddPage(
'',
'',
true);
741 if (!empty($tplidx)) {
742 $pdf->useTemplate($tplidx);
744 $pdf->setPage($pageposbefore + 1);
746 $curY = $this->tab_top_newpage;
749 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
750 $showpricebeforepagebreak = 1;
752 $showpricebeforepagebreak = 0;
756 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
757 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
759 $posYAfterImage = $curY + $imglinesize[
'height'];
765 $pdf->startTransaction();
767 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
768 $pageposafter = $pdf->getPage();
770 if ($pageposafter > $pageposbefore) {
771 $pdf->rollbackTransaction(
true);
772 $pageposafter = $pageposbefore;
773 $pdf->setPageOrientation(
'', 1, $this->heightforfooter);
775 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
777 $pageposafter = $pdf->getPage();
778 $posyafter = $pdf->GetY();
780 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
781 if ($i == ($nblines - 1)) {
782 $pdf->AddPage(
'',
'',
true);
783 if (!empty($tplidx)) {
784 $pdf->useTemplate($tplidx);
786 $pdf->setPage($pageposafter + 1);
791 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
792 $showpricebeforepagebreak = 1;
794 $showpricebeforepagebreak = 0;
799 $pdf->commitTransaction();
801 $posYAfterDescription = $pdf->GetY();
804 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
806 $pageposafter = $pdf->getPage();
807 $pdf->setPage($pageposbefore);
808 $pdf->setTopMargin($this->marge_haute);
809 $pdf->setPageOrientation(
'', 1, 0);
812 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
813 $pdf->setPage($pageposafter);
814 $curY = $this->tab_top_newpage;
817 $pdf->SetFont(
'',
'', $default_font_size - 1);
823 $nexY = max($pdf->GetY(), $nexY);
830 $nexY = max($pdf->GetY(), $nexY);
838 $nexY = max($pdf->GetY(), $nexY);
845 $nexY = max($pdf->GetY(), $nexY);
850 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
852 $nexY = max($pdf->GetY(), $nexY);
856 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
859 $nexY = max($pdf->GetY(), $nexY);
866 $nexY = max($pdf->GetY(), $nexY);
873 $nexY = max($pdf->GetY(), $nexY);
877 if (!empty($object->lines[$i]->array_options)) {
878 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
880 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
882 $nexY = max($pdf->GetY(), $nexY);
894 'outputlangs' => $outputlangs,
895 'hidedetails' => $hidedetails
897 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
901 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
905 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
906 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
907 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
908 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
910 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
913 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
914 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
916 $tvaligne = $sign * $object->lines[$i]->total_tva;
920 $localtax1ligne = $object->lines[$i]->total_localtax1;
921 $localtax2ligne = $object->lines[$i]->total_localtax2;
922 $localtax1_rate = $object->lines[$i]->localtax1_tx;
923 $localtax2_rate = $object->lines[$i]->localtax2_tx;
924 $localtax1_type = $object->lines[$i]->localtax1_type;
925 $localtax2_type = $object->lines[$i]->localtax2_type;
927 if ($object->remise_percent) {
928 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
930 if ($object->remise_percent) {
931 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
933 if ($object->remise_percent) {
934 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
937 $vatrate = (string) $object->lines[$i]->tva_tx;
940 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
941 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
943 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
944 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
948 if ($localtax1_type && $localtax1ligne != 0) {
949 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
951 if ($localtax2_type && $localtax2ligne != 0) {
952 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
955 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
960 if (!isset($this->tva[$vatrate])) {
961 $this->tva[$vatrate] = 0;
963 $this->tva[$vatrate] += $tvaligne;
964 $vatcode = $object->lines[$i]->vat_src_code;
965 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
966 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
968 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
970 $nexY = max($nexY, $posYAfterImage);
973 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
974 $pdf->setPage($pageposafter);
975 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
977 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
978 $pdf->SetLineStyle(array(
'dash'=>0));
982 while ($pagenb < $pageposafter) {
983 $pdf->setPage($pagenb);
984 if ($pagenb == $pageposbeforeprintlines) {
985 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
987 $this->
_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
989 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
991 $pdf->setPage($pagenb);
992 $pdf->setPageOrientation(
'', 1, 0);
994 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
996 if (!empty($tplidx)) {
997 $pdf->useTemplate($tplidx);
1001 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
1002 if ($pagenb == $pageposafter) {
1003 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
1005 $this->
_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
1007 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
1010 if (!empty($tplidx)) {
1011 $pdf->useTemplate($tplidx);
1015 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1021 if ($pagenb == $pageposbeforeprintlines) {
1022 $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);
1023 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
1025 $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);
1026 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
1030 $posy = $this->
drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
1033 $posy = $this->
drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1036 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) {
1041 $this->
_pagefoot($pdf, $object, $outputlangs);
1042 if (method_exists($pdf,
'AliasNbPages')) {
1043 $pdf->AliasNbPages();
1048 $pdf->Output($file,
'F');
1051 $hookmanager->initHooks(array(
'pdfgeneration'));
1052 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
1054 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1056 $this->error = $hookmanager->error;
1057 $this->errors = $hookmanager->errors;
1060 if (!empty($conf->global->MAIN_UMASK)) {
1061 @chmod($file, octdec($conf->global->MAIN_UMASK));
1064 $this->result = array(
'fullpath'=>$file);
1068 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1072 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1092 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1097 $tab3_top = $posy + 8;
1100 if ($this->page_largeur < 210) {
1106 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1107 if ($object->type == 2) {
1108 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1111 $pdf->SetFont(
'',
'', $default_font_size - 3);
1112 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1113 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1115 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1117 $pdf->SetFont(
'',
'', $default_font_size - 4);
1118 $pdf->SetXY($tab3_posx, $tab3_top);
1119 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1120 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1121 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1122 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1123 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1124 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1125 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1127 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1131 $pdf->SetFont(
'',
'', $default_font_size - 4);
1135 $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,";
1136 $sql .=
" re.description, re.fk_facture_source,";
1137 $sql .=
" f.type, f.datef";
1138 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1139 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int) $object->id);
1142 $num = $this->
db->num_rows(
$resql);
1147 $obj = $this->
db->fetch_object(
$resql);
1149 if ($obj->type == 2) {
1150 $text = $outputlangs->transnoentities(
"CreditNote");
1151 } elseif ($obj->type == 3) {
1152 $text = $outputlangs->transnoentities(
"Deposit");
1153 } elseif ($obj->type == 0) {
1154 $text = $outputlangs->transnoentities(
"ExcessReceived");
1156 $text = $outputlangs->transnoentities(
"UnknownType");
1159 $invoice->fetch($obj->fk_facture_source);
1161 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1162 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1163 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1164 $pdf->MultiCell(20, 3,
price((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1165 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1166 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1167 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1168 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1170 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1175 $this->error = $this->
db->lasterror();
1181 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1183 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1184 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1185 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
1187 $sql .=
" ORDER BY p.datep";
1191 $num = $this->
db->num_rows(
$resql);
1195 $row = $this->
db->fetch_object(
$resql);
1197 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1198 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1199 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1200 $pdf->MultiCell(20, 3,
price($sign * ((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1201 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1202 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1204 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1205 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1206 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1208 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1213 return $tab3_top + $y + 3;
1215 $this->error = $this->
db->lasterror();
1231 protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
1233 global $conf, $mysoc;
1237 $pdf->SetFont(
'',
'', $default_font_size - 1);
1240 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1241 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1242 $pdf->SetXY($this->marge_gauche, $posy);
1243 if ($mysoc->forme_juridique_code == 92) {
1244 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1246 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1249 $posy = $pdf->GetY() + 4;
1254 if ($this->page_largeur < 210) {
1259 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
1260 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1261 $pdf->SetXY($this->marge_gauche, $posy);
1262 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1263 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1265 $pdf->SetFont(
'',
'', $default_font_size - 2);
1266 $pdf->SetXY($posxval, $posy);
1267 $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);
1268 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1269 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1271 $posy = $pdf->GetY() + 3;
1275 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1276 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1277 $pdf->SetXY($this->marge_gauche, $posy);
1278 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1279 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1281 $pdf->SetFont(
'',
'', $default_font_size - 2);
1282 $pdf->SetXY($posxval, $posy);
1283 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1284 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1286 $posy = $pdf->GetY() + 3;
1289 if ($object->type != 2) {
1291 if (empty($object->mode_reglement_code)
1292 && empty($conf->global->FACTURE_CHQ_NUMBER)
1294 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1295 } elseif (($object->mode_reglement_code ==
'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
1296 || ($object->mode_reglement_code ==
'VIR' && !
getDolGlobalInt(
'FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
1298 $outputlangs->load(
"errors");
1300 $pdf->SetXY($this->marge_gauche, $posy);
1301 $pdf->SetTextColor(200, 0, 0);
1302 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1303 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1304 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1305 $pdf->SetTextColor(0, 0, 0);
1307 $posy = $pdf->GetY() + 1;
1311 if (!empty($object->mode_reglement_code)
1312 && $object->mode_reglement_code !=
'CHQ'
1313 && $object->mode_reglement_code !=
'VIR') {
1314 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1315 $pdf->SetXY($this->marge_gauche, $posy);
1316 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1317 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1319 $pdf->SetFont(
'',
'', $default_font_size - 2);
1320 $pdf->SetXY($posxval, $posy);
1321 $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);
1324 if ($object->mode_reglement_code ==
"PRE") {
1325 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1327 $bac->fetch(0, $object->thirdparty->id);
1328 $iban= $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1329 $lib_mode_reg .= $outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1332 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1334 $posy = $pdf->GetY();
1340 if ($this->emetteur->country_code ==
'FR') {
1341 if (isset($conf->global->TAX_MODE) && $conf->global->TAX_MODE == 1) {
1342 $pdf->SetXY($this->marge_gauche, $posy);
1343 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1345 $posy = $pdf->GetY() + 1;
1350 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CB' || $object->mode_reglement_code ==
'VAD') {
1351 $useonlinepayment = 0;
1352 if (!empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)) {
1354 $useonlinepayment++;
1357 $useonlinepayment++;
1360 $useonlinepayment++;
1366 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1369 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1370 $servicename = $langs->transnoentities(
'Online');
1371 $paiement_url = getOnlinePaymentUrl(
'',
'invoice', $object->ref,
'',
'',
'');
1372 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1374 $pdf->SetXY($this->marge_gauche, $posy);
1375 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1377 $posy = $pdf->GetY() + 1;
1382 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1384 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
1385 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1387 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
1389 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1391 $pdf->SetXY($this->marge_gauche, $posy);
1392 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1393 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1394 $posy = $pdf->GetY() + 1;
1396 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1397 $pdf->SetXY($this->marge_gauche, $posy);
1398 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1399 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1400 $posy = $pdf->GetY() + 2;
1403 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1404 $pdf->SetXY($this->marge_gauche, $posy);
1405 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1406 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1407 $posy = $pdf->GetY() + 1;
1409 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1410 $pdf->SetXY($this->marge_gauche, $posy);
1411 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1412 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1413 $posy = $pdf->GetY() + 2;
1420 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1421 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1422 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1423 if ($object->fk_bank > 0) {
1424 $bankid = $object->fk_bank;
1427 $account->fetch($bankid);
1429 $curx = $this->marge_gauche;
1432 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1454 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
1456 global $conf, $mysoc, $hookmanager;
1459 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1467 if (is_object($outputlangsbis)) {
1468 $pdf->SetFont(
'',
'', $default_font_size - 2);
1470 $pdf->SetFont(
'',
'', $default_font_size - 1);
1476 if ($this->page_largeur < 210) {
1480 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1486 $parameters = array(
1487 'object' => &$object,
1488 'outputlangs' => $outputlangs,
1490 $hookmanager->executeHooks(
'beforePercentCalculation', $parameters, $this);
1495 foreach ($object->lines as $line) {
1496 $percent += $line->situation_percent;
1501 $avancementGlobal = $percent / $i;
1503 $avancementGlobal = 0;
1506 $object->fetchPreviousNextSituationInvoice();
1507 $TPreviousIncoice = $object->tab_previous_situation_invoice;
1510 $total_a_payer_ttc = 0;
1511 foreach ($TPreviousIncoice as &$fac) {
1512 $total_a_payer += $fac->total_ht;
1513 $total_a_payer_ttc += $fac->total_ttc;
1515 $total_a_payer += $object->total_ht;
1516 $total_a_payer_ttc += $object->total_ttc;
1518 if (!empty($avancementGlobal)) {
1519 $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
1520 $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
1523 $total_a_payer_ttc = 0;
1527 if (!empty($TPreviousIncoice)) {
1528 $pdf->setY($tab2_top);
1529 $posy = $pdf->GetY();
1531 foreach ($TPreviousIncoice as &$fac) {
1532 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1533 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
1536 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1537 $pdf->setY($this->tab_top_newpage);
1539 $pdf->setY($this->marge_haute);
1541 $posy = $pdf->GetY();
1546 $pdf->SetFillColor(255, 255, 255);
1547 $pdf->SetXY($col1x, $posy);
1548 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $fac->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1550 $pdf->SetXY($col2x, $posy);
1554 $facSign = $fac->total_ht >= 0 ?
'+' :
'';
1557 $displayAmount =
' '.$facSign.
' '.
price($fac->total_ht, 0, $outputlangs);
1559 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1568 $pdf->SetFillColor(255, 255, 255);
1569 $pdf->SetXY($col1x, $posy);
1570 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $object->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1572 $pdf->SetXY($col2x, $posy);
1575 $facSign = $object->total_ht >= 0 ?
'+' :
'';
1578 if ($fac->type === facture::TYPE_CREDIT_NOTE) {
1583 $displayAmount =
' '.$facSign.
' '.
price($object->total_ht, 0, $outputlangs);
1584 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1589 $pdf->SetFont(
'',
'', $default_font_size - 1);
1590 $pdf->SetFillColor(255, 255, 255);
1591 $pdf->SetXY($col1x, $posy);
1592 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"SituationTotalProgress", $avancementGlobal), 0,
'L', 1);
1594 $pdf->SetXY($col2x, $posy);
1595 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0,
'R', 1);
1596 $pdf->SetFont(
'',
'', $default_font_size - 2);
1600 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1603 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1604 $pdf->setY($this->tab_top_newpage);
1606 $pdf->setY($this->marge_haute);
1609 $posy = $pdf->GetY();
1620 $total_ht = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1623 $total_line_remise = 0;
1624 foreach ($object->lines as $i => $line) {
1627 if ($line->total_ht < 0) {
1628 $total_line_remise += -$line->total_ht;
1631 if ($total_line_remise > 0) {
1632 if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
1633 $pdf->SetFillColor(255, 255, 255);
1634 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1635 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1636 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1637 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1642 if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
1643 $pdf->SetFillColor(255, 255, 255);
1644 $pdf->SetXY($col1x, $tab2_top + 0);
1645 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1646 $pdf->SetXY($col2x, $tab2_top + 0);
1647 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1654 $pdf->SetFillColor(255, 255, 255);
1655 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1656 $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);
1658 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1659 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1660 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1663 $pdf->SetFillColor(248, 248, 248);
1665 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1667 $this->atleastoneratenotnull = 0;
1668 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
1669 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1670 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
1678 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1679 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1683 foreach ($localtax_rate as $tvakey => $tvaval) {
1688 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1691 if (preg_match(
'/\*/', $tvakey)) {
1692 $tvakey = str_replace(
'*',
'', $tvakey);
1693 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1696 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1698 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1699 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1701 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1702 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1710 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1711 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1715 foreach ($localtax_rate as $tvakey => $tvaval) {
1720 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1723 if (preg_match(
'/\*/', $tvakey)) {
1724 $tvakey = str_replace(
'*',
'', $tvakey);
1725 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1727 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1729 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1730 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1732 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1733 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1740 if (
getDolGlobalInt(
'INVOICE_USE_SITUATION') == 1 && $object->situation_cycle_ref && $object->situation_counter > 1) {
1742 foreach ($this->tva as $tvakey => $tvaval) {
1743 $sum_pdf_tva += $tvaval;
1746 if ($sum_pdf_tva != $object->total_tva) {
1747 if (!empty($sum_pdf_tva)) {
1748 $coef_fix_tva = $object->total_tva / $sum_pdf_tva;
1754 foreach ($this->tva as $tvakey => $tvaval) {
1755 $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1757 foreach ($this->tva_array as $tvakey => $tvaval) {
1758 $this->tva_array[$tvakey][
'amount'] = $tvaval[
'amount'] * $coef_fix_tva;
1764 foreach ($this->tva_array as $tvakey => $tvaval) {
1766 $this->atleastoneratenotnull++;
1769 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1772 if (preg_match(
'/\*/', $tvakey)) {
1773 $tvakey = str_replace(
'*',
'', $tvakey);
1774 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1776 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1779 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1781 $totalvat .= ($tvaval[
'vatcode'] ? $tvaval[
'vatcode'] :
vatrate($tvaval[
'vatrate'], 1)).$tvacompl;
1783 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1785 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1787 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1788 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1795 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1796 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1800 foreach ($localtax_rate as $tvakey => $tvaval) {
1805 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1808 if (preg_match(
'/\*/', $tvakey)) {
1809 $tvakey = str_replace(
'*',
'', $tvakey);
1810 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1812 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1814 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1816 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1817 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1818 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1826 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1827 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1831 foreach ($localtax_rate as $tvakey => $tvaval) {
1837 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1840 if (preg_match(
'/\*/', $tvakey)) {
1841 $tvakey = str_replace(
'*',
'', $tvakey);
1842 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1844 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1847 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1848 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1850 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1851 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1858 if (
price2num($object->revenuestamp) != 0) {
1860 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1861 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1863 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1864 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $object->revenuestamp), $useborder,
'R', 1);
1869 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1870 $pdf->SetTextColor(0, 0, 60);
1871 $pdf->SetFillColor(224, 224, 224);
1872 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1874 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1875 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1879 if ($object->displayRetainedWarranty()) {
1880 $pdf->SetTextColor(40, 40, 40);
1881 $pdf->SetFillColor(255, 255, 255);
1883 $retainedWarranty = $object->getRetainedWarrantyAmount();
1884 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1888 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1889 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date($object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1891 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1892 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1896 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1898 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.$object->retained_warranty.
'%)';
1899 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date($object->retained_warranty_date_limit,
'day')) :
'';
1901 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1902 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1903 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1908 $pdf->SetTextColor(0, 0, 0);
1910 $creditnoteamount = $object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1911 $depositsamount = $object->getSumDepositsUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1913 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1914 if (!empty($object->paye)) {
1918 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) {
1921 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1922 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"Paid") :
''), 0,
'L', 0);
1923 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1924 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1927 if ($creditnoteamount) {
1928 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1929 $labeltouse .= (is_object($outputlangsbis) ? (
' / '.($outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities(
"CreditNotes")) :
'');
1931 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1932 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1933 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1934 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1953 $pdf->SetTextColor(0, 0, 60);
1954 $pdf->SetFillColor(224, 224, 224);
1955 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1956 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1957 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1958 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1960 $pdf->SetFont(
'',
'', $default_font_size - 1);
1961 $pdf->SetTextColor(0, 0, 0);
1965 return ($tab2_top + ($tab2_hl * $index));
1979 return parent::liste_modeles($db, $maxfilenamelength);
1997 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis =
null)
2007 $currency = !empty($currency) ? $currency : $conf->currency;
2011 $pdf->SetTextColor(0, 0, 0);
2012 $pdf->SetFont(
'',
'', $default_font_size - 2);
2014 if (empty($hidetop)) {
2016 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
2017 $categoryOfOperations = $outputlangs->transnoentities(
"MentionCategoryOfOperations") .
' : ' . $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
2018 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
2019 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
2022 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
2023 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
2024 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
2027 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
2028 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
2031 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
2032 $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));
2036 $pdf->SetDrawColor(128, 128, 128);
2037 $pdf->SetFont(
'',
'', $default_font_size - 1);
2040 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
2043 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
2045 if (empty($hidetop)) {
2046 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight);
2061 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
2063 global $conf, $langs;
2065 $ltrdirection =
'L';
2066 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
2069 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2075 $pdf->SetTextColor(0, 0, 60);
2076 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2080 $posy = $this->marge_haute;
2081 $posx = $this->page_largeur - $this->marge_droite - $w;
2083 $pdf->SetXY($this->marge_gauche, $posy);
2086 if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
2087 if ($this->emetteur->logo) {
2088 $logodir = $conf->mycompany->dir_output;
2089 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
2090 $logodir = $conf->mycompany->multidir_output[$object->entity];
2092 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
2093 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2095 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2097 if (is_readable($logo)) {
2099 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2101 $pdf->SetTextColor(200, 0, 0);
2102 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2103 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2104 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2107 $text = $this->emetteur->name;
2108 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2112 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2113 $pdf->SetXY($posx, $posy);
2114 $pdf->SetTextColor(0, 0, 60);
2115 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2116 if ($object->type == 1) {
2117 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2119 if ($object->type == 2) {
2120 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2122 if ($object->type == 3) {
2123 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2125 if ($object->type == 4) {
2126 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2128 if ($this->situationinvoice) {
2129 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
2131 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
2133 if ($object->type == 0) {
2134 if ($this->situationinvoice) {
2135 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2137 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2138 } elseif ($object->type == 1) {
2139 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2140 } elseif ($object->type == 2) {
2141 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2142 } elseif ($object->type == 3) {
2143 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2144 } elseif ($object->type == 4) {
2145 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2148 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
2149 if ($object->statut == $object::STATUS_DRAFT) {
2150 $pdf->SetTextColor(128, 0, 0);
2151 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2154 $pdf->MultiCell($w, 3, $title,
'',
'R');
2156 $pdf->SetFont(
'',
'B', $default_font_size);
2170 $pdf->SetFont(
'',
'', $default_font_size - 2);
2172 if ($object->ref_client) {
2174 $pdf->SetXY($posx, $posy);
2175 $pdf->SetTextColor(0, 0, 60);
2176 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65),
'',
'R');
2179 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
2180 $object->fetch_projet();
2181 if (!empty($object->project->ref)) {
2183 $pdf->SetXY($posx, $posy);
2184 $pdf->SetTextColor(0, 0, 60);
2185 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
2189 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
2190 $object->fetch_projet();
2191 if (!empty($object->project->ref)) {
2192 $outputlangs->load(
"projects");
2194 $pdf->SetXY($posx, $posy);
2195 $pdf->SetTextColor(0, 0, 60);
2196 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
2200 $objectidnext = $object->getIdReplacingInvoice(
'validated');
2201 if ($object->type == 0 && $objectidnext) {
2202 $objectreplacing =
new Facture($this->
db);
2203 $objectreplacing->fetch($objectidnext);
2206 $pdf->SetXY($posx, $posy);
2207 $pdf->SetTextColor(0, 0, 60);
2208 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2210 if ($object->type == 1) {
2211 $objectreplaced =
new Facture($this->
db);
2212 $objectreplaced->fetch($object->fk_facture_source);
2215 $pdf->SetXY($posx, $posy);
2216 $pdf->SetTextColor(0, 0, 60);
2217 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2219 if ($object->type == 2 && !empty($object->fk_facture_source)) {
2220 $objectreplaced =
new Facture($this->
db);
2221 $objectreplaced->fetch($object->fk_facture_source);
2224 $pdf->SetXY($posx, $posy);
2225 $pdf->SetTextColor(0, 0, 60);
2226 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2230 $pdf->SetXY($posx, $posy);
2231 $pdf->SetTextColor(0, 0, 60);
2233 $title = $outputlangs->transnoentities(
"DateInvoice");
2234 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
2235 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2237 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2239 if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) {
2241 $pdf->SetXY($posx, $posy);
2242 $pdf->SetTextColor(0, 0, 60);
2243 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date($object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2246 if ($object->type != 2) {
2248 $pdf->SetXY($posx, $posy);
2249 $pdf->SetTextColor(0, 0, 60);
2250 $title = $outputlangs->transnoentities(
"DateDue");
2251 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
2252 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2254 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2257 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && $object->thirdparty->code_client) {
2259 $pdf->SetXY($posx, $posy);
2260 $pdf->SetTextColor(0, 0, 60);
2261 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
2265 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
2266 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
2267 if (count($arrayidcontact) > 0) {
2268 $usertmp =
new User($this->
db);
2269 $usertmp->fetch($arrayidcontact[0]);
2271 $pdf->SetXY($posx, $posy);
2272 $pdf->SetTextColor(0, 0, 60);
2273 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2282 $current_y = $pdf->getY();
2283 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
2284 if ($current_y < $pdf->getY()) {
2285 $top_shift = $pdf->getY() - $current_y;
2290 $carac_emetteur =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
2293 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
2294 $posy += $top_shift;
2295 $posx = $this->marge_gauche;
2296 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
2297 $posx = $this->page_largeur - $this->marge_droite - 80;
2300 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
2301 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
2304 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
2305 $pdf->SetTextColor(0, 0, 0);
2306 $pdf->SetFont(
'',
'', $default_font_size - 2);
2307 $pdf->SetXY($posx, $posy - 5);
2308 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2309 $pdf->SetXY($posx, $posy);
2310 $pdf->SetFillColor(230, 230, 230);
2311 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2312 $pdf->SetTextColor(0, 0, 60);
2316 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
2317 $pdf->SetXY($posx + 2, $posy + 3);
2318 $pdf->SetFont(
'',
'B', $default_font_size);
2319 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2320 $posy = $pdf->getY();
2324 $pdf->SetXY($posx + 2, $posy);
2325 $pdf->SetFont(
'',
'', $default_font_size - 1);
2326 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2329 $usecontact =
false;
2330 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
2331 if (count($arrayidcontact) > 0) {
2333 $result = $object->fetch_contact($arrayidcontact[0]);
2337 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)))) {
2338 $thirdparty = $object->contact;
2340 $thirdparty = $object->thirdparty;
2346 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
2349 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
2350 if ($this->page_largeur < 210) {
2353 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
2354 $posy += $top_shift;
2355 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2356 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
2357 $posx = $this->marge_gauche;
2361 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
2362 $pdf->SetTextColor(0, 0, 0);
2363 $pdf->SetFont(
'',
'', $default_font_size - 2);
2364 $pdf->SetXY($posx + 2, $posy - 5);
2365 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2366 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2370 $pdf->SetXY($posx + 2, $posy + 3);
2371 $pdf->SetFont(
'',
'B', $default_font_size);
2372 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2374 $posy = $pdf->getY();
2377 $pdf->SetFont(
'',
'', $default_font_size - 1);
2378 $pdf->SetXY($posx + 2, $posy);
2379 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2383 $idaddressshipping = $object->getIdContact(
'external',
'SHIPPING');
2385 if (!empty($idaddressshipping)) {
2386 $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
2387 $companystatic =
new Societe($this->
db);
2388 $companystatic->fetch($object->contact->fk_soc);
2390 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact,
'target', $object);
2393 $carac_client_shipping=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'target', $object);
2395 if (!empty($carac_client_shipping)) {
2396 $posy += $hautcadre;
2399 $pdf->SetXY($posx + 2, $posy - 5);
2400 $pdf->SetFont(
'',
'', $default_font_size - 2);
2401 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2402 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2405 $pdf->SetXY($posx + 2, $posy + 3);
2406 $pdf->SetFont(
'',
'B', $default_font_size);
2407 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2409 $posy = $pdf->getY();
2412 $pdf->SetXY($posx+2, $posy);
2413 $pdf->SetFont(
'',
'', $default_font_size - 1);
2414 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2415 $shipp_shift += $hautcadre;
2420 $pdf->SetTextColor(0, 0, 0);
2422 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);
2436 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
2438 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
2439 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);
2452 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2454 global $conf, $hookmanager;
2457 $this->defaultContentsFieldsStyle = array(
2459 'padding' => array(1, 0.5, 1, 0.5),
2463 $this->defaultTitlesFieldsStyle = array(
2465 'padding' => array(0.5, 0, 0.5, 0),
2487 $this->cols[
'desc'] = array(
2492 'textkey' =>
'Designation',
2496 'padding' => array(0.5, 0.5, 0.5, 0.5),
2500 'padding' => array(1, 0.5, 1, 1.5),
2506 $this->cols[
'photo'] = array(
2508 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
2511 'textkey' =>
'Photo',
2515 'padding' => array(0, 0, 0, 0),
2517 'border-left' =>
false,
2520 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto)) {
2521 $this->cols[
'photo'][
'status'] =
true;
2526 $this->cols[
'vat'] = array(
2533 'border-left' =>
true,
2536 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
2537 $this->cols[
'vat'][
'status'] =
true;
2541 $this->cols[
'subprice'] = array(
2546 'textkey' =>
'PriceUHT'
2548 'border-left' =>
true,
2553 $nblines = count($object->lines);
2554 for ($i = 0; $i < $nblines; $i++) {
2556 $tmpwidth = max($tmpwidth, $tmpwidth2);
2558 if ($tmpwidth > 10) {
2559 $this->cols[
'subprice'][
'width'] += (2 * ($tmpwidth - 10));
2563 $this->cols[
'qty'] = array(
2570 'border-left' =>
true,
2574 $this->cols[
'progress'] = array(
2579 'textkey' =>
'ProgressShort'
2581 'border-left' =>
true,
2584 if ($this->situationinvoice) {
2585 $this->cols[
'progress'][
'status'] =
true;
2589 $this->cols[
'unit'] = array(
2596 'border-left' =>
true,
2598 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2599 $this->cols[
'unit'][
'status'] =
true;
2603 $this->cols[
'discount'] = array(
2608 'textkey' =>
'ReductionShort'
2610 'border-left' =>
true,
2612 if ($this->atleastonediscount) {
2613 $this->cols[
'discount'][
'status'] =
true;
2616 $rank = $rank + 1000;
2617 $this->cols[
'totalexcltax'] = array(
2620 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ?
true :
false,
2622 'textkey' =>
'TotalHTShort'
2624 'border-left' =>
true,
2627 $rank = $rank + 1010;
2628 $this->cols[
'totalincltax'] = array(
2631 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ?
false :
true,
2633 'textkey' =>
'TotalTTCShort'
2635 'border-left' =>
true,
2639 if (!empty($object->lines)) {
2640 $line = reset($object->lines);
2644 $parameters = array(
2645 'object' => $object,
2646 'outputlangs' => $outputlangs,
2647 'hidedetails' => $hidedetails,
2648 'hidedesc' => $hidedesc,
2649 'hideref' => $hideref
2652 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
2655 } elseif (empty($reshook)) {
2656 $this->cols = array_replace($this->cols, $hookmanager->resArray);
2658 $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 third parties objects (customers, suppliers, prospects...)
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.