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;
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;
1046 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'tot_ht'])) {
1047 $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'tot_ht'] = 0;
1049 $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);
1051 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
1052 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
1054 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
1057 $nexY = max($nexY, $posYAfterImage);
1061 $pdf->setPage($pageposafter);
1062 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
1064 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
1065 $pdf->SetLineStyle(array(
'dash' => 0));
1069 while ($pagenb < $pageposafter) {
1070 $pdf->setPage($pagenb);
1071 $tabtop = $this->tab_top;
1072 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1073 if ($pagenb != $pageposbeforeprintlines) {
1074 $tabtop = $this->tab_top_newpage;
1075 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1078 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1082 $pdf->setPage($pagenb);
1083 $pdf->setPageOrientation(
'', 1, 0);
1087 if (!empty($this->tplidx)) {
1088 $pdf->useTemplate($this->tplidx);
1092 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
1093 $tabtop = $this->tab_top;
1094 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1095 if ($pagenb != $pageposbeforeprintlines) {
1096 $tabtop = $this->tab_top_newpage;
1097 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter;
1100 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1105 if (!empty($this->tplidx)) {
1106 $pdf->useTemplate($this->tplidx);
1117 $tabtop = $this->tab_top_newpage;
1118 $tabhauteur = $this->page_hauteur - $tabtop - $this->heightforfooter - $this->heightforinfotot - $this->heightforfreetext;
1119 $tabTitleHeight = 0;
1120 $this->
_tableau($pdf, $tabtop, $tabhauteur, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1122 $bottomlasttab = $tabtop + $tabhauteur + $tabTitleHeight + 10;
1128 $posy = $this->
drawTotalTable($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1131 $listofpayments =
$object->getListOfPayments(
'', 0, 1);
1132 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1138 if (method_exists($pdf,
'AliasNbPages')) {
1139 $pdf->AliasNbPages();
1142 $this->resumeLastPage($pdf,
$object, 0, $tab_top, $outputlangs, $outputlangsbis);
1143 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
1148 $pdf->Output($file,
'F');
1151 $hookmanager->initHooks(array(
'pdfgeneration'));
1152 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1154 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1156 $this->error = $hookmanager->error;
1157 $this->errors = $hookmanager->errors;
1162 $this->result = array(
'fullpath' => $file);
1166 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1170 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1195 $tab3_top = $posy + 8;
1198 if ($this->page_largeur < 210) {
1204 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1206 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1209 $pdf->SetFont(
'',
'', $default_font_size - 3);
1210 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1211 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1213 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1215 $pdf->SetFont(
'',
'', $default_font_size - 4);
1216 $pdf->SetXY($tab3_posx, $tab3_top);
1217 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1218 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1219 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1220 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1221 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1222 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1223 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1225 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1229 $pdf->SetFont(
'',
'', $default_font_size - 4);
1233 $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,";
1234 $sql .=
" re.description, re.fk_facture_source,";
1235 $sql .=
" f.type, f.datef";
1236 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1237 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1238 $resql = $this->db->query($sql);
1240 $num = $this->db->num_rows($resql);
1242 $invoice =
new Facture($this->db);
1245 $obj = $this->db->fetch_object($resql);
1247 if ($obj->type == 2) {
1248 $text = $outputlangs->transnoentities(
"CreditNote");
1249 } elseif ($obj->type == 3) {
1250 $text = $outputlangs->transnoentities(
"Deposit");
1251 } elseif ($obj->type == 0) {
1252 $text = $outputlangs->transnoentities(
"ExcessReceived");
1254 $text = $outputlangs->transnoentities(
"UnknownType");
1257 $invoice->fetch($obj->fk_facture_source);
1259 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1260 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1261 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1262 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1263 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1264 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1265 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1266 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1268 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1273 $this->error = $this->db->lasterror();
1279 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1281 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1282 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1283 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1285 $sql .=
" ORDER BY p.datep";
1287 $resql = $this->db->query($sql);
1289 $num = $this->db->num_rows($resql);
1294 $row = $this->db->fetch_object($resql);
1295 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1296 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1297 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1298 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1299 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1300 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1302 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1303 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1304 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1305 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1306 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1307 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1312 return $tab3_top + $y + 3;
1314 $this->error = $this->db->lasterror();
1332 global $mysoc, $hookmanager;
1336 $pdf->SetFont(
'',
'', $default_font_size - 1);
1338 krsort($this->tva_array);
1345 $pdf->SetFillColor(224, 224, 224);
1347 $pdf->SetFont(
'',
'', $default_font_size - 2);
1348 $pdf->SetXY($this->marge_gauche, $posy);
1349 $titre = $outputlangs->transnoentities(
"VAT");
1350 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1352 $pdf->SetFont(
'',
'', $default_font_size - 2);
1353 $pdf->SetXY($this->marge_gauche + 25, $posy);
1354 $titre = $outputlangs->transnoentities(
"NetTotal");
1355 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1357 $pdf->SetFont(
'',
'', $default_font_size - 2);
1358 $pdf->SetXY($this->marge_gauche + 50, $posy);
1359 $titre = $outputlangs->transnoentities(
"VATAmount");
1360 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1362 $pdf->SetFont(
'',
'', $default_font_size - 2);
1363 $pdf->SetXY($this->marge_gauche + 75, $posy);
1364 $titre = $outputlangs->transnoentities(
"AmountTotal");
1365 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1367 $posy = $pdf->GetY();
1372 foreach ($this->tva_array as $tvakey => $tvaval) {
1373 $pdf->SetFont(
'',
'', $default_font_size - 2);
1374 $pdf->SetXY($this->marge_gauche, $posy);
1375 $titre = round((
float) $tvakey, 2) .
"%";
1376 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1378 $pdf->SetFont(
'',
'', $default_font_size - 2);
1379 $pdf->SetXY($this->marge_gauche + 25, $posy);
1380 $titre =
price($tvaval[
'tot_ht']);
1381 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1382 $tot_ht += $tvaval[
'tot_ht'];
1384 $pdf->SetFont(
'',
'', $default_font_size - 2);
1385 $pdf->SetXY($this->marge_gauche + 50, $posy);
1386 $titre =
price($tvaval[
'amount']);
1387 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1388 $tot_tva += $tvaval[
'amount'];
1390 $pdf->SetFont(
'',
'', $default_font_size - 2);
1391 $pdf->SetXY($this->marge_gauche + 75, $posy);
1392 $titre =
price($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1393 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1394 $tot_ttc += ($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1396 $posy = $pdf->GetY();
1401 if (in_array($this->emetteur->country_code, array(
'FR')) && empty(
$object->total_tva)) {
1402 $pdf->SetFont(
'',
'', $default_font_size - 2);
1403 $pdf->SetXY($this->marge_gauche, $posy);
1404 if (empty($mysoc->tva_assuj)) {
1405 if ($mysoc->forme_juridique_code == 92) {
1406 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1408 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1410 } elseif (
getDolGlobalString(
"INVOICE_VAT_SHOW_REVERSE_CHARGE_MENTION") && $this->emetteur->country_code !=
$object->thirdparty->country_code && $this->emetteur->isInEEC() &&
$object->thirdparty->isInEEC()) {
1411 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedReverseChargeProcedure"), 0,
'L', 0);
1413 $posy = $pdf->GetY() + 4;
1418 if ($this->page_largeur < 210) {
1424 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1425 $pdf->SetXY($this->marge_gauche, $posy);
1426 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1427 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1429 $pdf->SetFont(
'',
'', $default_font_size - 2);
1430 $pdf->SetXY($posxval, $posy);
1431 $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);
1432 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1433 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1435 $posy = $pdf->GetY() + 3;
1439 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1440 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1441 $pdf->SetXY($this->marge_gauche, $posy);
1442 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1443 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1445 $pdf->SetFont(
'',
'', $default_font_size - 2);
1446 $pdf->SetXY($posxval, $posy);
1447 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1448 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1450 $posy = $pdf->GetY() + 3;
1455 if (empty(
$object->mode_reglement_code)
1458 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1462 $outputlangs->load(
"errors");
1464 $pdf->SetXY($this->marge_gauche, $posy);
1465 $pdf->SetTextColor(200, 0, 0);
1466 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1467 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1468 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1469 $pdf->SetTextColor(0, 0, 0);
1471 $posy = $pdf->GetY() + 1;
1475 if (!empty(
$object->mode_reglement_code)
1476 &&
$object->mode_reglement_code !=
'CHQ'
1477 &&
$object->mode_reglement_code !=
'VIR') {
1478 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1479 $pdf->SetXY($this->marge_gauche, $posy);
1480 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1481 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1483 $pdf->SetFont(
'',
'', $default_font_size - 2);
1484 $pdf->SetXY($posxval, $posy);
1485 $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);
1488 if (
$object->mode_reglement_code ==
"PRE") {
1489 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1492 $bac->fetch(0,
$object->thirdparty->id);
1493 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1494 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1497 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1499 $posy = $pdf->GetY();
1505 if ($this->emetteur->country_code ==
'FR') {
1507 $pdf->SetXY($this->marge_gauche, $posy);
1508 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1510 $posy = $pdf->GetY() + 1;
1515 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1516 $useonlinepayment = 0;
1518 if (isModEnabled(
'paypal')) {
1519 $useonlinepayment++;
1521 if (isModEnabled(
'stripe')) {
1522 $useonlinepayment++;
1524 if (isModEnabled(
'paybox')) {
1525 $useonlinepayment++;
1527 $parameters = array();
1529 $reshook = $hookmanager->executeHooks(
'doShowOnlinePaymentUrl', $parameters,
$object, $action);
1531 if (isset($hookmanager->resArray[
'showonlinepaymenturl'])) {
1532 $useonlinepayment += $hookmanager->resArray[
'showonlinepaymenturl'];
1539 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1542 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1543 $servicename = $langs->transnoentities(
'Online');
1544 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1545 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1547 $pdf->SetXY($this->marge_gauche, $posy);
1548 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1550 $posy = $pdf->GetY() + 1;
1555 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1561 $account =
new Account($this->db);
1564 $pdf->SetXY($this->marge_gauche, $posy);
1565 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1566 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1567 $posy = $pdf->GetY() + 1;
1570 $pdf->SetXY($this->marge_gauche, $posy);
1571 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1572 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1573 $posy = $pdf->GetY() + 2;
1577 $pdf->SetXY($this->marge_gauche, $posy);
1578 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1579 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1580 $posy = $pdf->GetY() + 1;
1583 $pdf->SetXY($this->marge_gauche, $posy);
1584 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1585 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1586 $posy = $pdf->GetY() + 2;
1593 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1599 $account =
new Account($this->db);
1600 $account->fetch($bankid);
1602 $curx = $this->marge_gauche;
1605 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1611 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1614 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L', 0);
1637 global
$conf, $mysoc, $hookmanager;
1649 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1650 $default_font_size--;
1653 $tab2_top = $posy - 4;
1655 $pdf->SetFont(
'',
'', $default_font_size - 1);
1660 if ($this->page_largeur < 210) {
1663 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1669 $pdf->SetFillColor(255, 255, 255);
1670 $pdf->SetXY($col1x, $tab2_top + 0);
1671 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1673 $total_ht = ((isModEnabled(
'multicurrency') && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1674 $pdf->SetXY($col2x, $tab2_top + 0);
1675 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht, 0, $outputlangs), 0,
'R', 1);
1680 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1681 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"DiscountHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"DiscountHT") :
''), 0,
'L', 1);
1682 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1683 $pdf->MultiCell($largcol2, $tab2_hl,
price($remise, 0, $outputlangs), 0,
'R', 1);
1686 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1687 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTWithDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTWithDiscount") :
''), 0,
'L', 1);
1688 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1689 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht - $remise, 0, $outputlangs), 0,
'R', 1);
1694 $pdf->SetFillColor(255, 255, 255);
1695 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1696 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalVAT"), 0,
'L', 1);
1698 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1699 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->total_tva), 0,
'R', 1);
1703 $pdf->SetFillColor(248, 248, 248);
1705 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1707 $this->atleastoneratenotnull = 0;
1709 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1710 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1714 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1715 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1719 foreach ($localtax_rate as $tvakey => $tvaval) {
1724 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1727 if (preg_match(
'/\*/', $tvakey)) {
1728 $tvakey = str_replace(
'*',
'', $tvakey);
1729 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1732 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1736 $totalvat .= $tvacompl;
1738 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1741 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1743 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1745 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1746 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1752 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1753 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1757 foreach ($localtax_rate as $tvakey => $tvaval) {
1762 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1765 if (preg_match(
'/\*/', $tvakey)) {
1766 $tvakey = str_replace(
'*',
'', $tvakey);
1767 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1769 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1773 $totalvat .= $tvacompl;
1775 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1778 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1780 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1782 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1783 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1792 $nblines = count(
$object->lines);
1793 for ($i = 0; $i < $nblines; $i++) {
1794 $tvaligne =
$object->lines[$i]->total_tva;
1795 $vatrate = (string)
$object->lines[$i]->tva_tx;
1797 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
1800 if (! isset($tvas[$vatrate])) {
1801 $tvas[$vatrate] = 0;
1803 $tvas[$vatrate] += $tvaligne;
1806 foreach ($tvas as $tvakey => $tvaval) {
1808 $this->atleastoneratenotnull++;
1811 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1814 if (preg_match(
'/\*/', $tvakey)) {
1815 $tvakey = str_replace(
'*',
'', $tvakey);
1816 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1818 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1821 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1823 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1825 $totalvat .= $tvacompl;
1827 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1829 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1831 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1832 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1838 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1839 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1843 foreach ($localtax_rate as $tvakey => $tvaval) {
1848 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1851 if (preg_match(
'/\*/', $tvakey)) {
1852 $tvakey = str_replace(
'*',
'', $tvakey);
1853 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1855 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1859 $totalvat .= $tvacompl;
1861 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1864 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1866 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1868 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1869 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1875 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1876 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1880 foreach ($localtax_rate as $tvakey => $tvaval) {
1886 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1889 if (preg_match(
'/\*/', $tvakey)) {
1890 $tvakey = str_replace(
'*',
'', $tvakey);
1891 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1893 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1897 $totalvat .= $tvacompl;
1899 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1902 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1904 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1906 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1907 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1916 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1917 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1919 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1920 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1925 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1926 $pdf->SetTextColor(0, 0, 60);
1927 $pdf->SetFillColor(224, 224, 224);
1928 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1930 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1931 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1935 if (
$object->displayRetainedWarranty()) {
1936 $pdf->SetTextColor(40, 40, 40);
1937 $pdf->SetFillColor(255, 255, 255);
1939 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1940 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1944 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1945 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1947 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1948 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1952 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1954 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1955 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1957 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1958 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1959 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1964 $pdf->SetTextColor(0, 0, 0);
1972 if ($deja_regle > 0) {
1976 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1977 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1979 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1980 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1999 $pdf->SetTextColor(0, 0, 60);
2000 $pdf->SetFillColor(224, 224, 224);
2001 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
2002 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
2003 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
2004 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
2006 $pdf->SetFont(
'',
'', $default_font_size - 1);
2007 $pdf->SetTextColor(0, 0, 0);
2010 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
2012 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
2014 $this->error = $hookmanager->error;
2015 $this->errors = $hookmanager->errors;
2019 return ($tab2_top + ($tab2_hl * $index));
2144 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2147 global
$conf, $langs;
2149 $ltrdirection =
'L';
2150 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2151 $ltrdirection =
'R';
2155 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2161 $pdf->SetTextColor(0, 0, 60);
2162 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2166 $posy = $this->marge_haute;
2167 $posx = $this->page_largeur - $this->marge_droite - $w;
2169 $pdf->SetXY($this->marge_gauche, $posy);
2173 if ($this->emetteur->logo) {
2174 $logodir =
$conf->mycompany->dir_output;
2175 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
2176 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
2179 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2181 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2183 if (is_readable($logo)) {
2185 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2187 $pdf->SetTextColor(200, 0, 0);
2188 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2189 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2190 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2193 $text = $this->emetteur->name;
2194 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2198 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2199 $pdf->SetXY($posx, $posy);
2200 $pdf->SetTextColor(0, 0, 60);
2202 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2204 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2207 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2210 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2213 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2215 if ($this->situationinvoice) {
2216 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
2217 $subtitle = $outputlangs->transnoentities(
"PDFSituationTitle",
$object->situation_counter);
2219 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2222 if ($this->situationinvoice) {
2223 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2225 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2226 } elseif (
$object->type == 1) {
2227 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2228 } elseif (
$object->type == 2) {
2229 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2230 } elseif (
$object->type == 3) {
2231 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2232 } elseif (
$object->type == 4) {
2233 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2236 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2242 $pdf->MultiCell($w, 3, $title,
'',
'R');
2243 if (!empty($subtitle)) {
2244 $pdf->SetFont(
'',
'B', $default_font_size);
2245 $pdf->SetXY($posx, $posy + 5);
2246 $pdf->MultiCell($w, 6, $subtitle,
'',
'R');
2250 $pdf->SetFont(
'',
'B', $default_font_size);
2264 $pdf->SetFont(
'',
'', $default_font_size - 2);
2268 $pdf->SetXY($posx, $posy);
2269 $pdf->SetTextColor(0, 0, 60);
2270 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2275 if (!empty(
$object->project->ref)) {
2277 $pdf->SetXY($posx, $posy);
2278 $pdf->SetTextColor(0, 0, 60);
2279 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2285 if (!empty(
$object->project->ref)) {
2286 $outputlangs->load(
"projects");
2288 $pdf->SetXY($posx, $posy);
2289 $pdf->SetTextColor(0, 0, 60);
2290 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2294 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2295 if (
$object->type == 0 && $objectidnext) {
2296 $objectreplacing =
new Facture($this->db);
2297 $objectreplacing->fetch($objectidnext);
2300 $pdf->SetXY($posx, $posy);
2301 $pdf->SetTextColor(0, 0, 60);
2302 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2305 $objectreplaced =
new Facture($this->db);
2306 $objectreplaced->fetch(
$object->fk_facture_source);
2309 $pdf->SetXY($posx, $posy);
2310 $pdf->SetTextColor(0, 0, 60);
2311 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2314 $objectreplaced =
new Facture($this->db);
2315 $objectreplaced->fetch(
$object->fk_facture_source);
2318 $pdf->SetXY($posx, $posy);
2319 $pdf->SetTextColor(0, 0, 60);
2320 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2324 $pdf->SetXY($posx, $posy);
2325 $pdf->SetTextColor(0, 0, 60);
2327 $title = $outputlangs->transnoentities(
"DateInvoice");
2328 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2329 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2331 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2335 $pdf->SetXY($posx, $posy);
2336 $pdf->SetTextColor(0, 0, 60);
2337 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2342 $pdf->SetXY($posx, $posy);
2343 $pdf->SetTextColor(0, 0, 60);
2344 $title = $outputlangs->transnoentities(
"DateDue");
2345 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2346 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2348 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2353 $pdf->SetXY($posx, $posy);
2354 $pdf->SetTextColor(0, 0, 60);
2355 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2360 $pdf->SetXY($posx, $posy);
2361 $pdf->SetTextColor(0, 0, 60);
2362 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
2367 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2368 if (count($arrayidcontact) > 0) {
2369 $usertmp =
new User($this->db);
2370 $usertmp->fetch($arrayidcontact[0]);
2372 $pdf->SetXY($posx, $posy);
2373 $pdf->SetTextColor(0, 0, 60);
2374 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2383 $current_y = $pdf->getY();
2385 if ($current_y < $pdf->getY()) {
2386 $top_shift = $pdf->getY() - $current_y;
2395 $posy += $top_shift;
2396 $posx = $this->marge_gauche;
2398 $posx = $this->page_largeur - $this->marge_droite - 80;
2406 $pdf->SetTextColor(0, 0, 0);
2407 $pdf->SetFont(
'',
'', $default_font_size - 2);
2408 $pdf->SetXY($posx, $posy - 5);
2409 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2410 $pdf->SetXY($posx, $posy);
2411 $pdf->SetFillColor(230, 230, 230);
2412 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2413 $pdf->SetTextColor(0, 0, 60);
2418 $pdf->SetXY($posx + 2, $posy + 3);
2419 $pdf->SetFont(
'',
'B', $default_font_size);
2420 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2421 $posy = $pdf->getY();
2425 $pdf->SetXY($posx + 2, $posy);
2426 $pdf->SetFont(
'',
'', $default_font_size - 1);
2427 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2430 $usecontact =
false;
2431 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2432 if (count($arrayidcontact) > 0) {
2434 $result =
$object->fetch_contact($arrayidcontact[0]);
2438 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2439 $thirdparty =
$object->contact;
2441 $thirdparty =
$object->thirdparty;
2451 if ($this->page_largeur < 210) {
2455 $posy += $top_shift;
2456 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2458 $posx = $this->marge_gauche;
2463 $pdf->SetTextColor(0, 0, 0);
2464 $pdf->SetFont(
'',
'', $default_font_size - 2);
2465 $pdf->SetXY($posx + 2, $posy - 5);
2466 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2467 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2471 $pdf->SetXY($posx + 2, $posy + 3);
2472 $pdf->SetFont(
'',
'B', $default_font_size);
2474 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2476 $posy = $pdf->getY();
2479 $pdf->SetFont(
'',
'', $default_font_size - 1);
2480 $pdf->SetXY($posx + 2, $posy);
2482 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2486 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2488 if (!empty($idaddressshipping)) {
2489 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2490 $companystatic =
new Societe($this->db);
2491 $companystatic->fetch(
$object->contact->fk_soc);
2493 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
2498 if (!empty($carac_client_shipping)) {
2499 $posy += $hautcadre;
2502 $pdf->SetXY($posx + 2, $posy - 5);
2503 $pdf->SetFont(
'',
'', $default_font_size - 2);
2504 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2505 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2508 $pdf->SetXY($posx + 2, $posy + 3);
2509 $pdf->SetFont(
'',
'B', $default_font_size);
2510 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2512 $posy = $pdf->getY();
2515 $pdf->SetXY($posx + 2, $posy);
2516 $pdf->SetFont(
'',
'', $default_font_size - 1);
2517 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2518 $shipp_shift += $hautcadre;
2523 $pdf->SetTextColor(0, 0, 0);
2525 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);
2847 public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
2851 $form =
new Form($db);
2855 if (!$displayWarranty) {
2866 $currency = !empty($currency) ? $currency :
$conf->currency;
2870 $pdf->SetTextColor(0, 0, 0);
2871 $pdf->SetFont(
'',
'', $default_font_size - 2);
2873 if (empty($hidetop)) {
2874 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
2875 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 8);
2876 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
2878 $width = $this->page_largeur - $this->marge_gauche - $this->marge_droite - 83;
2882 $pdf->RoundedRect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, $this->corner_radius,
'1001',
'F', explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2884 $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')));
2888 $pdf->SetDrawColor(128, 128, 128);
2889 $pdf->SetFont(
'',
'', $default_font_size - 1);
2893 $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');
2895 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top, $this->posx_cumul_anterieur - 1, $tab_top + $tab_height);
2896 if (empty($hidetop)) {
2897 $pdf->SetXY($this->posx_cumul_anterieur - 1, $tab_top + 0.5);
2898 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceOldCumulation"),
'',
'C');
2902 $pdf->line($this->posx_new_cumul - 1, $tab_top, $this->posx_new_cumul - 1, $tab_top + $tab_height);
2903 if (empty($hidetop)) {
2904 $pdf->SetXY($this->posx_new_cumul - 1, $tab_top + 0.5);
2905 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceNewCumulation"),
'',
'C');
2908 $pdf->line($this->posx_current - 1, $tab_top, $this->posx_current - 1, $tab_top + $tab_height);
2909 if (empty($hidetop)) {
2910 $pdf->SetXY($this->posx_current - 1, $tab_top + 0.5);
2911 $pdf->MultiCell(36, 2, $outputlangs->transnoentities(
"CurrentSituationTotal",
$object->situation_counter),
'',
'C');
2915 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
2917 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 24, $this->page_largeur - $this->marge_droite, $tab_top + 24);
2919 $pdf->line($this->marge_gauche, $tab_top + 55, $this->page_largeur - $this->marge_droite, $tab_top + 55);
2921 $pdf->line($this->marge_gauche, $tab_top + 65, $this->page_largeur - $this->marge_droite, $tab_top + 65);
2923 if ($displayWarranty) {
2924 $pdf->line($this->marge_gauche, $tab_top + 85, $this->page_largeur - $this->marge_droite, $tab_top + 85);
2930 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 8);
2931 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceMainTask"),
'',
'L');
2933 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 12);
2934 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceAdditionalTask"),
'',
'L');
2936 $form->load_cache_vatrates(
"'".
$object->thirdparty->country_code.
"'");
2939 foreach ($form->cache_vatrates as $TVatInfo) {
2940 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2942 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2947 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 24 + $i);
2948 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalHT").
' '.$TVatInfo[
'label'],
'',
'L');
2950 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2951 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 28 + $i);
2952 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"VAT").
' '.$TVatInfo[
'label'],
'',
'L');
2958 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 33 + $i);
2959 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'L');
2962 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2963 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 58);
2964 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalSituationInvoice"),
'',
'L');
2965 $pdf->SetFont(
'',
'', $default_font_size - 2);
2967 if ($displayWarranty) {
2968 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 74);
2969 $pdf->MultiCell(80, 2, $outputlangs->trans(
"TotalSituationInvoiceWithRetainedWarranty",
$object->retained_warranty),
'',
'L');
2970 $nextY = $tab_top + 93;
2972 $nextY = $tab_top + 74;
2975 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2976 $pdf->SetXY($this->marge_gauche + 2, $nextY);
2977 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"SituationTotalRayToRest"),
'',
'L');
2978 $pdf->SetFont(
'',
'', $default_font_size - 2);
2982 $TToDisplay = array(
2988 $x = $this->marge_gauche + 85;
2992 foreach ($TToDisplay as $col) {
2994 $pdf->SetXY($x, $tab_top + 8);
2995 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2998 $pdf->SetXY($x, $tab_top + 12);
2999 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'travaux_sup'], 0,
'', 1, -1, 2),
'',
'R');
3002 foreach ($form->cache_vatrates as $TVatInfo) {
3003 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
3004 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
3010 $pdf->SetXY($x, $tab_top + 24 + $i);
3011 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
3014 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
3015 $pdf->SetXY($x, $tab_top + 28 + $i);
3016 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'TVA'], 0,
'', 1, -1, 2),
'',
'R');
3023 $pdf->SetXY($x, $tab_top + 33 + $i);
3024 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
3027 $pdf->SetFont(
'',
'B', $default_font_size - 1);
3028 $pdf->SetXY($x, $tab_top + 58);
3029 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
3030 $pdf->SetFont(
'',
'', $default_font_size - 2);
3033 if ($displayWarranty) {
3035 $pdf->SetXY($x, $tab_top + 74);
3036 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'retenue_garantie'], 0,
'', 1, -1, 2),
'',
'R');
3037 $nextY = $tab_top + 93;
3039 $nextY = $tab_top + 74;
3043 $pdf->SetFont(
'',
'B', $default_font_size - 1);
3044 $pdf->SetXY($x, $nextY);
3045 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'total_a_payer'], 0,
'', 1, -1, 2),
'',
'R');
3046 $pdf->SetFont(
'',
'', $default_font_size - 2);