275 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
278 global $user, $langs,
$conf, $mysoc, $db, $hookmanager, $nblines;
280 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
282 if (!is_object($outputlangs)) {
283 $outputlangs = $langs;
287 $outputlangs->charset_output =
'ISO-8859-1';
291 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
293 global $outputlangsbis;
294 $outputlangsbis =
null;
298 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
302 setEventMessage($langs->trans(
'WarningsObjectIsNotASituation'),
'warnings');
310 $nblines = count(
$object->lines);
318 $realpatharray = array();
319 $this->atleastonephoto =
false;
321 $objphoto =
new Product($this->db);
323 for ($i = 0; $i < $nblines; $i++) {
324 if (empty(
$object->lines[$i]->fk_product)) {
328 $objphoto->fetch(
$object->lines[$i]->fk_product);
332 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
333 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
335 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
336 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
341 foreach ($pdir as $midir) {
343 if (
$conf->entity != $objphoto->entity) {
344 $dir =
$conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
346 $dir =
$conf->product->dir_output.
'/'.$midir;
349 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
351 if ($obj[
'photo_vignette']) {
352 $filename = $obj[
'photo_vignette'];
354 $filename = $obj[
'photo'];
357 $filename = $obj[
'photo'];
360 $realpath = $dir.$filename;
362 $this->atleastonephoto =
true;
367 if ($realpath && $arephoto) {
368 $realpatharray[$i] = $realpath;
375 if (
$conf->facture->multidir_output[
$conf->entity]) {
378 $deja_regle =
$object->getSommePaiement((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
379 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
380 $amount_deposits_included =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
384 $dir =
$conf->facture->multidir_output[
$conf->entity];
385 $file = $dir.
"/SPECIMEN.pdf";
388 $dir =
$conf->facture->multidir_output[
$object->entity].
"/".$objectref;
389 $file = $dir.
"/".$objectref.
".pdf";
391 if (!file_exists($dir)) {
393 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
398 if (file_exists($dir)) {
400 if (!is_object($hookmanager)) {
401 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
404 $hookmanager->initHooks(array(
'pdfgeneration'));
405 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
407 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
410 $nblines = count(
$object->lines);
411 $nbpayments = count(
$object->getListOfPayments());
412 $nbprevsituation = is_array(
$object->tab_previous_situation_invoice) ? count(
$object->tab_previous_situation_invoice) : 0;
417 $default_font_size = 9;
418 $pdf->setAutoPageBreak(
true, 0);
421 $this->heightforinfotot = 45;
423 $this->heightforinfotot += 4 * ($nbpayments + 3);
425 if ($nbprevsituation > 0) {
426 $this->heightforinfotot += 4 * ($nbprevsituation + 3);
428 $this->heightforfreetext = (
getDolGlobalInt(
'MAIN_PDF_FREETEXT_HEIGHT', 5));
429 $this->heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
431 if (class_exists(
'TCPDF')) {
432 $pdf->setPrintHeader(
false);
433 $pdf->setPrintFooter(
false);
439 $logodir =
$conf->mycompany->dir_output;
440 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
441 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
443 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
444 $this->tplidx = $pdf->importPage(1);
449 $pdf->SetDrawColor(128, 128, 128);
451 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
452 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceSituationTitle"));
453 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
454 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
455 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
457 $pdf->SetCompression(
false);
461 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
462 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
473 'Name' => $this->emetteur->name,
474 'Location' =>
getCountry($this->emetteur->country_code,
''),
475 'Reason' =>
'INVOICE',
476 'ContactInfo' => $this->emetteur->email
478 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
482 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
486 $categoryOfOperation = 0;
489 for ($i = 0; $i < $nblines; $i++) {
490 if (
$object->lines[$i]->remise_percent) {
491 $this->atleastonediscount++;
495 if ($categoryOfOperation < 2) {
496 $lineProductType =
$object->lines[$i]->product_type;
502 if ($nbProduct > 0 && $nbService > 0) {
504 $categoryOfOperation = 2;
509 if ($categoryOfOperation <= 0) {
511 if ($nbProduct == 0 && $nbService > 0) {
512 $categoryOfOperation = 1;
515 $this->categoryOfOperation = $categoryOfOperation;
519 if (!empty($this->tplidx)) {
520 $pdf->useTemplate($this->tplidx);
525 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
526 $top_shift = $pagehead[
'top_shift'];
527 $shipp_shift = $pagehead[
'shipp_shift'];
528 $pdf->SetFont(
'',
'', $default_font_size - 1);
529 $pdf->MultiCell(0, 3,
'');
530 $pdf->SetTextColor(0, 0, 0);
535 $this->tab_top = 90 + $top_shift + $shipp_shift;
536 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
539 $extra_under_address_shift = 0;
542 $qrcodestring =
$object->buildZATCAQRString();
544 $qrcodestring =
$object->buildSwitzerlandQRString();
547 $qrcodecolor = array(
'25',
'25',
'25');
552 'fgcolor' => $qrcodecolor,
557 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
558 $extra_under_address_shift += 25;
566 'outputlangs' => $outputlangs,
567 'hidedetails' => $hidedetails
569 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
570 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
571 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
574 $this->tab_top += $extra_under_address_shift;
575 $this->tab_top_newpage += 0;
579 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->
getHeightForQRInvoice(1,
$object, $langs);
581 $nexY = $this->tab_top - 1;
591 $tab_height_newpage = 150;
593 $this->
_tableFirstPage($pdf, $tab_top, $this->page_hauteur - 100 - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
595 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
603 $pdf->setTopMargin($this->tab_top_newpage);
606 $height_incoterms = 0;
607 if (isModEnabled(
'incoterm')) {
608 $desc_incoterms =
$object->getIncotermsForPDF();
609 if ($desc_incoterms) {
612 $pdf->SetFont(
'',
'', $default_font_size - 1);
613 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
614 $nexY = max($pdf->GetY(), $nexY);
615 $height_incoterms = $nexY - $this->tab_top;
618 $pdf->SetDrawColor(192, 192, 192);
619 $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');
621 $this->tab_top = $nexY + 6;
622 $height_incoterms += 4;
627 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
630 if (is_object(
$object->thirdparty)) {
631 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
632 $salerepobj =
new User($this->db);
633 $salerepobj->fetch($salereparray[0][
'id']);
634 if (!empty($salerepobj->signature)) {
635 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
641 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
642 if (!empty($extranote)) {
646 $pagenb = $pdf->getPage();
650 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
651 $pageposbeforenote = $pagenb;
658 $pdf->startTransaction();
660 $pdf->SetFont(
'',
'', $default_font_size - 1);
661 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
663 $pageposafternote = $pdf->getPage();
664 $posyafter = $pdf->GetY();
666 if ($pageposafternote > $pageposbeforenote) {
667 $pdf->rollbackTransaction(
true);
670 while ($pagenb < $pageposafternote) {
673 if (!empty($this->tplidx)) {
674 $pdf->useTemplate($this->tplidx);
679 $pdf->setTopMargin($this->tab_top_newpage);
681 $pdf->setPageOrientation(
'',
true, $this->heightforfooter + $this->heightforfreetext);
685 $pdf->setPage($pageposbeforenote);
686 $pdf->setPageOrientation(
'',
true, $this->heightforfooter + $this->heightforfreetext);
687 $pdf->SetFont(
'',
'', $default_font_size - 1);
688 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
689 $pageposafternote = $pdf->getPage();
691 $posyafter = $pdf->GetY();
693 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
694 $pdf->AddPage(
'',
'',
true);
697 $pdf->setPage($pageposafternote);
698 $pdf->setTopMargin($this->tab_top_newpage);
700 $pdf->setPageOrientation(
'',
true, $this->heightforfooter + $this->heightforfreetext);
706 $i = $pageposbeforenote;
707 while ($i < $pageposafternote) {
711 $pdf->SetDrawColor(128, 128, 128);
713 if ($i > $pageposbeforenote) {
714 $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
715 $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
717 $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
718 $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
722 $pdf->setPageOrientation(
'',
true, 0);
729 $pdf->setPage($pageposafternote);
730 if (!empty($this->tplidx)) {
731 $pdf->useTemplate($this->tplidx);
736 $height_note = $posyafter - $this->tab_top_newpage;
737 $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
740 $pdf->commitTransaction();
741 $posyafter = $pdf->GetY();
742 $height_note = $posyafter - $this->tab_top;
743 $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
746 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
748 $pdf->AddPage(
'',
'',
true);
751 $pdf->setPage($pageposafternote);
752 if (!empty($this->tplidx)) {
753 $pdf->useTemplate($this->tplidx);
759 $posyafter = $this->tab_top_newpage;
763 $tab_height -= $height_note;
764 $this->tab_top = $posyafter + 6;
778 $nexY = $this->tab_top_newpage + $this->tabTitleHeight;
781 $pageposbeforeprintlines = $pdf->getPage();
782 $pagenb = $pageposbeforeprintlines;
783 for ($i = 0; $i < $nblines; $i++) {
785 $pdf->SetFont(
'',
'', $default_font_size - 1);
786 $pdf->SetTextColor(0, 0, 0);
789 $imglinesize = array();
790 if (!empty($realpatharray[$i])) {
794 $pdf->setTopMargin($this->tab_top_newpage);
795 $pdf->setPageOrientation(
'',
true, $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot);
796 $pageposbefore = $pdf->getPage();
798 $showpricebeforepagebreak = 1;
800 $posYAfterDescription = 0;
804 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($posy + $imglinesize[
'height']) > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
805 $pdf->AddPage(
'',
'',
true);
806 if (!empty($this->tplidx)) {
807 $pdf->useTemplate($this->tplidx);
809 $pdf->setPage($pageposbefore + 1);
811 $posy = $this->tab_top_newpage;
815 $showpricebeforepagebreak = 1;
817 $showpricebeforepagebreak = 0;
822 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
823 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $posy + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
825 $posYAfterImage = $posy + $imglinesize[
'height'];
831 $pdf->startTransaction();
834 $pageposafter = $pdf->getPage();
836 if ($pageposafter > $pageposbefore) {
837 $pdf->rollbackTransaction(
true);
838 $pageposafter = $pageposbefore;
839 $pdf->setPageOrientation(
'',
true, $this->heightforfooter);
843 $pageposafter = $pdf->getPage();
844 $posyafter = $pdf->GetY();
846 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
847 if ($i == ($nblines - 1)) {
848 $pdf->AddPage(
'',
'',
true);
849 if (!empty($this->tplidx)) {
850 $pdf->useTemplate($this->tplidx);
852 $pdf->setPage($pageposafter + 1);
858 $showpricebeforepagebreak = 1;
860 $showpricebeforepagebreak = 0;
864 $pdf->commitTransaction();
866 $posYAfterDescription = $pdf->GetY();
869 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
871 $pageposafter = $pdf->getPage();
872 $pdf->setPage($pageposbefore);
873 $pdf->setTopMargin($this->marge_haute);
874 $pdf->setPageOrientation(
'',
true, 0);
877 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
878 $pdf->setPage($pageposafter);
879 $posy = $this->tab_top_newpage;
882 $pdf->SetFont(
'',
'', $default_font_size - 1);
888 $nexY = max($pdf->GetY(), $nexY);
895 $nexY = max($pdf->GetY(), $nexY);
903 $nexY = max($pdf->GetY(), $nexY);
910 $nexY = max($pdf->GetY(), $nexY);
917 $nexY = max($pdf->GetY(), $nexY);
924 $nexY = max($pdf->GetY(), $nexY);
931 $nexY = max($pdf->GetY(), $nexY);
938 $columkey =
'btpsomme';
940 $printval =
price($TInfosLigneSituationPrecedente[
'total_ht_without_progress'], 0,
'', 1, -1, 2);
942 $nexY = max($pdf->GetY(), $nexY);
946 $columkey =
'progress_amount';
948 $printval =
price(
$object->lines[$i]->total_ht, 0,
'', 1, -1, 2);
950 $nexY = max($pdf->GetY(), $nexY);
953 $columkey =
'prev_progress';
955 $printval = $TInfosLigneSituationPrecedente[
'progress_prec'].
'%';
957 $nexY = max($pdf->GetY(), $nexY);
960 $columkey =
'prev_progress_amount';
962 $printval =
price($TInfosLigneSituationPrecedente[
'total_ht'], 0,
'', 1, -1, 2);
964 $nexY = max($pdf->GetY(), $nexY);
973 'outputlangs' => $outputlangs,
974 'hidedetails' => $hidedetails
976 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
984 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
985 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
986 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
987 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
989 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
992 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
993 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
995 $tvaligne = $sign *
$object->lines[$i]->total_tva;
999 $localtax1ligne =
$object->lines[$i]->total_localtax1;
1000 $localtax2ligne =
$object->lines[$i]->total_localtax2;
1001 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
1002 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
1003 $localtax1_type =
$object->lines[$i]->localtax1_type;
1004 $localtax2_type =
$object->lines[$i]->localtax2_type;
1006 $vatrate = (string)
$object->lines[$i]->tva_tx;
1009 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
1010 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
1012 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
1013 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
1017 if ($localtax1_type && $localtax1ligne != 0) {
1018 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
1019 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
1021 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
1024 if ($localtax2_type && $localtax2ligne != 0) {
1025 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
1026 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
1028 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
1032 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
1037 if (!isset($this->tva[$vatrate])) {
1038 $this->tva[$vatrate] = 0;
1040 $this->tva[$vatrate] += $tvaligne;
1041 $vatcode =
$object->lines[$i]->vat_src_code;
1043 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'tot_ht'])) {
1044 $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'tot_ht'] = 0;
1046 $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);
1048 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
1049 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
1051 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
1054 $nexY = max($nexY, $posYAfterImage);
1058 $pdf->setPage($pageposafter);
1059 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
1061 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
1062 $pdf->SetLineStyle(array(
'dash' => 0));
1066 while ($pagenb < $pageposafter) {
1067 $pdf->setPage($pagenb);
1068 $tabtop = $this->tab_top;
1069 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1070 if ($pagenb != $pageposbeforeprintlines) {
1071 $tabtop = $this->tab_top_newpage;
1072 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1075 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1079 $pdf->setPage($pagenb);
1080 $pdf->setPageOrientation(
'',
true, 0);
1084 if (!empty($this->tplidx)) {
1085 $pdf->useTemplate($this->tplidx);
1089 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
1090 $tabtop = $this->tab_top;
1091 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1092 if ($pagenb != $pageposbeforeprintlines) {
1093 $tabtop = $this->tab_top_newpage;
1094 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1097 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1102 if (!empty($this->tplidx)) {
1103 $pdf->useTemplate($this->tplidx);
1114 $tabtop = $this->tab_top_newpage;
1115 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter - $this->heightforinfotot - $this->heightforfreetext;
1116 $tabTitleHeight = 0;
1117 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1119 $bottomlasttab = $tabtop + $tabhauteur + $tabTitleHeight + 10;
1125 $posy = $this->
drawTotalTable($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1128 $listofpayments =
$object->getListOfPayments(
'', 0, 1);
1129 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1135 if (method_exists($pdf,
'AliasNbPages')) {
1136 $pdf->AliasNbPages();
1139 $this->resumeLastPage($pdf,
$object, 0, $tab_top, $outputlangs, $outputlangsbis);
1140 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
1145 if (
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_INVOICE') && $termsofsalefilename) {
1146 $termsofsale =
$conf->invoice->dir_output.
'/'.$termsofsalefilename;
1147 if (!empty(
$conf->invoice->multidir_output[
$object->entity ??
$conf->entity])) {
1148 $termsofsale =
$conf->invoice->multidir_output[
$object->entity ??
$conf->entity].
'/'.$termsofsalefilename;
1150 if (file_exists($termsofsale) && is_readable($termsofsale)) {
1151 $pagecount = $pdf->setSourceFile($termsofsale);
1152 for ($i = 1; $i <= $pagecount; $i++) {
1153 $tplIdx = $pdf->importPage($i);
1154 if ($tplIdx !==
false) {
1155 $s = $pdf->getTemplatesize($tplIdx);
1156 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
1157 $pdf->useTemplate($tplIdx);
1159 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
1167 $pdf->Output($file,
'F');
1170 $hookmanager->initHooks(array(
'pdfgeneration'));
1171 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1173 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1175 $this->error = $hookmanager->error;
1176 $this->errors = $hookmanager->errors;
1181 $this->result = array(
'fullpath' => $file);
1185 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1189 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1351 global $mysoc, $hookmanager;
1355 $pdf->SetFont(
'',
'', $default_font_size - 1);
1357 krsort($this->tva_array);
1364 $pdf->SetFillColor(224, 224, 224);
1366 $pdf->SetFont(
'',
'', $default_font_size - 2);
1367 $pdf->SetXY($this->marge_gauche, $posy);
1368 $titre = $outputlangs->transnoentities(
"VAT");
1369 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1371 $pdf->SetFont(
'',
'', $default_font_size - 2);
1372 $pdf->SetXY($this->marge_gauche + 25, $posy);
1373 $titre = $outputlangs->transnoentities(
"NetTotal");
1374 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1376 $pdf->SetFont(
'',
'', $default_font_size - 2);
1377 $pdf->SetXY($this->marge_gauche + 50, $posy);
1378 $titre = $outputlangs->transnoentities(
"VATAmount");
1379 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1381 $pdf->SetFont(
'',
'', $default_font_size - 2);
1382 $pdf->SetXY($this->marge_gauche + 75, $posy);
1383 $titre = $outputlangs->transnoentities(
"AmountTotal");
1384 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1386 $posy = $pdf->GetY();
1391 foreach ($this->tva_array as $tvakey => $tvaval) {
1392 $pdf->SetFont(
'',
'', $default_font_size - 2);
1393 $pdf->SetXY($this->marge_gauche, $posy);
1394 $titre = round((
float) $tvakey, 2) .
"%";
1395 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1397 $pdf->SetFont(
'',
'', $default_font_size - 2);
1398 $pdf->SetXY($this->marge_gauche + 25, $posy);
1399 $titre =
price($tvaval[
'tot_ht']);
1400 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1401 $tot_ht += $tvaval[
'tot_ht'];
1403 $pdf->SetFont(
'',
'', $default_font_size - 2);
1404 $pdf->SetXY($this->marge_gauche + 50, $posy);
1405 $titre =
price($tvaval[
'amount']);
1406 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1407 $tot_tva += $tvaval[
'amount'];
1409 $pdf->SetFont(
'',
'', $default_font_size - 2);
1410 $pdf->SetXY($this->marge_gauche + 75, $posy);
1411 $titre =
price($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1412 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1413 $tot_ttc += ($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1415 $posy = $pdf->GetY();
1420 if (in_array($this->emetteur->country_code, array(
'FR')) && empty(
$object->total_tva)) {
1421 $pdf->SetFont(
'',
'', $default_font_size - 2);
1422 $pdf->SetXY($this->marge_gauche, $posy);
1423 if (empty($mysoc->tva_assuj)) {
1424 if ($mysoc->forme_juridique_code == 92) {
1425 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L',
false);
1427 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
1429 } elseif (
getDolGlobalString(
"INVOICE_VAT_SHOW_REVERSE_CHARGE_MENTION") && $this->emetteur->country_code !=
$object->thirdparty->country_code && $this->emetteur->isInEEC() &&
$object->thirdparty->isInEEC()) {
1430 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedReverseChargeProcedure"), 0,
'L',
false);
1432 $posy = $pdf->GetY() + 4;
1437 if ($this->page_largeur < 210) {
1443 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1444 $pdf->SetXY($this->marge_gauche, $posy);
1445 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1446 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1448 $pdf->SetFont(
'',
'', $default_font_size - 2);
1449 $pdf->SetXY($posxval, $posy);
1450 $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);
1451 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1452 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1454 $posy = $pdf->GetY() + 3;
1458 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1459 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1460 $pdf->SetXY($this->marge_gauche, $posy);
1461 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1462 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1464 $pdf->SetFont(
'',
'', $default_font_size - 2);
1465 $pdf->SetXY($posxval, $posy);
1466 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1467 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1469 $posy = $pdf->GetY() + 3;
1474 if (empty(
$object->mode_reglement_code)
1477 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1481 $outputlangs->load(
"errors");
1483 $pdf->SetXY($this->marge_gauche, $posy);
1484 $pdf->SetTextColor(200, 0, 0);
1485 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1486 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1487 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L',
false);
1488 $pdf->SetTextColor(0, 0, 0);
1490 $posy = $pdf->GetY() + 1;
1494 if (!empty(
$object->mode_reglement_code)
1495 &&
$object->mode_reglement_code !=
'CHQ'
1496 &&
$object->mode_reglement_code !=
'VIR') {
1497 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1498 $pdf->SetXY($this->marge_gauche, $posy);
1499 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1500 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1502 $pdf->SetFont(
'',
'', $default_font_size - 2);
1503 $pdf->SetXY($posxval, $posy);
1504 $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);
1507 if (
$object->mode_reglement_code ==
"PRE") {
1508 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1511 $bac->fetch(0, (
string)
$object->thirdparty->id);
1512 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1513 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1516 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1518 $posy = $pdf->GetY();
1524 if ($this->emetteur->country_code ==
'FR') {
1526 $pdf->SetXY($this->marge_gauche, $posy);
1527 $pdf->writeHTMLCell(80, 5,
null,
null, $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1529 $posy = $pdf->GetY() + 1;
1534 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1535 $useonlinepayment = 0;
1537 if (isModEnabled(
'paypal')) {
1538 $useonlinepayment++;
1540 if (isModEnabled(
'stripe')) {
1541 $useonlinepayment++;
1543 if (isModEnabled(
'paybox')) {
1544 $useonlinepayment++;
1546 $parameters = array();
1548 $reshook = $hookmanager->executeHooks(
'doShowOnlinePaymentUrl', $parameters,
$object, $action);
1550 if (isset($hookmanager->resArray[
'showonlinepaymenturl'])) {
1551 $useonlinepayment += $hookmanager->resArray[
'showonlinepaymenturl'];
1558 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1561 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1562 $servicename = $langs->transnoentities(
'Online');
1563 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1564 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1566 $pdf->SetXY($this->marge_gauche, $posy);
1567 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
null,
null,
dol_htmlentitiesbr($linktopay), 0, 1);
1569 $posy = $pdf->GetY() + 1;
1574 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1580 $account =
new Account($this->db);
1583 $pdf->SetXY($this->marge_gauche, $posy);
1584 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1585 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1586 $posy = $pdf->GetY() + 1;
1589 $pdf->SetXY($this->marge_gauche, $posy);
1590 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1591 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1592 $posy = $pdf->GetY() + 2;
1596 $pdf->SetXY($this->marge_gauche, $posy);
1597 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1598 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1599 $posy = $pdf->GetY() + 1;
1602 $pdf->SetXY($this->marge_gauche, $posy);
1603 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1604 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1605 $posy = $pdf->GetY() + 2;
1612 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1618 $account =
new Account($this->db);
1619 $account->fetch($bankid);
1621 $curx = $this->marge_gauche;
1624 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1630 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1633 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L',
false);
1656 global
$conf, $mysoc, $hookmanager;
1668 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1669 $default_font_size--;
1672 $tab2_top = $posy - 4;
1674 $pdf->SetFont(
'',
'', $default_font_size - 1);
1679 if ($this->page_largeur < 210) {
1682 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1688 $pdf->SetFillColor(255, 255, 255);
1689 $pdf->SetXY($col1x, $tab2_top + 0);
1690 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L',
true);
1692 $total_ht = ((isModEnabled(
'multicurrency') && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1693 $pdf->SetXY($col2x, $tab2_top + 0);
1694 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht, 0, $outputlangs), 0,
'R',
true);
1698 $pdf->SetFillColor(255, 255, 255);
1699 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1700 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalVAT"), 0,
'L',
true);
1702 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1703 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->total_tva), 0,
'R',
true);
1707 $pdf->SetFillColor(248, 248, 248);
1709 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1711 $this->atleastoneratenotnull = 0;
1713 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1714 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1718 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1719 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1723 foreach ($localtax_rate as $tvakey => $tvaval) {
1728 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1731 if (preg_match(
'/\*/', $tvakey)) {
1732 $tvakey = str_replace(
'*',
'', $tvakey);
1733 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1736 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1740 $totalvat .= $tvacompl;
1742 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1745 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1747 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1749 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1750 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1756 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1757 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1761 foreach ($localtax_rate as $tvakey => $tvaval) {
1766 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1769 if (preg_match(
'/\*/', $tvakey)) {
1770 $tvakey = str_replace(
'*',
'', $tvakey);
1771 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1773 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1777 $totalvat .= $tvacompl;
1779 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1782 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1784 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1786 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1787 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1796 $nblines = count(
$object->lines);
1797 for ($i = 0; $i < $nblines; $i++) {
1798 $tvaligne =
$object->lines[$i]->total_tva;
1799 $vatrate = (string)
$object->lines[$i]->tva_tx;
1801 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
1804 if (! isset($tvas[$vatrate])) {
1805 $tvas[$vatrate] = 0;
1807 $tvas[$vatrate] += $tvaligne;
1810 foreach ($tvas as $tvakey => $tvaval) {
1812 $this->atleastoneratenotnull++;
1815 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1818 if (preg_match(
'/\*/', $tvakey)) {
1819 $tvakey = str_replace(
'*',
'', $tvakey);
1820 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1822 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1825 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).$tvacompl;
1827 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1829 $totalvat .= $tvacompl;
1831 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1833 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1835 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1836 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R',
true);
1842 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1843 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1847 foreach ($localtax_rate as $tvakey => $tvaval) {
1852 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1855 if (preg_match(
'/\*/', $tvakey)) {
1856 $tvakey = str_replace(
'*',
'', $tvakey);
1857 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1859 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1863 $totalvat .= $tvacompl;
1865 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1868 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1870 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1872 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1873 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1879 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1880 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1884 foreach ($localtax_rate as $tvakey => $tvaval) {
1890 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1893 if (preg_match(
'/\*/', $tvakey)) {
1894 $tvakey = str_replace(
'*',
'', $tvakey);
1895 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1897 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1901 $totalvat .= $tvacompl;
1903 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1906 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1908 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1910 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1911 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1920 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1921 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L',
true);
1923 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1924 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R',
true);
1929 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1930 $pdf->SetTextColor(0, 0, 60);
1931 $pdf->SetFillColor(224, 224, 224);
1932 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L',
true);
1934 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1935 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1939 if (
$object->displayRetainedWarranty()) {
1940 $pdf->SetTextColor(40, 40, 40);
1941 $pdf->SetFillColor(255, 255, 255);
1943 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1944 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1948 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1949 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L',
true);
1951 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1952 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R',
true);
1956 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1958 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1959 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1961 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L',
true);
1962 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1963 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R',
true);
1968 $pdf->SetTextColor(0, 0, 0);
1976 if ($deja_regle > 0) {
1980 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1981 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L',
false);
1983 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1984 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R',
false);
2003 $pdf->SetTextColor(0, 0, 60);
2004 $pdf->SetFillColor(224, 224, 224);
2005 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
2006 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L',
true);
2007 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
2008 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
2010 $pdf->SetFont(
'',
'', $default_font_size - 1);
2011 $pdf->SetTextColor(0, 0, 0);
2014 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
2016 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
2018 $this->error = $hookmanager->error;
2019 $this->errors = $hookmanager->errors;
2023 return ($tab2_top + ($tab2_hl * $index));
2148 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2151 global
$conf, $langs;
2153 $ltrdirection =
'L';
2154 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2155 $ltrdirection =
'R';
2159 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2165 $pdf->SetTextColor(0, 0, 60);
2166 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2170 $posy = $this->marge_haute;
2171 $posx = $this->page_largeur - $this->marge_droite - $w;
2173 $pdf->SetXY($this->marge_gauche, $posy);
2177 if ($this->emetteur->logo) {
2178 $logodir =
$conf->mycompany->dir_output;
2179 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
2180 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
2183 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2185 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2187 if (is_readable($logo)) {
2189 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2191 $pdf->SetTextColor(200, 0, 0);
2192 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2193 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2194 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2197 $text = $this->emetteur->name;
2198 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2202 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2203 $pdf->SetXY($posx, $posy);
2204 $pdf->SetTextColor(0, 0, 60);
2206 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2208 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2211 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2214 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2217 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2219 if ($this->situationinvoice) {
2220 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
2221 $subtitle = $outputlangs->transnoentities(
"PDFSituationTitle", (
string)
$object->situation_counter);
2223 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2226 if ($this->situationinvoice) {
2227 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2229 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2230 } elseif (
$object->type == 1) {
2231 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2232 } elseif (
$object->type == 2) {
2233 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2234 } elseif (
$object->type == 3) {
2235 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2236 } elseif (
$object->type == 4) {
2237 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2240 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2246 $pdf->MultiCell($w, 3, $title,
'',
'R');
2247 if (!empty($subtitle)) {
2248 $pdf->SetFont(
'',
'B', $default_font_size);
2249 $pdf->SetXY($posx, $posy + 5);
2250 $pdf->MultiCell($w, 6, $subtitle,
'',
'R');
2254 $pdf->SetFont(
'',
'B', $default_font_size);
2268 $pdf->SetFont(
'',
'', $default_font_size - 2);
2272 $pdf->SetXY($posx, $posy);
2273 $pdf->SetTextColor(0, 0, 60);
2274 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2279 if (!empty(
$object->project->ref)) {
2281 $pdf->SetXY($posx, $posy);
2282 $pdf->SetTextColor(0, 0, 60);
2283 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2289 if (!empty(
$object->project->ref)) {
2290 $outputlangs->load(
"projects");
2292 $pdf->SetXY($posx, $posy);
2293 $pdf->SetTextColor(0, 0, 60);
2294 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2298 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2299 if (
$object->type == 0 && $objectidnext) {
2300 $objectreplacing =
new Facture($this->db);
2301 $objectreplacing->fetch($objectidnext);
2304 $pdf->SetXY($posx, $posy);
2305 $pdf->SetTextColor(0, 0, 60);
2306 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2309 $objectreplaced =
new Facture($this->db);
2310 $objectreplaced->fetch(
$object->fk_facture_source);
2313 $pdf->SetXY($posx, $posy);
2314 $pdf->SetTextColor(0, 0, 60);
2315 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2318 $objectreplaced =
new Facture($this->db);
2319 $objectreplaced->fetch(
$object->fk_facture_source);
2322 $pdf->SetXY($posx, $posy);
2323 $pdf->SetTextColor(0, 0, 60);
2324 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2328 $pdf->SetXY($posx, $posy);
2329 $pdf->SetTextColor(0, 0, 60);
2331 $title = $outputlangs->transnoentities(
"DateInvoice");
2332 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2333 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2335 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2339 $pdf->SetXY($posx, $posy);
2340 $pdf->SetTextColor(0, 0, 60);
2341 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2346 $pdf->SetXY($posx, $posy);
2347 $pdf->SetTextColor(0, 0, 60);
2348 $title = $outputlangs->transnoentities(
"DateDue");
2349 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2350 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2352 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2357 $pdf->SetXY($posx, $posy);
2358 $pdf->SetTextColor(0, 0, 60);
2359 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2364 $pdf->SetXY($posx, $posy);
2365 $pdf->SetTextColor(0, 0, 60);
2366 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
2371 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2372 if (count($arrayidcontact) > 0) {
2373 $usertmp =
new User($this->db);
2374 $usertmp->fetch($arrayidcontact[0]);
2376 $pdf->SetXY($posx, $posy);
2377 $pdf->SetTextColor(0, 0, 60);
2378 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2388 $current_y = $pdf->getY();
2390 if ($current_y < $pdf->getY()) {
2391 $top_shift = $pdf->getY() - $current_y;
2401 $posy += $top_shift;
2402 $posx = $this->marge_gauche;
2404 $posx = $this->page_largeur - $this->marge_droite - 80;
2412 $pdf->SetTextColor(0, 0, 0);
2413 $pdf->SetFont(
'',
'', $default_font_size - 2);
2414 $pdf->SetXY($posx, $posy - 5);
2415 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2416 $pdf->SetXY($posx, $posy);
2417 $pdf->SetFillColor(230, 230, 230);
2418 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2419 $pdf->SetTextColor(0, 0, 60);
2424 $pdf->SetXY($posx + 2, $posy + 3);
2425 $pdf->SetFont(
'',
'B', $default_font_size);
2426 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2427 $posy = $pdf->getY();
2431 $pdf->SetXY($posx + 2, $posy);
2432 $pdf->SetFont(
'',
'', $default_font_size - 1);
2433 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2436 $usecontact =
false;
2437 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2438 if (count($arrayidcontact) > 0) {
2440 $result =
$object->fetch_contact($arrayidcontact[0]);
2444 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2445 $thirdparty =
$object->contact;
2447 $thirdparty =
$object->thirdparty;
2457 if ($this->page_largeur < 210) {
2461 $posy += $top_shift;
2462 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2464 $posx = $this->marge_gauche;
2469 $pdf->SetTextColor(0, 0, 0);
2470 $pdf->SetFont(
'',
'', $default_font_size - 2);
2471 $pdf->SetXY($posx + 2, $posy - 5);
2472 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2473 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2477 $pdf->SetXY($posx + 2, $posy + 3);
2478 $pdf->SetFont(
'',
'B', $default_font_size);
2480 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2482 $posy = $pdf->getY();
2485 $pdf->SetFont(
'',
'', $default_font_size - 1);
2486 $pdf->SetXY($posx + 2, $posy);
2488 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2492 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2494 if (!empty($idaddressshipping)) {
2495 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2496 $companystatic =
new Societe($this->db);
2497 $companystatic->fetch(
$object->contact->fk_soc);
2504 if (!empty($carac_client_shipping)) {
2505 $posy += $hautcadre;
2510 $pdf->SetXY($posx + 2, $posy - 5);
2511 $pdf->SetFont(
'',
'', $default_font_size - 2);
2512 $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities(
'ShippingTo'), 0,
'L',
false);
2513 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2516 $pdf->SetXY($posx + 2, $posy + 3);
2517 $pdf->SetFont(
'',
'B', $default_font_size);
2518 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2520 $posy = $pdf->getY();
2523 $pdf->SetXY($posx + 2, $posy);
2524 $pdf->SetFont(
'',
'', $default_font_size - 1);
2525 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2526 $shipp_shift += $hautcadre;
2531 $pdf->SetTextColor(0, 0, 0);
2533 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);
2855 public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
2859 $form =
new Form($db);
2863 if (!$displayWarranty) {
2874 $currency = !empty($currency) ? $currency :
$conf->currency;
2878 $pdf->SetTextColor(0, 0, 0);
2879 $pdf->SetFont(
'',
'', $default_font_size - 2);
2881 if (empty($hidetop)) {
2882 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
2883 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 8);
2884 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
2886 $width = $this->page_largeur - $this->marge_gauche - $this->marge_droite - 83;
2890 $pdf->RoundedRect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, $this->corner_radius,
'1001',
'F', explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2892 $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')));
2896 $pdf->SetDrawColor(128, 128, 128);
2897 $pdf->SetFont(
'',
'', $default_font_size - 1);
2901 $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');
2903 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top, $this->posx_cumul_anterieur - 1, $tab_top + $tab_height);
2904 if (empty($hidetop)) {
2905 $pdf->SetXY($this->posx_cumul_anterieur - 1, $tab_top + 0.5);
2906 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceOldCumulation"),
'',
'C');
2910 $pdf->line($this->posx_new_cumul - 1, $tab_top, $this->posx_new_cumul - 1, $tab_top + $tab_height);
2911 if (empty($hidetop)) {
2912 $pdf->SetXY($this->posx_new_cumul - 1, $tab_top + 0.5);
2913 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceNewCumulation"),
'',
'C');
2916 $pdf->line($this->posx_current - 1, $tab_top, $this->posx_current - 1, $tab_top + $tab_height);
2917 if (empty($hidetop)) {
2918 $pdf->SetXY($this->posx_current - 1, $tab_top + 0.5);
2919 $pdf->MultiCell(36, 2, $outputlangs->transnoentities(
"CurrentSituationTotal", (
string)
$object->situation_counter),
'',
'C');
2923 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
2925 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 24, $this->page_largeur - $this->marge_droite, $tab_top + 24);
2927 $pdf->line($this->marge_gauche, $tab_top + 55, $this->page_largeur - $this->marge_droite, $tab_top + 55);
2929 $pdf->line($this->marge_gauche, $tab_top + 65, $this->page_largeur - $this->marge_droite, $tab_top + 65);
2931 if ($displayWarranty) {
2932 $pdf->line($this->marge_gauche, $tab_top + 85, $this->page_largeur - $this->marge_droite, $tab_top + 85);
2938 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 8);
2939 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceMainTask"),
'',
'L');
2941 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 12);
2942 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceAdditionalTask"),
'',
'L');
2944 $form->load_cache_vatrates(
"'".
$object->thirdparty->country_code.
"'");
2947 foreach ($form->cache_vatrates as $TVatInfo) {
2948 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2950 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2955 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 24 + $i);
2956 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalHT").
' '.$TVatInfo[
'label'],
'',
'L');
2958 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2959 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 28 + $i);
2960 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"VAT").
' '.$TVatInfo[
'label'],
'',
'L');
2966 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 33 + $i);
2967 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'L');
2970 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2971 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 58);
2972 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalSituationInvoice"),
'',
'L');
2973 $pdf->SetFont(
'',
'', $default_font_size - 2);
2975 if ($displayWarranty) {
2976 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 74);
2977 $pdf->MultiCell(80, 2, $outputlangs->trans(
"TotalSituationInvoiceWithRetainedWarranty", (
string)
$object->retained_warranty),
'',
'L');
2978 $nextY = $tab_top + 93;
2980 $nextY = $tab_top + 74;
2983 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2984 $pdf->SetXY($this->marge_gauche + 2, $nextY);
2985 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"SituationTotalRayToRest"),
'',
'L');
2986 $pdf->SetFont(
'',
'', $default_font_size - 2);
2990 $TToDisplay = array(
2996 $x = $this->marge_gauche + 85;
3000 foreach ($TToDisplay as $col) {
3002 $pdf->SetXY($x, $tab_top + 8);
3003 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
3006 $pdf->SetXY($x, $tab_top + 12);
3007 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'travaux_sup'], 0,
'', 1, -1, 2),
'',
'R');
3010 foreach ($form->cache_vatrates as $TVatInfo) {
3011 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
3012 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
3018 $pdf->SetXY($x, $tab_top + 24 + $i);
3019 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
3022 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
3023 $pdf->SetXY($x, $tab_top + 28 + $i);
3024 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'TVA'], 0,
'', 1, -1, 2),
'',
'R');
3031 $pdf->SetXY($x, $tab_top + 33 + $i);
3032 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
3035 $pdf->SetFont(
'',
'B', $default_font_size - 1);
3036 $pdf->SetXY($x, $tab_top + 58);
3037 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
3038 $pdf->SetFont(
'',
'', $default_font_size - 2);
3041 if ($displayWarranty) {
3043 $pdf->SetXY($x, $tab_top + 74);
3044 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'retenue_garantie'], 0,
'', 1, -1, 2),
'',
'R');
3045 $nextY = $tab_top + 93;
3047 $nextY = $tab_top + 74;
3051 $pdf->SetFont(
'',
'B', $default_font_size - 1);
3052 $pdf->SetXY($x, $nextY);
3053 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'total_a_payer'], 0,
'', 1, -1, 2),
'',
'R');
3054 $pdf->SetFont(
'',
'', $default_font_size - 2);