268 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
271 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
273 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
275 if (!is_object($outputlangs)) {
276 $outputlangs = $langs;
280 $outputlangs->charset_output =
'ISO-8859-1';
284 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
286 global $outputlangsbis;
287 $outputlangsbis =
null;
289 $outputlangsbis =
new Translate(
'', $conf);
291 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
295 setEventMessage($langs->trans(
'WarningsObjectIsNotASituation'),
'warnings');
303 $nblines = count(
$object->lines);
311 $realpatharray = array();
312 $this->atleastonephoto =
false;
314 $objphoto =
new Product($this->db);
316 for ($i = 0; $i < $nblines; $i++) {
317 if (empty(
$object->lines[$i]->fk_product)) {
321 $objphoto->fetch(
$object->lines[$i]->fk_product);
325 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
326 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
328 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
329 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
333 foreach ($pdir as $midir) {
335 if ($conf->entity != $objphoto->entity) {
336 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
338 $dir = $conf->product->dir_output.
'/'.$midir;
341 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
343 if ($obj[
'photo_vignette']) {
344 $filename = $obj[
'photo_vignette'];
346 $filename = $obj[
'photo'];
349 $filename = $obj[
'photo'];
352 $realpath = $dir.$filename;
354 $this->atleastonephoto =
true;
359 if ($realpath && $arephoto) {
360 $realpatharray[$i] = $realpath;
367 if ($conf->facture->multidir_output[$conf->entity]) {
370 $deja_regle =
$object->getSommePaiement((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
371 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
372 $amount_deposits_included =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
376 $dir = $conf->facture->multidir_output[$conf->entity];
377 $file = $dir.
"/SPECIMEN.pdf";
380 $dir = $conf->facture->multidir_output[
$object->entity].
"/".$objectref;
381 $file = $dir.
"/".$objectref.
".pdf";
383 if (!file_exists($dir)) {
385 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
390 if (file_exists($dir)) {
392 if (!is_object($hookmanager)) {
393 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
396 $hookmanager->initHooks(array(
'pdfgeneration'));
397 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
399 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
402 $nblines = count(
$object->lines);
403 $nbpayments = count(
$object->getListOfPayments());
404 $nbprevsituation = is_array(
$object->tab_previous_situation_invoice) ? count(
$object->tab_previous_situation_invoice) : 0;
409 $default_font_size = 9;
410 $pdf->SetAutoPageBreak(1, 0);
413 $this->heightforinfotot = 45;
415 $this->heightforinfotot += 4 * ($nbpayments + 3);
417 if ($nbprevsituation > 0) {
418 $this->heightforinfotot += 4 * ($nbprevsituation + 3);
420 $this->heightforfreetext = (
getDolGlobalInt(
'MAIN_PDF_FREETEXT_HEIGHT', 5));
421 $this->heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
423 if (class_exists(
'TCPDF')) {
424 $pdf->setPrintHeader(
false);
425 $pdf->setPrintFooter(
false);
431 $logodir = $conf->mycompany->dir_output;
432 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
433 $logodir = $conf->mycompany->multidir_output[
$object->entity];
435 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
436 $this->tplidx = $pdf->importPage(1);
441 $pdf->SetDrawColor(128, 128, 128);
443 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
444 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceSituationTitle"));
445 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
446 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
447 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
449 $pdf->SetCompression(
false);
453 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
454 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
465 'Name' => $this->emetteur->name,
466 'Location' =>
getCountry($this->emetteur->country_code,
''),
467 'Reason' =>
'INVOICE',
468 'ContactInfo' => $this->emetteur->email
470 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
474 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
478 $categoryOfOperation = 0;
481 for ($i = 0; $i < $nblines; $i++) {
482 if (
$object->lines[$i]->remise_percent) {
483 $this->atleastonediscount++;
487 if ($categoryOfOperation < 2) {
488 $lineProductType =
$object->lines[$i]->product_type;
494 if ($nbProduct > 0 && $nbService > 0) {
496 $categoryOfOperation = 2;
501 if ($categoryOfOperation <= 0) {
503 if ($nbProduct == 0 && $nbService > 0) {
504 $categoryOfOperation = 1;
507 $this->categoryOfOperation = $categoryOfOperation;
511 if (!empty($this->tplidx)) {
512 $pdf->useTemplate($this->tplidx);
517 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
518 $top_shift = $pagehead[
'top_shift'];
519 $shipp_shift = $pagehead[
'shipp_shift'];
520 $pdf->SetFont(
'',
'', $default_font_size - 1);
521 $pdf->MultiCell(0, 3,
'');
522 $pdf->SetTextColor(0, 0, 0);
527 $this->tab_top = 90 + $top_shift + $shipp_shift;
528 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
531 $extra_under_address_shift = 0;
534 $qrcodestring =
$object->buildZATCAQRString();
536 $qrcodestring =
$object->buildSwitzerlandQRString();
539 $qrcodecolor = array(
'25',
'25',
'25');
544 'fgcolor' => $qrcodecolor,
549 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
550 $extra_under_address_shift += 25;
558 'outputlangs' => $outputlangs,
559 'hidedetails' => $hidedetails
561 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
562 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
563 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
566 $this->tab_top += $extra_under_address_shift;
567 $this->tab_top_newpage += 0;
571 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->
getHeightForQRInvoice(1,
$object, $langs);
573 $nexY = $this->tab_top - 1;
578 $tab_height_newpage = 150;
580 $this->
_tableFirstPage($pdf, $tab_top, $this->page_hauteur - 100 - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
582 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
590 $pdf->setTopMargin($this->tab_top_newpage);
593 $height_incoterms = 0;
594 if (isModEnabled(
'incoterm')) {
595 $desc_incoterms =
$object->getIncotermsForPDF();
596 if ($desc_incoterms) {
599 $pdf->SetFont(
'',
'', $default_font_size - 1);
600 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
601 $nexY = max($pdf->GetY(), $nexY);
602 $height_incoterms = $nexY - $this->tab_top;
605 $pdf->SetDrawColor(192, 192, 192);
606 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
608 $this->tab_top = $nexY + 6;
609 $height_incoterms += 4;
614 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
617 if (is_object(
$object->thirdparty)) {
618 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
619 $salerepobj =
new User($this->db);
620 $salerepobj->fetch($salereparray[0][
'id']);
621 if (!empty($salerepobj->signature)) {
622 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
628 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
629 if (!empty($extranote)) {
633 $pagenb = $pdf->getPage();
637 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
638 $pageposbeforenote = $pagenb;
645 $pdf->startTransaction();
647 $pdf->SetFont(
'',
'', $default_font_size - 1);
648 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
650 $pageposafternote = $pdf->getPage();
651 $posyafter = $pdf->GetY();
653 if ($pageposafternote > $pageposbeforenote) {
654 $pdf->rollbackTransaction(
true);
657 while ($pagenb < $pageposafternote) {
660 if (!empty($this->tplidx)) {
661 $pdf->useTemplate($this->tplidx);
666 $pdf->setTopMargin($this->tab_top_newpage);
668 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
672 $pdf->setPage($pageposbeforenote);
673 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
674 $pdf->SetFont(
'',
'', $default_font_size - 1);
675 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
676 $pageposafternote = $pdf->getPage();
678 $posyafter = $pdf->GetY();
680 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
681 $pdf->AddPage(
'',
'',
true);
684 $pdf->setPage($pageposafternote);
685 $pdf->setTopMargin($this->tab_top_newpage);
687 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
693 $i = $pageposbeforenote;
694 while ($i < $pageposafternote) {
698 $pdf->SetDrawColor(128, 128, 128);
700 if ($i > $pageposbeforenote) {
701 $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
702 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
704 $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
705 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
709 $pdf->setPageOrientation(
'', 1, 0);
716 $pdf->setPage($pageposafternote);
717 if (!empty($this->tplidx)) {
718 $pdf->useTemplate($this->tplidx);
723 $height_note = $posyafter - $this->tab_top_newpage;
724 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
727 $pdf->commitTransaction();
728 $posyafter = $pdf->GetY();
729 $height_note = $posyafter - $this->tab_top;
730 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
733 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
735 $pdf->AddPage(
'',
'',
true);
738 $pdf->setPage($pageposafternote);
739 if (!empty($this->tplidx)) {
740 $pdf->useTemplate($this->tplidx);
746 $posyafter = $this->tab_top_newpage;
750 $tab_height -= $height_note;
751 $this->tab_top = $posyafter + 6;
765 $nexY = $this->tab_top_newpage + $this->tabTitleHeight;
768 $pageposbeforeprintlines = $pdf->getPage();
769 $pagenb = $pageposbeforeprintlines;
770 for ($i = 0; $i < $nblines; $i++) {
772 $pdf->SetFont(
'',
'', $default_font_size - 1);
773 $pdf->SetTextColor(0, 0, 0);
776 $imglinesize = array();
777 if (!empty($realpatharray[$i])) {
781 $pdf->setTopMargin($this->tab_top_newpage);
782 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot);
783 $pageposbefore = $pdf->getPage();
785 $showpricebeforepagebreak = 1;
787 $posYAfterDescription = 0;
791 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($posy + $imglinesize[
'height']) > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
792 $pdf->AddPage(
'',
'',
true);
793 if (!empty($this->tplidx)) {
794 $pdf->useTemplate($this->tplidx);
796 $pdf->setPage($pageposbefore + 1);
798 $posy = $this->tab_top_newpage;
802 $showpricebeforepagebreak = 1;
804 $showpricebeforepagebreak = 0;
808 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
809 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $posy + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
811 $posYAfterImage = $posy + $imglinesize[
'height'];
817 $pdf->startTransaction();
820 $pageposafter = $pdf->getPage();
822 if ($pageposafter > $pageposbefore) {
823 $pdf->rollbackTransaction(
true);
824 $pageposafter = $pageposbefore;
825 $pdf->setPageOrientation(
'', 1, $this->heightforfooter);
829 $pageposafter = $pdf->getPage();
830 $posyafter = $pdf->GetY();
832 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
833 if ($i == ($nblines - 1)) {
834 $pdf->AddPage(
'',
'',
true);
835 if (!empty($this->tplidx)) {
836 $pdf->useTemplate($this->tplidx);
838 $pdf->setPage($pageposafter + 1);
844 $showpricebeforepagebreak = 1;
846 $showpricebeforepagebreak = 0;
850 $pdf->commitTransaction();
852 $posYAfterDescription = $pdf->GetY();
855 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
857 $pageposafter = $pdf->getPage();
858 $pdf->setPage($pageposbefore);
859 $pdf->setTopMargin($this->marge_haute);
860 $pdf->setPageOrientation(
'', 1, 0);
863 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
864 $pdf->setPage($pageposafter);
865 $posy = $this->tab_top_newpage;
868 $pdf->SetFont(
'',
'', $default_font_size - 1);
874 $nexY = max($pdf->GetY(), $nexY);
881 $nexY = max($pdf->GetY(), $nexY);
889 $nexY = max($pdf->GetY(), $nexY);
896 $nexY = max($pdf->GetY(), $nexY);
903 $nexY = max($pdf->GetY(), $nexY);
910 $nexY = max($pdf->GetY(), $nexY);
917 $nexY = max($pdf->GetY(), $nexY);
924 $columkey =
'btpsomme';
926 $printval =
price($TInfosLigneSituationPrecedente[
'total_ht_without_progress'], 0,
'', 1, -1, 2);
928 $nexY = max($pdf->GetY(), $nexY);
932 $columkey =
'progress_amount';
934 $printval =
price(
$object->lines[$i]->total_ht, 0,
'', 1, -1, 2);
936 $nexY = max($pdf->GetY(), $nexY);
939 $columkey =
'prev_progress';
941 $printval = $TInfosLigneSituationPrecedente[
'progress_prec'].
'%';
943 $nexY = max($pdf->GetY(), $nexY);
946 $columkey =
'prev_progress_amount';
948 $printval =
price($TInfosLigneSituationPrecedente[
'total_ht'], 0,
'', 1, -1, 2);
950 $nexY = max($pdf->GetY(), $nexY);
959 'outputlangs' => $outputlangs,
960 'hidedetails' => $hidedetails
962 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
970 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
971 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
972 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
973 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
975 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
978 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
979 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
981 $tvaligne = $sign *
$object->lines[$i]->total_tva;
985 $localtax1ligne =
$object->lines[$i]->total_localtax1;
986 $localtax2ligne =
$object->lines[$i]->total_localtax2;
987 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
988 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
989 $localtax1_type =
$object->lines[$i]->localtax1_type;
990 $localtax2_type =
$object->lines[$i]->localtax2_type;
1003 $vatrate = (string)
$object->lines[$i]->tva_tx;
1006 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
1007 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
1009 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
1010 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
1014 if ($localtax1_type && $localtax1ligne != 0) {
1015 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
1016 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
1018 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
1021 if ($localtax2_type && $localtax2ligne != 0) {
1022 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
1023 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
1025 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
1029 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
1034 if (!isset($this->tva[$vatrate])) {
1035 $this->tva[$vatrate] = 0;
1037 $this->tva[$vatrate] += $tvaligne;
1038 $vatcode =
$object->lines[$i]->vat_src_code;
1039 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
1040 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
1042 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
1044 $nexY = max($nexY, $posYAfterImage);
1048 $pdf->setPage($pageposafter);
1049 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
1051 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
1052 $pdf->SetLineStyle(array(
'dash' => 0));
1056 while ($pagenb < $pageposafter) {
1057 $pdf->setPage($pagenb);
1058 $tabtop = $this->tab_top;
1059 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1060 if ($pagenb != $pageposbeforeprintlines) {
1061 $tabtop = $this->tab_top_newpage;
1062 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1065 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1069 $pdf->setPage($pagenb);
1070 $pdf->setPageOrientation(
'', 1, 0);
1074 if (!empty($this->tplidx)) {
1075 $pdf->useTemplate($this->tplidx);
1079 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
1080 $tabtop = $this->tab_top;
1081 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1082 if ($pagenb != $pageposbeforeprintlines) {
1083 $tabtop = $this->tab_top_newpage;
1084 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1087 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1092 if (!empty($this->tplidx)) {
1093 $pdf->useTemplate($this->tplidx);
1104 $tabtop = $this->tab_top_newpage;
1105 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter - $this->heightforinfotot - $this->heightforfreetext;
1106 $tabTitleHeight = 0;
1107 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1109 $bottomlasttab = $tabtop + $tabhauteur + $tabTitleHeight + 10;
1115 $posy = $this->
drawTotalTable($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1118 $listofpayments =
$object->getListOfPayments(
'', 0, 1);
1119 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1125 if (method_exists($pdf,
'AliasNbPages')) {
1126 $pdf->AliasNbPages();
1129 $this->resumeLastPage($pdf,
$object, 0, $tab_top, $outputlangs, $outputlangsbis);
1130 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
1135 $pdf->Output($file,
'F');
1138 $hookmanager->initHooks(array(
'pdfgeneration'));
1139 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1141 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1143 $this->error = $hookmanager->error;
1144 $this->errors = $hookmanager->errors;
1149 $this->result = array(
'fullpath' => $file);
1153 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1157 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1182 $tab3_top = $posy + 8;
1185 if ($this->page_largeur < 210) {
1191 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1193 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1196 $pdf->SetFont(
'',
'', $default_font_size - 3);
1197 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1198 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1200 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1202 $pdf->SetFont(
'',
'', $default_font_size - 4);
1203 $pdf->SetXY($tab3_posx, $tab3_top);
1204 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1205 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1206 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1207 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1208 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1209 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1210 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1212 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1216 $pdf->SetFont(
'',
'', $default_font_size - 4);
1220 $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,";
1221 $sql .=
" re.description, re.fk_facture_source,";
1222 $sql .=
" f.type, f.datef";
1223 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1224 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1225 $resql = $this->db->query($sql);
1227 $num = $this->db->num_rows($resql);
1229 $invoice =
new Facture($this->db);
1232 $obj = $this->db->fetch_object($resql);
1234 if ($obj->type == 2) {
1235 $text = $outputlangs->transnoentities(
"CreditNote");
1236 } elseif ($obj->type == 3) {
1237 $text = $outputlangs->transnoentities(
"Deposit");
1238 } elseif ($obj->type == 0) {
1239 $text = $outputlangs->transnoentities(
"ExcessReceived");
1241 $text = $outputlangs->transnoentities(
"UnknownType");
1244 $invoice->fetch($obj->fk_facture_source);
1246 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1247 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1248 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1249 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1250 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1251 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1252 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1253 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1255 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1260 $this->error = $this->db->lasterror();
1266 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1268 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1269 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1270 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1272 $sql .=
" ORDER BY p.datep";
1274 $resql = $this->db->query($sql);
1276 $num = $this->db->num_rows($resql);
1281 $row = $this->db->fetch_object($resql);
1282 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1283 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1284 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1285 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1286 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1287 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1289 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1290 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1291 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1292 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1293 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1294 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1299 return $tab3_top + $y + 3;
1301 $this->error = $this->db->lasterror();
1319 global $conf, $mysoc, $hookmanager;
1323 $pdf->SetFont(
'',
'', $default_font_size - 1);
1326 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1327 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1328 $pdf->SetXY($this->marge_gauche, $posy);
1329 if ($mysoc->forme_juridique_code == 92) {
1330 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1332 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1335 $posy = $pdf->GetY() + 4;
1340 if ($this->page_largeur < 210) {
1346 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1347 $pdf->SetXY($this->marge_gauche, $posy);
1348 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1349 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1351 $pdf->SetFont(
'',
'', $default_font_size - 2);
1352 $pdf->SetXY($posxval, $posy);
1353 $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);
1354 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1355 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1357 $posy = $pdf->GetY() + 3;
1361 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1362 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1363 $pdf->SetXY($this->marge_gauche, $posy);
1364 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1365 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1367 $pdf->SetFont(
'',
'', $default_font_size - 2);
1368 $pdf->SetXY($posxval, $posy);
1369 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1370 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1372 $posy = $pdf->GetY() + 3;
1377 if (empty(
$object->mode_reglement_code)
1380 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1384 $outputlangs->load(
"errors");
1386 $pdf->SetXY($this->marge_gauche, $posy);
1387 $pdf->SetTextColor(200, 0, 0);
1388 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1389 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1390 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1391 $pdf->SetTextColor(0, 0, 0);
1393 $posy = $pdf->GetY() + 1;
1397 if (!empty(
$object->mode_reglement_code)
1398 &&
$object->mode_reglement_code !=
'CHQ'
1399 &&
$object->mode_reglement_code !=
'VIR') {
1400 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1401 $pdf->SetXY($this->marge_gauche, $posy);
1402 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1403 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1405 $pdf->SetFont(
'',
'', $default_font_size - 2);
1406 $pdf->SetXY($posxval, $posy);
1407 $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);
1410 if (
$object->mode_reglement_code ==
"PRE") {
1411 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1414 $bac->fetch(0,
$object->thirdparty->id);
1415 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1416 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1419 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1421 $posy = $pdf->GetY();
1427 if ($this->emetteur->country_code ==
'FR') {
1429 $pdf->SetXY($this->marge_gauche, $posy);
1430 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1432 $posy = $pdf->GetY() + 1;
1437 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1438 $useonlinepayment = 0;
1440 if (isModEnabled(
'paypal')) {
1441 $useonlinepayment++;
1443 if (isModEnabled(
'stripe')) {
1444 $useonlinepayment++;
1446 if (isModEnabled(
'paybox')) {
1447 $useonlinepayment++;
1449 $parameters = array();
1451 $reshook = $hookmanager->executeHooks(
'doShowOnlinePaymentUrl', $parameters,
$object, $action);
1453 if (isset($hookmanager->resArray[
'showonlinepaymenturl'])) {
1454 $useonlinepayment += $hookmanager->resArray[
'showonlinepaymenturl'];
1461 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1464 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1465 $servicename = $langs->transnoentities(
'Online');
1466 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1467 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1469 $pdf->SetXY($this->marge_gauche, $posy);
1470 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1472 $posy = $pdf->GetY() + 1;
1477 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1483 $account =
new Account($this->db);
1486 $pdf->SetXY($this->marge_gauche, $posy);
1487 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1488 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1489 $posy = $pdf->GetY() + 1;
1492 $pdf->SetXY($this->marge_gauche, $posy);
1493 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1494 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1495 $posy = $pdf->GetY() + 2;
1499 $pdf->SetXY($this->marge_gauche, $posy);
1500 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1501 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1502 $posy = $pdf->GetY() + 1;
1505 $pdf->SetXY($this->marge_gauche, $posy);
1506 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1507 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1508 $posy = $pdf->GetY() + 2;
1515 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1521 $account =
new Account($this->db);
1522 $account->fetch($bankid);
1524 $curx = $this->marge_gauche;
1527 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1551 global $conf, $mysoc, $hookmanager;
1561 $outputlangsbis =
new Translate(
'', $conf);
1563 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1564 $default_font_size--;
1567 $tab2_top = $posy - 4;
1569 $pdf->SetFont(
'',
'', $default_font_size - 1);
1574 if ($this->page_largeur < 210) {
1577 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1583 $pdf->SetFillColor(255, 255, 255);
1584 $pdf->SetXY($col1x, $tab2_top + 0);
1585 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1587 $total_ht = ((!empty($conf->multicurrency->enabled) && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1588 $pdf->SetXY($col2x, $tab2_top + 0);
1589 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht, 0, $outputlangs), 0,
'R', 1);
1594 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1595 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"DiscountHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"DiscountHT") :
''), 0,
'L', 1);
1596 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1597 $pdf->MultiCell($largcol2, $tab2_hl,
price($remise, 0, $outputlangs), 0,
'R', 1);
1600 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1601 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTWithDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTWithDiscount") :
''), 0,
'L', 1);
1602 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1603 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht - $remise, 0, $outputlangs), 0,
'R', 1);
1607 $pdf->SetFillColor(248, 248, 248);
1609 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1611 $this->atleastoneratenotnull = 0;
1613 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1614 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1618 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1619 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1623 foreach ($localtax_rate as $tvakey => $tvaval) {
1628 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1631 if (preg_match(
'/\*/', $tvakey)) {
1632 $tvakey = str_replace(
'*',
'', $tvakey);
1633 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1636 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1640 $totalvat .= $tvacompl;
1642 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1645 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1647 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1649 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1650 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1656 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1657 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1661 foreach ($localtax_rate as $tvakey => $tvaval) {
1666 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1669 if (preg_match(
'/\*/', $tvakey)) {
1670 $tvakey = str_replace(
'*',
'', $tvakey);
1671 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1673 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1677 $totalvat .= $tvacompl;
1679 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1682 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1684 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1686 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1687 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1695 $nblines = count(
$object->lines);
1696 for ($i = 0; $i < $nblines; $i++) {
1697 $tvaligne =
$object->lines[$i]->total_tva;
1698 $vatrate = (string)
$object->lines[$i]->tva_tx;
1700 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
1703 if (! isset($tvas[$vatrate])) {
1704 $tvas[$vatrate] = 0;
1706 $tvas[$vatrate] += $tvaligne;
1709 foreach ($tvas as $tvakey => $tvaval) {
1711 $this->atleastoneratenotnull++;
1714 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1717 if (preg_match(
'/\*/', $tvakey)) {
1718 $tvakey = str_replace(
'*',
'', $tvakey);
1719 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1721 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1724 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1726 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1728 $totalvat .= $tvacompl;
1730 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1732 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1734 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1735 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1740 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1741 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1745 foreach ($localtax_rate as $tvakey => $tvaval) {
1750 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1753 if (preg_match(
'/\*/', $tvakey)) {
1754 $tvakey = str_replace(
'*',
'', $tvakey);
1755 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1757 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1761 $totalvat .= $tvacompl;
1763 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1766 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1768 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1770 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1771 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1777 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1778 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1782 foreach ($localtax_rate as $tvakey => $tvaval) {
1788 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1791 if (preg_match(
'/\*/', $tvakey)) {
1792 $tvakey = str_replace(
'*',
'', $tvakey);
1793 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1795 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1799 $totalvat .= $tvacompl;
1801 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1804 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1806 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1808 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1809 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1818 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1819 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1821 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1822 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1827 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1828 $pdf->SetTextColor(0, 0, 60);
1829 $pdf->SetFillColor(224, 224, 224);
1830 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1832 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1833 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1837 if (
$object->displayRetainedWarranty()) {
1838 $pdf->SetTextColor(40, 40, 40);
1839 $pdf->SetFillColor(255, 255, 255);
1841 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1842 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1846 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1847 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1849 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1850 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1854 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1856 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1857 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1859 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1860 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1861 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1866 $pdf->SetTextColor(0, 0, 0);
1874 if ($deja_regle > 0) {
1878 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1879 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1881 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1882 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1901 $pdf->SetTextColor(0, 0, 60);
1902 $pdf->SetFillColor(224, 224, 224);
1903 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1904 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1905 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1906 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1908 $pdf->SetFont(
'',
'', $default_font_size - 1);
1909 $pdf->SetTextColor(0, 0, 0);
1912 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1914 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1916 $this->error = $hookmanager->error;
1917 $this->errors = $hookmanager->errors;
1921 return ($tab2_top + ($tab2_hl * $index));
2046 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2049 global $conf, $langs;
2051 $ltrdirection =
'L';
2052 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2053 $ltrdirection =
'R';
2057 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2063 $pdf->SetTextColor(0, 0, 60);
2064 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2068 $posy = $this->marge_haute;
2069 $posx = $this->page_largeur - $this->marge_droite - $w;
2071 $pdf->SetXY($this->marge_gauche, $posy);
2075 if ($this->emetteur->logo) {
2076 $logodir = $conf->mycompany->dir_output;
2077 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
2078 $logodir = $conf->mycompany->multidir_output[
$object->entity];
2081 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2083 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2085 if (is_readable($logo)) {
2087 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2089 $pdf->SetTextColor(200, 0, 0);
2090 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2091 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2092 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2095 $text = $this->emetteur->name;
2096 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2100 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2101 $pdf->SetXY($posx, $posy);
2102 $pdf->SetTextColor(0, 0, 60);
2104 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2106 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2109 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2112 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2115 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2117 if ($this->situationinvoice) {
2118 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
2119 $subtitle = $outputlangs->transnoentities(
"PDFSituationTitle",
$object->situation_counter);
2121 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2124 if ($this->situationinvoice) {
2125 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2127 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2128 } elseif (
$object->type == 1) {
2129 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2130 } elseif (
$object->type == 2) {
2131 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2132 } elseif (
$object->type == 3) {
2133 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2134 } elseif (
$object->type == 4) {
2135 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2138 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2144 $pdf->MultiCell($w, 3, $title,
'',
'R');
2145 if (!empty($subtitle)) {
2146 $pdf->SetFont(
'',
'B', $default_font_size);
2147 $pdf->SetXY($posx, $posy + 5);
2148 $pdf->MultiCell($w, 6, $subtitle,
'',
'R');
2152 $pdf->SetFont(
'',
'B', $default_font_size);
2166 $pdf->SetFont(
'',
'', $default_font_size - 2);
2170 $pdf->SetXY($posx, $posy);
2171 $pdf->SetTextColor(0, 0, 60);
2172 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2177 if (!empty(
$object->project->ref)) {
2179 $pdf->SetXY($posx, $posy);
2180 $pdf->SetTextColor(0, 0, 60);
2181 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2187 if (!empty(
$object->project->ref)) {
2188 $outputlangs->load(
"projects");
2190 $pdf->SetXY($posx, $posy);
2191 $pdf->SetTextColor(0, 0, 60);
2192 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2196 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2197 if (
$object->type == 0 && $objectidnext) {
2198 $objectreplacing =
new Facture($this->db);
2199 $objectreplacing->fetch($objectidnext);
2202 $pdf->SetXY($posx, $posy);
2203 $pdf->SetTextColor(0, 0, 60);
2204 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2207 $objectreplaced =
new Facture($this->db);
2208 $objectreplaced->fetch(
$object->fk_facture_source);
2211 $pdf->SetXY($posx, $posy);
2212 $pdf->SetTextColor(0, 0, 60);
2213 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2216 $objectreplaced =
new Facture($this->db);
2217 $objectreplaced->fetch(
$object->fk_facture_source);
2220 $pdf->SetXY($posx, $posy);
2221 $pdf->SetTextColor(0, 0, 60);
2222 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2226 $pdf->SetXY($posx, $posy);
2227 $pdf->SetTextColor(0, 0, 60);
2229 $title = $outputlangs->transnoentities(
"DateInvoice");
2230 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2231 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2233 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2237 $pdf->SetXY($posx, $posy);
2238 $pdf->SetTextColor(0, 0, 60);
2239 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2244 $pdf->SetXY($posx, $posy);
2245 $pdf->SetTextColor(0, 0, 60);
2246 $title = $outputlangs->transnoentities(
"DateDue");
2247 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2248 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2250 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2255 $pdf->SetXY($posx, $posy);
2256 $pdf->SetTextColor(0, 0, 60);
2257 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2262 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2263 if (count($arrayidcontact) > 0) {
2264 $usertmp =
new User($this->db);
2265 $usertmp->fetch($arrayidcontact[0]);
2267 $pdf->SetXY($posx, $posy);
2268 $pdf->SetTextColor(0, 0, 60);
2269 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2278 $current_y = $pdf->getY();
2280 if ($current_y < $pdf->getY()) {
2281 $top_shift = $pdf->getY() - $current_y;
2290 $posy += $top_shift;
2291 $posx = $this->marge_gauche;
2293 $posx = $this->page_largeur - $this->marge_droite - 80;
2301 $pdf->SetTextColor(0, 0, 0);
2302 $pdf->SetFont(
'',
'', $default_font_size - 2);
2303 $pdf->SetXY($posx, $posy - 5);
2304 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2305 $pdf->SetXY($posx, $posy);
2306 $pdf->SetFillColor(230, 230, 230);
2307 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2308 $pdf->SetTextColor(0, 0, 60);
2313 $pdf->SetXY($posx + 2, $posy + 3);
2314 $pdf->SetFont(
'',
'B', $default_font_size);
2315 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2316 $posy = $pdf->getY();
2320 $pdf->SetXY($posx + 2, $posy);
2321 $pdf->SetFont(
'',
'', $default_font_size - 1);
2322 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2325 $usecontact =
false;
2326 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2327 if (count($arrayidcontact) > 0) {
2329 $result =
$object->fetch_contact($arrayidcontact[0]);
2333 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2334 $thirdparty =
$object->contact;
2336 $thirdparty =
$object->thirdparty;
2346 if ($this->page_largeur < 210) {
2350 $posy += $top_shift;
2351 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2353 $posx = $this->marge_gauche;
2358 $pdf->SetTextColor(0, 0, 0);
2359 $pdf->SetFont(
'',
'', $default_font_size - 2);
2360 $pdf->SetXY($posx + 2, $posy - 5);
2361 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2362 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2366 $pdf->SetXY($posx + 2, $posy + 3);
2367 $pdf->SetFont(
'',
'B', $default_font_size);
2369 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2371 $posy = $pdf->getY();
2374 $pdf->SetFont(
'',
'', $default_font_size - 1);
2375 $pdf->SetXY($posx + 2, $posy);
2377 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2381 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2383 if (!empty($idaddressshipping)) {
2384 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2385 $companystatic =
new Societe($this->db);
2386 $companystatic->fetch(
$object->contact->fk_soc);
2388 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
2393 if (!empty($carac_client_shipping)) {
2394 $posy += $hautcadre;
2397 $pdf->SetXY($posx + 2, $posy - 5);
2398 $pdf->SetFont(
'',
'', $default_font_size - 2);
2399 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2400 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2403 $pdf->SetXY($posx + 2, $posy + 3);
2404 $pdf->SetFont(
'',
'B', $default_font_size);
2405 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2407 $posy = $pdf->getY();
2410 $pdf->SetXY($posx + 2, $posy);
2411 $pdf->SetFont(
'',
'', $default_font_size - 1);
2412 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2413 $shipp_shift += $hautcadre;
2418 $pdf->SetTextColor(0, 0, 0);
2420 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);
2742 public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
2746 $form =
new Form($db);
2750 if (!$displayWarranty) {
2761 $currency = !empty($currency) ? $currency : $conf->currency;
2765 $pdf->SetTextColor(0, 0, 0);
2766 $pdf->SetFont(
'',
'', $default_font_size - 2);
2768 if (empty($hidetop)) {
2769 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
2770 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 8);
2771 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
2773 $width = $this->page_largeur - $this->marge_gauche - $this->marge_droite - 83;
2777 $pdf->Rect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2778 $pdf->Rect($this->marge_gauche, $tab_top + 92.5, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 5,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2782 $pdf->SetDrawColor(128, 128, 128);
2783 $pdf->SetFont(
'',
'', $default_font_size - 1);
2787 $this->
printRectBtp($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
2789 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top, $this->posx_cumul_anterieur - 1, $tab_top + $tab_height);
2790 if (empty($hidetop)) {
2791 $pdf->SetXY($this->posx_cumul_anterieur - 1, $tab_top + 0.5);
2792 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceOldCumulation"),
'',
'C');
2796 $pdf->line($this->posx_new_cumul - 1, $tab_top, $this->posx_new_cumul - 1, $tab_top + $tab_height);
2797 if (empty($hidetop)) {
2798 $pdf->SetXY($this->posx_new_cumul - 1, $tab_top + 0.5);
2799 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceNewCumulation"),
'',
'C');
2802 $pdf->line($this->posx_current - 1, $tab_top, $this->posx_current - 1, $tab_top + $tab_height);
2803 if (empty($hidetop)) {
2804 $pdf->SetXY($this->posx_current - 1, $tab_top + 0.5);
2805 $pdf->MultiCell(36, 2, $outputlangs->transnoentities(
"CurrentSituationTotal",
$object->situation_counter),
'',
'C');
2809 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
2811 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 24, $this->page_largeur - $this->marge_droite, $tab_top + 24);
2813 $pdf->line($this->marge_gauche, $tab_top + 55, $this->page_largeur - $this->marge_droite, $tab_top + 55);
2815 $pdf->line($this->marge_gauche, $tab_top + 65, $this->page_largeur - $this->marge_droite, $tab_top + 65);
2817 if ($displayWarranty) {
2818 $pdf->line($this->marge_gauche, $tab_top + 85, $this->page_largeur - $this->marge_droite, $tab_top + 85);
2824 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 8);
2825 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceMainTask"),
'',
'L');
2827 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 12);
2828 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceAdditionalTask"),
'',
'L');
2830 $form->load_cache_vatrates(
"'".
$object->thirdparty->country_code.
"'");
2833 foreach ($form->cache_vatrates as $TVatInfo) {
2834 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2836 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2841 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 24 + $i);
2842 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalHT").
' '.$TVatInfo[
'label'],
'',
'L');
2844 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2845 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 28 + $i);
2846 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"VAT").
' '.$TVatInfo[
'label'],
'',
'L');
2852 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 33 + $i);
2853 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'L');
2856 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2857 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 58);
2858 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalSituationInvoice"),
'',
'L');
2859 $pdf->SetFont(
'',
'', $default_font_size - 2);
2861 if ($displayWarranty) {
2862 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 74);
2863 $pdf->MultiCell(80, 2, $outputlangs->trans(
"TotalSituationInvoiceWithRetainedWarranty",
$object->retained_warranty),
'',
'L');
2864 $nextY = $tab_top + 93;
2866 $nextY = $tab_top + 74;
2869 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2870 $pdf->SetXY($this->marge_gauche + 2, $nextY);
2871 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"SituationTotalRayToRest"),
'',
'L');
2872 $pdf->SetFont(
'',
'', $default_font_size - 2);
2876 $TToDisplay = array(
2882 $x = $this->marge_gauche + 85;
2886 foreach ($TToDisplay as $col) {
2888 $pdf->SetXY($x, $tab_top + 8);
2889 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2892 $pdf->SetXY($x, $tab_top + 12);
2893 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'travaux_sup'], 0,
'', 1, -1, 2),
'',
'R');
2896 foreach ($form->cache_vatrates as $TVatInfo) {
2897 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2898 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2904 $pdf->SetXY($x, $tab_top + 24 + $i);
2905 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2908 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2909 $pdf->SetXY($x, $tab_top + 28 + $i);
2910 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'TVA'], 0,
'', 1, -1, 2),
'',
'R');
2917 $pdf->SetXY($x, $tab_top + 33 + $i);
2918 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
2921 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2922 $pdf->SetXY($x, $tab_top + 58);
2923 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
2924 $pdf->SetFont(
'',
'', $default_font_size - 2);
2927 if ($displayWarranty) {
2929 $pdf->SetXY($x, $tab_top + 74);
2930 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'retenue_garantie'], 0,
'', 1, -1, 2),
'',
'R');
2931 $nextY = $tab_top + 93;
2933 $nextY = $tab_top + 74;
2937 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2938 $pdf->SetXY($x, $nextY);
2939 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'total_a_payer'], 0,
'', 1, -1, 2),
'',
'R');
2940 $pdf->SetFont(
'',
'', $default_font_size - 2);