265 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
268 global $user, $langs,
$conf,
$mysoc, $hookmanager, $nblines;
270 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
272 if (!is_object($outputlangs)) {
273 $outputlangs = $langs;
277 $outputlangs->charset_output =
'ISO-8859-1';
281 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
283 global $outputlangsbis;
284 $outputlangsbis =
null;
288 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
292 setEventMessage($langs->trans(
'WarningsObjectIsNotASituation'),
'warnings');
300 $nblines = count(
$object->lines);
308 $realpatharray = array();
309 $this->atleastonephoto =
false;
311 $objphoto =
new Product($this->db);
313 for ($i = 0; $i < $nblines; $i++) {
314 if (empty(
$object->lines[$i]->fk_product)) {
318 $objphoto->fetch(
$object->lines[$i]->fk_product);
322 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
323 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
325 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
326 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
331 foreach ($pdir as $midir) {
333 $entity = $objphoto->entity;
334 if ($entity !==
null &&
$conf->entity != $entity) {
335 $dir =
$conf->product->multidir_output[$entity].
'/'.$midir;
337 $dir =
$conf->product->dir_output.
'/'.$midir;
340 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
342 if ($obj[
'photo_vignette']) {
343 $filename = $obj[
'photo_vignette'];
345 $filename = $obj[
'photo'];
348 $filename = $obj[
'photo'];
351 $realpath = $dir.$filename;
353 $this->atleastonephoto =
true;
358 if (!empty($realpath) && $arephoto) {
359 $realpatharray[$i] = $realpath;
366 if (
$conf->facture->multidir_output[
$conf->entity]) {
370 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
371 $amount_deposits_included =
$object->getSumDepositsUsed((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
375 $dir =
$conf->facture->multidir_output[
$conf->entity];
376 $file = $dir.
"/SPECIMEN.pdf";
379 $dir =
$conf->facture->multidir_output[
$object->entity ??
$conf->entity].
"/".$objectref;
380 $file = $dir.
"/".$objectref.
".pdf";
382 if (!file_exists($dir)) {
384 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
389 if (file_exists($dir)) {
391 if (!is_object($hookmanager)) {
392 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
395 $hookmanager->initHooks(array(
'pdfgeneration'));
396 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
398 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
401 $nblines = count(
$object->lines);
402 $nbpayments = count(
$object->getListOfPayments());
403 $nbprevsituation = is_array(
$object->tab_previous_situation_invoice) ? count(
$object->tab_previous_situation_invoice) : 0;
408 $pdf->setAutoPageBreak(
true, 0);
411 $this->heightforinfotot = 50;
413 $this->heightforinfotot += (4 * ($nbpayments + 3));
415 if ($nbprevsituation > 0) {
416 $this->heightforinfotot += (4 * ($nbprevsituation + 3));
418 $this->heightforfreetext =
getDolGlobalInt(
'MAIN_PDF_FREETEXT_HEIGHT', 5);
419 $this->heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
421 $heightforqrinvoice = 0;
425 $this->heightforinfotot = 30 + (4 * $nbpayments);
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 ??
$conf->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->getAnonymisableFullName($outputlangs)) :
''));
453 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
455 $pdf->SetCompression(
false);
465 'Name' => $this->emetteur->name,
466 'Location' =>
getCountry($this->emetteur->country_code,
''),
467 'Reason' =>
'INVOICE',
468 'ContactInfo' => $this->emetteur->email
470 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
474 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
478 $categoryOfOperation = 0;
481 for ($i = 0; $i < $nblines; $i++) {
483 if ($line->remise_percent) {
484 $this->atleastonediscount++;
488 if ($line->isDepositLine()) {
493 if ($categoryOfOperation < 2) {
494 $lineProductType = $line->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;
516 if (
$object->situation_cycle_ref) {
517 $this->situationinvoice =
true;
522 if (!empty($this->tplidx)) {
523 $pdf->useTemplate($this->tplidx);
528 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
529 $top_shift = $pagehead[
'top_shift'];
530 $shipp_shift = $pagehead[
'shipp_shift'];
531 $pdf->SetFont(
'',
'', $default_font_size - 1);
532 $pdf->MultiCell(0, 3,
'');
533 $pdf->SetTextColor(0, 0, 0);
538 $this->tab_top = 90 + $top_shift + $shipp_shift;
539 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
542 $extra_under_address_shift = 0;
545 $qrcodestring =
$object->buildZATCAQRString();
548 $qrcodestring =
$object->buildSwitzerlandQRString();
552 $qrcodestring =
$object->buildEPCQrCodeString();
557 $qrcodecolor = array(
'25',
'25',
'25');
562 'fgcolor' => $qrcodecolor,
567 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
571 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
572 $pdf->SetFont(
'',
'', $default_font_size - 4);
573 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L',
false);
577 $extra_under_address_shift += 25;
585 'outputlangs' => $outputlangs,
586 'hidedetails' => $hidedetails
588 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
589 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
590 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
593 $this->tab_top += $extra_under_address_shift;
594 $this->tab_top_newpage += 0;
598 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->
getHeightForQRInvoice(1,
$object, $langs);
600 $nexY = $this->tab_top - 1;
610 $tab_height_newpage = 150;
612 $this->
tableFirstPage($pdf, $tab_top, $this->page_hauteur - 100 - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
614 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
622 $pdf->setTopMargin($this->tab_top_newpage);
637 $nexY = $this->tab_top_newpage + $this->tabTitleHeight;
640 $pageposbeforeprintlines = $pdf->getPage();
641 $pagenb = $pageposbeforeprintlines;
643 $pdf_sub_options = array();
644 $pdf_sub_options[
'titleshowuponpdf'] = 1;
645 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = 1;
647 for ($i = 0; $i < $nblines; $i++) {
648 $sub_options =
$object->lines[$i]->extraparams[
"subtotal"] ?? array();
650 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
651 $level =
$object->lines[$i]->qty;
653 if (isset($sub_options[
'titleshowuponpdf'])) {
654 $pdf_sub_options[
'titleshowuponpdf'] = isset($pdf_sub_options[
'titleshowuponpdf']) && $pdf_sub_options[
'titleshowuponpdf'] < $level ? $pdf_sub_options[
'titleshowuponpdf'] : $level;
655 } elseif (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
656 unset($pdf_sub_options[
'titleshowuponpdf']);
658 if (isset($sub_options[
'titleshowtotalexludingvatonpdf'])) {
659 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] < $level ? $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] : $level;
660 } elseif (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
661 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
664 if (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
665 unset($pdf_sub_options[
'titleshowuponpdf']);
667 if (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
668 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
673 $parameters = array(
'i' => $i,
'object' =>
$object);
674 $reshook = $hookmanager->executeHooks(
'beforePrintPDFline', $parameters, $this, $action);
675 if ($reshook > 0 && !empty($hookmanager->resArray[
'object'])) {
676 $object = $hookmanager->resArray[
'object'];
678 $linePosition = $i + 1;
681 $sub_options =
$object->lines[$i]->extraparams[
"subtotal"] ?? array();
683 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
684 $level =
$object->lines[$i]->qty;
686 if (isset($sub_options[
'titleshowuponpdf'])) {
687 $pdf_sub_options[
'titleshowuponpdf'] = isset($pdf_sub_options[
'titleshowuponpdf']) && $pdf_sub_options[
'titleshowuponpdf'] < $level ? $pdf_sub_options[
'titleshowuponpdf'] : $level;
688 } elseif (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
689 unset($pdf_sub_options[
'titleshowuponpdf']);
691 if (isset($sub_options[
'titleshowtotalexludingvatonpdf'])) {
692 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] < $level ? $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] : $level;
693 } elseif (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
694 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
697 if (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
698 unset($pdf_sub_options[
'titleshowuponpdf']);
700 if (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
701 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
705 if (($curY + 6) > ($this->page_hauteur - $this->heightforfooter) || isset($sub_options[
'titleforcepagebreak']) && !($pdf->getNumPages() == 1 && $curY == $this->tab_top + $this->tabTitleHeight)) {
706 $object->lines[$i]->pagebreak =
true;
710 $pdf->SetFont(
'',
'', $default_font_size - 1);
711 $pdf->SetTextColor(0, 0, 0);
714 $imglinesize = array();
715 if (!empty($realpatharray[$i])) {
719 $pdf->setTopMargin($this->tab_top_newpage);
720 $pdf->setPageOrientation(
'',
true, $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot);
721 $pageposbefore = $pdf->getPage();
724 $showpricebeforepagebreak =
getDolGlobalInt(
'MAIN_PDF_DATA_ON_FIRST_PAGE');
727 $posYAfterDescription = 0;
732 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($posy + $imglinesize[
'height']) > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
733 $pdf->AddPage(
'',
'',
true);
734 if (!empty($this->tplidx)) {
735 $pdf->useTemplate($this->tplidx);
737 $pdf->setPage($pageposbefore + 1);
738 $pdf->setPageOrientation(
'',
true, $this->heightforfooter);
739 $posy = $this->tab_top_newpage;
740 $showpricebeforepagebreak = 0;
744 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
745 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $posy + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
747 $posYAfterImage = $posy + $imglinesize[
'height'];
754 $pdf->setPageOrientation(
'',
true, $this->heightforfooter);
758 $pdf->startTransaction();
761 $pageposafter = $pdf->getPage();
763 if ($pageposafter > $pageposbefore) {
764 $pdf->rollbackTransaction(
true);
765 $pageposafter = $pageposbefore;
766 $pdf->setPageOrientation(
'',
true, $this->heightforfooter);
770 $pageposafter = $pdf->getPage();
771 $posyafter = $pdf->GetY();
773 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) {
774 if ($i == ($nblines - 1)) {
775 $pdf->AddPage(
'',
'',
true);
776 if (!empty($this->tplidx)) {
777 $pdf->useTemplate($this->tplidx);
779 $pdf->setPage($pageposafter + 1);
785 $showpricebeforepagebreak = 1;
787 $showpricebeforepagebreak = 0;
791 $pdf->commitTransaction();
793 $posYAfterDescription = $pdf->GetY();
796 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
798 $pageposafter = $pdf->getPage();
799 $pdf->setPage($pageposbefore);
800 $pdf->setTopMargin($this->marge_haute);
801 $pdf->setPageOrientation(
'',
true, 0);
804 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
805 $pdf->setPage($pageposafter);
806 $posy = $this->tab_top_newpage;
809 $pdf->SetFont(
'',
'', $default_font_size - 1);
820 $nexY = max($pdf->GetY(), $nexY);
824 if ($this->
getColumnStatus(
'subprice') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowuponpdf'])) {
827 $nexY = max($pdf->GetY(), $nexY);
835 $nexY = max($pdf->GetY(), $nexY);
842 $nexY = max($pdf->GetY(), $nexY);
849 $nexY = max($pdf->GetY(), $nexY);
853 if ($this->
getColumnStatus(
'discount') &&
$object->lines[$i]->remise_percent &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
856 $nexY = max($pdf->GetY(), $nexY);
861 if (
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE && isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf'])) {
864 } elseif (
$object->lines[$i]->qty < 0 && isset($sub_options[
'subtotalshowtotalexludingvatonpdf'])) {
866 $total_excl_tax =
$object->getSubtotalLineMulticurrencyAmount(
$object->lines[$i]);
868 $total_excl_tax =
$object->getSubtotalLineAmount(
$object->lines[$i]);
872 $nexY = max($pdf->GetY(), $nexY);
879 $columkey =
'btpsomme';
881 $printval =
price($TInfosLigneSituationPrecedente[
'total_ht_without_progress'], 0,
'', 1, -1, 2);
883 $nexY = max($pdf->GetY(), $nexY);
887 $columkey =
'progress_amount';
889 $printval =
price(
$object->lines[$i]->total_ht, 0,
'', 1, -1, 2);
891 $nexY = max($pdf->GetY(), $nexY);
894 $columkey =
'prev_progress';
896 $printval = $TInfosLigneSituationPrecedente[
'progress_prec'].
'%';
898 $nexY = max($pdf->GetY(), $nexY);
901 $columkey =
'prev_progress_amount';
903 $printval =
price($TInfosLigneSituationPrecedente[
'total_ht'], 0,
'', 1, -1, 2);
905 $nexY = max($pdf->GetY(), $nexY);
914 'nexY' => & $afterPosData[
'y'],
915 'outputlangs' => $outputlangs,
916 'hidedetails' => $hidedetails
918 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
927 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
929 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
931 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
935 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
937 $tvaligne = $sign *
$object->lines[$i]->total_tva;
941 $localtax1ligne =
$object->lines[$i]->total_localtax1;
942 $localtax2ligne =
$object->lines[$i]->total_localtax2;
943 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
944 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
945 $localtax1_type =
$object->lines[$i]->localtax1_type;
946 $localtax2_type =
$object->lines[$i]->localtax2_type;
951 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
952 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
954 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
955 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
959 if ($localtax1_type && $localtax1ligne != 0) {
960 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
961 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
963 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
966 if ($localtax2_type && $localtax2ligne != 0) {
967 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
968 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
970 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
974 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
980 $vatcode =
$object->lines[$i]->vat_src_code;
981 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
982 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
985 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'tot_ht'])) {
986 $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'tot_ht'] = 0;
988 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne,
'tot_ht' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'tot_ht'] +
$object->lines[$i]->total_ht);
990 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
994 $pdf->setPage($afterPosData[
'page']);
995 $nexY = max($nexY, $posYAfterImage);
998 if (
getDolGlobalString(
'MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1) && $afterPosData[
'y'] < $this->page_hauteur - $this->heightforfooter - 5) {
999 $pdf->setPage($pageposafter);
1000 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
1002 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
1003 $pdf->SetLineStyle(array(
'dash' => 0));
1007 while ($pagenb < $pageposafter) {
1008 $pdf->setPage($pagenb);
1009 $tabtop = $this->tab_top;
1010 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1011 if ($pagenb != $pageposbeforeprintlines) {
1012 $tabtop = $this->tab_top_newpage;
1013 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1016 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1020 $pdf->setPage($pagenb);
1021 $pdf->setPageOrientation(
'',
true, 0);
1025 if (!empty($this->tplidx)) {
1026 $pdf->useTemplate($this->tplidx);
1030 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
1031 $tabtop = $this->tab_top;
1032 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1033 if ($pagenb != $pageposbeforeprintlines) {
1034 $tabtop = $this->tab_top_newpage;
1035 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1038 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1043 if (!empty($this->tplidx)) {
1044 $pdf->useTemplate($this->tplidx);
1055 $tabtop = $this->tab_top_newpage;
1056 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter - $this->heightforinfotot - $this->heightforfreetext;
1057 $tabTitleHeight = 0;
1058 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1061 $pdf->SetTextColor(0, 0, 0);
1063 $pdf->setPage($pdf->getNumPages());
1065 $bottomlasttab = $tabtop + $tabhauteur + $tabTitleHeight + 10;
1072 $posy = $this->
drawTotalTable($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1075 $listofpayments =
$object->getListOfPayments(
'', 0, 1);
1076 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1083 if (method_exists($pdf,
'AliasNbPages')) {
1084 $pdf->AliasNbPages();
1088 if (
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_INVOICE') && $termsofsalefilename) {
1089 $termsofsale =
$conf->invoice->dir_output.
'/'.$termsofsalefilename;
1090 if (!empty(
$conf->invoice->multidir_output[
$object->entity ??
$conf->entity])) {
1091 $termsofsale =
$conf->invoice->multidir_output[
$object->entity ??
$conf->entity].
'/'.$termsofsalefilename;
1093 if (file_exists($termsofsale) && is_readable($termsofsale)) {
1094 $pagecount = $pdf->setSourceFile($termsofsale);
1095 for ($i = 1; $i <= $pagecount; $i++) {
1096 $tplIdx = $pdf->importPage($i);
1097 if ($tplIdx !==
false) {
1098 $s = $pdf->getTemplatesize($tplIdx);
1099 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
1100 $pdf->useTemplate($tplIdx);
1102 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
1108 $this->resumeLastPage($pdf,
$object, 0, $tab_top, $outputlangs, $outputlangsbis);
1109 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
1118 $pdf->Output($file,
'F');
1121 $hookmanager->initHooks(array(
'pdfgeneration'));
1122 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1124 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1125 $this->warnings = $hookmanager->warnings;
1127 $this->error = $hookmanager->error;
1128 $this->errors = $hookmanager->errors;
1135 $this->result = array(
'fullpath' => $file);
1139 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1143 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1166 $tab3_top = $posy + 8;
1169 if ($this->page_largeur < 210) {
1175 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1177 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1180 $pdf->SetFont(
'',
'', $default_font_size - 3);
1181 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1182 $pdf->MultiCell(60, 3, $title, 0,
'L',
false);
1184 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1186 $pdf->SetFont(
'',
'', $default_font_size - 4);
1187 $pdf->SetXY($tab3_posx, $tab3_top);
1188 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L',
false);
1189 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1190 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L',
false);
1191 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1192 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L',
false);
1193 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1194 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L',
false);
1196 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1200 $pdf->SetFont(
'',
'', $default_font_size - 4);
1204 $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,";
1205 $sql .=
" re.description, re.fk_facture_source,";
1206 $sql .=
" f.type, f.datef";
1207 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1208 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1209 $resql = $this->db->query($sql);
1211 $num = $this->db->num_rows($resql);
1213 $invoice =
new Facture($this->db);
1216 $obj = $this->db->fetch_object($resql);
1218 if ($obj->type == 2) {
1219 $text = $outputlangs->transnoentities(
"CreditNote");
1220 } elseif ($obj->type == 3) {
1221 $text = $outputlangs->transnoentities(
"Deposit");
1222 } elseif ($obj->type == 0) {
1223 $text = $outputlangs->transnoentities(
"ExcessReceived");
1225 $text = $outputlangs->transnoentities(
"UnknownType");
1228 $invoice->fetch($obj->fk_facture_source);
1230 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1231 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L',
false);
1232 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1233 $pdf->MultiCell(20, 3,
price((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L',
false);
1234 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1235 $pdf->MultiCell(20, 3, $text, 0,
'L',
false);
1236 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1237 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L',
false);
1239 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1244 $this->error = $this->db->lasterror();
1250 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1252 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1253 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1254 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1256 $sql .=
" ORDER BY p.datep";
1258 $resql = $this->db->query($sql);
1260 $num = $this->db->num_rows($resql);
1265 $row = $this->db->fetch_object($resql);
1266 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1267 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L',
false);
1268 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1269 $pdf->MultiCell(20, 3,
price($sign * ((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L',
false);
1270 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1271 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1273 $pdf->MultiCell(20, 3, $oper, 0,
'L',
false);
1274 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1275 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1276 $pdf->MultiCell(30, 3, $row->num, 0,
'L',
false);
1277 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1278 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1283 return $tab3_top + $y + 3;
1285 $this->error = $this->db->lasterror();
1307 $pdf->SetFont(
'',
'', $default_font_size - 1);
1309 krsort($this->tva_array);
1316 $pdf->SetFillColor(224, 224, 224);
1318 $pdf->SetFont(
'',
'', $default_font_size - 2);
1319 $pdf->SetXY($this->marge_gauche, $posy);
1320 $titre = $outputlangs->transnoentities(
"VAT");
1321 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1323 $pdf->SetFont(
'',
'', $default_font_size - 2);
1324 $pdf->SetXY($this->marge_gauche + 25, $posy);
1325 $titre = $outputlangs->transnoentities(
"NetTotal");
1326 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1328 $pdf->SetFont(
'',
'', $default_font_size - 2);
1329 $pdf->SetXY($this->marge_gauche + 50, $posy);
1330 $titre = $outputlangs->transnoentities(
"VATAmount");
1331 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1333 $pdf->SetFont(
'',
'', $default_font_size - 2);
1334 $pdf->SetXY($this->marge_gauche + 75, $posy);
1335 $titre = $outputlangs->transnoentities(
"AmountTotal");
1336 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1338 $posy = $pdf->GetY();
1343 foreach ($this->tva_array as $tvakey => $tvaval) {
1344 $pdf->SetFont(
'',
'', $default_font_size - 2);
1345 $pdf->SetXY($this->marge_gauche, $posy);
1346 $titre = round((
float) $tvakey, 2) .
"%";
1347 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1349 $pdf->SetFont(
'',
'', $default_font_size - 2);
1350 $pdf->SetXY($this->marge_gauche + 25, $posy);
1351 $titre =
price($tvaval[
'tot_ht']);
1352 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1353 $tot_ht += $tvaval[
'tot_ht'];
1355 $pdf->SetFont(
'',
'', $default_font_size - 2);
1356 $pdf->SetXY($this->marge_gauche + 50, $posy);
1357 $titre =
price($tvaval[
'amount']);
1358 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1359 $tot_tva += $tvaval[
'amount'];
1361 $pdf->SetFont(
'',
'', $default_font_size - 2);
1362 $pdf->SetXY($this->marge_gauche + 75, $posy);
1363 $titre =
price($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1364 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1365 $tot_ttc += ($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1367 $posy = $pdf->GetY();
1372 $showvatmention = 0;
1373 if (in_array($this->emetteur->country_code, array(
'FR')) && empty(
$object->total_tva)) {
1374 $pdf->SetFont(
'',
'', $default_font_size - 2);
1375 $pdf->SetXY($this->marge_gauche, $posy);
1376 if (empty(
$mysoc->tva_assuj)) {
1377 if (
$mysoc->forme_juridique_code == 92) {
1378 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L',
false);
1380 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
1383 } elseif (
getDolGlobalString(
"INVOICE_VAT_SHOW_REVERSE_CHARGE_MENTION") && $this->emetteur->country_code !=
$object->thirdparty->country_code && $this->emetteur->isInEEC() &&
$object->thirdparty->isInEEC()) {
1384 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedReverseChargeProcedure"), 0,
'L',
false);
1387 $posy = $pdf->GetY();
1390 $showvatmention +=
pdfCertifMention($pdf, $outputlangs, $this->emetteur, $default_font_size, $posy, $this);
1392 if ($showvatmention) {
1399 if ($this->page_largeur < 210) {
1406 $sql =
"SELECT f.rowid, f.datef, f.total_ttc";
1407 $sql .=
" FROM " . MAIN_DB_PREFIX .
"facture as f";
1408 $sql .=
" WHERE f.fk_soc = " . ((int)
$object->socid);
1409 $sql .=
" AND f.entity IN (" .
getEntity(
'invoice') .
")";
1410 $sql .=
" AND f.datef <= '" . $this->db->idate(
$object->date) .
"'";
1411 $sql .=
" AND f.rowid < " . ((int)
$object->id);
1412 $sql .=
" AND f.fk_statut > 0";
1413 $sql .=
" ORDER BY f.datef ASC";
1416 $invoices = array();
1417 $resql = $this->db->query($sql);
1419 while ($obj = $this->db->fetch_object($resql)) {
1421 $old_balance += $obj->total_ttc;
1423 $this->db->free($resql);
1427 $sql_payments =
"SELECT p.datep, pf.fk_facture, pf.amount";
1428 $sql_payments .=
" FROM " . MAIN_DB_PREFIX .
"paiement_facture as pf";
1429 $sql_payments .=
" INNER JOIN " . MAIN_DB_PREFIX .
"paiement as p ON p.rowid = pf.fk_paiement";
1430 $sql_payments .=
" INNER JOIN " . MAIN_DB_PREFIX .
"facture as f ON f.rowid = pf.fk_facture";
1431 $sql_payments .=
" WHERE f.fk_soc = " . ((int)
$object->socid);
1432 $sql_payments .=
" AND p.datep < '" . $this->db->idate(
$object->date) .
"'";
1433 $sql_payments .=
" ORDER BY p.datep ASC";
1435 $total_payments = 0;
1436 $resql_payments = $this->db->query($sql_payments);
1437 if ($resql_payments) {
1438 while ($obj_payment = $this->db->fetch_object($resql_payments)) {
1439 $total_payments += $obj_payment->amount;
1441 $this->db->free($resql_payments);
1445 $sql_current_date_payments =
"SELECT p.datep, pf.fk_facture, pf.amount";
1446 $sql_current_date_payments .=
" FROM " . MAIN_DB_PREFIX .
"paiement_facture as pf";
1447 $sql_current_date_payments .=
" INNER JOIN " . MAIN_DB_PREFIX .
"paiement as p ON p.rowid = pf.fk_paiement";
1448 $sql_current_date_payments .=
" INNER JOIN " . MAIN_DB_PREFIX .
"facture as f ON f.rowid = pf.fk_facture";
1449 $sql_current_date_payments .=
" WHERE f.fk_soc = " . ((int)
$object->socid);
1450 $sql_current_date_payments .=
" AND DATE(p.datep) = DATE('" . $this->db->idate(
$object->date) .
"')";
1452 $current_date_payments = 0;
1453 $resql_current_date = $this->db->query($sql_current_date_payments);
1454 if ($resql_current_date) {
1455 while ($obj_current = $this->db->fetch_object($resql_current_date)) {
1456 $current_date_payments += $obj_current->amount;
1458 $this->db->free($resql_current_date);
1462 $old_balance -= $total_payments;
1465 $new_balance = $old_balance +
$object->total_ttc - $current_date_payments;
1467 $pdf->SetFillColor(224, 224, 224);
1468 $pdf->SetFont(
'',
'', $default_font_size - 2);
1469 $pdf->SetXY($this->marge_gauche, $posy);
1470 $titre = $outputlangs->transnoentities(
"PreviousBalance").
' : '.
price($old_balance);
1471 $pdf->MultiCell($posxval - $this->marge_gauche + 8, 4, $titre, 0,
'L',
true);
1473 $pdf->SetFont(
'',
'', $default_font_size - 2);
1474 $pdf->SetXY($posxval + 8, $posy);
1475 $titre = $outputlangs->transnoentities(
"NewBalance").
' : '.
price($new_balance);
1476 $pdf->MultiCell($posxend - $posxval - 8, 4, $titre, 0,
'L',
true);
1478 $posy = $pdf->GetY() + 1;
1483 $pdf->SetFont(
'',
'', $default_font_size - 2);
1484 $pdf->SetXY($this->marge_gauche, $posy);
1485 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1486 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1488 $pdf->SetFont(
'',
'', $default_font_size - 2);
1489 $pdf->SetXY($posxval, $posy);
1490 $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);
1491 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1492 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1494 $posy = $pdf->GetY() + 3;
1498 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1499 $pdf->SetFont(
'',
'', $default_font_size - 2);
1500 $pdf->SetXY($this->marge_gauche, $posy);
1501 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1502 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1504 $pdf->SetFont(
'',
'', $default_font_size - 2);
1505 $pdf->SetXY($posxval, $posy);
1506 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1507 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1509 $posy = $pdf->GetY() + 3;
1514 if (empty(
$object->mode_reglement_code)
1517 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1521 $outputlangs->load(
"errors");
1523 $pdf->SetXY($this->marge_gauche, $posy);
1524 $pdf->SetTextColor(200, 0, 0);
1525 $pdf->SetFont(
'',
'', $default_font_size - 2);
1526 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1527 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L',
false);
1528 $pdf->SetTextColor(0, 0, 0);
1530 $posy = $pdf->GetY() + 1;
1534 if (!empty(
$object->mode_reglement_code)
1535 &&
$object->mode_reglement_code !=
'CHQ'
1536 &&
$object->mode_reglement_code !=
'VIR') {
1537 $pdf->SetFont(
'',
'', $default_font_size - 2);
1538 $pdf->SetXY($this->marge_gauche, $posy);
1539 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1540 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1542 $pdf->SetFont(
'',
'', $default_font_size - 2);
1543 $pdf->SetXY($posxval, $posy);
1544 $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);
1547 if (
$object->mode_reglement_code ==
"PRE") {
1548 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1551 $bac->fetch(0,
'',
$object->thirdparty->id);
1552 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1553 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1556 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1558 $posy = $pdf->GetY();
1564 if ($this->emetteur->country_code ==
'FR') {
1566 $pdf->SetXY($this->marge_gauche, $posy);
1567 $pdf->writeHTMLCell(80, 5,
null,
null, $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1569 $posy = $pdf->GetY() + 1;
1574 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1575 $useonlinepayment = 0;
1579 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1580 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1581 $useonlinepayment = count($validpaymentmethod);
1586 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1589 $langs->loadLangs(array(
'payment',
'stripe'));
1590 $servicename = $langs->transnoentities(
'Online');
1591 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1592 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1594 $pdf->SetXY($this->marge_gauche, $posy);
1595 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
null,
null,
dol_htmlentitiesbr($linktopay), 0, 1);
1597 $posy = $pdf->GetY() + 1;
1602 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1608 $account =
new Account($this->db);
1611 $pdf->SetXY($this->marge_gauche, $posy);
1612 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1613 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1614 $posy = $pdf->GetY() + 1;
1617 $pdf->SetXY($this->marge_gauche, $posy);
1618 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1619 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1620 $posy = $pdf->GetY() + 2;
1624 $pdf->SetXY($this->marge_gauche, $posy);
1625 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1626 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1627 $posy = $pdf->GetY() + 1;
1630 $pdf->SetXY($this->marge_gauche, $posy);
1631 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1632 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1633 $posy = $pdf->GetY() + 2;
1640 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1646 $account =
new Account($this->db);
1647 $account->fetch($bankid);
1649 $curx = $this->marge_gauche;
1652 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1658 $qrPosX = $this->marge_gauche + 5;
1660 $qrCodeColor = array(
'25',
'25',
'25');
1664 'fgcolor' => $qrCodeColor,
1666 'module_width' => 1,
1667 'module_height' => 1
1670 $EPCQrCodeString =
$object->buildEPCQrCodeString();
1671 $pdf->write2DBarcode($EPCQrCodeString,
'QRCODE,M', $qrPosX, $qrPosY, 20, 20, $styleQr,
'N');
1673 $pdf->SetXY($qrPosX + 25, $posy + 5);
1674 $pdf->SetFont(
'',
'', $default_font_size - 5);
1675 $pdf->MultiCell(30, 3, $outputlangs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L',
false);
1676 $posy = $pdf->GetY() + 2;
1681 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1684 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L',
false);
1716 $tab2_top = $posy - 4;
1718 if (is_object($outputlangsbis)) {
1719 $pdf->SetFont(
'',
'', $default_font_size - 2);
1721 $pdf->SetFont(
'',
'', $default_font_size - 1);
1727 if ($this->page_largeur < 210) {
1731 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1737 $pdf->SetFillColor(255, 255, 255);
1738 $pdf->SetXY($col1x, $tab2_top + 0);
1739 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L',
true);
1742 $pdf->SetXY($col2x, $tab2_top + 0);
1743 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht, 0, $outputlangs), 0,
'R',
true);
1747 $pdf->SetFillColor(255, 255, 255);
1748 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1749 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalVAT"), 0,
'L',
true);
1751 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1752 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->total_tva), 0,
'R',
true);
1756 $pdf->SetFillColor(248, 248, 248);
1759 $total_ttc_origin =
$object->total_ttc;
1761 $this->atleastoneratenotnull = 0;
1764 if (!empty($this->tva_array) && count($this->tva_array) == 1) {
1765 $tva_el = reset($this->tva_array);
1766 if ($tva_el[
'vatrate'] ==
'0.000' && is_float($tva_el[
'amount'])) {
1770 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1774 pdfWriteVATArray($this, $index, $pdf, $outputlangs, $outputlangsbis,
$object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl);
1779 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1780 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp",
$mysoc->country_code) :
''), $useborder,
'L',
true);
1782 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1783 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R',
true);
1788 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1789 $pdf->SetTextColor(0, 0, 60);
1790 $pdf->SetFillColor(224, 224, 224);
1791 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L',
true);
1793 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1795 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1797 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1801 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1802 $pdf->SetTextColor(0, 0, 60);
1803 $pdf->SetFillColor(224, 224, 224);
1804 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
'').
' ('.$outputlangs->getCurrencySymbol(
$mysoc->currency_code).
')', $useborder,
'L',
true);
1806 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1807 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc_origin, 0, $outputlangs, 1, -1, -1,
$mysoc->currency_code), $useborder,
'L',
true);
1812 if (
$object->displayRetainedWarranty()) {
1813 $pdf->SetTextColor(40, 40, 40);
1814 $pdf->SetFillColor(255, 255, 255);
1816 $retainedWarranty =
$object->getRetainedWarrantyAmount(
'MT');
1817 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1821 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1822 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L',
true);
1824 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1825 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R',
true);
1829 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1831 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1832 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1834 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L',
true);
1835 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1836 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R',
true);
1841 $pdf->SetTextColor(0, 0, 0);
1843 $creditnoteamount =
$object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1846 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1849 $deja_regle_origin = 0;
1850 $creditnoteamount_origin = 0;
1851 $depositsamount_origin = 0;
1852 $resteapayer_origin = 0;
1854 $deja_regle_origin =
$object->getSommePaiement(0);
1855 $creditnoteamount_origin =
$object->getSumCreditNotesUsed(0);
1856 $depositsamount_origin =
$object->getSumDepositsUsed(0);
1857 $resteapayer_origin =
price2num($total_ttc_origin - $deja_regle_origin - $creditnoteamount_origin - $depositsamount_origin,
'MT');
1861 $resteapayer_origin = 0;
1864 pdfWriteAlreadyPaid($this, $index, $pdf, $outputlangs, $outputlangsbis,
$object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl, $deja_regle, $creditnoteamount, $depositsamount, $resteapayer, $resteapayer_origin);
1866 $pdf->SetFont(
'',
'', $default_font_size - 1);
1867 $pdf->SetTextColor(0, 0, 0);
1869 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
1871 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
1873 $this->error = $hookmanager->error;
1874 $this->errors = $hookmanager->errors;
1878 return ($tab2_top + ($tab2_hl * $index));
2004 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2007 global
$conf, $langs;
2009 $ltrdirection =
'L';
2010 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2011 $ltrdirection =
'R';
2015 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2021 $pdf->SetTextColor(0, 0, 60);
2022 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2026 $posy = $this->marge_haute;
2027 $posx = $this->page_largeur - $this->marge_droite - $w;
2029 $pdf->SetXY($this->marge_gauche, $posy);
2033 if ($this->emetteur->logo) {
2034 $logodir =
$conf->mycompany->dir_output;
2035 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
2039 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2041 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2043 if (is_readable($logo)) {
2045 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2047 $pdf->SetTextColor(200, 0, 0);
2048 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2049 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2050 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2053 $text = $this->emetteur->name;
2054 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2058 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2059 $pdf->SetXY($posx, $posy);
2060 $pdf->SetTextColor(0, 0, 60);
2062 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2064 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2067 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2070 $title = $outputlangs->transnoentities(
"PdfInvoiceDepositTitle");
2072 if ($this->situationinvoice) {
2073 $outputlangs->loadLangs(array(
"other"));
2074 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
2075 $subtitle = $outputlangs->transnoentities(
"PDFSituationTitle", (
string)
$object->situation_counter);
2077 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2080 if ($this->situationinvoice) {
2081 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2083 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2084 } elseif (
$object->type == 1) {
2085 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2086 } elseif (
$object->type == 2) {
2087 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2088 } elseif (
$object->type == 3) {
2089 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2090 } elseif (
$object->type == 4) {
2091 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2094 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2095 if (
$object->status == $object::STATUS_DRAFT) {
2096 $pdf->SetTextColor(128, 0, 0);
2097 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2100 $pdf->MultiCell($w, 3, $title,
'',
'R');
2101 if (!empty($subtitle)) {
2102 $pdf->SetFont(
'',
'B', $default_font_size);
2103 $pdf->SetXY($posx, $posy + 5);
2104 $pdf->MultiCell($w, 6, $subtitle,
'',
'R');
2108 $pdf->SetFont(
'',
'', $default_font_size - 2);
2125 $pdf->SetFont(
'',
'', $default_font_size - 2);
2129 $pdf->SetXY($posx, $posy);
2130 $pdf->SetTextColor(0, 0, 60);
2131 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2136 if (!empty(
$object->project->title)) {
2138 $pdf->SetXY($posx, $posy);
2139 $pdf->SetTextColor(0, 0, 60);
2140 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".
$object->project->title,
'',
'R');
2146 if (!empty(
$object->project->ref)) {
2147 $outputlangs->load(
"projects");
2149 $pdf->SetXY($posx, $posy);
2150 $pdf->SetTextColor(0, 0, 60);
2151 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".
$object->project->ref,
'',
'R');
2155 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2156 if (
$object->type == 0 && $objectidnext) {
2157 $objectreplacing =
new Facture($this->db);
2158 $objectreplacing->fetch($objectidnext);
2161 $pdf->SetXY($posx, $posy);
2162 $pdf->SetTextColor(0, 0, 60);
2163 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2166 $objectreplaced =
new Facture($this->db);
2167 $objectreplaced->fetch(
$object->fk_facture_source);
2170 $pdf->SetXY($posx, $posy);
2171 $pdf->SetTextColor(0, 0, 60);
2172 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2175 $objectreplaced =
new Facture($this->db);
2176 $objectreplaced->fetch(
$object->fk_facture_source);
2179 $pdf->SetXY($posx, $posy);
2180 $pdf->SetTextColor(0, 0, 60);
2181 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2185 $pdf->SetXY($posx, $posy);
2186 $pdf->SetTextColor(0, 0, 60);
2188 $title = $outputlangs->transnoentities(
"DateInvoice");
2189 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2190 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2192 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2196 $pdf->SetXY($posx, $posy);
2197 $pdf->SetTextColor(0, 0, 60);
2198 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2203 $pdf->SetXY($posx, $posy);
2204 $pdf->SetTextColor(0, 0, 60);
2205 $title = $outputlangs->transnoentities(
"DateDue");
2206 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2207 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2209 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2214 $pdf->SetXY($posx, $posy);
2215 $pdf->SetTextColor(0, 0, 60);
2216 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_client),
'',
'R');
2221 $pdf->SetXY($posx, $posy);
2222 $pdf->SetTextColor(0, 0, 60);
2223 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_compta_client),
'',
'R');
2228 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2229 if (count($arrayidcontact) > 0) {
2230 $usertmp =
new User($this->db);
2231 $usertmp->fetch($arrayidcontact[0]);
2233 $pdf->SetXY($posx, $posy);
2234 $pdf->SetTextColor(0, 0, 60);
2235 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2245 $current_y = $pdf->getY();
2247 if ($current_y < $pdf->getY()) {
2248 $top_shift = $pdf->getY() - $current_y;
2254 $carac_emetteur =
'';
2256 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2257 if (count($arrayidcontact) > 0) {
2258 $object->fetch_user($arrayidcontact[0]);
2259 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2260 $carac_emetteur .= $labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2261 $carac_emetteur .=
"\n";
2268 $posy += $top_shift;
2269 $posx = $this->marge_gauche;
2271 $posx = $this->page_largeur - $this->marge_droite - 80;
2279 $pdf->SetTextColor(0, 0, 0);
2280 $pdf->SetFont(
'',
'', $default_font_size - 2);
2281 $pdf->SetXY($posx, $posy - 5);
2282 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2283 $pdf->SetXY($posx, $posy);
2284 $pdf->SetFillColor(230, 230, 230);
2285 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2286 $pdf->SetTextColor(0, 0, 60);
2291 $pdf->SetXY($posx + 2, $posy + 3);
2292 $pdf->SetFont(
'',
'B', $default_font_size);
2293 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2294 $posy = $pdf->getY();
2298 $pdf->SetXY($posx + 2, $posy);
2299 $pdf->SetFont(
'',
'', $default_font_size - 1);
2300 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2303 $usecontact =
false;
2304 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2305 if (count($arrayidcontact) > 0) {
2307 $result =
$object->fetch_contact($arrayidcontact[0]);
2311 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2312 $thirdparty =
$object->contact;
2314 $thirdparty =
$object->thirdparty;
2324 if ($this->page_largeur < 210) {
2328 $posy += $top_shift;
2329 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2331 $posx = $this->marge_gauche;
2336 $pdf->SetTextColor(0, 0, 0);
2337 $pdf->SetFont(
'',
'', $default_font_size - 2);
2338 $pdf->SetXY($posx + 2, $posy - 5);
2339 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2340 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2344 $pdf->SetXY($posx + 2, $posy + 3);
2345 $pdf->SetFont(
'',
'B', $default_font_size);
2347 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2349 $posy = $pdf->getY();
2352 $pdf->SetFont(
'',
'', $default_font_size - 1);
2353 $pdf->SetXY($posx + 2, $posy);
2355 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2359 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2361 if (!empty($idaddressshipping)) {
2362 $object->fetch_contact($idaddressshipping[0]);
2363 $companystatic =
new Societe($this->db);
2364 $companystatic->fetch(
$object->contact->fk_soc);
2371 if (!empty($carac_client_shipping)) {
2372 $posy += $hautcadre;
2377 $pdf->SetXY($posx + 2, $posy - 5);
2378 $pdf->SetFont(
'',
'', $default_font_size - 2);
2379 $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities(
'ShippingTo'), 0,
'L',
false);
2380 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2383 $pdf->SetXY($posx + 2, $posy + 3);
2384 $pdf->SetFont(
'',
'B', $default_font_size);
2385 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2387 $posy = $pdf->getY();
2390 $pdf->SetXY($posx + 2, $posy);
2391 $pdf->SetFont(
'',
'', $default_font_size - 1);
2392 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2394 $shipp_shift += $hautcadre;
2399 $pdf->SetTextColor(0, 0, 0);
2401 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);
2744 public function tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
2752 if (!$displayWarranty) {
2763 $currency = !empty($currency) ? $currency : (
string)
$conf->currency;
2767 $pdf->SetTextColor(0, 0, 0);
2768 $pdf->SetFont(
'',
'', $default_font_size - 2);
2770 if (empty($hidetop)) {
2771 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
2772 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 8);
2773 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
2775 $width = $this->page_largeur - $this->marge_gauche - $this->marge_droite - 83;
2779 $pdf->RoundedRect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, $this->corner_radius,
'1001',
'F', explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2781 $pdf->RoundedRect($this->marge_gauche, $tab_top + 92.5, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F', array(), explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2785 $pdf->SetDrawColor(128, 128, 128);
2786 $pdf->SetFont(
'',
'', $default_font_size - 1);
2788 $height_incoterms = 0;
2790 $desc_incoterms =
$object->getIncotermsForPDF();
2791 if ($desc_incoterms) {
2792 $this->tab_top -= 2;
2793 $posybefore = $pdf->GetY();
2794 $pdf->SetFont(
'',
'', $default_font_size - 1);
2795 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
2798 $pdf->SetDrawColor(192, 192, 192);
2799 $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');
2800 $posyafter = $pdf->GetY();
2801 $tab_top += $posyafter - $posybefore + 2;
2805 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
2808 if (is_object(
$object->thirdparty)) {
2809 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
2810 $salerepobj =
new User($this->db);
2811 $salerepobj->fetch($salereparray[0][
'id']);
2812 if (!empty($salerepobj->signature)) {
2813 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
2819 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
2820 if (!empty($extranote)) {
2826 $posybefore = $pdf->GetY();
2832 $pdf->SetFont(
'',
'', $default_font_size - 1);
2833 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
2835 $posyafter = $pdf->GetY();
2836 $tab_top += $posyafter - $posybefore + 2;
2841 $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');
2843 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top, $this->posx_cumul_anterieur - 1, $tab_top + $tab_height);
2844 if (empty($hidetop)) {
2845 $pdf->SetXY($this->posx_cumul_anterieur - 1, $tab_top + 0.5);
2846 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceOldCumulation"),
'',
'C');
2850 $pdf->line($this->posx_new_cumul - 1, $tab_top, $this->posx_new_cumul - 1, $tab_top + $tab_height);
2851 if (empty($hidetop)) {
2852 $pdf->SetXY($this->posx_new_cumul - 1, $tab_top + 0.5);
2853 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceNewCumulation"),
'',
'C');
2856 $pdf->line($this->posx_current - 1, $tab_top, $this->posx_current - 1, $tab_top + $tab_height);
2857 if (empty($hidetop)) {
2858 $pdf->SetXY($this->posx_current - 1, $tab_top + 0.5);
2859 $pdf->MultiCell(36, 2, $outputlangs->transnoentities(
"CurrentSituationTotal", (
string)
$object->situation_counter),
'',
'C');
2863 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
2865 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 24, $this->page_largeur - $this->marge_droite, $tab_top + 24);
2867 $pdf->line($this->marge_gauche, $tab_top + 55, $this->page_largeur - $this->marge_droite, $tab_top + 55);
2869 $pdf->line($this->marge_gauche, $tab_top + 65, $this->page_largeur - $this->marge_droite, $tab_top + 65);
2871 if ($displayWarranty) {
2872 $pdf->line($this->marge_gauche, $tab_top + 85, $this->page_largeur - $this->marge_droite, $tab_top + 85);
2878 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 8);
2879 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceMainTask"),
'',
'L');
2881 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 12);
2882 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceAdditionalTask"),
'',
'L');
2884 $form->load_cache_vatrates(
"'".
$object->thirdparty->country_code.
"'");
2887 foreach ($form->cache_vatrates as $TVatInfo) {
2888 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2890 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2895 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 24 + $i);
2896 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalHT").
' '.$TVatInfo[
'label'],
'',
'L');
2898 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2899 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 28 + $i);
2900 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"VAT").
' '.$TVatInfo[
'label'],
'',
'L');
2906 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 33 + $i);
2907 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'L');
2910 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2911 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 58);
2912 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalSituationInvoice"),
'',
'L');
2913 $pdf->SetFont(
'',
'', $default_font_size - 2);
2915 if ($displayWarranty) {
2916 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 74);
2917 $pdf->MultiCell(80, 2, $outputlangs->trans(
"TotalSituationInvoiceWithRetainedWarranty", (
string)
$object->retained_warranty),
'',
'L');
2918 $nextY = $tab_top + 93;
2920 $nextY = $tab_top + 74;
2923 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2924 $pdf->SetXY($this->marge_gauche + 2, $nextY);
2925 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"SituationTotalRayToRest"),
'',
'L');
2926 $pdf->SetFont(
'',
'', $default_font_size - 2);
2930 $TToDisplay = array(
2936 $x = $this->marge_gauche + 85;
2940 foreach ($TToDisplay as $col) {
2942 $pdf->SetXY($x, $tab_top + 8);
2943 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2946 $pdf->SetXY($x, $tab_top + 12);
2947 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'travaux_sup'], 0,
'', 1, -1, 2),
'',
'R');
2950 foreach ($form->cache_vatrates as $TVatInfo) {
2951 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2952 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2958 $pdf->SetXY($x, $tab_top + 24 + $i);
2959 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2962 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2963 $pdf->SetXY($x, $tab_top + 28 + $i);
2964 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'TVA'], 0,
'', 1, -1, 2),
'',
'R');
2971 $pdf->SetXY($x, $tab_top + 33 + $i);
2972 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
2975 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2976 $pdf->SetXY($x, $tab_top + 58);
2977 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
2978 $pdf->SetFont(
'',
'', $default_font_size - 2);
2981 if ($displayWarranty) {
2983 $pdf->SetXY($x, $tab_top + 74);
2984 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'retenue_garantie'], 0,
'', 1, -1, 2),
'',
'R');
2985 $nextY = $tab_top + 93;
2987 $nextY = $tab_top + 74;
2991 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2992 $pdf->SetXY($x, $nextY);
2993 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'total_a_payer'], 0,
'', 1, -1, 2),
'',
'R');
2994 $pdf->SetFont(
'',
'', $default_font_size - 2);