274 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
277 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
279 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
281 if (!is_object($outputlangs)) {
282 $outputlangs = $langs;
286 $outputlangs->charset_output =
'ISO-8859-1';
290 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
292 global $outputlangsbis;
293 $outputlangsbis =
null;
295 $outputlangsbis =
new Translate(
'', $conf);
297 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
301 setEventMessage($langs->trans(
'WarningsObjectIsNotASituation'),
'warnings');
309 $nblines = count(
$object->lines);
317 $realpatharray = array();
318 $this->atleastonephoto =
false;
320 $objphoto =
new Product($this->db);
322 for ($i = 0; $i < $nblines; $i++) {
323 if (empty(
$object->lines[$i]->fk_product)) {
327 $objphoto->fetch(
$object->lines[$i]->fk_product);
331 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
332 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
334 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
335 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
339 foreach ($pdir as $midir) {
341 if ($conf->entity != $objphoto->entity) {
342 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
344 $dir = $conf->product->dir_output.
'/'.$midir;
347 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
349 if ($obj[
'photo_vignette']) {
350 $filename = $obj[
'photo_vignette'];
352 $filename = $obj[
'photo'];
355 $filename = $obj[
'photo'];
358 $realpath = $dir.$filename;
360 $this->atleastonephoto =
true;
365 if ($realpath && $arephoto) {
366 $realpatharray[$i] = $realpath;
373 if ($conf->facture->multidir_output[$conf->entity]) {
376 $deja_regle =
$object->getSommePaiement((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
377 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
378 $amount_deposits_included =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
382 $dir = $conf->facture->multidir_output[$conf->entity];
383 $file = $dir.
"/SPECIMEN.pdf";
386 $dir = $conf->facture->multidir_output[
$object->entity].
"/".$objectref;
387 $file = $dir.
"/".$objectref.
".pdf";
389 if (!file_exists($dir)) {
391 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
396 if (file_exists($dir)) {
398 if (!is_object($hookmanager)) {
399 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
402 $hookmanager->initHooks(array(
'pdfgeneration'));
403 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
405 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
408 $nblines = count(
$object->lines);
409 $nbpayments = count(
$object->getListOfPayments());
410 $nbprevsituation = is_array(
$object->tab_previous_situation_invoice) ? count(
$object->tab_previous_situation_invoice) : 0;
415 $default_font_size = 9;
416 $pdf->SetAutoPageBreak(1, 0);
419 $this->heightforinfotot = 45;
421 $this->heightforinfotot += 4 * ($nbpayments + 3);
423 if ($nbprevsituation > 0) {
424 $this->heightforinfotot += 4 * ($nbprevsituation + 3);
426 $this->heightforfreetext = (
getDolGlobalInt(
'MAIN_PDF_FREETEXT_HEIGHT', 5));
427 $this->heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
429 if (class_exists(
'TCPDF')) {
430 $pdf->setPrintHeader(
false);
431 $pdf->setPrintFooter(
false);
437 $logodir = $conf->mycompany->dir_output;
438 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
439 $logodir = $conf->mycompany->multidir_output[
$object->entity];
441 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
442 $this->tplidx = $pdf->importPage(1);
447 $pdf->SetDrawColor(128, 128, 128);
449 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
450 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceSituationTitle"));
451 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
452 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
453 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
455 $pdf->SetCompression(
false);
459 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
460 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
471 'Name' => $this->emetteur->name,
472 'Location' =>
getCountry($this->emetteur->country_code,
''),
473 'Reason' =>
'INVOICE',
474 'ContactInfo' => $this->emetteur->email
476 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
480 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
484 $categoryOfOperation = 0;
487 for ($i = 0; $i < $nblines; $i++) {
488 if (
$object->lines[$i]->remise_percent) {
489 $this->atleastonediscount++;
493 if ($categoryOfOperation < 2) {
494 $lineProductType =
$object->lines[$i]->product_type;
500 if ($nbProduct > 0 && $nbService > 0) {
502 $categoryOfOperation = 2;
507 if ($categoryOfOperation <= 0) {
509 if ($nbProduct == 0 && $nbService > 0) {
510 $categoryOfOperation = 1;
513 $this->categoryOfOperation = $categoryOfOperation;
517 if (!empty($this->tplidx)) {
518 $pdf->useTemplate($this->tplidx);
523 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
524 $top_shift = $pagehead[
'top_shift'];
525 $shipp_shift = $pagehead[
'shipp_shift'];
526 $pdf->SetFont(
'',
'', $default_font_size - 1);
527 $pdf->MultiCell(0, 3,
'');
528 $pdf->SetTextColor(0, 0, 0);
533 $this->tab_top = 90 + $top_shift + $shipp_shift;
534 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
537 $extra_under_address_shift = 0;
540 $qrcodestring =
$object->buildZATCAQRString();
542 $qrcodestring =
$object->buildSwitzerlandQRString();
545 $qrcodecolor = array(
'25',
'25',
'25');
550 'fgcolor' => $qrcodecolor,
555 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
556 $extra_under_address_shift += 25;
564 'outputlangs' => $outputlangs,
565 'hidedetails' => $hidedetails
567 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
568 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
569 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
572 $this->tab_top += $extra_under_address_shift;
573 $this->tab_top_newpage += 0;
577 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->
getHeightForQRInvoice(1,
$object, $langs);
579 $nexY = $this->tab_top - 1;
584 $tab_height_newpage = 150;
586 $this->
_tableFirstPage($pdf, $tab_top, $this->page_hauteur - 100 - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
588 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
596 $pdf->setTopMargin($this->tab_top_newpage);
599 $height_incoterms = 0;
600 if (isModEnabled(
'incoterm')) {
601 $desc_incoterms =
$object->getIncotermsForPDF();
602 if ($desc_incoterms) {
605 $pdf->SetFont(
'',
'', $default_font_size - 1);
606 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
607 $nexY = max($pdf->GetY(), $nexY);
608 $height_incoterms = $nexY - $this->tab_top;
611 $pdf->SetDrawColor(192, 192, 192);
612 $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius,
'1234',
'D');
614 $this->tab_top = $nexY + 6;
615 $height_incoterms += 4;
620 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
623 if (is_object(
$object->thirdparty)) {
624 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
625 $salerepobj =
new User($this->db);
626 $salerepobj->fetch($salereparray[0][
'id']);
627 if (!empty($salerepobj->signature)) {
628 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
634 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
635 if (!empty($extranote)) {
639 $pagenb = $pdf->getPage();
643 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
644 $pageposbeforenote = $pagenb;
651 $pdf->startTransaction();
653 $pdf->SetFont(
'',
'', $default_font_size - 1);
654 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
656 $pageposafternote = $pdf->getPage();
657 $posyafter = $pdf->GetY();
659 if ($pageposafternote > $pageposbeforenote) {
660 $pdf->rollbackTransaction(
true);
663 while ($pagenb < $pageposafternote) {
666 if (!empty($this->tplidx)) {
667 $pdf->useTemplate($this->tplidx);
672 $pdf->setTopMargin($this->tab_top_newpage);
674 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
678 $pdf->setPage($pageposbeforenote);
679 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
680 $pdf->SetFont(
'',
'', $default_font_size - 1);
681 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
682 $pageposafternote = $pdf->getPage();
684 $posyafter = $pdf->GetY();
686 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
687 $pdf->AddPage(
'',
'',
true);
690 $pdf->setPage($pageposafternote);
691 $pdf->setTopMargin($this->tab_top_newpage);
693 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
699 $i = $pageposbeforenote;
700 while ($i < $pageposafternote) {
704 $pdf->SetDrawColor(128, 128, 128);
706 if ($i > $pageposbeforenote) {
707 $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
708 $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
710 $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
711 $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
715 $pdf->setPageOrientation(
'', 1, 0);
722 $pdf->setPage($pageposafternote);
723 if (!empty($this->tplidx)) {
724 $pdf->useTemplate($this->tplidx);
729 $height_note = $posyafter - $this->tab_top_newpage;
730 $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
733 $pdf->commitTransaction();
734 $posyafter = $pdf->GetY();
735 $height_note = $posyafter - $this->tab_top;
736 $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
739 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
741 $pdf->AddPage(
'',
'',
true);
744 $pdf->setPage($pageposafternote);
745 if (!empty($this->tplidx)) {
746 $pdf->useTemplate($this->tplidx);
752 $posyafter = $this->tab_top_newpage;
756 $tab_height -= $height_note;
757 $this->tab_top = $posyafter + 6;
771 $nexY = $this->tab_top_newpage + $this->tabTitleHeight;
774 $pageposbeforeprintlines = $pdf->getPage();
775 $pagenb = $pageposbeforeprintlines;
776 for ($i = 0; $i < $nblines; $i++) {
778 $pdf->SetFont(
'',
'', $default_font_size - 1);
779 $pdf->SetTextColor(0, 0, 0);
782 $imglinesize = array();
783 if (!empty($realpatharray[$i])) {
787 $pdf->setTopMargin($this->tab_top_newpage);
788 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot);
789 $pageposbefore = $pdf->getPage();
791 $showpricebeforepagebreak = 1;
793 $posYAfterDescription = 0;
797 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($posy + $imglinesize[
'height']) > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
798 $pdf->AddPage(
'',
'',
true);
799 if (!empty($this->tplidx)) {
800 $pdf->useTemplate($this->tplidx);
802 $pdf->setPage($pageposbefore + 1);
804 $posy = $this->tab_top_newpage;
808 $showpricebeforepagebreak = 1;
810 $showpricebeforepagebreak = 0;
814 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
815 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $posy + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
817 $posYAfterImage = $posy + $imglinesize[
'height'];
823 $pdf->startTransaction();
826 $pageposafter = $pdf->getPage();
828 if ($pageposafter > $pageposbefore) {
829 $pdf->rollbackTransaction(
true);
830 $pageposafter = $pageposbefore;
831 $pdf->setPageOrientation(
'', 1, $this->heightforfooter);
835 $pageposafter = $pdf->getPage();
836 $posyafter = $pdf->GetY();
838 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
839 if ($i == ($nblines - 1)) {
840 $pdf->AddPage(
'',
'',
true);
841 if (!empty($this->tplidx)) {
842 $pdf->useTemplate($this->tplidx);
844 $pdf->setPage($pageposafter + 1);
850 $showpricebeforepagebreak = 1;
852 $showpricebeforepagebreak = 0;
856 $pdf->commitTransaction();
858 $posYAfterDescription = $pdf->GetY();
861 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
863 $pageposafter = $pdf->getPage();
864 $pdf->setPage($pageposbefore);
865 $pdf->setTopMargin($this->marge_haute);
866 $pdf->setPageOrientation(
'', 1, 0);
869 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
870 $pdf->setPage($pageposafter);
871 $posy = $this->tab_top_newpage;
874 $pdf->SetFont(
'',
'', $default_font_size - 1);
880 $nexY = max($pdf->GetY(), $nexY);
887 $nexY = max($pdf->GetY(), $nexY);
895 $nexY = max($pdf->GetY(), $nexY);
902 $nexY = max($pdf->GetY(), $nexY);
909 $nexY = max($pdf->GetY(), $nexY);
916 $nexY = max($pdf->GetY(), $nexY);
923 $nexY = max($pdf->GetY(), $nexY);
930 $columkey =
'btpsomme';
932 $printval =
price($TInfosLigneSituationPrecedente[
'total_ht_without_progress'], 0,
'', 1, -1, 2);
934 $nexY = max($pdf->GetY(), $nexY);
938 $columkey =
'progress_amount';
940 $printval =
price(
$object->lines[$i]->total_ht, 0,
'', 1, -1, 2);
942 $nexY = max($pdf->GetY(), $nexY);
945 $columkey =
'prev_progress';
947 $printval = $TInfosLigneSituationPrecedente[
'progress_prec'].
'%';
949 $nexY = max($pdf->GetY(), $nexY);
952 $columkey =
'prev_progress_amount';
954 $printval =
price($TInfosLigneSituationPrecedente[
'total_ht'], 0,
'', 1, -1, 2);
956 $nexY = max($pdf->GetY(), $nexY);
965 'outputlangs' => $outputlangs,
966 'hidedetails' => $hidedetails
968 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
976 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
977 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
978 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
979 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
981 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
984 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
985 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
987 $tvaligne = $sign *
$object->lines[$i]->total_tva;
991 $localtax1ligne =
$object->lines[$i]->total_localtax1;
992 $localtax2ligne =
$object->lines[$i]->total_localtax2;
993 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
994 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
995 $localtax1_type =
$object->lines[$i]->localtax1_type;
996 $localtax2_type =
$object->lines[$i]->localtax2_type;
1009 $vatrate = (string)
$object->lines[$i]->tva_tx;
1012 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
1013 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
1015 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
1016 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
1020 if ($localtax1_type && $localtax1ligne != 0) {
1021 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
1022 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
1024 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
1027 if ($localtax2_type && $localtax2ligne != 0) {
1028 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
1029 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
1031 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
1035 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
1040 if (!isset($this->tva[$vatrate])) {
1041 $this->tva[$vatrate] = 0;
1043 $this->tva[$vatrate] += $tvaligne;
1044 $vatcode =
$object->lines[$i]->vat_src_code;
1045 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
1046 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
1048 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
1050 $nexY = max($nexY, $posYAfterImage);
1054 $pdf->setPage($pageposafter);
1055 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
1057 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
1058 $pdf->SetLineStyle(array(
'dash' => 0));
1062 while ($pagenb < $pageposafter) {
1063 $pdf->setPage($pagenb);
1064 $tabtop = $this->tab_top;
1065 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1066 if ($pagenb != $pageposbeforeprintlines) {
1067 $tabtop = $this->tab_top_newpage;
1068 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1071 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1075 $pdf->setPage($pagenb);
1076 $pdf->setPageOrientation(
'', 1, 0);
1080 if (!empty($this->tplidx)) {
1081 $pdf->useTemplate($this->tplidx);
1085 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
1086 $tabtop = $this->tab_top;
1087 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1088 if ($pagenb != $pageposbeforeprintlines) {
1089 $tabtop = $this->tab_top_newpage;
1090 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1093 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1098 if (!empty($this->tplidx)) {
1099 $pdf->useTemplate($this->tplidx);
1110 $tabtop = $this->tab_top_newpage;
1111 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter - $this->heightforinfotot - $this->heightforfreetext;
1112 $tabTitleHeight = 0;
1113 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1115 $bottomlasttab = $tabtop + $tabhauteur + $tabTitleHeight + 10;
1121 $posy = $this->
drawTotalTable($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1124 $listofpayments =
$object->getListOfPayments(
'', 0, 1);
1125 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1131 if (method_exists($pdf,
'AliasNbPages')) {
1132 $pdf->AliasNbPages();
1135 $this->resumeLastPage($pdf,
$object, 0, $tab_top, $outputlangs, $outputlangsbis);
1136 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
1141 $pdf->Output($file,
'F');
1144 $hookmanager->initHooks(array(
'pdfgeneration'));
1145 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1147 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1149 $this->error = $hookmanager->error;
1150 $this->errors = $hookmanager->errors;
1155 $this->result = array(
'fullpath' => $file);
1159 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1163 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1188 $tab3_top = $posy + 8;
1191 if ($this->page_largeur < 210) {
1197 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1199 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1202 $pdf->SetFont(
'',
'', $default_font_size - 3);
1203 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1204 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1206 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1208 $pdf->SetFont(
'',
'', $default_font_size - 4);
1209 $pdf->SetXY($tab3_posx, $tab3_top);
1210 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1211 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1212 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1213 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1214 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1215 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1216 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1218 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1222 $pdf->SetFont(
'',
'', $default_font_size - 4);
1226 $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,";
1227 $sql .=
" re.description, re.fk_facture_source,";
1228 $sql .=
" f.type, f.datef";
1229 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1230 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1231 $resql = $this->db->query($sql);
1233 $num = $this->db->num_rows($resql);
1235 $invoice =
new Facture($this->db);
1238 $obj = $this->db->fetch_object($resql);
1240 if ($obj->type == 2) {
1241 $text = $outputlangs->transnoentities(
"CreditNote");
1242 } elseif ($obj->type == 3) {
1243 $text = $outputlangs->transnoentities(
"Deposit");
1244 } elseif ($obj->type == 0) {
1245 $text = $outputlangs->transnoentities(
"ExcessReceived");
1247 $text = $outputlangs->transnoentities(
"UnknownType");
1250 $invoice->fetch($obj->fk_facture_source);
1252 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1253 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1254 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1255 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1256 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1257 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1258 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1259 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1261 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1266 $this->error = $this->db->lasterror();
1272 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1274 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1275 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1276 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1278 $sql .=
" ORDER BY p.datep";
1280 $resql = $this->db->query($sql);
1282 $num = $this->db->num_rows($resql);
1287 $row = $this->db->fetch_object($resql);
1288 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1289 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1290 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1291 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1292 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1293 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1295 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1296 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1297 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1298 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1299 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1300 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1305 return $tab3_top + $y + 3;
1307 $this->error = $this->db->lasterror();
1325 global $conf, $mysoc, $hookmanager;
1329 $pdf->SetFont(
'',
'', $default_font_size - 1);
1332 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1333 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1334 $pdf->SetXY($this->marge_gauche, $posy);
1335 if ($mysoc->forme_juridique_code == 92) {
1336 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1338 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1341 $posy = $pdf->GetY() + 4;
1346 if ($this->page_largeur < 210) {
1352 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1353 $pdf->SetXY($this->marge_gauche, $posy);
1354 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1355 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1357 $pdf->SetFont(
'',
'', $default_font_size - 2);
1358 $pdf->SetXY($posxval, $posy);
1359 $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);
1360 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1361 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1363 $posy = $pdf->GetY() + 3;
1367 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1368 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1369 $pdf->SetXY($this->marge_gauche, $posy);
1370 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1371 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1373 $pdf->SetFont(
'',
'', $default_font_size - 2);
1374 $pdf->SetXY($posxval, $posy);
1375 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1376 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1378 $posy = $pdf->GetY() + 3;
1383 if (empty(
$object->mode_reglement_code)
1386 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1390 $outputlangs->load(
"errors");
1392 $pdf->SetXY($this->marge_gauche, $posy);
1393 $pdf->SetTextColor(200, 0, 0);
1394 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1395 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1396 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1397 $pdf->SetTextColor(0, 0, 0);
1399 $posy = $pdf->GetY() + 1;
1403 if (!empty(
$object->mode_reglement_code)
1404 &&
$object->mode_reglement_code !=
'CHQ'
1405 &&
$object->mode_reglement_code !=
'VIR') {
1406 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1407 $pdf->SetXY($this->marge_gauche, $posy);
1408 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1409 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1411 $pdf->SetFont(
'',
'', $default_font_size - 2);
1412 $pdf->SetXY($posxval, $posy);
1413 $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);
1416 if (
$object->mode_reglement_code ==
"PRE") {
1417 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1420 $bac->fetch(0,
$object->thirdparty->id);
1421 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1422 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1425 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1427 $posy = $pdf->GetY();
1433 if ($this->emetteur->country_code ==
'FR') {
1435 $pdf->SetXY($this->marge_gauche, $posy);
1436 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1438 $posy = $pdf->GetY() + 1;
1443 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1444 $useonlinepayment = 0;
1446 if (isModEnabled(
'paypal')) {
1447 $useonlinepayment++;
1449 if (isModEnabled(
'stripe')) {
1450 $useonlinepayment++;
1452 if (isModEnabled(
'paybox')) {
1453 $useonlinepayment++;
1455 $parameters = array();
1457 $reshook = $hookmanager->executeHooks(
'doShowOnlinePaymentUrl', $parameters,
$object, $action);
1459 if (isset($hookmanager->resArray[
'showonlinepaymenturl'])) {
1460 $useonlinepayment += $hookmanager->resArray[
'showonlinepaymenturl'];
1467 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1470 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1471 $servicename = $langs->transnoentities(
'Online');
1472 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1473 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1475 $pdf->SetXY($this->marge_gauche, $posy);
1476 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1478 $posy = $pdf->GetY() + 1;
1483 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1489 $account =
new Account($this->db);
1492 $pdf->SetXY($this->marge_gauche, $posy);
1493 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1494 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1495 $posy = $pdf->GetY() + 1;
1498 $pdf->SetXY($this->marge_gauche, $posy);
1499 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1500 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1501 $posy = $pdf->GetY() + 2;
1505 $pdf->SetXY($this->marge_gauche, $posy);
1506 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1507 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1508 $posy = $pdf->GetY() + 1;
1511 $pdf->SetXY($this->marge_gauche, $posy);
1512 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1513 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1514 $posy = $pdf->GetY() + 2;
1521 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1527 $account =
new Account($this->db);
1528 $account->fetch($bankid);
1530 $curx = $this->marge_gauche;
1533 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1539 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1542 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L', 0);
1565 global $conf, $mysoc, $hookmanager;
1575 $outputlangsbis =
new Translate(
'', $conf);
1577 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1578 $default_font_size--;
1581 $tab2_top = $posy - 4;
1583 $pdf->SetFont(
'',
'', $default_font_size - 1);
1588 if ($this->page_largeur < 210) {
1591 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1597 $pdf->SetFillColor(255, 255, 255);
1598 $pdf->SetXY($col1x, $tab2_top + 0);
1599 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1601 $total_ht = ((!empty($conf->multicurrency->enabled) && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1602 $pdf->SetXY($col2x, $tab2_top + 0);
1603 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht, 0, $outputlangs), 0,
'R', 1);
1608 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1609 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"DiscountHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"DiscountHT") :
''), 0,
'L', 1);
1610 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1611 $pdf->MultiCell($largcol2, $tab2_hl,
price($remise, 0, $outputlangs), 0,
'R', 1);
1614 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1615 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTWithDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTWithDiscount") :
''), 0,
'L', 1);
1616 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1617 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht - $remise, 0, $outputlangs), 0,
'R', 1);
1621 $pdf->SetFillColor(248, 248, 248);
1623 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1625 $this->atleastoneratenotnull = 0;
1627 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1628 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1632 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1633 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1637 foreach ($localtax_rate as $tvakey => $tvaval) {
1642 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1645 if (preg_match(
'/\*/', $tvakey)) {
1646 $tvakey = str_replace(
'*',
'', $tvakey);
1647 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1650 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1654 $totalvat .= $tvacompl;
1656 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1659 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1661 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1663 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1664 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1670 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1671 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1675 foreach ($localtax_rate as $tvakey => $tvaval) {
1680 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1683 if (preg_match(
'/\*/', $tvakey)) {
1684 $tvakey = str_replace(
'*',
'', $tvakey);
1685 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1687 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1691 $totalvat .= $tvacompl;
1693 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1696 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1698 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1700 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1701 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1709 $nblines = count(
$object->lines);
1710 for ($i = 0; $i < $nblines; $i++) {
1711 $tvaligne =
$object->lines[$i]->total_tva;
1712 $vatrate = (string)
$object->lines[$i]->tva_tx;
1714 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
1717 if (! isset($tvas[$vatrate])) {
1718 $tvas[$vatrate] = 0;
1720 $tvas[$vatrate] += $tvaligne;
1723 foreach ($tvas as $tvakey => $tvaval) {
1725 $this->atleastoneratenotnull++;
1728 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1731 if (preg_match(
'/\*/', $tvakey)) {
1732 $tvakey = str_replace(
'*',
'', $tvakey);
1733 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1735 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1738 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1740 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1742 $totalvat .= $tvacompl;
1744 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1746 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1748 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1749 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1754 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1755 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1759 foreach ($localtax_rate as $tvakey => $tvaval) {
1764 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1767 if (preg_match(
'/\*/', $tvakey)) {
1768 $tvakey = str_replace(
'*',
'', $tvakey);
1769 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1771 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1775 $totalvat .= $tvacompl;
1777 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1780 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1782 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1784 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1785 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1791 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1792 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1796 foreach ($localtax_rate as $tvakey => $tvaval) {
1802 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1805 if (preg_match(
'/\*/', $tvakey)) {
1806 $tvakey = str_replace(
'*',
'', $tvakey);
1807 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1809 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1813 $totalvat .= $tvacompl;
1815 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1818 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1820 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1822 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1823 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1832 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1833 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1835 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1836 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1841 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1842 $pdf->SetTextColor(0, 0, 60);
1843 $pdf->SetFillColor(224, 224, 224);
1844 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1846 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1847 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1851 if (
$object->displayRetainedWarranty()) {
1852 $pdf->SetTextColor(40, 40, 40);
1853 $pdf->SetFillColor(255, 255, 255);
1855 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1856 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1860 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1861 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1863 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1864 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1868 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1870 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1871 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1873 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1874 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1875 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1880 $pdf->SetTextColor(0, 0, 0);
1888 if ($deja_regle > 0) {
1892 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1893 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1895 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1896 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1915 $pdf->SetTextColor(0, 0, 60);
1916 $pdf->SetFillColor(224, 224, 224);
1917 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1918 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1919 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1920 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1922 $pdf->SetFont(
'',
'', $default_font_size - 1);
1923 $pdf->SetTextColor(0, 0, 0);
1926 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1928 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1930 $this->error = $hookmanager->error;
1931 $this->errors = $hookmanager->errors;
1935 return ($tab2_top + ($tab2_hl * $index));
2060 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2063 global $conf, $langs;
2065 $ltrdirection =
'L';
2066 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2067 $ltrdirection =
'R';
2071 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2077 $pdf->SetTextColor(0, 0, 60);
2078 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2082 $posy = $this->marge_haute;
2083 $posx = $this->page_largeur - $this->marge_droite - $w;
2085 $pdf->SetXY($this->marge_gauche, $posy);
2089 if ($this->emetteur->logo) {
2090 $logodir = $conf->mycompany->dir_output;
2091 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
2092 $logodir = $conf->mycompany->multidir_output[
$object->entity];
2095 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2097 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2099 if (is_readable($logo)) {
2101 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2103 $pdf->SetTextColor(200, 0, 0);
2104 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2105 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2106 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2109 $text = $this->emetteur->name;
2110 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2114 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2115 $pdf->SetXY($posx, $posy);
2116 $pdf->SetTextColor(0, 0, 60);
2118 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2120 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2123 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2126 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2129 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2131 if ($this->situationinvoice) {
2132 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
2133 $subtitle = $outputlangs->transnoentities(
"PDFSituationTitle",
$object->situation_counter);
2135 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2138 if ($this->situationinvoice) {
2139 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2141 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2142 } elseif (
$object->type == 1) {
2143 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2144 } elseif (
$object->type == 2) {
2145 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2146 } elseif (
$object->type == 3) {
2147 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2148 } elseif (
$object->type == 4) {
2149 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2152 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2158 $pdf->MultiCell($w, 3, $title,
'',
'R');
2159 if (!empty($subtitle)) {
2160 $pdf->SetFont(
'',
'B', $default_font_size);
2161 $pdf->SetXY($posx, $posy + 5);
2162 $pdf->MultiCell($w, 6, $subtitle,
'',
'R');
2166 $pdf->SetFont(
'',
'B', $default_font_size);
2180 $pdf->SetFont(
'',
'', $default_font_size - 2);
2184 $pdf->SetXY($posx, $posy);
2185 $pdf->SetTextColor(0, 0, 60);
2186 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2191 if (!empty(
$object->project->ref)) {
2193 $pdf->SetXY($posx, $posy);
2194 $pdf->SetTextColor(0, 0, 60);
2195 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2201 if (!empty(
$object->project->ref)) {
2202 $outputlangs->load(
"projects");
2204 $pdf->SetXY($posx, $posy);
2205 $pdf->SetTextColor(0, 0, 60);
2206 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2210 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2211 if (
$object->type == 0 && $objectidnext) {
2212 $objectreplacing =
new Facture($this->db);
2213 $objectreplacing->fetch($objectidnext);
2216 $pdf->SetXY($posx, $posy);
2217 $pdf->SetTextColor(0, 0, 60);
2218 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2221 $objectreplaced =
new Facture($this->db);
2222 $objectreplaced->fetch(
$object->fk_facture_source);
2225 $pdf->SetXY($posx, $posy);
2226 $pdf->SetTextColor(0, 0, 60);
2227 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2230 $objectreplaced =
new Facture($this->db);
2231 $objectreplaced->fetch(
$object->fk_facture_source);
2234 $pdf->SetXY($posx, $posy);
2235 $pdf->SetTextColor(0, 0, 60);
2236 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2240 $pdf->SetXY($posx, $posy);
2241 $pdf->SetTextColor(0, 0, 60);
2243 $title = $outputlangs->transnoentities(
"DateInvoice");
2244 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2245 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2247 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2251 $pdf->SetXY($posx, $posy);
2252 $pdf->SetTextColor(0, 0, 60);
2253 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2258 $pdf->SetXY($posx, $posy);
2259 $pdf->SetTextColor(0, 0, 60);
2260 $title = $outputlangs->transnoentities(
"DateDue");
2261 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2262 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2264 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2269 $pdf->SetXY($posx, $posy);
2270 $pdf->SetTextColor(0, 0, 60);
2271 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2276 $pdf->SetXY($posx, $posy);
2277 $pdf->SetTextColor(0, 0, 60);
2278 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
2283 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2284 if (count($arrayidcontact) > 0) {
2285 $usertmp =
new User($this->db);
2286 $usertmp->fetch($arrayidcontact[0]);
2288 $pdf->SetXY($posx, $posy);
2289 $pdf->SetTextColor(0, 0, 60);
2290 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2299 $current_y = $pdf->getY();
2301 if ($current_y < $pdf->getY()) {
2302 $top_shift = $pdf->getY() - $current_y;
2311 $posy += $top_shift;
2312 $posx = $this->marge_gauche;
2314 $posx = $this->page_largeur - $this->marge_droite - 80;
2322 $pdf->SetTextColor(0, 0, 0);
2323 $pdf->SetFont(
'',
'', $default_font_size - 2);
2324 $pdf->SetXY($posx, $posy - 5);
2325 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2326 $pdf->SetXY($posx, $posy);
2327 $pdf->SetFillColor(230, 230, 230);
2328 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2329 $pdf->SetTextColor(0, 0, 60);
2334 $pdf->SetXY($posx + 2, $posy + 3);
2335 $pdf->SetFont(
'',
'B', $default_font_size);
2336 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2337 $posy = $pdf->getY();
2341 $pdf->SetXY($posx + 2, $posy);
2342 $pdf->SetFont(
'',
'', $default_font_size - 1);
2343 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2346 $usecontact =
false;
2347 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2348 if (count($arrayidcontact) > 0) {
2350 $result =
$object->fetch_contact($arrayidcontact[0]);
2354 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2355 $thirdparty =
$object->contact;
2357 $thirdparty =
$object->thirdparty;
2367 if ($this->page_largeur < 210) {
2371 $posy += $top_shift;
2372 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2374 $posx = $this->marge_gauche;
2379 $pdf->SetTextColor(0, 0, 0);
2380 $pdf->SetFont(
'',
'', $default_font_size - 2);
2381 $pdf->SetXY($posx + 2, $posy - 5);
2382 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2383 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2387 $pdf->SetXY($posx + 2, $posy + 3);
2388 $pdf->SetFont(
'',
'B', $default_font_size);
2390 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2392 $posy = $pdf->getY();
2395 $pdf->SetFont(
'',
'', $default_font_size - 1);
2396 $pdf->SetXY($posx + 2, $posy);
2398 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2402 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2404 if (!empty($idaddressshipping)) {
2405 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2406 $companystatic =
new Societe($this->db);
2407 $companystatic->fetch(
$object->contact->fk_soc);
2409 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
2414 if (!empty($carac_client_shipping)) {
2415 $posy += $hautcadre;
2418 $pdf->SetXY($posx + 2, $posy - 5);
2419 $pdf->SetFont(
'',
'', $default_font_size - 2);
2420 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2421 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2424 $pdf->SetXY($posx + 2, $posy + 3);
2425 $pdf->SetFont(
'',
'B', $default_font_size);
2426 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2428 $posy = $pdf->getY();
2431 $pdf->SetXY($posx + 2, $posy);
2432 $pdf->SetFont(
'',
'', $default_font_size - 1);
2433 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2434 $shipp_shift += $hautcadre;
2439 $pdf->SetTextColor(0, 0, 0);
2441 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);
2763 public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
2767 $form =
new Form($db);
2771 if (!$displayWarranty) {
2782 $currency = !empty($currency) ? $currency : $conf->currency;
2786 $pdf->SetTextColor(0, 0, 0);
2787 $pdf->SetFont(
'',
'', $default_font_size - 2);
2789 if (empty($hidetop)) {
2790 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
2791 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 8);
2792 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
2794 $width = $this->page_largeur - $this->marge_gauche - $this->marge_droite - 83;
2799 $pdf->RoundedRect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, $this->corner_radius,
'1001',
'F', explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2801 $pdf->RoundedRect($this->marge_gauche, $tab_top + 92.5, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2805 $pdf->SetDrawColor(128, 128, 128);
2806 $pdf->SetFont(
'',
'', $default_font_size - 1);
2810 $this->
printRoundedRectBtp($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom,
'D');
2812 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top, $this->posx_cumul_anterieur - 1, $tab_top + $tab_height);
2813 if (empty($hidetop)) {
2814 $pdf->SetXY($this->posx_cumul_anterieur - 1, $tab_top + 0.5);
2815 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceOldCumulation"),
'',
'C');
2819 $pdf->line($this->posx_new_cumul - 1, $tab_top, $this->posx_new_cumul - 1, $tab_top + $tab_height);
2820 if (empty($hidetop)) {
2821 $pdf->SetXY($this->posx_new_cumul - 1, $tab_top + 0.5);
2822 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceNewCumulation"),
'',
'C');
2825 $pdf->line($this->posx_current - 1, $tab_top, $this->posx_current - 1, $tab_top + $tab_height);
2826 if (empty($hidetop)) {
2827 $pdf->SetXY($this->posx_current - 1, $tab_top + 0.5);
2828 $pdf->MultiCell(36, 2, $outputlangs->transnoentities(
"CurrentSituationTotal",
$object->situation_counter),
'',
'C');
2832 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
2834 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 24, $this->page_largeur - $this->marge_droite, $tab_top + 24);
2836 $pdf->line($this->marge_gauche, $tab_top + 55, $this->page_largeur - $this->marge_droite, $tab_top + 55);
2838 $pdf->line($this->marge_gauche, $tab_top + 65, $this->page_largeur - $this->marge_droite, $tab_top + 65);
2840 if ($displayWarranty) {
2841 $pdf->line($this->marge_gauche, $tab_top + 85, $this->page_largeur - $this->marge_droite, $tab_top + 85);
2847 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 8);
2848 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceMainTask"),
'',
'L');
2850 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 12);
2851 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceAdditionalTask"),
'',
'L');
2853 $form->load_cache_vatrates(
"'".
$object->thirdparty->country_code.
"'");
2856 foreach ($form->cache_vatrates as $TVatInfo) {
2857 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2859 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2864 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 24 + $i);
2865 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalHT").
' '.$TVatInfo[
'label'],
'',
'L');
2867 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2868 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 28 + $i);
2869 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"VAT").
' '.$TVatInfo[
'label'],
'',
'L');
2875 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 33 + $i);
2876 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'L');
2879 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2880 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 58);
2881 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalSituationInvoice"),
'',
'L');
2882 $pdf->SetFont(
'',
'', $default_font_size - 2);
2884 if ($displayWarranty) {
2885 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 74);
2886 $pdf->MultiCell(80, 2, $outputlangs->trans(
"TotalSituationInvoiceWithRetainedWarranty",
$object->retained_warranty),
'',
'L');
2887 $nextY = $tab_top + 93;
2889 $nextY = $tab_top + 74;
2892 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2893 $pdf->SetXY($this->marge_gauche + 2, $nextY);
2894 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"SituationTotalRayToRest"),
'',
'L');
2895 $pdf->SetFont(
'',
'', $default_font_size - 2);
2899 $TToDisplay = array(
2905 $x = $this->marge_gauche + 85;
2909 foreach ($TToDisplay as $col) {
2911 $pdf->SetXY($x, $tab_top + 8);
2912 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2915 $pdf->SetXY($x, $tab_top + 12);
2916 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'travaux_sup'], 0,
'', 1, -1, 2),
'',
'R');
2919 foreach ($form->cache_vatrates as $TVatInfo) {
2920 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2921 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2927 $pdf->SetXY($x, $tab_top + 24 + $i);
2928 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2931 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2932 $pdf->SetXY($x, $tab_top + 28 + $i);
2933 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'TVA'], 0,
'', 1, -1, 2),
'',
'R');
2940 $pdf->SetXY($x, $tab_top + 33 + $i);
2941 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
2944 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2945 $pdf->SetXY($x, $tab_top + 58);
2946 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
2947 $pdf->SetFont(
'',
'', $default_font_size - 2);
2950 if ($displayWarranty) {
2952 $pdf->SetXY($x, $tab_top + 74);
2953 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'retenue_garantie'], 0,
'', 1, -1, 2),
'',
'R');
2954 $nextY = $tab_top + 93;
2956 $nextY = $tab_top + 74;
2960 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2961 $pdf->SetXY($x, $nextY);
2962 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'total_a_payer'], 0,
'', 1, -1, 2),
'',
'R');
2963 $pdf->SetFont(
'',
'', $default_font_size - 2);