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
$conf, $mysoc, $hookmanager;
1336 $pdf->SetFont(
'',
'', $default_font_size - 1);
1338 krsort($this->tva_array);
1342 $pdf->SetFillColor(224, 224, 224);
1344 $pdf->SetFont(
'',
'', $default_font_size - 2);
1345 $pdf->SetXY($this->marge_gauche, $posy);
1346 $titre = $outputlangs->transnoentities(
"VAT");
1347 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1349 $pdf->SetFont(
'',
'', $default_font_size - 2);
1350 $pdf->SetXY($this->marge_gauche + 25, $posy);
1351 $titre = $outputlangs->transnoentities(
"NetTotal");
1352 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1354 $pdf->SetFont(
'',
'', $default_font_size - 2);
1355 $pdf->SetXY($this->marge_gauche + 50, $posy);
1356 $titre = $outputlangs->transnoentities(
"VATAmount");
1357 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1359 $pdf->SetFont(
'',
'', $default_font_size - 2);
1360 $pdf->SetXY($this->marge_gauche + 75, $posy);
1361 $titre = $outputlangs->transnoentities(
"AmountTotal");
1362 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1364 $posy = $pdf->GetY();
1369 foreach ($this->tva_array as $tvakey => $tvaval) {
1370 $pdf->SetFont(
'',
'', $default_font_size - 2);
1371 $pdf->SetXY($this->marge_gauche, $posy);
1372 $titre = round((
float) $tvakey, 2) .
"%";
1373 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1375 $pdf->SetFont(
'',
'', $default_font_size - 2);
1376 $pdf->SetXY($this->marge_gauche + 25, $posy);
1377 $titre =
price($tvaval[
'tot_ht']);
1378 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1379 $tot_ht += $tvaval[
'tot_ht'];
1381 $pdf->SetFont(
'',
'', $default_font_size - 2);
1382 $pdf->SetXY($this->marge_gauche + 50, $posy);
1383 $titre =
price($tvaval[
'amount']);
1384 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1385 $tot_tva += $tvaval[
'amount'];
1387 $pdf->SetFont(
'',
'', $default_font_size - 2);
1388 $pdf->SetXY($this->marge_gauche + 75, $posy);
1389 $titre =
price($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1390 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1391 $tot_ttc += ($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1393 $posy = $pdf->GetY();
1398 if ($this->emetteur->country_code ==
'FR' && empty(
$object->total_tva) && (empty($mysoc->tva_assuj) || ($this->emetteur->isInEEC() &&
$object->thirdparty->isInEEC()))) {
1399 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1400 $pdf->SetXY($this->marge_gauche, $posy);
1401 if ($mysoc->forme_juridique_code == 92) {
1402 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1404 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1407 $posy = $pdf->GetY() + 4;
1412 if ($this->page_largeur < 210) {
1418 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1419 $pdf->SetXY($this->marge_gauche, $posy);
1420 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1421 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1423 $pdf->SetFont(
'',
'', $default_font_size - 2);
1424 $pdf->SetXY($posxval, $posy);
1425 $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);
1426 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1427 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1429 $posy = $pdf->GetY() + 3;
1433 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1434 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1435 $pdf->SetXY($this->marge_gauche, $posy);
1436 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1437 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1439 $pdf->SetFont(
'',
'', $default_font_size - 2);
1440 $pdf->SetXY($posxval, $posy);
1441 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1442 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1444 $posy = $pdf->GetY() + 3;
1449 if (empty(
$object->mode_reglement_code)
1452 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1456 $outputlangs->load(
"errors");
1458 $pdf->SetXY($this->marge_gauche, $posy);
1459 $pdf->SetTextColor(200, 0, 0);
1460 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1461 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1462 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1463 $pdf->SetTextColor(0, 0, 0);
1465 $posy = $pdf->GetY() + 1;
1469 if (!empty(
$object->mode_reglement_code)
1470 &&
$object->mode_reglement_code !=
'CHQ'
1471 &&
$object->mode_reglement_code !=
'VIR') {
1472 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1473 $pdf->SetXY($this->marge_gauche, $posy);
1474 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1475 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1477 $pdf->SetFont(
'',
'', $default_font_size - 2);
1478 $pdf->SetXY($posxval, $posy);
1479 $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);
1482 if (
$object->mode_reglement_code ==
"PRE") {
1483 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1486 $bac->fetch(0,
$object->thirdparty->id);
1487 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1488 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1491 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1493 $posy = $pdf->GetY();
1499 if ($this->emetteur->country_code ==
'FR') {
1501 $pdf->SetXY($this->marge_gauche, $posy);
1502 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1504 $posy = $pdf->GetY() + 1;
1509 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1510 $useonlinepayment = 0;
1512 if (isModEnabled(
'paypal')) {
1513 $useonlinepayment++;
1515 if (isModEnabled(
'stripe')) {
1516 $useonlinepayment++;
1518 if (isModEnabled(
'paybox')) {
1519 $useonlinepayment++;
1521 $parameters = array();
1523 $reshook = $hookmanager->executeHooks(
'doShowOnlinePaymentUrl', $parameters,
$object, $action);
1525 if (isset($hookmanager->resArray[
'showonlinepaymenturl'])) {
1526 $useonlinepayment += $hookmanager->resArray[
'showonlinepaymenturl'];
1533 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1536 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1537 $servicename = $langs->transnoentities(
'Online');
1538 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1539 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1541 $pdf->SetXY($this->marge_gauche, $posy);
1542 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1544 $posy = $pdf->GetY() + 1;
1549 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1555 $account =
new Account($this->db);
1558 $pdf->SetXY($this->marge_gauche, $posy);
1559 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1560 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1561 $posy = $pdf->GetY() + 1;
1564 $pdf->SetXY($this->marge_gauche, $posy);
1565 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1566 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1567 $posy = $pdf->GetY() + 2;
1571 $pdf->SetXY($this->marge_gauche, $posy);
1572 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1573 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1574 $posy = $pdf->GetY() + 1;
1577 $pdf->SetXY($this->marge_gauche, $posy);
1578 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1579 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1580 $posy = $pdf->GetY() + 2;
1587 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1593 $account =
new Account($this->db);
1594 $account->fetch($bankid);
1596 $curx = $this->marge_gauche;
1599 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1605 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1608 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L', 0);
1631 global
$conf, $mysoc, $hookmanager;
1643 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1644 $default_font_size--;
1647 $tab2_top = $posy - 4;
1649 $pdf->SetFont(
'',
'', $default_font_size - 1);
1654 if ($this->page_largeur < 210) {
1657 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1663 $pdf->SetFillColor(255, 255, 255);
1664 $pdf->SetXY($col1x, $tab2_top + 0);
1665 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1667 $total_ht = ((!empty(
$conf->multicurrency->enabled) && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1668 $pdf->SetXY($col2x, $tab2_top + 0);
1669 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht, 0, $outputlangs), 0,
'R', 1);
1674 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1675 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"DiscountHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"DiscountHT") :
''), 0,
'L', 1);
1676 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1677 $pdf->MultiCell($largcol2, $tab2_hl,
price($remise, 0, $outputlangs), 0,
'R', 1);
1680 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1681 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTWithDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTWithDiscount") :
''), 0,
'L', 1);
1682 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1683 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht - $remise, 0, $outputlangs), 0,
'R', 1);
1688 $pdf->SetFillColor(255, 255, 255);
1689 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1690 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalVAT"), 0,
'L', 1);
1692 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1693 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->total_tva), 0,
'R', 1);
1697 $pdf->SetFillColor(248, 248, 248);
1699 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1701 $this->atleastoneratenotnull = 0;
1703 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1704 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1708 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1709 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1713 foreach ($localtax_rate as $tvakey => $tvaval) {
1718 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1721 if (preg_match(
'/\*/', $tvakey)) {
1722 $tvakey = str_replace(
'*',
'', $tvakey);
1723 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1726 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1730 $totalvat .= $tvacompl;
1732 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1735 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1737 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1739 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1740 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1746 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1747 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1751 foreach ($localtax_rate as $tvakey => $tvaval) {
1756 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1759 if (preg_match(
'/\*/', $tvakey)) {
1760 $tvakey = str_replace(
'*',
'', $tvakey);
1761 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1763 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1767 $totalvat .= $tvacompl;
1769 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1772 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1774 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1776 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1777 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1786 $nblines = count(
$object->lines);
1787 for ($i = 0; $i < $nblines; $i++) {
1788 $tvaligne =
$object->lines[$i]->total_tva;
1789 $vatrate = (string)
$object->lines[$i]->tva_tx;
1791 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
1794 if (! isset($tvas[$vatrate])) {
1795 $tvas[$vatrate] = 0;
1797 $tvas[$vatrate] += $tvaligne;
1800 foreach ($tvas as $tvakey => $tvaval) {
1802 $this->atleastoneratenotnull++;
1805 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1808 if (preg_match(
'/\*/', $tvakey)) {
1809 $tvakey = str_replace(
'*',
'', $tvakey);
1810 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1812 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1815 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1817 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1819 $totalvat .= $tvacompl;
1821 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1823 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1825 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1826 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1832 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1833 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1837 foreach ($localtax_rate as $tvakey => $tvaval) {
1842 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1845 if (preg_match(
'/\*/', $tvakey)) {
1846 $tvakey = str_replace(
'*',
'', $tvakey);
1847 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1849 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1853 $totalvat .= $tvacompl;
1855 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1858 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1860 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1862 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1863 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1869 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1870 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1874 foreach ($localtax_rate as $tvakey => $tvaval) {
1880 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1883 if (preg_match(
'/\*/', $tvakey)) {
1884 $tvakey = str_replace(
'*',
'', $tvakey);
1885 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1887 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1891 $totalvat .= $tvacompl;
1893 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1896 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1898 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1900 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1901 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1910 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1911 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1913 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1914 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1919 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1920 $pdf->SetTextColor(0, 0, 60);
1921 $pdf->SetFillColor(224, 224, 224);
1922 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1924 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1925 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1929 if (
$object->displayRetainedWarranty()) {
1930 $pdf->SetTextColor(40, 40, 40);
1931 $pdf->SetFillColor(255, 255, 255);
1933 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1934 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1938 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1939 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1941 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1942 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1946 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1948 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1949 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1951 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1952 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1953 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1958 $pdf->SetTextColor(0, 0, 0);
1966 if ($deja_regle > 0) {
1970 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1971 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1973 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1974 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1993 $pdf->SetTextColor(0, 0, 60);
1994 $pdf->SetFillColor(224, 224, 224);
1995 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1996 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1997 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1998 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
2000 $pdf->SetFont(
'',
'', $default_font_size - 1);
2001 $pdf->SetTextColor(0, 0, 0);
2004 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
2006 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
2008 $this->error = $hookmanager->error;
2009 $this->errors = $hookmanager->errors;
2013 return ($tab2_top + ($tab2_hl * $index));
2138 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2141 global
$conf, $langs;
2143 $ltrdirection =
'L';
2144 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2145 $ltrdirection =
'R';
2149 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2155 $pdf->SetTextColor(0, 0, 60);
2156 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2160 $posy = $this->marge_haute;
2161 $posx = $this->page_largeur - $this->marge_droite - $w;
2163 $pdf->SetXY($this->marge_gauche, $posy);
2167 if ($this->emetteur->logo) {
2168 $logodir =
$conf->mycompany->dir_output;
2169 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
2170 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
2173 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2175 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2177 if (is_readable($logo)) {
2179 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2181 $pdf->SetTextColor(200, 0, 0);
2182 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2183 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2184 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2187 $text = $this->emetteur->name;
2188 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2192 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2193 $pdf->SetXY($posx, $posy);
2194 $pdf->SetTextColor(0, 0, 60);
2196 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2198 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2201 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2204 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2207 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2209 if ($this->situationinvoice) {
2210 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
2211 $subtitle = $outputlangs->transnoentities(
"PDFSituationTitle",
$object->situation_counter);
2213 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2216 if ($this->situationinvoice) {
2217 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2219 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2220 } elseif (
$object->type == 1) {
2221 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2222 } elseif (
$object->type == 2) {
2223 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2224 } elseif (
$object->type == 3) {
2225 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2226 } elseif (
$object->type == 4) {
2227 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2230 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2236 $pdf->MultiCell($w, 3, $title,
'',
'R');
2237 if (!empty($subtitle)) {
2238 $pdf->SetFont(
'',
'B', $default_font_size);
2239 $pdf->SetXY($posx, $posy + 5);
2240 $pdf->MultiCell($w, 6, $subtitle,
'',
'R');
2244 $pdf->SetFont(
'',
'B', $default_font_size);
2258 $pdf->SetFont(
'',
'', $default_font_size - 2);
2262 $pdf->SetXY($posx, $posy);
2263 $pdf->SetTextColor(0, 0, 60);
2264 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2269 if (!empty(
$object->project->ref)) {
2271 $pdf->SetXY($posx, $posy);
2272 $pdf->SetTextColor(0, 0, 60);
2273 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2279 if (!empty(
$object->project->ref)) {
2280 $outputlangs->load(
"projects");
2282 $pdf->SetXY($posx, $posy);
2283 $pdf->SetTextColor(0, 0, 60);
2284 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2288 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2289 if (
$object->type == 0 && $objectidnext) {
2290 $objectreplacing =
new Facture($this->db);
2291 $objectreplacing->fetch($objectidnext);
2294 $pdf->SetXY($posx, $posy);
2295 $pdf->SetTextColor(0, 0, 60);
2296 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2299 $objectreplaced =
new Facture($this->db);
2300 $objectreplaced->fetch(
$object->fk_facture_source);
2303 $pdf->SetXY($posx, $posy);
2304 $pdf->SetTextColor(0, 0, 60);
2305 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2308 $objectreplaced =
new Facture($this->db);
2309 $objectreplaced->fetch(
$object->fk_facture_source);
2312 $pdf->SetXY($posx, $posy);
2313 $pdf->SetTextColor(0, 0, 60);
2314 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2318 $pdf->SetXY($posx, $posy);
2319 $pdf->SetTextColor(0, 0, 60);
2321 $title = $outputlangs->transnoentities(
"DateInvoice");
2322 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2323 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2325 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2329 $pdf->SetXY($posx, $posy);
2330 $pdf->SetTextColor(0, 0, 60);
2331 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2336 $pdf->SetXY($posx, $posy);
2337 $pdf->SetTextColor(0, 0, 60);
2338 $title = $outputlangs->transnoentities(
"DateDue");
2339 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2340 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2342 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2347 $pdf->SetXY($posx, $posy);
2348 $pdf->SetTextColor(0, 0, 60);
2349 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2354 $pdf->SetXY($posx, $posy);
2355 $pdf->SetTextColor(0, 0, 60);
2356 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
2361 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2362 if (count($arrayidcontact) > 0) {
2363 $usertmp =
new User($this->db);
2364 $usertmp->fetch($arrayidcontact[0]);
2366 $pdf->SetXY($posx, $posy);
2367 $pdf->SetTextColor(0, 0, 60);
2368 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2377 $current_y = $pdf->getY();
2379 if ($current_y < $pdf->getY()) {
2380 $top_shift = $pdf->getY() - $current_y;
2389 $posy += $top_shift;
2390 $posx = $this->marge_gauche;
2392 $posx = $this->page_largeur - $this->marge_droite - 80;
2400 $pdf->SetTextColor(0, 0, 0);
2401 $pdf->SetFont(
'',
'', $default_font_size - 2);
2402 $pdf->SetXY($posx, $posy - 5);
2403 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2404 $pdf->SetXY($posx, $posy);
2405 $pdf->SetFillColor(230, 230, 230);
2406 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2407 $pdf->SetTextColor(0, 0, 60);
2412 $pdf->SetXY($posx + 2, $posy + 3);
2413 $pdf->SetFont(
'',
'B', $default_font_size);
2414 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2415 $posy = $pdf->getY();
2419 $pdf->SetXY($posx + 2, $posy);
2420 $pdf->SetFont(
'',
'', $default_font_size - 1);
2421 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2424 $usecontact =
false;
2425 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2426 if (count($arrayidcontact) > 0) {
2428 $result =
$object->fetch_contact($arrayidcontact[0]);
2432 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2433 $thirdparty =
$object->contact;
2435 $thirdparty =
$object->thirdparty;
2445 if ($this->page_largeur < 210) {
2449 $posy += $top_shift;
2450 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2452 $posx = $this->marge_gauche;
2457 $pdf->SetTextColor(0, 0, 0);
2458 $pdf->SetFont(
'',
'', $default_font_size - 2);
2459 $pdf->SetXY($posx + 2, $posy - 5);
2460 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2461 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2465 $pdf->SetXY($posx + 2, $posy + 3);
2466 $pdf->SetFont(
'',
'B', $default_font_size);
2468 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2470 $posy = $pdf->getY();
2473 $pdf->SetFont(
'',
'', $default_font_size - 1);
2474 $pdf->SetXY($posx + 2, $posy);
2476 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2480 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2482 if (!empty($idaddressshipping)) {
2483 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2484 $companystatic =
new Societe($this->db);
2485 $companystatic->fetch(
$object->contact->fk_soc);
2487 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
2492 if (!empty($carac_client_shipping)) {
2493 $posy += $hautcadre;
2496 $pdf->SetXY($posx + 2, $posy - 5);
2497 $pdf->SetFont(
'',
'', $default_font_size - 2);
2498 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2499 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2502 $pdf->SetXY($posx + 2, $posy + 3);
2503 $pdf->SetFont(
'',
'B', $default_font_size);
2504 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2506 $posy = $pdf->getY();
2509 $pdf->SetXY($posx + 2, $posy);
2510 $pdf->SetFont(
'',
'', $default_font_size - 1);
2511 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2512 $shipp_shift += $hautcadre;
2517 $pdf->SetTextColor(0, 0, 0);
2519 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);
2841 public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
2845 $form =
new Form($db);
2849 if (!$displayWarranty) {
2860 $currency = !empty($currency) ? $currency :
$conf->currency;
2864 $pdf->SetTextColor(0, 0, 0);
2865 $pdf->SetFont(
'',
'', $default_font_size - 2);
2867 if (empty($hidetop)) {
2868 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
2869 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 8);
2870 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
2872 $width = $this->page_largeur - $this->marge_gauche - $this->marge_droite - 83;
2877 $pdf->RoundedRect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, $this->corner_radius,
'1001',
'F', explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
2879 $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')));
2883 $pdf->SetDrawColor(128, 128, 128);
2884 $pdf->SetFont(
'',
'', $default_font_size - 1);
2888 $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');
2890 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top, $this->posx_cumul_anterieur - 1, $tab_top + $tab_height);
2891 if (empty($hidetop)) {
2892 $pdf->SetXY($this->posx_cumul_anterieur - 1, $tab_top + 0.5);
2893 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceOldCumulation"),
'',
'C');
2897 $pdf->line($this->posx_new_cumul - 1, $tab_top, $this->posx_new_cumul - 1, $tab_top + $tab_height);
2898 if (empty($hidetop)) {
2899 $pdf->SetXY($this->posx_new_cumul - 1, $tab_top + 0.5);
2900 $pdf->MultiCell(35, 2, $outputlangs->transnoentities(
"SituationInvoiceNewCumulation"),
'',
'C');
2903 $pdf->line($this->posx_current - 1, $tab_top, $this->posx_current - 1, $tab_top + $tab_height);
2904 if (empty($hidetop)) {
2905 $pdf->SetXY($this->posx_current - 1, $tab_top + 0.5);
2906 $pdf->MultiCell(36, 2, $outputlangs->transnoentities(
"CurrentSituationTotal",
$object->situation_counter),
'',
'C');
2910 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
2912 $pdf->line($this->posx_cumul_anterieur - 1, $tab_top + 24, $this->page_largeur - $this->marge_droite, $tab_top + 24);
2914 $pdf->line($this->marge_gauche, $tab_top + 55, $this->page_largeur - $this->marge_droite, $tab_top + 55);
2916 $pdf->line($this->marge_gauche, $tab_top + 65, $this->page_largeur - $this->marge_droite, $tab_top + 65);
2918 if ($displayWarranty) {
2919 $pdf->line($this->marge_gauche, $tab_top + 85, $this->page_largeur - $this->marge_droite, $tab_top + 85);
2925 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 8);
2926 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceMainTask"),
'',
'L');
2928 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 12);
2929 $pdf->MultiCell(60, 2, $outputlangs->transnoentities(
"SituationInvoiceAdditionalTask"),
'',
'L');
2931 $form->load_cache_vatrates(
"'".
$object->thirdparty->country_code.
"'");
2934 foreach ($form->cache_vatrates as $TVatInfo) {
2935 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2937 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
2942 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 24 + $i);
2943 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalHT").
' '.$TVatInfo[
'label'],
'',
'L');
2945 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
2946 $pdf->SetXY($this->marge_gauche + 10, $tab_top + 28 + $i);
2947 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"VAT").
' '.$TVatInfo[
'label'],
'',
'L');
2953 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 33 + $i);
2954 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalTTC"),
'',
'L');
2957 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2958 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 58);
2959 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"TotalSituationInvoice"),
'',
'L');
2960 $pdf->SetFont(
'',
'', $default_font_size - 2);
2962 if ($displayWarranty) {
2963 $pdf->SetXY($this->marge_gauche + 2, $tab_top + 74);
2964 $pdf->MultiCell(80, 2, $outputlangs->trans(
"TotalSituationInvoiceWithRetainedWarranty",
$object->retained_warranty),
'',
'L');
2965 $nextY = $tab_top + 93;
2967 $nextY = $tab_top + 74;
2970 $pdf->SetFont(
'',
'B', $default_font_size - 1);
2971 $pdf->SetXY($this->marge_gauche + 2, $nextY);
2972 $pdf->MultiCell(80, 2, $outputlangs->transnoentities(
"SituationTotalRayToRest"),
'',
'L');
2973 $pdf->SetFont(
'',
'', $default_font_size - 2);
2977 $TToDisplay = array(
2983 $x = $this->marge_gauche + 85;
2987 foreach ($TToDisplay as $col) {
2989 $pdf->SetXY($x, $tab_top + 8);
2990 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
2993 $pdf->SetXY($x, $tab_top + 12);
2994 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'travaux_sup'], 0,
'', 1, -1, 2),
'',
'R');
2997 foreach ($form->cache_vatrates as $TVatInfo) {
2998 $tva_tx_formated = sprintf(
"%01.3f", (
float) $TVatInfo[
'txtva']);
2999 if (empty($this->TDataSituation[
'current'][$tva_tx_formated])) {
3005 $pdf->SetXY($x, $tab_top + 24 + $i);
3006 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'HT'], 0,
'', 1, -1, 2),
'',
'R');
3009 if (! empty($this->TDataSituation[
'current'][$tva_tx_formated][
'TVA'])) {
3010 $pdf->SetXY($x, $tab_top + 28 + $i);
3011 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][$tva_tx_formated][
'TVA'], 0,
'', 1, -1, 2),
'',
'R');
3018 $pdf->SetXY($x, $tab_top + 33 + $i);
3019 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
3022 $pdf->SetFont(
'',
'B', $default_font_size - 1);
3023 $pdf->SetXY($x, $tab_top + 58);
3024 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'TTC'], 0,
'', 1, -1, 2),
'',
'R');
3025 $pdf->SetFont(
'',
'', $default_font_size - 2);
3028 if ($displayWarranty) {
3030 $pdf->SetXY($x, $tab_top + 74);
3031 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'retenue_garantie'], 0,
'', 1, -1, 2),
'',
'R');
3032 $nextY = $tab_top + 93;
3034 $nextY = $tab_top + 74;
3038 $pdf->SetFont(
'',
'B', $default_font_size - 1);
3039 $pdf->SetXY($x, $nextY);
3040 $pdf->MultiCell(32, 2,
price($this->TDataSituation[$col][
'total_a_payer'], 0,
'', 1, -1, 2),
'',
'R');
3041 $pdf->SetFont(
'',
'', $default_font_size - 2);