72 public $update_main_doc_field;
83 public $version =
'disabled';
88 public $position = 60;
94 public $heightforinfotot;
99 public $heightforfreetext;
104 public $heightforfooter;
114 public $tab_top_newpage;
119 public $situationinvoice;
130 public $categoryOfOperation = -1;
137 public $TDataSituation;
142 public $posx_cumul_anterieur;
147 public $posx_new_cumul;
152 public $posx_current;
157 public $tabTitleHeight;
182 $conf->global->USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL = 1;
191 $langs->loadLangs(array(
"main",
"bills"));
194 $this->
name =
"octopus";
195 $this->
description = $langs->trans(
'PDFOctopusDescription');
196 $this->update_main_doc_field = 1;
201 $this->page_largeur = $formatarray[
'width'];
202 $this->page_hauteur = $formatarray[
'height'];
203 $this->format = array($this->page_largeur, $this->page_hauteur);
208 $this->corner_radius =
getDolGlobalInt(
'MAIN_PDF_FRAME_CORNER_RADIUS', 0);
210 $this->posx_cumul_anterieur = 94;
211 $this->posx_new_cumul = 130;
212 $this->posx_current = 166;
214 $this->option_logo = 1;
215 $this->option_tva = 1;
216 $this->option_modereg = 1;
217 $this->option_condreg = 1;
218 $this->option_multilang = 1;
219 $this->option_escompte = 1;
220 $this->option_credit_note = 1;
221 $this->option_freetext = 1;
222 $this->option_draft_watermark = 1;
223 $this->watermark =
'';
232 if (empty($this->emetteur->country_code)) {
233 $this->emetteur->country_code = substr($langs->defaultlang, -2);
237 $this->posxdesc = $this->marge_gauche + 1;
240 $this->tabTitleHeight = 8;
244 $this->tva = array();
245 $this->tva_array = array();
246 $this->localtax1 = array();
247 $this->localtax2 = array();
248 $this->atleastoneratenotnull = 0;
249 $this->atleastonediscount = 0;
250 $this->situationinvoice =
true;
266 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
269 global $user, $langs,
$conf,
$mysoc, $hookmanager, $nblines;
271 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
273 if (!is_object($outputlangs)) {
274 $outputlangs = $langs;
278 $outputlangs->charset_output =
'ISO-8859-1';
282 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
284 global $outputlangsbis;
285 $outputlangsbis =
null;
289 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
293 setEventMessage($langs->trans(
'WarningsObjectIsNotASituation'),
'warnings');
297 $this->TDataSituation = $this->getDataSituation(
$object);
304 $nblines = count(
$object->lines);
312 $realpatharray = array();
313 $this->atleastonephoto =
false;
315 $objphoto =
new Product($this->db);
317 for ($i = 0; $i < $nblines; $i++) {
318 if (empty(
$object->lines[$i]->fk_product)) {
322 $objphoto->fetch(
$object->lines[$i]->fk_product);
326 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
327 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
329 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
330 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
335 foreach ($pdir as $midir) {
337 $entity = $objphoto->entity;
338 if ($entity !==
null &&
$conf->entity != $entity) {
339 $dir =
$conf->product->multidir_output[$entity].
'/'.$midir;
341 $dir =
$conf->product->dir_output.
'/'.$midir;
344 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
346 if ($obj[
'photo_vignette']) {
347 $filename = $obj[
'photo_vignette'];
349 $filename = $obj[
'photo'];
352 $filename = $obj[
'photo'];
355 $realpath = $dir.$filename;
357 $this->atleastonephoto =
true;
362 if (!empty($realpath) && $arephoto) {
363 $realpatharray[$i] = $realpath;
370 if (
$conf->facture->multidir_output[
$conf->entity]) {
374 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
375 $amount_deposits_included =
$object->getSumDepositsUsed((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
379 $dir =
$conf->facture->multidir_output[
$conf->entity];
380 $file = $dir.
"/SPECIMEN.pdf";
383 $dir =
$conf->facture->multidir_output[
$object->entity ??
$conf->entity].
"/".$objectref;
384 $file = $dir.
"/".$objectref.
".pdf";
386 if (!file_exists($dir)) {
388 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
393 if (file_exists($dir)) {
395 if (!is_object($hookmanager)) {
396 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
399 $hookmanager->initHooks(array(
'pdfgeneration'));
400 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
402 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
405 $nblines = count(
$object->lines);
406 $nbpayments = count(
$object->getListOfPayments());
407 $nbprevsituation = is_array(
$object->tab_previous_situation_invoice) ? count(
$object->tab_previous_situation_invoice) : 0;
412 $pdf->setAutoPageBreak(
true, 0);
415 $this->heightforinfotot = 50;
417 $this->heightforinfotot += (4 * ($nbpayments + 3));
419 if ($nbprevsituation > 0) {
420 $this->heightforinfotot += (4 * ($nbprevsituation + 3));
422 $this->heightforfreetext =
getDolGlobalInt(
'MAIN_PDF_FREETEXT_HEIGHT', 5);
423 $this->heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
425 $heightforqrinvoice = 0;
429 $this->heightforinfotot = 30 + (4 * $nbpayments);
433 if (class_exists(
'TCPDF')) {
434 $pdf->setPrintHeader(
false);
435 $pdf->setPrintFooter(
false);
441 $logodir =
$conf->mycompany->dir_output;
442 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
445 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
446 $this->tplidx = $pdf->importPage(1);
451 $pdf->SetDrawColor(128, 128, 128);
453 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
454 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceSituationTitle"));
455 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
456 $pdf->SetAuthor(
$mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)) :
''));
457 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
459 $pdf->SetCompression(
false);
469 'Name' => $this->emetteur->name,
470 'Location' =>
getCountry($this->emetteur->country_code,
''),
471 'Reason' =>
'INVOICE',
472 'ContactInfo' => $this->emetteur->email
474 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
478 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
482 $categoryOfOperation = 0;
485 for ($i = 0; $i < $nblines; $i++) {
487 if ($line->remise_percent) {
488 $this->atleastonediscount++;
492 if ($line->isDepositLine()) {
497 if ($categoryOfOperation < 2) {
498 $lineProductType = $line->product_type;
504 if ($nbProduct > 0 && $nbService > 0) {
506 $categoryOfOperation = 2;
511 if ($categoryOfOperation <= 0) {
513 if ($nbProduct == 0 && $nbService > 0) {
514 $categoryOfOperation = 1;
517 $this->categoryOfOperation = $categoryOfOperation;
520 if (
$object->situation_cycle_ref) {
521 $this->situationinvoice =
true;
526 if (!empty($this->tplidx)) {
527 $pdf->useTemplate($this->tplidx);
532 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
533 $top_shift = $pagehead[
'top_shift'];
534 $shipp_shift = $pagehead[
'shipp_shift'];
535 $pdf->SetFont(
'',
'', $default_font_size - 1);
536 $pdf->MultiCell(0, 3,
'');
537 $pdf->SetTextColor(0, 0, 0);
542 $this->tab_top = $this->marge_haute + 80 + $top_shift + $shipp_shift;
543 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? $this->marge_haute + 32 + $top_shift : $this->marge_haute);
546 $extra_under_address_shift = 0;
549 $qrcodestring =
$object->buildZATCAQRString();
552 $qrcodestring =
$object->buildSwitzerlandQRString();
557 $qrcodestring =
$object->buildEPCQrCodeString();
562 $qrcodecolor = array(
'25',
'25',
'25');
567 'fgcolor' => $qrcodecolor,
572 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
576 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
577 $pdf->SetFont(
'',
'', $default_font_size - 4);
578 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L',
false);
582 $extra_under_address_shift += 25;
590 'outputlangs' => $outputlangs,
591 'hidedetails' => $hidedetails
593 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
594 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
595 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
598 $this->tab_top += $extra_under_address_shift;
599 $this->tab_top_newpage += 0;
603 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->
getHeightForQRInvoice(1,
$object, $langs);
605 $nexY = $this->tab_top - 1;
615 $tab_height_newpage = 150;
617 $this->
tableFirstPage(
$object, $pdf, $tab_top, $this->page_hauteur - 100 - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
619 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
627 $pdf->setTopMargin($this->tab_top_newpage + $this->tabTitleHeight + 2);
642 $nexY = $this->tab_top_newpage + $this->tabTitleHeight;
645 $pageposbeforeprintlines = $pdf->getPage();
646 $pagenb = $pageposbeforeprintlines;
648 $pdf_sub_options = array();
649 $pdf_sub_options[
'titleshowuponpdf'] = 1;
650 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = 1;
652 for ($i = 0; $i < $nblines; $i++) {
653 $sub_options =
$object->lines[$i]->extraparams[
"subtotal"] ?? array();
655 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
656 $level =
$object->lines[$i]->qty;
658 if (isset($sub_options[
'titleshowuponpdf'])) {
659 $pdf_sub_options[
'titleshowuponpdf'] = isset($pdf_sub_options[
'titleshowuponpdf']) && $pdf_sub_options[
'titleshowuponpdf'] < $level ? $pdf_sub_options[
'titleshowuponpdf'] : $level;
660 } elseif (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
661 unset($pdf_sub_options[
'titleshowuponpdf']);
663 if (isset($sub_options[
'titleshowtotalexludingvatonpdf'])) {
664 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] < $level ? $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] : $level;
665 } elseif (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
666 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
669 if (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
670 unset($pdf_sub_options[
'titleshowuponpdf']);
672 if (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
673 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
678 $parameters = array(
'i' => $i,
'object' =>
$object);
679 $reshook = $hookmanager->executeHooks(
'beforePrintPDFline', $parameters, $this, $action);
680 if ($reshook > 0 && !empty($hookmanager->resArray[
'object'])) {
681 $object = $hookmanager->resArray[
'object'];
683 $linePosition = $i + 1;
686 $sub_options =
$object->lines[$i]->extraparams[
"subtotal"] ?? array();
688 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
689 $level =
$object->lines[$i]->qty;
691 if (isset($sub_options[
'titleshowuponpdf'])) {
692 $pdf_sub_options[
'titleshowuponpdf'] = isset($pdf_sub_options[
'titleshowuponpdf']) && $pdf_sub_options[
'titleshowuponpdf'] < $level ? $pdf_sub_options[
'titleshowuponpdf'] : $level;
693 } elseif (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
694 unset($pdf_sub_options[
'titleshowuponpdf']);
696 if (isset($sub_options[
'titleshowtotalexludingvatonpdf'])) {
697 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] < $level ? $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] : $level;
698 } elseif (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
699 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
702 if (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
703 unset($pdf_sub_options[
'titleshowuponpdf']);
705 if (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
706 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
710 if (($curY + 6) > ($this->page_hauteur - $this->heightforfooter) || isset($sub_options[
'titleforcepagebreak']) && !($pdf->getNumPages() == 1 && $curY == $this->tab_top + $this->tabTitleHeight)) {
711 $object->lines[$i]->pagebreak =
true;
715 $pdf->SetFont(
'',
'', $default_font_size - 1);
716 $pdf->SetTextColor(0, 0, 0);
719 $imglinesize = array();
720 if (!empty($realpatharray[$i])) {
724 $pdf->setTopMargin($this->tab_top_newpage + $this->tabTitleHeight + 2);
725 $pdf->setPageOrientation(
'',
true, $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot);
726 $pageposbefore = $pdf->getPage();
729 $showpricebeforepagebreak =
getDolGlobalInt(
'MAIN_PDF_DATA_ON_FIRST_PAGE');
732 $posYAfterDescription = 0;
737 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($posy + $imglinesize[
'height']) > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
738 $pdf->AddPage(
'',
'',
true);
739 if (!empty($this->tplidx)) {
740 $pdf->useTemplate($this->tplidx);
742 $pdf->setPage($pageposbefore + 1);
743 $pdf->setPageOrientation(
'',
true, $this->heightforfooter);
744 $posy = $this->tab_top_newpage + $this->tabTitleHeight;
748 $showpricebeforepagebreak = 0;
752 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
753 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $posy + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
755 $posYAfterImage = $posy + $imglinesize[
'height'];
762 $pdf->setPageOrientation(
'',
true, $this->heightforfooter);
766 $pdf->startTransaction();
769 $pageposafter = $pdf->getPage();
771 if ($pageposafter > $pageposbefore) {
772 $pdf->rollbackTransaction(
true);
773 $pageposafter = $pageposbefore;
774 $pdf->setPageOrientation(
'',
true, $this->heightforfooter);
778 $pageposafter = $pdf->getPage();
779 $posyafter = $pdf->GetY();
781 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
782 if ($i == ($nblines - 1)) {
783 $pdf->AddPage(
'',
'',
true);
784 if (!empty($this->tplidx)) {
785 $pdf->useTemplate($this->tplidx);
787 $pdf->setPage($pageposafter + 1);
793 $showpricebeforepagebreak = 1;
795 $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(
'',
true, 0);
812 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
813 $pdf->setPage($pageposafter);
814 $posy = $this->tab_top_newpage + $this->tabTitleHeight;
819 $pdf->SetFont(
'',
'', $default_font_size - 1);
830 $nexY = max($pdf->GetY(), $nexY);
834 if ($this->
getColumnStatus(
'subprice') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowuponpdf'])) {
837 $nexY = max($pdf->GetY(), $nexY);
845 $nexY = max($pdf->GetY(), $nexY);
852 $nexY = max($pdf->GetY(), $nexY);
859 $nexY = max($pdf->GetY(), $nexY);
863 if ($this->
getColumnStatus(
'discount') &&
$object->lines[$i]->remise_percent &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
866 $nexY = max($pdf->GetY(), $nexY);
871 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf'])) {
874 } elseif (
$object->lines[$i]->qty < 0 && isset($sub_options[
'subtotalshowtotalexludingvatonpdf'])) {
876 $total_excl_tax =
$object->getSubtotalLineMulticurrencyAmount(
$object->lines[$i]);
878 $total_excl_tax =
$object->getSubtotalLineAmount(
$object->lines[$i]);
882 $nexY = max($pdf->GetY(), $nexY);
886 $currentline =
$object->lines[$i];
887 '@phan-var-force FactureLigne $currentline';
892 $columkey =
'btpsomme';
894 $printval =
price($TInfosLigneSituationPrecedente[
'total_ht_without_progress'], 0,
'', 1, -1, 2);
896 $nexY = max($pdf->GetY(), $nexY);
900 $columkey =
'progress_amount';
902 $printval =
price(
$object->lines[$i]->total_ht, 0,
'', 1, -1, 2);
904 $nexY = max($pdf->GetY(), $nexY);
907 $columkey =
'prev_progress';
909 $printval = $TInfosLigneSituationPrecedente[
'progress_prec'].
'%';
911 $nexY = max($pdf->GetY(), $nexY);
914 $columkey =
'prev_progress_amount';
916 $printval =
price($TInfosLigneSituationPrecedente[
'total_ht'], 0,
'', 1, -1, 2);
918 $nexY = max($pdf->GetY(), $nexY);
927 'nexY' => & $afterPosData[
'y'],
928 'outputlangs' => $outputlangs,
929 'hidedetails' => $hidedetails
931 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
939 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE &&
$object->lines[$i]->product_type != 9) {
941 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
943 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
945 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
949 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
951 $tvaligne = $sign *
$object->lines[$i]->total_tva;
955 $localtax1ligne =
$object->lines[$i]->total_localtax1;
956 $localtax2ligne =
$object->lines[$i]->total_localtax2;
957 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
958 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
959 $localtax1_type =
$object->lines[$i]->localtax1_type;
960 $localtax2_type =
$object->lines[$i]->localtax2_type;
962 $vatrate = (string)
$object->lines[$i]->tva_tx;
965 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
966 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
968 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
969 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
973 if ($localtax1_type && $localtax1ligne != 0) {
974 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
975 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
977 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
980 if ($localtax2_type && $localtax2ligne != 0) {
981 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
982 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
984 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
988 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
994 $vatcode =
$object->lines[$i]->vat_src_code;
995 if (empty($this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'amount'])) {
996 $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'amount'] = 0;
999 if (empty($this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'tot_ht'])) {
1000 $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'tot_ht'] = 0;
1002 $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'amount'] + $tvaligne,
'tot_ht' => $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'tot_ht'] +
$object->lines[$i]->total_ht);
1004 $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'amount'] + $tvaligne);
1009 $pdf->setPage($afterPosData[
'page']);
1010 $nexY = max($nexY, $posYAfterImage);
1013 if (
getDolGlobalString(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1) && $afterPosData[
'y'] < $this->page_hauteur - $this->heightforfooter - 5) {
1014 $pdf->setPage($pageposafter);
1015 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
1017 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
1018 $pdf->SetLineStyle(array(
'dash' => 0));
1022 while ($pagenb < $pageposafter) {
1023 $pdf->setPage($pagenb);
1024 $tabtop = $this->tab_top_newpage;
1025 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1026 if ($pagenb != $pageposbeforeprintlines) {
1027 $tabtop = $this->tab_top_newpage;
1028 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1031 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1035 $pdf->setPage($pagenb);
1036 $pdf->setPageOrientation(
'',
true, 0);
1040 if (!empty($this->tplidx)) {
1041 $pdf->useTemplate($this->tplidx);
1045 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
1046 $tabtop = $this->tab_top_newpage;
1047 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1048 if ($pagenb != $pageposbeforeprintlines) {
1049 $tabtop = $this->tab_top_newpage;
1050 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1053 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1058 if (!empty($this->tplidx)) {
1059 $pdf->useTemplate($this->tplidx);
1070 $tabtop = $this->tab_top_newpage;
1071 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter - $this->heightforinfotot - $this->heightforfreetext;
1072 $tabTitleHeight = 0;
1073 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1076 $pdf->SetTextColor(0, 0, 0);
1078 $pdf->setPage($pdf->getNumPages());
1080 $bottomlasttab = $tabtop + $tabhauteur + $tabTitleHeight + 10;
1087 $posy = $this->
drawTotalTable($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1090 $listofpayments =
$object->getListOfPayments(
'', 0, 1);
1091 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1098 if (method_exists($pdf,
'AliasNbPages')) {
1099 $pdf->AliasNbPages();
1104 $termsofsale =
$conf->invoice->dir_output.
'/'.$termsofsalefilename;
1105 if (!empty(
$conf->invoice->multidir_output[
$object->entity ??
$conf->entity])) {
1106 $termsofsale =
$conf->invoice->multidir_output[
$object->entity ??
$conf->entity].
'/'.$termsofsalefilename;
1108 if (file_exists($termsofsale) && is_readable($termsofsale)) {
1109 $pagecount = $pdf->setSourceFile($termsofsale);
1110 for ($i = 1; $i <= $pagecount; $i++) {
1111 $tplIdx = $pdf->importPage($i);
1112 if ($tplIdx !==
false) {
1113 $s = $pdf->getTemplatesize($tplIdx);
1114 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
1115 $pdf->useTemplate($tplIdx);
1117 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
1123 $this->resumeLastPage($pdf,
$object, 0, $tab_top, $outputlangs, $outputlangsbis);
1124 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
1133 $pdf->Output($file,
'F');
1136 $hookmanager->initHooks(array(
'pdfgeneration'));
1137 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1139 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1140 $this->warnings = $hookmanager->warnings;
1142 $this->error = $hookmanager->error;
1143 $this->errors = $hookmanager->errors;
1150 $this->result = array(
'fullpath' => $file);
1154 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1158 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1181 $tab3_top = $posy + 8;
1184 if ($this->page_largeur < 210) {
1190 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1192 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1195 $pdf->SetFont(
'',
'', $default_font_size - 3);
1196 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1197 $pdf->MultiCell(60, 3, $title, 0,
'L',
false);
1199 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1201 $pdf->SetFont(
'',
'', $default_font_size - 4);
1202 $pdf->SetXY($tab3_posx, $tab3_top);
1203 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L',
false);
1204 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1205 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L',
false);
1206 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1207 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L',
false);
1208 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1209 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L',
false);
1211 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1215 $pdf->SetFont(
'',
'', $default_font_size - 4);
1219 $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,";
1220 $sql .=
" re.description, re.fk_facture_source,";
1221 $sql .=
" f.type, f.datef";
1222 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1223 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1224 $resql = $this->db->query($sql);
1226 $num = $this->db->num_rows($resql);
1228 $invoice =
new Facture($this->db);
1231 $obj = $this->db->fetch_object($resql);
1233 if ($obj->type == 2) {
1234 $text = $outputlangs->transnoentities(
"CreditNote");
1235 } elseif ($obj->type == 3) {
1236 $text = $outputlangs->transnoentities(
"Deposit");
1237 } elseif ($obj->type == 0) {
1238 $text = $outputlangs->transnoentities(
"ExcessReceived");
1240 $text = $outputlangs->transnoentities(
"UnknownType");
1243 $invoice->fetch($obj->fk_facture_source);
1245 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1246 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L',
false);
1247 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1248 $pdf->MultiCell(20, 3,
price((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L',
false);
1249 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1250 $pdf->MultiCell(20, 3, $text, 0,
'L',
false);
1251 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1252 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L',
false);
1254 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1259 $this->error = $this->db->lasterror();
1265 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1267 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1268 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1269 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1271 $sql .=
" ORDER BY p.datep";
1273 $resql = $this->db->query($sql);
1275 $num = $this->db->num_rows($resql);
1280 $row = $this->db->fetch_object($resql);
1281 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1282 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L',
false);
1283 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1284 $pdf->MultiCell(20, 3,
price($sign * ((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L',
false);
1285 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1286 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1288 $pdf->MultiCell(20, 3, $oper, 0,
'L',
false);
1289 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1290 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1291 $pdf->MultiCell(30, 3, $row->num, 0,
'L',
false);
1292 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1293 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1298 return $tab3_top + $y + 3;
1300 $this->error = $this->db->lasterror();
1322 $pdf->SetFont(
'',
'', $default_font_size - 1);
1324 krsort($this->tva_array);
1331 $pdf->SetFillColor(224, 224, 224);
1333 $pdf->SetFont(
'',
'', $default_font_size - 2);
1334 $pdf->SetXY($this->marge_gauche, $posy);
1335 $titre = $outputlangs->transnoentities(
"VAT");
1336 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1338 $pdf->SetFont(
'',
'', $default_font_size - 2);
1339 $pdf->SetXY($this->marge_gauche + 25, $posy);
1340 $titre = $outputlangs->transnoentities(
"NetTotal");
1341 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1343 $pdf->SetFont(
'',
'', $default_font_size - 2);
1344 $pdf->SetXY($this->marge_gauche + 50, $posy);
1345 $titre = $outputlangs->transnoentities(
"VATAmount");
1346 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1348 $pdf->SetFont(
'',
'', $default_font_size - 2);
1349 $pdf->SetXY($this->marge_gauche + 75, $posy);
1350 $titre = $outputlangs->transnoentities(
"AmountTotal");
1351 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1353 $posy = $pdf->GetY();
1358 foreach ($this->tva_array as $tvakey => $tvaval) {
1359 $pdf->SetFont(
'',
'', $default_font_size - 2);
1360 $pdf->SetXY($this->marge_gauche, $posy);
1361 $titre = round((
float) $tvakey, 2) .
"%";
1362 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1364 $pdf->SetFont(
'',
'', $default_font_size - 2);
1365 $pdf->SetXY($this->marge_gauche + 25, $posy);
1366 $titre =
price($tvaval[
'tot_ht']);
1367 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1368 $tot_ht += $tvaval[
'tot_ht'];
1370 $pdf->SetFont(
'',
'', $default_font_size - 2);
1371 $pdf->SetXY($this->marge_gauche + 50, $posy);
1372 $titre =
price($tvaval[
'amount']);
1373 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1374 $tot_tva += $tvaval[
'amount'];
1376 $pdf->SetFont(
'',
'', $default_font_size - 2);
1377 $pdf->SetXY($this->marge_gauche + 75, $posy);
1378 $titre =
price($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1379 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1380 $tot_ttc += ($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1382 $posy = $pdf->GetY();
1387 $showvatmention = 0;
1388 if (in_array($this->emetteur->country_code, array(
'FR')) && empty(
$object->total_tva)) {
1389 $pdf->SetFont(
'',
'', $default_font_size - 2);
1390 $pdf->SetXY($this->marge_gauche, $posy);
1391 if (empty(
$mysoc->tva_assuj)) {
1392 if (
$mysoc->forme_juridique_code == 92) {
1393 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L',
false);
1395 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
1398 } elseif (
getDolGlobalString(
"INVOICE_VAT_SHOW_REVERSE_CHARGE_MENTION") && $this->emetteur->country_code !=
$object->thirdparty->country_code && $this->emetteur->isInEEC() &&
$object->thirdparty->isInEEC()) {
1399 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedReverseChargeProcedure"), 0,
'L',
false);
1402 $posy = $pdf->GetY();
1405 $showvatmention +=
pdfCertifMention($pdf, $outputlangs, $this->emetteur, $default_font_size, $posy, $this);
1407 if ($showvatmention) {
1414 if ($this->page_largeur < 210) {
1421 $sql =
"SELECT f.rowid, f.datef, f.total_ttc";
1422 $sql .=
" FROM " . MAIN_DB_PREFIX .
"facture as f";
1423 $sql .=
" WHERE f.fk_soc = " . ((int)
$object->socid);
1424 $sql .=
" AND f.entity IN (" .
getEntity(
'invoice') .
")";
1425 $sql .=
" AND f.datef <= '" . $this->db->idate(
$object->date) .
"'";
1426 $sql .=
" AND f.rowid < " . ((int)
$object->id);
1427 $sql .=
" AND f.fk_statut > 0";
1428 $sql .=
" ORDER BY f.datef ASC";
1431 $invoices = array();
1432 $resql = $this->db->query($sql);
1434 while ($obj = $this->db->fetch_object($resql)) {
1436 $old_balance += $obj->total_ttc;
1438 $this->db->free($resql);
1442 $sql_payments =
"SELECT p.datep, pf.fk_facture, pf.amount";
1443 $sql_payments .=
" FROM " . MAIN_DB_PREFIX .
"paiement_facture as pf";
1444 $sql_payments .=
" INNER JOIN " . MAIN_DB_PREFIX .
"paiement as p ON p.rowid = pf.fk_paiement";
1445 $sql_payments .=
" INNER JOIN " . MAIN_DB_PREFIX .
"facture as f ON f.rowid = pf.fk_facture";
1446 $sql_payments .=
" WHERE f.fk_soc = " . ((int)
$object->socid);
1447 $sql_payments .=
" AND p.datep < '" . $this->db->idate(
$object->date) .
"'";
1448 $sql_payments .=
" ORDER BY p.datep ASC";
1450 $total_payments = 0;
1451 $resql_payments = $this->db->query($sql_payments);
1452 if ($resql_payments) {
1453 while ($obj_payment = $this->db->fetch_object($resql_payments)) {
1454 $total_payments += $obj_payment->amount;
1456 $this->db->free($resql_payments);
1460 $sql_current_date_payments =
"SELECT p.datep, pf.fk_facture, pf.amount";
1461 $sql_current_date_payments .=
" FROM " . MAIN_DB_PREFIX .
"paiement_facture as pf";
1462 $sql_current_date_payments .=
" INNER JOIN " . MAIN_DB_PREFIX .
"paiement as p ON p.rowid = pf.fk_paiement";
1463 $sql_current_date_payments .=
" INNER JOIN " . MAIN_DB_PREFIX .
"facture as f ON f.rowid = pf.fk_facture";
1464 $sql_current_date_payments .=
" WHERE f.fk_soc = " . ((int)
$object->socid);
1465 $sql_current_date_payments .=
" AND DATE(p.datep) = DATE('" . $this->db->idate(
$object->date) .
"')";
1467 $current_date_payments = 0;
1468 $resql_current_date = $this->db->query($sql_current_date_payments);
1469 if ($resql_current_date) {
1470 while ($obj_current = $this->db->fetch_object($resql_current_date)) {
1471 $current_date_payments += $obj_current->amount;
1473 $this->db->free($resql_current_date);
1477 $old_balance -= $total_payments;
1480 $new_balance = $old_balance +
$object->total_ttc - $current_date_payments;
1482 $pdf->SetFillColor(224, 224, 224);
1483 $pdf->SetFont(
'',
'', $default_font_size - 2);
1484 $pdf->SetXY($this->marge_gauche, $posy);
1485 $titre = $outputlangs->transnoentities(
"PreviousBalance").
' : '.
price($old_balance);
1486 $pdf->MultiCell($posxval - $this->marge_gauche + 8, 4, $titre, 0,
'L',
true);
1488 $pdf->SetFont(
'',
'', $default_font_size - 2);
1489 $pdf->SetXY($posxval + 8, $posy);
1490 $titre = $outputlangs->transnoentities(
"NewBalance").
' : '.
price($new_balance);
1491 $pdf->MultiCell($posxend - $posxval - 8, 4, $titre, 0,
'L',
true);
1493 $posy = $pdf->GetY() + 1;
1498 $pdf->SetFont(
'',
'', $default_font_size - 2);
1499 $pdf->SetXY($this->marge_gauche, $posy);
1500 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1501 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1503 $pdf->SetFont(
'',
'', $default_font_size - 2);
1504 $pdf->SetXY($posxval, $posy);
1505 $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);
1506 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1507 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1509 $posy = $pdf->GetY() + 3;
1513 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1514 $pdf->SetFont(
'',
'', $default_font_size - 2);
1515 $pdf->SetXY($this->marge_gauche, $posy);
1516 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1517 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1519 $pdf->SetFont(
'',
'', $default_font_size - 2);
1520 $pdf->SetXY($posxval, $posy);
1521 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1522 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1524 $posy = $pdf->GetY() + 3;
1529 if (empty(
$object->mode_reglement_code)
1532 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1536 $outputlangs->load(
"errors");
1538 $pdf->SetXY($this->marge_gauche, $posy);
1539 $pdf->SetTextColor(200, 0, 0);
1540 $pdf->SetFont(
'',
'', $default_font_size - 2);
1541 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1542 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L',
false);
1543 $pdf->SetTextColor(0, 0, 0);
1545 $posy = $pdf->GetY() + 1;
1549 if (!empty(
$object->mode_reglement_code)
1550 &&
$object->mode_reglement_code !=
'CHQ'
1551 &&
$object->mode_reglement_code !=
'VIR') {
1552 $pdf->SetFont(
'',
'', $default_font_size - 2);
1553 $pdf->SetXY($this->marge_gauche, $posy);
1554 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1555 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1557 $pdf->SetFont(
'',
'', $default_font_size - 2);
1558 $pdf->SetXY($posxval, $posy);
1559 $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);
1562 if (
$object->mode_reglement_code ==
"PRE") {
1563 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1566 $bac->fetch(0,
'',
$object->thirdparty->id);
1567 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1568 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
pdf_truncate_text($pdf, $iban, 6,
'right',
''));
1571 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1573 $posy = $pdf->GetY();
1579 if ($this->emetteur->country_code ==
'FR') {
1581 $pdf->SetXY($this->marge_gauche, $posy);
1582 $pdf->writeHTMLCell(80, 5,
null,
null, $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1584 $posy = $pdf->GetY() + 1;
1589 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1590 $useonlinepayment = 0;
1594 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1595 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1596 $useonlinepayment = count($validpaymentmethod);
1601 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1604 $langs->loadLangs(array(
'payment',
'stripe'));
1605 $servicename = $langs->transnoentities(
'Online');
1606 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1607 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1609 $pdf->SetXY($this->marge_gauche, $posy);
1610 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
null,
null,
dol_htmlentitiesbr($linktopay), 0, 1);
1612 $posy = $pdf->GetY() + 1;
1617 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1623 $account =
new Account($this->db);
1626 $pdf->SetXY($this->marge_gauche, $posy);
1627 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1628 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1629 $posy = $pdf->GetY() + 1;
1632 $pdf->SetXY($this->marge_gauche, $posy);
1633 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1634 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1635 $posy = $pdf->GetY() + 2;
1639 $pdf->SetXY($this->marge_gauche, $posy);
1640 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1641 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1642 $posy = $pdf->GetY() + 1;
1645 $pdf->SetXY($this->marge_gauche, $posy);
1646 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1647 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1648 $posy = $pdf->GetY() + 2;
1655 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1661 $account =
new Account($this->db);
1662 $account->fetch($bankid);
1664 $curx = $this->marge_gauche;
1667 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1673 $qrPosX = $this->marge_gauche + 5;
1675 $qrCodeColor = array(
'25',
'25',
'25');
1679 'fgcolor' => $qrCodeColor,
1681 'module_width' => 1,
1682 'module_height' => 1
1685 $EPCQrCodeString =
$object->buildEPCQrCodeString();
1686 $pdf->write2DBarcode($EPCQrCodeString,
'QRCODE,M', $qrPosX, $qrPosY, 20, 20, $styleQr,
'N');
1688 $pdf->SetXY($qrPosX + 25, $posy + 5);
1689 $pdf->SetFont(
'',
'', $default_font_size - 5);
1690 $pdf->MultiCell(30, 3, $outputlangs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L',
false);
1691 $posy = $pdf->GetY() + 2;
1696 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1699 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L',
false);
1731 $tab2_top = $posy - 4;
1733 if (is_object($outputlangsbis)) {
1734 $pdf->SetFont(
'',
'', $default_font_size - 2);
1736 $pdf->SetFont(
'',
'', $default_font_size - 1);
1742 if ($this->page_largeur < 210) {
1746 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1752 $pdf->SetFillColor(255, 255, 255);
1753 $pdf->SetXY($col1x, $tab2_top + 0);
1754 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L',
true);
1757 $pdf->SetXY($col2x, $tab2_top + 0);
1758 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht, 0, $outputlangs), 0,
'R',
true);
1762 $pdf->SetFillColor(255, 255, 255);
1763 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1764 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalVAT"), 0,
'L',
true);
1766 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1767 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->total_tva), 0,
'R',
true);
1771 $pdf->SetFillColor(248, 248, 248);
1774 $total_ttc_origin =
$object->total_ttc;
1776 $this->atleastoneratenotnull = 0;
1779 if (!empty($this->tva_array) && count($this->tva_array) == 1) {
1780 $tva_el = reset($this->tva_array);
1781 if ($tva_el[
'vatrate'] ==
'0.000' && is_float($tva_el[
'amount'])) {
1785 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1789 pdfWriteVATArray($this, $index, $pdf, $outputlangs, $outputlangsbis,
$object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl);
1794 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1795 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp",
$mysoc->country_code) :
''), $useborder,
'L',
true);
1797 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1798 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R',
true);
1803 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1804 $pdf->SetTextColor(0, 0, 60);
1805 $pdf->SetFillColor(224, 224, 224);
1806 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L',
true);
1808 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1810 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1812 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1816 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1817 $pdf->SetTextColor(0, 0, 60);
1818 $pdf->SetFillColor(224, 224, 224);
1819 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
'').
' ('.$outputlangs->getCurrencySymbol(
$mysoc->currency_code).
')', $useborder,
'L',
true);
1821 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1822 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc_origin, 0, $outputlangs, 1, -1, -1,
$mysoc->currency_code), $useborder,
'L',
true);
1827 if (
$object->displayRetainedWarranty()) {
1828 $pdf->SetTextColor(40, 40, 40);
1829 $pdf->SetFillColor(255, 255, 255);
1831 $retainedWarranty =
$object->getRetainedWarrantyAmount(
'MT');
1832 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1836 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1837 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L',
true);
1839 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1840 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R',
true);
1844 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1846 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1847 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1849 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L',
true);
1850 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1851 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R',
true);
1856 $pdf->SetTextColor(0, 0, 0);
1858 $creditnoteamount =
$object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1861 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1864 $deja_regle_origin = 0;
1865 $creditnoteamount_origin = 0;
1866 $depositsamount_origin = 0;
1867 $resteapayer_origin = 0;
1869 $deja_regle_origin =
$object->getSommePaiement(0);
1870 $creditnoteamount_origin =
$object->getSumCreditNotesUsed(0);
1871 $depositsamount_origin =
$object->getSumDepositsUsed(0);
1872 $resteapayer_origin =
price2num($total_ttc_origin - $deja_regle_origin - $creditnoteamount_origin - $depositsamount_origin,
'MT');
1876 $resteapayer_origin = 0;
1879 pdfWriteAlreadyPaid($this, $index, $pdf, $outputlangs, $outputlangsbis,
$object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl, $deja_regle, $creditnoteamount, $depositsamount, $resteapayer, $resteapayer_origin);
1881 $pdf->SetFont(
'',
'', $default_font_size - 1);
1882 $pdf->SetTextColor(0, 0, 0);
1884 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1886 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1888 $this->error = $hookmanager->error;
1889 $this->errors = $hookmanager->errors;
1893 return ($tab2_top + ($tab2_hl * $index));
1907 return parent::liste_modeles($db, $maxfilenamelength);
1925 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis =
null)
1934 $currency = !empty($currency) ? $currency :
$conf->currency;
1938 $pdf->SetTextColor(0, 0, 0);
1939 $pdf->SetFont(
'',
'', $default_font_size - 2);
1941 if (empty($hidetop)) {
1943 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
1944 $categoryOfOperations = $outputlangs->transnoentities(
"MentionCategoryOfOperations") .
' : ' . $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1945 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
1946 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
1949 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1950 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1951 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1955 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F', array(), explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1960 $pdf->SetDrawColor(128, 128, 128);
1961 $pdf->SetFont(
'',
'', $default_font_size - 1);
1964 $this->
printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom,
'D');
1967 $pdf->SetFont(
'',
'', $default_font_size - 2);
1969 foreach ($this->cols as $colKey => $colDef) {
1973 $xstartpos = (int) ($colDef[
'xStartPos'] ?? 0);
1975 if (!empty($colDef[
'overtitle']) && is_array($colDef[
'overtitle'])) {
1976 $overtitle_top = $tab_top - 4;
1977 $overtitle = $colDef[
'overtitle'][
'textkey'] ??
'';
1978 $textWidth = $colDef[
'overtitle'][
'width'] ?? 0;
1979 $pdf->SetXY($xstartpos + $colDef[
'overtitle'][
'padding'][3], $overtitle_top);
1980 $pdf->MultiCell($textWidth, 2, $overtitle,
'', $colDef[
'overtitle'][
'align']);
1981 $pdf->line($xstartpos, $overtitle_top, $xstartpos, $overtitle_top + 4);
1982 $pdf->line($xstartpos, $overtitle_top, $xstartpos + $textWidth, $overtitle_top);
1983 $pdf->line($xstartpos + $textWidth, $overtitle_top, $xstartpos + $textWidth, $overtitle_top + 4);
1987 $colDef[
'title'][
'label'] = !empty($colDef[
'title'][
'label']) ? $colDef[
'title'][
'label'] : $outputlangs->transnoentities($colDef[
'title'][
'textkey']);
1990 if (!empty($colDef[
'border-left'])) {
1991 $pdf->line($xstartpos, $tab_top, $xstartpos, $tab_top + $tab_height);
1994 if (empty($hidetop)) {
1995 $pdf->SetXY($xstartpos + $colDef[
'title'][
'padding'][3], $tab_top + $colDef[
'title'][
'padding'][0]);
1997 $textWidth = $colDef[
'width'] - $colDef[
'title'][
'padding'][3] - $colDef[
'title'][
'padding'][1];
1998 $pdf->MultiCell($textWidth, 2, $colDef[
'title'][
'label'],
'', $colDef[
'title'][
'align']);
2001 $pdf->SetFont(
'',
'', $default_font_size - 1);
2003 if (empty($hidetop)) {
2004 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
2019 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2022 global
$conf, $langs;
2024 $ltrdirection =
'L';
2025 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2026 $ltrdirection =
'R';
2030 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2036 $pdf->SetTextColor(0, 0, 60);
2037 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2041 $posy = $this->marge_haute;
2042 $posx = $this->page_largeur - $this->marge_droite - $w;
2044 $pdf->SetXY($this->marge_gauche, $posy);
2047 $logodir =
$conf->mycompany->dir_output;
2048 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
2051 pdf_writeLogoOrCompanyName($pdf, $outputlangs, $this->emetteur, $logodir, $this->marge_gauche, $posy, $w, $default_font_size, $ltrdirection);
2053 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2054 $pdf->SetXY($posx, $posy);
2055 $pdf->SetTextColor(0, 0, 60);
2057 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2059 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2062 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2065 $title = $outputlangs->transnoentities(
"PdfInvoiceDepositTitle");
2067 if ($this->situationinvoice) {
2068 $outputlangs->loadLangs(array(
"other"));
2069 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
2070 $subtitle = $outputlangs->transnoentities(
"PDFSituationTitle", (
string)
$object->situation_counter);
2072 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2075 if ($this->situationinvoice) {
2076 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2078 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2079 } elseif (
$object->type == 1) {
2080 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2081 } elseif (
$object->type == 2) {
2082 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2083 } elseif (
$object->type == 3) {
2084 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2085 } elseif (
$object->type == 4) {
2086 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2089 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2090 if (
$object->status == $object::STATUS_DRAFT) {
2091 $pdf->SetTextColor(128, 0, 0);
2092 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2095 $pdf->MultiCell($w, 3, $title,
'',
'R');
2096 if (!empty($subtitle)) {
2097 $pdf->SetFont(
'',
'B', $default_font_size);
2098 $pdf->SetXY($posx, $posy + 5);
2099 $pdf->MultiCell($w, 6, $subtitle,
'',
'R');
2103 $pdf->SetFont(
'',
'', $default_font_size - 2);
2120 $pdf->SetFont(
'',
'', $default_font_size - 2);
2124 $pdf->SetXY($posx, $posy);
2125 $pdf->SetTextColor(0, 0, 60);
2126 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
pdf_truncate_text($pdf, $outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2131 if (!empty(
$object->project->title)) {
2133 $pdf->SetXY($posx, $posy);
2134 $pdf->SetTextColor(0, 0, 60);
2135 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".
pdf_truncate_text($pdf,
$object->project->title, 50),
'',
'R');
2141 if (!empty(
$object->project->ref)) {
2142 $outputlangs->load(
"projects");
2144 $pdf->SetXY($posx, $posy);
2145 $pdf->SetTextColor(0, 0, 60);
2146 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".
$object->project->ref,
'',
'R');
2150 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2151 if (
$object->type == 0 && $objectidnext) {
2152 $objectreplacing =
new Facture($this->db);
2153 $objectreplacing->fetch($objectidnext);
2156 $pdf->SetXY($posx, $posy);
2157 $pdf->SetTextColor(0, 0, 60);
2158 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2161 $objectreplaced =
new Facture($this->db);
2162 $objectreplaced->fetch(
$object->fk_facture_source);
2165 $pdf->SetXY($posx, $posy);
2166 $pdf->SetTextColor(0, 0, 60);
2167 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2170 $objectreplaced =
new Facture($this->db);
2171 $objectreplaced->fetch(
$object->fk_facture_source);
2174 $pdf->SetXY($posx, $posy);
2175 $pdf->SetTextColor(0, 0, 60);
2176 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2180 $pdf->SetXY($posx, $posy);
2181 $pdf->SetTextColor(0, 0, 60);
2183 $title = $outputlangs->transnoentities(
"DateInvoice");
2184 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2185 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2187 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2191 $pdf->SetXY($posx, $posy);
2192 $pdf->SetTextColor(0, 0, 60);
2193 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2198 $pdf->SetXY($posx, $posy);
2199 $pdf->SetTextColor(0, 0, 60);
2200 $title = $outputlangs->transnoentities(
"DateDue");
2201 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2202 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2204 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2209 $pdf->SetXY($posx, $posy);
2210 $pdf->SetTextColor(0, 0, 60);
2211 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_client),
'',
'R');
2216 $pdf->SetXY($posx, $posy);
2217 $pdf->SetTextColor(0, 0, 60);
2218 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_compta_client),
'',
'R');
2223 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2224 if (count($arrayidcontact) > 0) {
2225 $usertmp =
new User($this->db);
2226 $usertmp->fetch($arrayidcontact[0]);
2228 $pdf->SetXY($posx, $posy);
2229 $pdf->SetTextColor(0, 0, 60);
2230 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2240 $current_y = $pdf->getY();
2242 if ($current_y < $pdf->getY()) {
2243 $top_shift = $pdf->getY() - $current_y;
2249 $carac_emetteur =
'';
2251 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2252 if (count($arrayidcontact) > 0) {
2253 $object->fetch_user($arrayidcontact[0]);
2254 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2255 $carac_emetteur .= $labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2256 $carac_emetteur .=
"\n";
2262 $posy =
getDolGlobalString(
'MAIN_PDF_USE_ISO_LOCATION') ? $this->marge_haute + 30 : $this->marge_haute + 32;
2263 $posy += $top_shift;
2264 $posx = $this->marge_gauche;
2266 $posx = $this->page_largeur - $this->marge_droite - 80;
2274 $pdf->SetTextColor(0, 0, 0);
2275 $pdf->SetFont(
'',
'', $default_font_size - 2);
2276 $pdf->SetXY($posx, $posy - 5);
2277 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2278 $pdf->SetXY($posx, $posy);
2279 $pdf->SetFillColor(230, 230, 230);
2280 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2281 $pdf->SetTextColor(0, 0, 60);
2286 $pdf->SetXY($posx + 2, $posy + 3);
2287 $pdf->SetFont(
'',
'B', $default_font_size);
2288 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2289 $posy = $pdf->getY();
2293 $pdf->SetXY($posx + 2, $posy);
2294 $pdf->SetFont(
'',
'', $default_font_size - 1);
2295 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2298 $usecontact =
false;
2299 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2300 if (count($arrayidcontact) > 0) {
2302 $result =
$object->fetch_contact($arrayidcontact[0]);
2306 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2307 $thirdparty =
$object->contact;
2309 $thirdparty =
$object->thirdparty;
2319 if ($this->page_largeur < 210) {
2322 $posy =
getDolGlobalString(
'MAIN_PDF_USE_ISO_LOCATION') ? $this->marge_haute + 30 : $this->marge_haute + 32;
2323 $posy += $top_shift;
2324 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2326 $posx = $this->marge_gauche;
2331 $pdf->SetTextColor(0, 0, 0);
2332 $pdf->SetFont(
'',
'', $default_font_size - 2);
2333 $pdf->SetXY($posx + 2, $posy - 5);
2334 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2335 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2339 $pdf->SetXY($posx + 2, $posy + 3);
2340 $pdf->SetFont(
'',
'B', $default_font_size);
2342 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2344 $posy = $pdf->getY();
2347 $pdf->SetFont(
'',
'', $default_font_size - 1);
2348 $pdf->SetXY($posx + 2, $posy);
2350 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2354 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2356 if (!empty($idaddressshipping)) {
2357 $object->fetch_contact($idaddressshipping[0]);
2358 $companystatic =
new Societe($this->db);
2359 $companystatic->fetch(
$object->contact->fk_soc);
2366 if (!empty($carac_client_shipping)) {
2367 $posy += $hautcadre;
2372 $pdf->SetXY($posx + 2, $posy - 5);
2373 $pdf->SetFont(
'',
'', $default_font_size - 2);
2374 $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities(
'ShippingTo'), 0,
'L',
false);
2375 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2378 $pdf->SetXY($posx + 2, $posy + 3);
2379 $pdf->SetFont(
'',
'B', $default_font_size);
2380 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2382 $posy = $pdf->getY();
2385 $pdf->SetXY($posx + 2, $posy);
2386 $pdf->SetFont(
'',
'', $default_font_size - 1);
2387 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2389 $shipp_shift += $hautcadre;
2394 $pdf->SetTextColor(0, 0, 0);
2396 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);
2412 protected function _pagefoot(&$pdf,
$object, $outputlangs, $hidefreetext = 0, $heightforqrinvoice = 0)
2415 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
2416 return pdf_pagefoot($pdf, $outputlangs,
'INVOICE_FREE_TEXT', $this->emetteur, $heightforqrinvoice + $this->marge_basse, $this->marge_gauche, $this->page_hauteur,
$object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
2431 global $hookmanager;
2434 $this->defaultContentsFieldsStyle = array(
2436 'padding' => array(1, 0.5, 1, 0.5),
2440 $this->defaultTitlesFieldsStyle = array(
2442 'padding' => array(0.5, 0, 0.5, 0),
2464 $this->cols[
'position'] = array(
2473 'padding' => array(0.5, 0.5, 0.5, 0.5),
2477 'padding' => array(1.0, 0.5, 1.0, 1.5),
2482 $this->cols[
'desc'] = array(
2487 'textkey' =>
'Designation',
2491 'padding' => array(0.5, 0.5, 0.5, 0.5),
2495 'padding' => array(1.0, 0.5, 1.0, 1.5),
2501 $this->cols[
'photo'] = array(
2503 'width' => (
float)
getDolGlobalInt(
'MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20),
2506 'textkey' =>
'Photo',
2510 'padding' => array(0.0, 0.0, 0.0, 0.0),
2512 'border-left' =>
false,
2515 if (
getDolGlobalString(
'MAIN_GENERATE_INVOICES_WITH_PICTURE') && !empty($this->atleastonephoto)) {
2516 $this->cols[
'photo'][
'status'] =
true;
2521 $this->cols[
'vat'] = array(
2528 'border-left' =>
true,
2532 $this->cols[
'vat'][
'status'] =
true;
2536 $this->cols[
'unit'] = array(
2543 'border-left' =>
true,
2546 $this->cols[
'unit'][
'status'] =
false;
2550 $this->cols[
'subprice'] = array(
2555 'textkey' =>
'PriceUHT'
2557 'border-left' =>
true,
2562 $nblines = count(
$object->lines);
2563 for ($i = 0; $i < $nblines; $i++) {
2565 $tmpwidth = max($tmpwidth, $tmpwidth2);
2567 if ($tmpwidth > 10) {
2568 $this->cols[
'subprice'][
'width'] += (2 * ($tmpwidth - 10));
2572 $this->cols[
'qty'] = array(
2579 'border-left' =>
true,
2582 $this->cols[
'qty'][
'status'] =
true;
2586 $this->cols[
'btpsomme'] = array(
2591 'textkey' =>
'Chantier'
2593 'border-left' =>
true,
2594 'overtitle' => array(
2595 'textkey' =>
'Chantier',
2597 'padding' => array(0.5,0.5,0.5,0.5),
2601 if (!empty($this->TDataSituation[
'date_derniere_situation'])) {
2602 $this->cols[
'btpsomme'][
'status'] =
true;
2607 $this->cols[
'prev_progress'] = array(
2612 'textkey' => $outputlangs->transnoentities(
'ProgressShort')
2614 'border-left' =>
true,
2615 'overtitle' => array(
2617 'textkey' =>
'S'.(!empty($this->TDataSituation[
'derniere_situation']) ? $this->TDataSituation[
'derniere_situation']->situation_counter .
' - ' .
dol_print_date($this->TDataSituation[
'derniere_situation']->
date,
"%d/%m/%Y") :
''),
2619 'padding' => array(0.5,0.2,0.5,0.2),
2623 if ($this->situationinvoice && !empty($this->TDataSituation[
'date_derniere_situation'])) {
2624 $this->cols[
'prev_progress'][
'status'] =
true;
2629 $this->cols[
'prev_progress_amount'] = array(
2634 'textkey' => $outputlangs->transnoentities(
'Amount')
2636 'border-left' =>
true,
2638 if ($this->situationinvoice && ! empty($this->TDataSituation[
'date_derniere_situation'])) {
2639 $this->cols[
'prev_progress_amount'][
'status'] =
true;
2644 $this->cols[
'progress'] = array(
2649 'textkey' => $outputlangs->transnoentities(
'ProgressShort')
2651 'border-left' =>
true,
2652 'overtitle' => array(
2655 'padding' => array(0.5,0.2,0.5,0.2),
2662 $this->cols[
'progress_amount'] = array(
2667 'textkey' => $outputlangs->transnoentities(
'Amount')
2669 'border-left' =>
true,
2671 if ($this->situationinvoice) {
2672 $this->cols[
'progress_amount'][
'status'] =
true;
2678 $this->cols[
'discount'] = array(
2683 'textkey' =>
'ReductionShort'
2685 'border-left' =>
true,
2687 if ($this->atleastonediscount) {
2688 $this->cols[
'discount'][
'status'] =
true;
2691 $this->cols[
'totalexcltax'] = array(
2696 'textkey' => $outputlangs->transnoentities(
'TotalHT')
2698 'border-left' =>
true,
2703 $line = reset(
$object->lines);
2707 $parameters = array(
2709 'outputlangs' => $outputlangs,
2710 'hidedetails' => $hidedetails,
2711 'hidedesc' => $hidedesc,
2712 'hideref' => $hideref
2715 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
2717 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2718 } elseif (empty($reshook)) {
2720 $this->cols = array_replace($this->cols, $hookmanager->resArray);
2722 $this->cols = $hookmanager->resArray;
2740 public function tableFirstPage(
$object, &$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
2742 global $user,
$conf;
2744 $form =
new Form($this->db);
2748 if (!$displayWarranty) {
2759 $currency = !empty($currency) ? $currency : (string)
$conf->currency;
2763 $pdf->SetTextColor(0, 0, 0);
2764 $pdf->SetFont(
'',
'', $default_font_size - 2);
2766 if (empty($hidetop)) {
2767 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
2768 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 8);
2769 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
2771 $width = $this->page_largeur - $this->marge_gauche - $this->marge_droite - 83;
2775 $pdf->RoundedRect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, $this->corner_radius,
'1001',
'F', explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2777 $pdf->RoundedRect($this->marge_gauche, $tab_top + 92.5, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F', array(), explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2781 $pdf->SetDrawColor(128, 128, 128);
2782 $pdf->SetFont(
'',
'', $default_font_size - 1);
2784 $height_incoterms = 0;
2786 $desc_incoterms =
$object->getIncotermsForPDF();
2787 if ($desc_incoterms) {
2788 $this->tab_top -= 2;
2789 $posybefore = $pdf->GetY();
2790 $pdf->SetFont(
'',
'', $default_font_size - 1);
2791 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
2794 $pdf->SetDrawColor(192, 192, 192);
2795 $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius,
'1234',
'D');
2796 $posyafter = $pdf->GetY();
2797 $tab_top += $posyafter - $posybefore + 2;
2801 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
2804 if (is_object(
$object->thirdparty)) {
2805 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
2806 $salerepobj =
new User($this->db);
2807 $salerepobj->fetch($salereparray[0][
'id']);
2808 if (!empty($salerepobj->signature)) {
2809 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
2815 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
2816 if (!empty($extranote)) {
2822 $posybefore = $pdf->GetY();
2828 $pdf->SetFont(
'',
'', $default_font_size - 1);
2829 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
2831 $posyafter = $pdf->GetY();
2832 $tab_top += $posyafter - $posybefore + 2;
2837 $this->
printRoundedRectBtp($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom,
'D');
2839 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top, $this->posx_cumul_anterieur - 1, $tab_top + $tab_height);
2840 if (empty($hidetop)) {
2841 $pdf->SetXY($this->posx_cumul_anterieur - 1, $tab_top + 0.5);
2842 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceOldCumulation"),
'',
'C');
2846 $pdf->line($this->posx_new_cumul - 1, $tab_top, $this->posx_new_cumul - 1, $tab_top + $tab_height);
2847 if (empty($hidetop)) {
2848 $pdf->SetXY($this->posx_new_cumul - 1, $tab_top + 0.5);
2849 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceNewCumulation"),
'',
'C');
2852 $pdf->line($this->posx_current - 1, $tab_top, $this->posx_current - 1, $tab_top + $tab_height);
2853 if (empty($hidetop)) {
2854 $pdf->SetXY($this->posx_current - 1, $tab_top + 0.5);
2855 $pdf->MultiCell(36, 2, $outputlangs->transnoentities(
"CurrentSituationTotal", (
string)
$object->situation_counter),
'',
'C');
2859 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
2861 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 24, $this->page_largeur - $this->marge_droite, $tab_top + 24);
2863 $pdf->line($this->marge_gauche, $tab_top + 55, $this->page_largeur - $this->marge_droite, $tab_top + 55);
2865 $pdf->line($this->marge_gauche, $tab_top + 65, $this->page_largeur - $this->marge_droite, $tab_top + 65);
2867 if ($displayWarranty) {
2868 $pdf->line($this->marge_gauche, $tab_top + 85, $this->page_largeur - $this->marge_droite, $tab_top + 85);
2874 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 8);
2875 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceMainTask"),
'',
'L');
2877 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 12);
2878 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceAdditionalTask"),
'',
'L');
2880 $form->load_cache_vatrates(
"'".
$object->thirdparty->country_code.
"'");
2883 foreach ($form->cache_vatrates as $TVatInfo) {
2884 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2886 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2891 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 24 + $i);
2892 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalHT").
' '.$TVatInfo[
'label'],
'',
'L');
2894 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2895 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 28 + $i);
2896 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"VAT").
' '.$TVatInfo[
'label'],
'',
'L');
2902 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 33 + $i);
2903 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'L');
2906 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2907 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 58);
2908 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalSituationInvoice"),
'',
'L');
2909 $pdf->SetFont(
'',
'', $default_font_size - 2);
2911 if ($displayWarranty) {
2912 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 74);
2913 $pdf->MultiCell(80, 2, $outputlangs->trans(
"TotalSituationInvoiceWithRetainedWarranty", (
string)
$object->retained_warranty),
'',
'L');
2914 $nextY = $tab_top + 93;
2916 $nextY = $tab_top + 74;
2919 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2920 $pdf->SetXY($this->marge_gauche + 2, $nextY);
2921 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"SituationTotalRayToRest"),
'',
'L');
2922 $pdf->SetFont(
'',
'', $default_font_size - 2);
2926 $TToDisplay = array(
2932 $x = $this->marge_gauche + 85;
2936 foreach ($TToDisplay as $col) {
2938 $pdf->SetXY($x, $tab_top + 8);
2939 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2942 $pdf->SetXY($x, $tab_top + 12);
2943 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'travaux_sup'], 0,
'', 1, -1, 2),
'',
'R');
2946 foreach ($form->cache_vatrates as $TVatInfo) {
2947 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2948 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2954 $pdf->SetXY($x, $tab_top + 24 + $i);
2955 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2958 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2959 $pdf->SetXY($x, $tab_top + 28 + $i);
2960 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'TVA'], 0,
'', 1, -1, 2),
'',
'R');
2967 $pdf->SetXY($x, $tab_top + 33 + $i);
2968 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
2971 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2972 $pdf->SetXY($x, $tab_top + 58);
2973 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
2974 $pdf->SetFont(
'',
'', $default_font_size - 2);
2977 if ($displayWarranty) {
2979 $pdf->SetXY($x, $tab_top + 74);
2980 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'retenue_garantie'], 0,
'', 1, -1, 2),
'',
'R');
2981 $nextY = $tab_top + 93;
2983 $nextY = $tab_top + 74;
2987 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2988 $pdf->SetXY($x, $nextY);
2989 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'total_a_payer'], 0,
'', 1, -1, 2),
'',
'R');
2990 $pdf->SetFont(
'',
'', $default_font_size - 2);
3018 public function getDataSituation(&
$object)
3022 $object->fetchPreviousNextSituationInvoice();
3024 $TPreviousInvoices =
$object->tab_previous_situation_invoice;
3025 unset(
$object->tab_previous_situation_invoice);
3029 $TPreviousInvoices = array_reverse($TPreviousInvoices);
3030 $facDerniereSituation = reset($TPreviousInvoices);
3032 $TDataSituation = array();
3034 if (! empty($facDerniereSituation)) {
3035 $TDataSituation[
'derniere_situation'] = $facDerniereSituation;
3036 $TDataSituation[
'date_derniere_situation'] = $facDerniereSituation->date;
3039 $retenue_garantie = 0;
3040 $retenue_garantie_anterieure = 0;
3042 $TDataSituation[
'cumul_anterieur'] = array(
3046 'retenue_garantie' => 0,
3049 'total_a_payer' => 0
3053 if (!empty($TPreviousInvoices)) {
3055 foreach ($TPreviousInvoices as $i => $previousInvoice) {
3056 $TDataSituation[
'cumul_anterieur'][
'HT'] += $previousInvoice->total_ht;
3058 $TDataSituation[
'cumul_anterieur'][
'TVA'] += $previousInvoice->total_tva;
3064 foreach ($previousInvoice->lines as $k => $l) {
3065 $total_ht = (float) $l->total_ht;
3066 if (empty($total_ht)) {
3071 $prevSituationPercent = 0;
3072 $isFirstSituation =
false;
3073 if (!empty($l->fk_prev_id)) {
3074 $prevSituationPercent = $l->get_prev_progress($previousInvoice->id,
true);
3075 } elseif (! array_key_exists($i + 1, $TPreviousInvoices)) {
3076 $isFirstSituation =
true;
3079 $calc_ht = $l->total_ht;
3081 $ltvatx = (float) sprintf(
"%01.3f", $l->tva_tx);
3084 $amounttva = $calc_ht * ($ltvatx / 100);
3085 if (! isset($TDataSituation[
'cumul_anterieur'][$ltvatx])) {
3086 $TDataSituation[
'cumul_anterieur'][$ltvatx][
'HT'] = $calc_ht;
3087 $TDataSituation[
'cumul_anterieur'][$ltvatx][
'TVA'] = $amounttva;
3090 $TDataSituation[
'cumul_anterieur'][$ltvatx][
'HT'] += ($calc_ht);
3091 $TDataSituation[
'cumul_anterieur'][$ltvatx][
'TVA'] += $amounttva;
3097 if (empty($l->fk_prev_id) && ! $isFirstSituation) {
3099 $TDataSituation[
'cumul_anterieur'][
'travaux_sup'] += $calc_ht;
3104 if (! empty($previousInvoice->retained_warranty) && !
getDolGlobalString(
'USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL')) {
3105 $retenue_garantie_anterieure += $previousInvoice->getRetainedWarrantyAmount(
'MT');
3109 $TDataSituation[
'cumul_anterieur'][
'HT'] -= $TDataSituation[
'cumul_anterieur'][
'travaux_sup'];
3110 $TDataSituation[
'cumul_anterieur'][
'retenue_garantie'] = $retenue_garantie_anterieure;
3111 $TDataSituation[
'cumul_anterieur'][
'TTC'] = $TDataSituation[
'cumul_anterieur'][
'HT'] + $TDataSituation[
'cumul_anterieur'][
'TVA'];
3112 $TDataSituation[
'cumul_anterieur'][
'total_a_payer'] = $TDataSituation[
'cumul_anterieur'][
'TTC'] - $retenue_garantie_anterieure;
3116 $TDataSituation[
'current'] = $this->btpGetInvoiceAmounts(
$object->id);
3118 if (! empty($facDerniereSituation->lines)) {
3119 $TFacLinesKey = array_keys($facDerniereSituation->lines);
3120 $TObjectLinesKey = array_keys(
$object->lines);
3121 $TDiffKey = array_diff($TObjectLinesKey, $TFacLinesKey);
3125 foreach ($TDiffKey as $i) {
3126 if (empty(
$object->lines[$i]->fk_prev_id)) {
3129 $TDataSituation[
'current'][
'travaux_sup'] +=
$object->lines[$i]->total_ht;
3135 $TDataSituation[
'nouveau_cumul'] = $this->
sumSituation($TDataSituation[
'current'], $TDataSituation[
'cumul_anterieur']);
3137 return $TDataSituation;
3152 foreach ($a as $k => $v) {
3154 if (isset($b[$k])) {
3161 if (isset($b[$k])) {
3167 dol_syslog(
"sumSituation first arg is not an array");
3181 if (is_callable(array(
$object,
'displayRetainedWarranty'))) {
3182 return $object->displayRetainedWarranty();
3190 $displayWarranty =
false;
3191 if (!empty(
$object->retained_warranty)) {
3192 $displayWarranty =
true;
3196 $displayWarranty =
false;
3197 if (!empty(
$object->situation_final)) {
3198 $displayWarranty =
true;
3201 $displayWarranty =
true;
3203 foreach (
$object->lines as $i => $line) {
3204 if ($line->product_type < 2 && $line->situation_percent < 100) {
3205 $displayWarranty =
false;
3212 return $displayWarranty;
3225 if (empty(
$object->situation_cycle_ref) ||
$object->situation_counter <= 1) {
3229 $facDerniereSituation = &$this->TDataSituation[
'derniere_situation'];
3232 foreach ($facDerniereSituation->lines as $l) {
3233 if ($l->rowid == $current_line->fk_prev_id) {
3235 $ltvatx = (float) sprintf(
"%01.3f", $l->tva_tx);
3236 $tabprice =
calcul_price_total($l->qty, $l->subprice, $l->remise_percent, $ltvatx, $l->localtax1_tx, $l->localtax2_tx, 0,
'HT', $l->info_bits, $l->product_type);
3237 $total_ht = $tabprice[0];
3238 $total_tva = $tabprice[1];
3239 $total_ttc = $tabprice[2];
3240 $total_localtax1 = $tabprice[9];
3241 $total_localtax2 = $tabprice[10];
3242 $pu_ht = $tabprice[3];
3245 'progress_prec' => (
float) $l->situation_percent,
3246 'total_ht_without_progress' => (
float) $total_ht,
3247 'total_ht' => $l->total_ht,
3295 if (empty($hidetop) || $hidetop == -1) {
3296 $pdf->RoundedRect($x, $y, $w, $h, $r,
'1111', $style);
3299 $pdf->RoundedRect($x, $y, $w, $h, $r,
'0111', $style);
3301 if (!empty($hidebottom)) {
3302 $pdf->RoundedRect($x, $y, $w, $h, $r,
'1101', $style);
3314 public function btpGetInvoiceAmounts(
$id, $forceReadFromDB =
false)
3323 $object->fetchPreviousNextSituationInvoice();
3325 $TPreviousInvoices =
$object->tab_previous_situation_invoice;
3326 unset(
$object->tab_previous_situation_invoice);
3328 $TPreviousInvoices = array_reverse($TPreviousInvoices);
3329 $facDerniereSituation = reset($TPreviousInvoices);
3336 'retenue_garantie' => 0,
3338 'total_a_payer' => 0
3341 if (! empty($facDerniereSituation)) {
3342 $ret[
'derniere_situation'] = $facDerniereSituation;
3343 $ret[
'date_derniere_situation'] = $facDerniereSituation->date;
3347 foreach (
$object->lines as $k => $l) {
3348 $total_ht = (float) $l->total_ht;
3349 if (empty($total_ht)) {
3355 if (isset($ret[$ltvatx])) {
3357 $ret[$ltvatx][
'TVA'] += $l->total_tva;
3359 $ret[$ltvatx][
'HT'] += $l->total_ht;
3361 $ret[$ltvatx][
'TVA'] = $l->total_tva;
3362 $ret[$ltvatx][
'HT'] = $l->total_ht;
3367 $retenue_garantie =
$object->getRetainedWarrantyAmount(
'MT');
3368 if ($retenue_garantie == -1) {
3369 $retenue_garantie = 0;
3373 $ret[
'TTC'] =
$object->total_ttc;
3374 $ret[
'TVA'] =
$object->total_tva;
3375 $ret[
'HT'] =
$object->total_ht - $ret[
'travaux_sup'];
3376 $ret[
'total_a_payer'] = $ret[
'TTC'] - $retenue_garantie;
3377 $ret[
'retenue_garantie'] = $retenue_garantie;
3380 if (array_key_exists(
'derniere_situation', $ret)) {
3381 unset($ret[
'derniere_situation']->db);
3382 unset($ret[
'derniere_situation']->fields);
3383 unset($ret[
'derniere_situation']->lines);
3402 public function resumeLastPage(&$pdf,
$object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
3414 if (!empty($this->tplidx)) {
3415 $pdf->useTemplate($this->tplidx);
3418 $pagehead = $this->
_pagehead($pdf,
$object, 0, $outputlangs, $outputlangsbis);
3420 $tab2_top = $this->tab_top_newpage - 4;
3422 $posx = $this->marge_gauche;
3424 $outputlangs->load(
'orders');
3425 $outputlangs->load(
'propal');
3427 $width2 = $this->page_largeur - $posx - $width - $this->marge_droite;
3429 $pdf->SetFont(
'',
'', $default_font_size - 1);
3430 $pdf->MultiCell(0, 3,
'');
3431 $pdf->SetTextColor(0, 0, 0);
3432 $pdf->setY($tab2_top);
3434 if (is_object($outputlangsbis)) {
3435 $pdf->SetFont(
'',
'', $default_font_size - 2);
3437 $pdf->SetFont(
'',
'', $default_font_size - 1);
3440 if (empty(
$object->tab_previous_situation_invoice)) {
3441 $object->fetchPreviousNextSituationInvoice();
3444 $previousinvoices = count(
$object->tab_previous_situation_invoice) ?
$object->tab_previous_situation_invoice : array();
3446 $remain_to_pay_in_proposals_or_orders = 0;
3447 $remain_to_pay_in_invoice = 0;
3453 if (count($previousinvoices)) {
3454 foreach ($previousinvoices as $invoice) {
3455 if ($invoice->is_first()) {
3456 $invoice->fetchObjectLinked();
3458 $propals = isset($invoice->linkedObjects[
'propal']) ? $invoice->linkedObjects[
'propal'] : array();
3459 $orders = isset($invoice->linkedObjects[
'commande']) ? $invoice->linkedObjects[
'commande'] : array();
3466 $propals = isset(
$object->linkedObjects[
'propal']) ?
$object->linkedObjects[
'propal'] : array();
3467 $orders = isset(
$object->linkedObjects[
'commande']) ?
$object->linkedObjects[
'commande'] : array();
3475 if (count($propals)) {
3476 $propal = array_pop($propals);
3478 $total_ht = (
isModEnabled(
'multicurrency') && $propal->multicurrency_tx != 1) ? $propal->multicurrency_total_ht : $propal->total_ht;
3479 $remain_to_pay_in_proposals_or_orders = $total_ht;
3481 $pdf->SetTextColor(0, 0, 60);
3482 $pdf->SetFont(
'',
'', $default_font_size - 1);
3484 $label = $outputlangs->transnoentities(
"SituationInvoiceTotalProposal");
3485 $pdf->MultiCell($this->page_largeur - ($this->marge_droite + $this->marge_gauche), 3, $label, 0,
'L',
false, 1, $posx, $posy + 1);
3487 $amount =
price($sign * $total_ht);
3488 $pdf->MultiCell($width2, 3, $amount, 0,
'R',
false, 1, $posx + $width, $posy + 1);
3490 $pdf->SetFont(
'',
'', $default_font_size - 1);
3493 $pdf->SetDrawColor(128, 128, 128);
3495 $this->
printRoundedRect($pdf, $posx, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 6, $this->corner_radius, 0, 0,
'D');
3498 } elseif (count($orders)) {
3499 $order = array_pop($orders);
3501 $total_ht = (
isModEnabled(
'multicurrency') && $order->multicurrency_tx != 1 ? $order->multicurrency_total_ht : $order->total_ht);
3502 $remain_to_pay_in_proposals_or_orders = $total_ht;
3515 $pdf->SetTextColor(0, 0, 60);
3516 $pdf->SetFont(
'',
'B', $default_font_size + 3);
3519 $pdf->SetXY($posx, $posy);
3522 $depositsamount =
$object->getSumDepositsUsed();
3523 $deja_regle =
$object->getSommePaiement();
3525 $tot_deja_regle = ($depositsamount + $deja_regle);
3527 $previousinvoices[] =
$object;
3529 $force_to_zero =
false;
3532 while ($idinv < count($previousinvoices)) {
3533 $invoice = $previousinvoices[$idinv];
3538 $pdf->SetTextColor(0, 0, 60);
3539 $pdf->SetFont(
'',
'B', $default_font_size + 3);
3541 $pageposbefore = $pdf->getPage();
3542 $pdf->startTransaction();
3544 $pdf->SetXY($posx, $posy);
3546 $ref = $outputlangs->transnoentities(
"InvoiceSituation").$outputlangs->convToOutputCharset(
" n°".$invoice->situation_counter);
3550 if ($invoice->situation_final) {
3552 $force_to_zero =
true;
3556 $ref .=
' - '. $invoice->ref;
3557 $ref .=
' ('.dol_print_date($invoice->date,
"%d/%m/%Y",
false, $outputlangs).
')';
3558 $pdf->MultiCell($this->page_largeur - ($this->marge_droite + $this->marge_gauche), 3, $ref, 0,
'L',
false);
3560 $pdf->SetFont(
'',
'', $default_font_size - 1);
3569 $pdf->SetFillColor(255, 255, 255);
3570 $pdf->SetXY($posx, $posy);
3571 $pdf->MultiCell($width, $height, $outputlangs->transnoentities(
"TotalHT"), 0,
'L',
true);
3573 $total_ht = (
isModEnabled(
'multicurrency') && $invoice->multicurrency_tx != 1 ? $invoice->multicurrency_total_ht : $invoice->total_ht);
3575 $pdf->SetXY($posx + $width, $posy);
3576 $pdf->MultiCell($width2, $height,
price($sign * $total_ht, 0, $outputlangs), 0,
'R',
true);
3579 $nblines = count($invoice->lines);
3580 for ($i = 0; $i < $nblines; $i++) {
3581 $tvaligne = $invoice->lines[$i]->total_tva;
3582 $vatrate = (string) $invoice->lines[$i]->tva_tx;
3584 if (($invoice->lines[$i]->info_bits & 0x01) == 0x01) {
3587 if (! isset($tvas[$vatrate])) {
3588 $tvas[$vatrate] = 0;
3590 $tvas[$vatrate] += $tvaligne;
3594 $pdf->SetFillColor(248, 248, 248);
3595 foreach ($tvas as $tvakey => $tvaval) {
3598 $pdf->SetXY($posx, $posy + $height * $index);
3601 if (preg_match(
'/\*/', $tvakey)) {
3602 $tvakey = str_replace(
'*',
'', $tvakey);
3603 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
3605 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).
' ';
3606 $totalvat .=
vatrate($tvakey,
true).$tvacompl;
3607 $pdf->MultiCell($width, $height, $totalvat, 0,
'L',
true);
3609 $pdf->SetXY($posx + $width, $posy + $height * $index);
3610 $pdf->MultiCell($width2, $height,
price($tvaval, 0, $outputlangs), 0,
'R',
true);
3616 $total_ht = (
isModEnabled(
'multicurrency') && $invoice->multicurrency_tx != 1) ? $invoice->multicurrency_total_ht : $invoice->total_ht;
3617 $total_ttc = (
isModEnabled(
'multicurrency') && $invoice->multicurrency_tx != 1) ? $invoice->multicurrency_total_ttc : $invoice->total_ttc;
3620 $pdf->SetXY($posx, $posy + $height * $index);
3621 $pdf->SetTextColor(0, 0, 60);
3622 $pdf->SetFillColor(224, 224, 224);
3623 $pdf->MultiCell($width, $height, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
3626 $pdf->SetXY($posx + $width, $posy + $height * $index);
3627 $pdf->MultiCell($width2, $height,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R',
true);
3637 $pdf->SetXY($posx, $posy + $height * $index);
3638 $pdf->SetTextColor(0, 0, 60);
3639 $pdf->SetFillColor(241, 241, 241);
3640 $pdf->MultiCell($width, $height, $outputlangs->transnoentities(
"RetainedWarrantyShort", (
string) $retainedWarrantyRate), $useborder,
'L',
true);
3642 $total_ht_rg = (float)
price2num(
price($total_ht * $retainedWarrantyRate / 100),
'MT');
3643 $total_ttc_rg = (float)
price2num(
price($total_ttc * $retainedWarrantyRate / 100),
'MT');
3645 $pdf->SetXY($posx + $width, $posy + $height * $index);
3646 $pdf->MultiCell($width2, $height,
price(-$sign * $total_ht_rg, 0, $outputlangs), $useborder,
'R',
true);
3648 $total_ht_with_rg = $total_ht - $total_ht_rg;
3649 $total_ttc_with_rg = $total_ttc - $total_ttc_rg;
3654 $pdf->SetXY($posx, $posy + $height * $index);
3655 $pdf->SetTextColor(0, 0, 60);
3656 $pdf->SetFillColor(224, 224, 224);
3657 $pdf->MultiCell($width, $height, $outputlangs->transnoentities(
"TotalSituationInvoiceWithRetainedWarranty"), $useborder,
'L',
true);
3659 $pdf->SetXY($posx + $width, $posy + $height * $index);
3660 $pdf->MultiCell($width2, $height,
price($sign * $total_ttc_with_rg, 0, $outputlangs), $useborder,
'R',
true);
3667 $pdf->SetTextColor(0, 0, 0);
3669 $creditnoteamount = $invoice->getSumCreditNotesUsed();
3670 $depositsamount = $invoice->getSumDepositsUsed();
3671 $deja_regle = $invoice->getSommePaiement();
3673 $resteapayer =
price2num($invoice->total_ttc - $deja_regle - $total_ttc_rg - $creditnoteamount - $depositsamount,
'MT');
3674 if ($invoice->paye) {
3682 $tot_deja_regle += $deja_regle + $depositsamount;
3684 $pdf->SetXY($posx, $posy + $height * $index);
3685 $pdf->MultiCell($width, $height, $outputlangs->transnoentities(
"Paid"), 0,
'L',
false);
3686 $pdf->SetXY($posx + $width, $posy + $height * $index);
3687 $pdf->MultiCell($width2, $height,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R',
false);
3690 if ($creditnoteamount) {
3692 $pdf->SetXY($posx, $posy + $height * $index);
3693 $pdf->MultiCell($width, $height, $outputlangs->transnoentities(
"CreditNotes"), 0,
'L',
false);
3694 $pdf->SetXY($posx + $width, $posy + $height * $index);
3695 $pdf->MultiCell($width2, $height,
price($creditnoteamount, 0, $outputlangs), 0,
'R',
false);
3699 if ($invoice->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
3701 $pdf->SetFillColor(255, 255, 255);
3703 $pdf->SetXY($posx, $posy + $height * $index);
3704 $pdf->MultiCell($width, $height, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L',
true);
3705 $pdf->SetXY($posx + $width, $posy + $height * $index);
3706 $pdf->MultiCell($width2, $height,
price($invoice->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R',
true);
3712 $pdf->SetTextColor(0, 0, 60);
3713 $pdf->SetFillColor(224, 224, 224);
3714 $pdf->SetXY($posx, $posy + $height * $index);
3715 $pdf->MultiCell($width, $height, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
3716 $pdf->SetXY($posx + $width, $posy + $height * $index);
3717 $pdf->MultiCell($width2, $height,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
3719 $pdf->SetFont(
'',
'', $default_font_size - 1);
3720 $pdf->SetTextColor(0, 0, 0);
3724 if ($deja_regle > 0) {
3725 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
3726 if ($invoice->type == 2) {
3727 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
3730 $pdf->SetFont(
'',
'', $default_font_size - 3);
3731 $pdf->SetXY($posx, $posy + $height * $index);
3732 $pdf->MultiCell($width, $height, $title, 0,
'L',
false);
3738 $width4 = ($this->page_largeur - $this->marge_droite - $posx) / 4;
3740 $pdf->SetFont(
'',
'', $default_font_size - 4);
3741 $pdf->SetXY($posx, $posy + $height * $index);
3742 $pdf->MultiCell($width4, $height - 1, $outputlangs->transnoentities(
"Payment"), 0,
'L',
false);
3743 $pdf->SetXY($posx + $width4, $posy + $height * $index);
3744 $pdf->MultiCell($width4, $height - 1, $outputlangs->transnoentities(
"Amount"), 0,
'L',
false);
3745 $pdf->SetXY($posx + $width4 * 2, $posy + $height * $index);
3746 $pdf->MultiCell($width4, $height - 1, $outputlangs->transnoentities(
"Type"), 0,
'L',
false);
3747 $pdf->SetXY($posx + $width4 * 3, $posy + $height * $index);
3748 $pdf->MultiCell($width4, $height - 1, $outputlangs->transnoentities(
"Num"), 0,
'L',
false);
3754 $pdf->SetFont(
'',
'', $default_font_size - 4);
3756 $payments = $invoice->getListOfPayments();
3758 if (count($payments)) {
3759 foreach ($payments as $payment) {
3760 $pdf->SetXY($posx, $posy + $height * $index + $y);
3761 $pdf->MultiCell($width4, $height - 1,
dol_print_date($this->db->jdate($payment[
'date']),
'day',
false, $outputlangs,
true), 0,
'L',
false);
3762 $pdf->SetXY($posx + $width4, $posy + $height * $index + $y);
3763 $pdf->MultiCell($width4, $height - 1,
price($sign * $payment[
'amount'], 0, $outputlangs), 0,
'L',
false);
3764 $pdf->SetXY($posx + $width4 * 2, $posy + $height * $index + $y);
3765 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort" . $payment[
'type']);
3767 $pdf->MultiCell($width4, $height - 1, $oper, 0,
'L',
false);
3768 $pdf->SetXY($posx + $width4 * 3, $posy + $height * $index + $y);
3769 $pdf->MultiCell($width4, $height - 1, $payment[
'num'], 0,
'L',
false);
3772 $y += ($height - 1);
3778 $pdf->SetDrawColor(128, 128, 128);
3780 $this->
printRoundedRect($pdf, $this->marge_gauche, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height * $index + $y, $this->corner_radius, 0, 0,
'D');
3781 $posy += $height * $index + $y;
3783 $pageposafter = $pdf->getPage();
3784 if ($pageposafter > $pageposbefore) {
3785 $pdf->rollbackTransaction(
true);
3787 $pageposafter = $pageposbefore;
3788 $pdf->AddPage(
'',
'',
true);
3789 if (!empty($this->tplidx)) {
3790 $pdf->useTemplate($this->tplidx);
3795 $pdf->setPage($pageposafter + 1);
3796 $pdf->setPageOrientation(
'',
true, 0);
3798 $posy = $this->tab_top_newpage + 1;
3802 $remain_to_pay_in_invoice = $sign * $total_ht;
3805 if (count($invoice->lines)) {
3806 foreach ($invoice->lines as $l) {
3807 if ($l->fk_remise_except > 0) {
3809 $result = $discount->fetch((
int) $l->fk_remise_except);
3811 $rem += $discount->total_ht;
3817 $remain_to_pay_in_invoice -= $rem;
3819 $pdf->commitTransaction();
3823 if ($force_to_zero) {
3824 $remain_to_pay_in_invoice = 0;
3829 $pdf->setPageOrientation(
'',
true, 0);
3835 if (count($propals) || count($orders)) {
3836 $pdf->SetTextColor(0, 0, 60);
3837 $pdf->SetFont(
'',
'', $default_font_size - 1);
3838 $pdf->SetXY($this->marge_gauche, $posy + 1);
3839 $label = $outputlangs->transnoentities(
"SituationTotalRayToRest");
3840 $pdf->MultiCell($this->page_largeur - ($this->marge_droite + $this->marge_gauche), 3, $label, 0,
'L',
false);
3842 $amount =
price($remain_to_pay_in_proposals_or_orders);
3843 $pdf->MultiCell($width2, 3, $amount, 0,
'R',
false, 1, $posx + $width, $posy + 1);
3845 $pdf->SetDrawColor(128, 128, 128);
3847 $this->
printRoundedRect($pdf, $this->marge_gauche, $posy, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 7, $this->corner_radius, 0, 0,
'D');