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, 0),
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 = $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 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1124 if (method_exists($pdf,
'AliasNbPages')) {
1125 $pdf->AliasNbPages();
1128 $this->resumeLastPage($pdf,
$object, 0, $tab_top, $outputlangs, $outputlangsbis);
1129 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
1134 $pdf->Output($file,
'F');
1137 $hookmanager->initHooks(array(
'pdfgeneration'));
1138 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1140 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1142 $this->error = $hookmanager->error;
1143 $this->errors = $hookmanager->errors;
1148 $this->result = array(
'fullpath' => $file);
1152 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1156 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1181 $tab3_top = $posy + 8;
1184 if ($this->page_largeur < 210) {
1190 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1192 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1195 $pdf->SetFont(
'',
'', $default_font_size - 3);
1196 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1197 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1199 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1201 $pdf->SetFont(
'',
'', $default_font_size - 4);
1202 $pdf->SetXY($tab3_posx, $tab3_top);
1203 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1204 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1205 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1206 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1207 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1208 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1209 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1211 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1215 $pdf->SetFont(
'',
'', $default_font_size - 4);
1219 $sql =
"SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,";
1220 $sql .=
" re.description, re.fk_facture_source,";
1221 $sql .=
" f.type, f.datef";
1222 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1223 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1224 $resql = $this->db->query($sql);
1226 $num = $this->db->num_rows($resql);
1228 $invoice =
new Facture($this->db);
1231 $obj = $this->db->fetch_object($resql);
1233 if ($obj->type == 2) {
1234 $text = $outputlangs->transnoentities(
"CreditNote");
1235 } elseif ($obj->type == 3) {
1236 $text = $outputlangs->transnoentities(
"Deposit");
1237 } elseif ($obj->type == 0) {
1238 $text = $outputlangs->transnoentities(
"ExcessReceived");
1240 $text = $outputlangs->transnoentities(
"UnknownType");
1243 $invoice->fetch($obj->fk_facture_source);
1245 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1246 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1247 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1248 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1249 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1250 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1251 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1252 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1254 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1259 $this->error = $this->db->lasterror();
1265 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1267 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1268 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1269 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1271 $sql .=
" ORDER BY p.datep";
1273 $resql = $this->db->query($sql);
1275 $num = $this->db->num_rows($resql);
1280 $row = $this->db->fetch_object($resql);
1281 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1282 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1283 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1284 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1285 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1286 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1288 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1289 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1290 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1291 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1292 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1293 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1298 return $tab3_top + $y + 3;
1300 $this->error = $this->db->lasterror();
1318 global $conf, $mysoc, $hookmanager;
1322 $pdf->SetFont(
'',
'', $default_font_size - 1);
1325 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1326 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1327 $pdf->SetXY($this->marge_gauche, $posy);
1328 if ($mysoc->forme_juridique_code == 92) {
1329 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1331 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1334 $posy = $pdf->GetY() + 4;
1339 if ($this->page_largeur < 210) {
1345 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1346 $pdf->SetXY($this->marge_gauche, $posy);
1347 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1348 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1350 $pdf->SetFont(
'',
'', $default_font_size - 2);
1351 $pdf->SetXY($posxval, $posy);
1352 $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);
1353 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1354 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1356 $posy = $pdf->GetY() + 3;
1360 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1361 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1362 $pdf->SetXY($this->marge_gauche, $posy);
1363 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1364 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1366 $pdf->SetFont(
'',
'', $default_font_size - 2);
1367 $pdf->SetXY($posxval, $posy);
1368 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1369 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1371 $posy = $pdf->GetY() + 3;
1376 if (empty(
$object->mode_reglement_code)
1379 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1383 $outputlangs->load(
"errors");
1385 $pdf->SetXY($this->marge_gauche, $posy);
1386 $pdf->SetTextColor(200, 0, 0);
1387 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1388 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1389 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1390 $pdf->SetTextColor(0, 0, 0);
1392 $posy = $pdf->GetY() + 1;
1396 if (!empty(
$object->mode_reglement_code)
1397 &&
$object->mode_reglement_code !=
'CHQ'
1398 &&
$object->mode_reglement_code !=
'VIR') {
1399 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1400 $pdf->SetXY($this->marge_gauche, $posy);
1401 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1402 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1404 $pdf->SetFont(
'',
'', $default_font_size - 2);
1405 $pdf->SetXY($posxval, $posy);
1406 $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);
1409 if (
$object->mode_reglement_code ==
"PRE") {
1410 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1413 $bac->fetch(0,
$object->thirdparty->id);
1414 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1415 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1418 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1420 $posy = $pdf->GetY();
1426 if ($this->emetteur->country_code ==
'FR') {
1428 $pdf->SetXY($this->marge_gauche, $posy);
1429 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1431 $posy = $pdf->GetY() + 1;
1436 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1437 $useonlinepayment = 0;
1439 if (isModEnabled(
'paypal')) {
1440 $useonlinepayment++;
1442 if (isModEnabled(
'stripe')) {
1443 $useonlinepayment++;
1445 if (isModEnabled(
'paybox')) {
1446 $useonlinepayment++;
1448 $parameters = array();
1450 $reshook = $hookmanager->executeHooks(
'doShowOnlinePaymentUrl', $parameters,
$object, $action);
1452 if (isset($hookmanager->resArray[
'showonlinepaymenturl'])) {
1453 $useonlinepayment += $hookmanager->resArray[
'showonlinepaymenturl'];
1460 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1463 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1464 $servicename = $langs->transnoentities(
'Online');
1465 $paiement_url = getOnlinePaymentUrl(
'',
'invoice',
$object->ref,
'',
'',
'');
1466 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1468 $pdf->SetXY($this->marge_gauche, $posy);
1469 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1471 $posy = $pdf->GetY() + 1;
1476 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1482 $account =
new Account($this->db);
1485 $pdf->SetXY($this->marge_gauche, $posy);
1486 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1487 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1488 $posy = $pdf->GetY() + 1;
1491 $pdf->SetXY($this->marge_gauche, $posy);
1492 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1493 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1494 $posy = $pdf->GetY() + 2;
1498 $pdf->SetXY($this->marge_gauche, $posy);
1499 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1500 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1501 $posy = $pdf->GetY() + 1;
1504 $pdf->SetXY($this->marge_gauche, $posy);
1505 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1506 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1507 $posy = $pdf->GetY() + 2;
1514 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1520 $account =
new Account($this->db);
1521 $account->fetch($bankid);
1523 $curx = $this->marge_gauche;
1526 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1550 global $conf, $mysoc, $hookmanager;
1560 $outputlangsbis =
new Translate(
'', $conf);
1562 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1563 $default_font_size--;
1566 $tab2_top = $posy - 4;
1568 $pdf->SetFont(
'',
'', $default_font_size - 1);
1573 if ($this->page_largeur < 210) {
1576 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1582 $pdf->SetFillColor(255, 255, 255);
1583 $pdf->SetXY($col1x, $tab2_top + 0);
1584 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1586 $total_ht = ((!empty($conf->multicurrency->enabled) && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1587 $pdf->SetXY($col2x, $tab2_top + 0);
1588 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht, 0, $outputlangs), 0,
'R', 1);
1593 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1594 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"DiscountHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"DiscountHT") :
''), 0,
'L', 1);
1595 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1596 $pdf->MultiCell($largcol2, $tab2_hl,
price($remise, 0, $outputlangs), 0,
'R', 1);
1599 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1600 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTWithDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTWithDiscount") :
''), 0,
'L', 1);
1601 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1602 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht - $remise, 0, $outputlangs), 0,
'R', 1);
1606 $pdf->SetFillColor(248, 248, 248);
1608 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1610 $this->atleastoneratenotnull = 0;
1612 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1613 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1617 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1618 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1622 foreach ($localtax_rate as $tvakey => $tvaval) {
1627 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1630 if (preg_match(
'/\*/', $tvakey)) {
1631 $tvakey = str_replace(
'*',
'', $tvakey);
1632 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1635 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1639 $totalvat .= $tvacompl;
1641 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1644 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1646 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1648 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1649 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1655 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1656 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1660 foreach ($localtax_rate as $tvakey => $tvaval) {
1665 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1668 if (preg_match(
'/\*/', $tvakey)) {
1669 $tvakey = str_replace(
'*',
'', $tvakey);
1670 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1672 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1676 $totalvat .= $tvacompl;
1678 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1681 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1683 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1685 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1686 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1694 $nblines = count(
$object->lines);
1695 for ($i = 0; $i < $nblines; $i++) {
1696 $tvaligne =
$object->lines[$i]->total_tva;
1697 $vatrate = (string)
$object->lines[$i]->tva_tx;
1699 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
1702 if (! isset($tvas[$vatrate])) {
1703 $tvas[$vatrate] = 0;
1705 $tvas[$vatrate] += $tvaligne;
1708 foreach ($tvas as $tvakey => $tvaval) {
1710 $this->atleastoneratenotnull++;
1713 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1716 if (preg_match(
'/\*/', $tvakey)) {
1717 $tvakey = str_replace(
'*',
'', $tvakey);
1718 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1720 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1723 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1725 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1727 $totalvat .= $tvacompl;
1729 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1731 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1733 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1734 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1739 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1740 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1744 foreach ($localtax_rate as $tvakey => $tvaval) {
1749 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1752 if (preg_match(
'/\*/', $tvakey)) {
1753 $tvakey = str_replace(
'*',
'', $tvakey);
1754 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1756 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1760 $totalvat .= $tvacompl;
1762 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1765 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1767 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1769 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1770 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1776 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1777 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1781 foreach ($localtax_rate as $tvakey => $tvaval) {
1787 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1790 if (preg_match(
'/\*/', $tvakey)) {
1791 $tvakey = str_replace(
'*',
'', $tvakey);
1792 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1794 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1798 $totalvat .= $tvacompl;
1800 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1803 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1805 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1807 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1808 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1817 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1818 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1820 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1821 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1826 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1827 $pdf->SetTextColor(0, 0, 60);
1828 $pdf->SetFillColor(224, 224, 224);
1829 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1831 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1832 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1836 if (
$object->displayRetainedWarranty()) {
1837 $pdf->SetTextColor(40, 40, 40);
1838 $pdf->SetFillColor(255, 255, 255);
1840 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1841 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1845 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1846 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1848 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1849 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1853 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1855 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1856 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1858 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1859 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1860 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1865 $pdf->SetTextColor(0, 0, 0);
1873 if ($deja_regle > 0) {
1877 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1878 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1880 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1881 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1900 $pdf->SetTextColor(0, 0, 60);
1901 $pdf->SetFillColor(224, 224, 224);
1902 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1903 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1904 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1905 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1907 $pdf->SetFont(
'',
'', $default_font_size - 1);
1908 $pdf->SetTextColor(0, 0, 0);
1911 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1913 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1915 $this->error = $hookmanager->error;
1916 $this->errors = $hookmanager->errors;
1920 return ($tab2_top + ($tab2_hl * $index));
2045 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2048 global $conf, $langs;
2050 $ltrdirection =
'L';
2051 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2052 $ltrdirection =
'R';
2056 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2062 $pdf->SetTextColor(0, 0, 60);
2063 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2067 $posy = $this->marge_haute;
2068 $posx = $this->page_largeur - $this->marge_droite - $w;
2070 $pdf->SetXY($this->marge_gauche, $posy);
2074 if ($this->emetteur->logo) {
2075 $logodir = $conf->mycompany->dir_output;
2076 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
2077 $logodir = $conf->mycompany->multidir_output[
$object->entity];
2080 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2082 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2084 if (is_readable($logo)) {
2086 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2088 $pdf->SetTextColor(200, 0, 0);
2089 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2090 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2091 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2094 $text = $this->emetteur->name;
2095 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2099 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2100 $pdf->SetXY($posx, $posy);
2101 $pdf->SetTextColor(0, 0, 60);
2103 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2105 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2108 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2111 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2114 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2116 if ($this->situationinvoice) {
2117 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
2118 $subtitle = $outputlangs->transnoentities(
"PDFSituationTitle",
$object->situation_counter);
2120 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2123 if ($this->situationinvoice) {
2124 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2126 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2127 } elseif (
$object->type == 1) {
2128 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2129 } elseif (
$object->type == 2) {
2130 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2131 } elseif (
$object->type == 3) {
2132 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2133 } elseif (
$object->type == 4) {
2134 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2137 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2143 $pdf->MultiCell($w, 3, $title,
'',
'R');
2144 if (!empty($subtitle)) {
2145 $pdf->SetFont(
'',
'B', $default_font_size);
2146 $pdf->SetXY($posx, $posy + 5);
2147 $pdf->MultiCell($w, 6, $subtitle,
'',
'R');
2151 $pdf->SetFont(
'',
'B', $default_font_size);
2165 $pdf->SetFont(
'',
'', $default_font_size - 2);
2169 $pdf->SetXY($posx, $posy);
2170 $pdf->SetTextColor(0, 0, 60);
2171 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2176 if (!empty(
$object->project->ref)) {
2178 $pdf->SetXY($posx, $posy);
2179 $pdf->SetTextColor(0, 0, 60);
2180 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2186 if (!empty(
$object->project->ref)) {
2187 $outputlangs->load(
"projects");
2189 $pdf->SetXY($posx, $posy);
2190 $pdf->SetTextColor(0, 0, 60);
2191 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2195 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2196 if (
$object->type == 0 && $objectidnext) {
2197 $objectreplacing =
new Facture($this->db);
2198 $objectreplacing->fetch($objectidnext);
2201 $pdf->SetXY($posx, $posy);
2202 $pdf->SetTextColor(0, 0, 60);
2203 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2206 $objectreplaced =
new Facture($this->db);
2207 $objectreplaced->fetch(
$object->fk_facture_source);
2210 $pdf->SetXY($posx, $posy);
2211 $pdf->SetTextColor(0, 0, 60);
2212 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2215 $objectreplaced =
new Facture($this->db);
2216 $objectreplaced->fetch(
$object->fk_facture_source);
2219 $pdf->SetXY($posx, $posy);
2220 $pdf->SetTextColor(0, 0, 60);
2221 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2225 $pdf->SetXY($posx, $posy);
2226 $pdf->SetTextColor(0, 0, 60);
2228 $title = $outputlangs->transnoentities(
"DateInvoice");
2229 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2230 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2232 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2236 $pdf->SetXY($posx, $posy);
2237 $pdf->SetTextColor(0, 0, 60);
2238 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2243 $pdf->SetXY($posx, $posy);
2244 $pdf->SetTextColor(0, 0, 60);
2245 $title = $outputlangs->transnoentities(
"DateDue");
2246 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2247 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2249 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2254 $pdf->SetXY($posx, $posy);
2255 $pdf->SetTextColor(0, 0, 60);
2256 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2261 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2262 if (count($arrayidcontact) > 0) {
2263 $usertmp =
new User($this->db);
2264 $usertmp->fetch($arrayidcontact[0]);
2266 $pdf->SetXY($posx, $posy);
2267 $pdf->SetTextColor(0, 0, 60);
2268 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2277 $current_y = $pdf->getY();
2279 if ($current_y < $pdf->getY()) {
2280 $top_shift = $pdf->getY() - $current_y;
2289 $posy += $top_shift;
2290 $posx = $this->marge_gauche;
2292 $posx = $this->page_largeur - $this->marge_droite - 80;
2300 $pdf->SetTextColor(0, 0, 0);
2301 $pdf->SetFont(
'',
'', $default_font_size - 2);
2302 $pdf->SetXY($posx, $posy - 5);
2303 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2304 $pdf->SetXY($posx, $posy);
2305 $pdf->SetFillColor(230, 230, 230);
2306 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2307 $pdf->SetTextColor(0, 0, 60);
2312 $pdf->SetXY($posx + 2, $posy + 3);
2313 $pdf->SetFont(
'',
'B', $default_font_size);
2314 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2315 $posy = $pdf->getY();
2319 $pdf->SetXY($posx + 2, $posy);
2320 $pdf->SetFont(
'',
'', $default_font_size - 1);
2321 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2324 $usecontact =
false;
2325 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2326 if (count($arrayidcontact) > 0) {
2328 $result =
$object->fetch_contact($arrayidcontact[0]);
2332 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2333 $thirdparty =
$object->contact;
2335 $thirdparty =
$object->thirdparty;
2345 if ($this->page_largeur < 210) {
2349 $posy += $top_shift;
2350 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2352 $posx = $this->marge_gauche;
2357 $pdf->SetTextColor(0, 0, 0);
2358 $pdf->SetFont(
'',
'', $default_font_size - 2);
2359 $pdf->SetXY($posx + 2, $posy - 5);
2360 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2361 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2365 $pdf->SetXY($posx + 2, $posy + 3);
2366 $pdf->SetFont(
'',
'B', $default_font_size);
2368 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2370 $posy = $pdf->getY();
2373 $pdf->SetFont(
'',
'', $default_font_size - 1);
2374 $pdf->SetXY($posx + 2, $posy);
2376 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2380 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2382 if (!empty($idaddressshipping)) {
2383 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2384 $companystatic =
new Societe($this->db);
2385 $companystatic->fetch(
$object->contact->fk_soc);
2392 if (!empty($carac_client_shipping)) {
2393 $posy += $hautcadre;
2396 $pdf->SetXY($posx + 2, $posy - 5);
2397 $pdf->SetFont(
'',
'', $default_font_size - 2);
2398 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2399 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2402 $pdf->SetXY($posx + 2, $posy + 3);
2403 $pdf->SetFont(
'',
'B', $default_font_size);
2404 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2406 $posy = $pdf->getY();
2409 $pdf->SetXY($posx + 2, $posy);
2410 $pdf->SetFont(
'',
'', $default_font_size - 1);
2411 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2412 $shipp_shift += $hautcadre;
2417 $pdf->SetTextColor(0, 0, 0);
2419 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);
2741 public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
2745 $form =
new Form($db);
2749 if (!$displayWarranty) {
2760 $currency = !empty($currency) ? $currency : $conf->currency;
2764 $pdf->SetTextColor(0, 0, 0);
2765 $pdf->SetFont(
'',
'', $default_font_size - 2);
2767 if (empty($hidetop)) {
2768 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
2769 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 8);
2770 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
2772 $width = $this->page_largeur - $this->marge_gauche - $this->marge_droite - 83;
2776 $pdf->Rect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2777 $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')));
2781 $pdf->SetDrawColor(128, 128, 128);
2782 $pdf->SetFont(
'',
'', $default_font_size - 1);
2786 $this->
printRectBtp($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
2788 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top, $this->posx_cumul_anterieur - 1, $tab_top + $tab_height);
2789 if (empty($hidetop)) {
2790 $pdf->SetXY($this->posx_cumul_anterieur - 1, $tab_top + 0.5);
2791 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceOldCumulation"),
'',
'C');
2795 $pdf->line($this->posx_new_cumul - 1, $tab_top, $this->posx_new_cumul - 1, $tab_top + $tab_height);
2796 if (empty($hidetop)) {
2797 $pdf->SetXY($this->posx_new_cumul - 1, $tab_top + 0.5);
2798 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceNewCumulation"),
'',
'C');
2801 $pdf->line($this->posx_current - 1, $tab_top, $this->posx_current - 1, $tab_top + $tab_height);
2802 if (empty($hidetop)) {
2803 $pdf->SetXY($this->posx_current - 1, $tab_top + 0.5);
2804 $pdf->MultiCell(36, 2, $outputlangs->transnoentities(
"CurrentSituationTotal",
$object->situation_counter),
'',
'C');
2808 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
2810 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 24, $this->page_largeur - $this->marge_droite, $tab_top + 24);
2812 $pdf->line($this->marge_gauche, $tab_top + 55, $this->page_largeur - $this->marge_droite, $tab_top + 55);
2814 $pdf->line($this->marge_gauche, $tab_top + 65, $this->page_largeur - $this->marge_droite, $tab_top + 65);
2816 if ($displayWarranty) {
2817 $pdf->line($this->marge_gauche, $tab_top + 85, $this->page_largeur - $this->marge_droite, $tab_top + 85);
2823 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 8);
2824 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceMainTask"),
'',
'L');
2826 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 12);
2827 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceAdditionalTask"),
'',
'L');
2829 $form->load_cache_vatrates(
"'".
$object->thirdparty->country_code.
"'");
2832 foreach ($form->cache_vatrates as $TVatInfo) {
2833 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2835 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2840 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 24 + $i);
2841 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalHT").
' '.$TVatInfo[
'label'],
'',
'L');
2843 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2844 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 28 + $i);
2845 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"VAT").
' '.$TVatInfo[
'label'],
'',
'L');
2851 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 33 + $i);
2852 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'L');
2855 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2856 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 58);
2857 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalSituationInvoice"),
'',
'L');
2858 $pdf->SetFont(
'',
'', $default_font_size - 2);
2860 if ($displayWarranty) {
2861 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 74);
2862 $pdf->MultiCell(80, 2, $outputlangs->trans(
"TotalSituationInvoiceWithRetainedWarranty",
$object->retained_warranty),
'',
'L');
2863 $nextY = $tab_top + 93;
2865 $nextY = $tab_top + 74;
2868 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2869 $pdf->SetXY($this->marge_gauche + 2, $nextY);
2870 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"SituationTotalRayToRest"),
'',
'L');
2871 $pdf->SetFont(
'',
'', $default_font_size - 2);
2875 $TToDisplay = array(
2881 $x = $this->marge_gauche + 85;
2885 foreach ($TToDisplay as $col) {
2887 $pdf->SetXY($x, $tab_top + 8);
2888 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2891 $pdf->SetXY($x, $tab_top + 12);
2892 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'travaux_sup'], 0,
'', 1, -1, 2),
'',
'R');
2895 foreach ($form->cache_vatrates as $TVatInfo) {
2896 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2897 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2903 $pdf->SetXY($x, $tab_top + 24 + $i);
2904 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2907 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2908 $pdf->SetXY($x, $tab_top + 28 + $i);
2909 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'TVA'], 0,
'', 1, -1, 2),
'',
'R');
2916 $pdf->SetXY($x, $tab_top + 33 + $i);
2917 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
2920 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2921 $pdf->SetXY($x, $tab_top + 58);
2922 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
2923 $pdf->SetFont(
'',
'', $default_font_size - 2);
2926 if ($displayWarranty) {
2928 $pdf->SetXY($x, $tab_top + 74);
2929 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'retenue_garantie'], 0,
'', 1, -1, 2),
'',
'R');
2930 $nextY = $tab_top + 93;
2932 $nextY = $tab_top + 74;
2936 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2937 $pdf->SetXY($x, $nextY);
2938 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'total_a_payer'], 0,
'', 1, -1, 2),
'',
'R');
2939 $pdf->SetFont(
'',
'', $default_font_size - 2);