203 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
206 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
208 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
210 if (!is_object($outputlangs)) {
211 $outputlangs = $langs;
215 $outputlangs->charset_output =
'ISO-8859-1';
219 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
221 global $outputlangsbis;
222 $outputlangsbis =
null;
224 $outputlangsbis =
new Translate(
'', $conf);
226 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
234 $nblines = count(
$object->lines);
242 $realpatharray = array();
243 $this->atleastonephoto =
false;
245 $objphoto =
new Product($this->db);
247 for ($i = 0; $i < $nblines; $i++) {
248 if (empty(
$object->lines[$i]->fk_product)) {
252 $objphoto->fetch(
$object->lines[$i]->fk_product);
256 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
257 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
259 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
260 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
264 foreach ($pdir as $midir) {
266 if ($conf->entity != $objphoto->entity) {
267 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
269 $dir = $conf->product->dir_output.
'/'.$midir;
272 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
274 if ($obj[
'photo_vignette']) {
275 $filename = $obj[
'photo_vignette'];
277 $filename = $obj[
'photo'];
280 $filename = $obj[
'photo'];
283 $realpath = $dir.$filename;
285 $this->atleastonephoto =
true;
290 if ($realpath && $arephoto) {
291 $realpatharray[$i] = $realpath;
298 if ($conf->facture->multidir_output[$conf->entity]) {
301 $deja_regle =
$object->getSommePaiement((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
302 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
303 $amount_deposits_included =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
307 $dir = $conf->facture->multidir_output[$conf->entity];
308 $file = $dir.
"/SPECIMEN.pdf";
311 $dir = $conf->facture->multidir_output[
$object->entity].
"/".$objectref;
312 $file = $dir.
"/".$objectref.
".pdf";
314 if (!file_exists($dir)) {
316 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
321 if (file_exists($dir)) {
323 if (!is_object($hookmanager)) {
324 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
327 $hookmanager->initHooks(array(
'pdfgeneration'));
328 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
330 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
333 $nblines = count(
$object->lines);
334 $nbpayments = count(
$object->getListOfPayments());
339 $pdf->SetAutoPageBreak(1, 0);
341 $this->heightforinfotot = 50 + (4 * $nbpayments);
342 $this->heightforfreetext =
getDolGlobalInt(
'MAIN_PDF_FREETEXT_HEIGHT', 5);
343 $this->heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
345 $heightforqrinvoice = $heightforqrinvoice_firstpage = 0;
349 $this->heightforinfotot = 30 + (4 * $nbpayments);
353 if (class_exists(
'TCPDF')) {
354 $pdf->setPrintHeader(
false);
355 $pdf->setPrintFooter(
false);
361 $logodir = $conf->mycompany->dir_output;
362 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
363 $logodir = $conf->mycompany->multidir_output[
$object->entity];
365 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
366 $tplidx = $pdf->importPage(1);
371 $pdf->SetDrawColor(128, 128, 128);
373 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
374 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
375 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
376 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
377 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
379 $pdf->SetCompression(
false);
383 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
384 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
395 'Name' => $this->emetteur->name,
396 'Location' =>
getCountry($this->emetteur->country_code,
''),
397 'Reason' =>
'INVOICE',
398 'ContactInfo' => $this->emetteur->email
400 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
404 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
408 $categoryOfOperation = 0;
411 for ($i = 0; $i < $nblines; $i++) {
412 if (
$object->lines[$i]->remise_percent) {
413 $this->atleastonediscount++;
417 if ($categoryOfOperation < 2) {
418 $lineProductType =
$object->lines[$i]->product_type;
424 if ($nbProduct > 0 && $nbService > 0) {
426 $categoryOfOperation = 2;
431 if ($categoryOfOperation <= 0) {
433 if ($nbProduct == 0 && $nbService > 0) {
434 $categoryOfOperation = 1;
437 $this->categoryOfOperation = $categoryOfOperation;
440 if (
$object->situation_cycle_ref) {
441 $this->situationinvoice =
true;
446 if (!empty($tplidx)) {
447 $pdf->useTemplate($tplidx);
452 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
453 $top_shift = $pagehead[
'top_shift'];
454 $shipp_shift = $pagehead[
'shipp_shift'];
455 $pdf->SetFont(
'',
'', $default_font_size - 1);
456 $pdf->MultiCell(0, 3,
'');
457 $pdf->SetTextColor(0, 0, 0);
462 $this->tab_top = 90 + $top_shift + $shipp_shift;
463 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
466 $extra_under_address_shift = 0;
469 $qrcodestring =
$object->buildZATCAQRString();
472 $qrcodestring =
$object->buildSwitzerlandQRString();
476 $qrcodestring =
$object->buildEPCQrCodeString();
481 $qrcodecolor = array(
'25',
'25',
'25');
486 'fgcolor' => $qrcodecolor,
491 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
495 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
496 $pdf->SetFont(
'',
'', $default_font_size - 4);
497 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
501 $extra_under_address_shift += 25;
509 'outputlangs' => $outputlangs,
510 'hidedetails' => $hidedetails
512 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
513 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
514 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
517 $this->tab_top += $extra_under_address_shift;
518 $this->tab_top_newpage += 0;
522 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->
getHeightForQRInvoice(1,
$object, $langs);
524 $nexY = $this->tab_top - 1;
527 $height_incoterms = 0;
528 if (isModEnabled(
'incoterm')) {
529 $desc_incoterms =
$object->getIncotermsForPDF();
530 if ($desc_incoterms) {
533 $pdf->SetFont(
'',
'', $default_font_size - 1);
534 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
535 $nexY = max($pdf->GetY(), $nexY);
536 $height_incoterms = $nexY - $this->tab_top;
539 $pdf->SetDrawColor(192, 192, 192);
540 $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');
542 $this->tab_top = $nexY + 6;
543 $height_incoterms += 4;
548 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
551 if (is_object(
$object->thirdparty)) {
552 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
553 $salerepobj =
new User($this->db);
554 $salerepobj->fetch($salereparray[0][
'id']);
555 if (!empty($salerepobj->signature)) {
556 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
562 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
563 if (!empty($extranote)) {
567 $pagenb = $pdf->getPage();
571 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
572 $pageposbeforenote = $pagenb;
579 $pdf->startTransaction();
581 $pdf->SetFont(
'',
'', $default_font_size - 1);
582 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
584 $pageposafternote = $pdf->getPage();
585 $posyafter = $pdf->GetY();
587 if ($pageposafternote > $pageposbeforenote) {
588 $pdf->rollbackTransaction(
true);
591 while ($pagenb < $pageposafternote) {
594 if (!empty($tplidx)) {
595 $pdf->useTemplate($tplidx);
600 $pdf->setTopMargin($this->tab_top_newpage);
602 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
606 $pdf->setPage($pageposbeforenote);
607 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
608 $pdf->SetFont(
'',
'', $default_font_size - 1);
609 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
610 $pageposafternote = $pdf->getPage();
612 $posyafter = $pdf->GetY();
614 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
615 $pdf->AddPage(
'',
'',
true);
618 $pdf->setPage($pageposafternote);
619 $pdf->setTopMargin($this->tab_top_newpage);
621 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
627 $i = $pageposbeforenote;
628 while ($i < $pageposafternote) {
632 $pdf->SetDrawColor(128, 128, 128);
634 if ($i > $pageposbeforenote) {
635 $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
636 $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
638 $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
639 $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
643 $pdf->setPageOrientation(
'', 1, 0);
650 $pdf->setPage($pageposafternote);
651 if (!empty($tplidx)) {
652 $pdf->useTemplate($tplidx);
657 $height_note = $posyafter - $this->tab_top_newpage;
658 $pdf->RoundedRect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
661 $pdf->commitTransaction();
662 $posyafter = $pdf->GetY();
663 $height_note = $posyafter - $this->tab_top;
664 $pdf->RoundedRect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
667 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
669 $pdf->AddPage(
'',
'',
true);
672 $pdf->setPage($pageposafternote);
673 if (!empty($tplidx)) {
674 $pdf->useTemplate($tplidx);
680 $posyafter = $this->tab_top_newpage;
684 $tab_height -= $height_note;
685 $this->tab_top = $posyafter + 6;
694 $pdf->startTransaction();
695 $this->
pdfTabTitles($pdf, $this->tab_top, $tab_height, $outputlangs, $hidetop);
696 $pdf->rollbackTransaction(
true);
698 $nexY = $this->tab_top + $this->tabTitleHeight;
701 $pageposbeforeprintlines = $pdf->getPage();
702 $pagenb = $pageposbeforeprintlines;
703 for ($i = 0; $i < $nblines; $i++) {
705 $pdf->SetFont(
'',
'', $default_font_size - 1);
706 $pdf->SetTextColor(0, 0, 0);
709 $imglinesize = array();
710 if (!empty($realpatharray[$i])) {
714 $pdf->setTopMargin($this->tab_top_newpage);
715 $page_bottom_margin = $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(),
$object, $langs);
716 $pdf->setPageOrientation(
'', 1, $page_bottom_margin);
717 $pageposbefore = $pdf->getPage();
719 $showpricebeforepagebreak = 1;
721 $posYAfterDescription = 0;
725 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
726 $pdf->AddPage(
'',
'',
true);
727 if (!empty($tplidx)) {
728 $pdf->useTemplate($tplidx);
730 $pdf->setPage($pageposbefore + 1);
732 $curY = $this->tab_top_newpage;
736 $showpricebeforepagebreak = 1;
738 $showpricebeforepagebreak = 0;
742 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
743 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
745 $posYAfterImage = $curY + $imglinesize[
'height'];
751 $pdf->startTransaction();
754 $pageposafter = $pdf->getPage();
756 if ($pageposafter > $pageposbefore) {
757 $pdf->rollbackTransaction(
true);
758 $pageposafter = $pageposbefore;
759 $pdf->setPageOrientation(
'', 1, $this->heightforfooter);
763 $pageposafter = $pdf->getPage();
764 $posyafter = $pdf->GetY();
766 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
767 if ($i == ($nblines - 1)) {
768 $pdf->AddPage(
'',
'',
true);
769 if (!empty($tplidx)) {
770 $pdf->useTemplate($tplidx);
772 $pdf->setPage($pageposafter + 1);
778 $showpricebeforepagebreak = 1;
780 $showpricebeforepagebreak = 0;
784 $pdf->commitTransaction();
786 $posYAfterDescription = $pdf->GetY();
789 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
791 $pageposafter = $pdf->getPage();
792 $pdf->setPage($pageposbefore);
793 $pdf->setTopMargin($this->marge_haute);
794 $pdf->setPageOrientation(
'', 1, 0);
797 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
798 $pdf->setPage($pageposafter);
799 $curY = $this->tab_top_newpage;
802 $pdf->SetFont(
'',
'', $default_font_size - 1);
813 $nexY = max($pdf->GetY(), $nexY);
820 $nexY = max($pdf->GetY(), $nexY);
828 $nexY = max($pdf->GetY(), $nexY);
835 $nexY = max($pdf->GetY(), $nexY);
842 $nexY = max($pdf->GetY(), $nexY);
849 $nexY = max($pdf->GetY(), $nexY);
856 $nexY = max($pdf->GetY(), $nexY);
863 $nexY = max($pdf->GetY(), $nexY);
867 if (!empty(
$object->lines[$i]->array_options)) {
868 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
872 $nexY = max($pdf->GetY(), $nexY);
884 'outputlangs' => $outputlangs,
885 'hidedetails' => $hidedetails
887 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
895 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
896 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
897 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
898 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
900 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
903 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
904 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
906 $tvaligne = $sign *
$object->lines[$i]->total_tva;
910 $localtax1ligne =
$object->lines[$i]->total_localtax1;
911 $localtax2ligne =
$object->lines[$i]->total_localtax2;
912 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
913 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
914 $localtax1_type =
$object->lines[$i]->localtax1_type;
915 $localtax2_type =
$object->lines[$i]->localtax2_type;
928 $vatrate = (string)
$object->lines[$i]->tva_tx;
931 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
932 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
934 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
935 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
939 if ($localtax1_type && $localtax1ligne != 0) {
940 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
941 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
943 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
946 if ($localtax2_type && $localtax2ligne != 0) {
947 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
948 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
950 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
954 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
959 if (!isset($this->tva[$vatrate])) {
960 $this->tva[$vatrate] = 0;
962 $this->tva[$vatrate] += $tvaligne;
963 $vatcode =
$object->lines[$i]->vat_src_code;
964 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
965 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
967 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
969 $nexY = max($nexY, $posYAfterImage);
973 $pdf->setPage($pageposafter);
974 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
976 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
977 $pdf->SetLineStyle(array(
'dash' => 0));
981 while ($pagenb < $pageposafter) {
982 $pdf->setPage($pagenb);
984 if ($pagenb == $pageposbeforeprintlines) {
985 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
987 $this->
_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
991 $pdf->setPage($pagenb);
992 $pdf->setPageOrientation(
'', 1, 0);
996 if (!empty($tplidx)) {
997 $pdf->useTemplate($tplidx);
1001 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
1003 if ($pagenb == $pageposafter) {
1004 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1006 $this->
_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
1011 if (!empty($tplidx)) {
1012 $pdf->useTemplate($tplidx);
1023 if ($pagenb == $pageposbeforeprintlines) {
1024 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code, $outputlangsbis);
1025 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1027 $this->
_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 0,
$object->multicurrency_code, $outputlangsbis);
1028 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1035 $posy = $this->
drawTotalTable($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1038 $listofpayments =
$object->getListOfPayments(
'', 0, 1);
1039 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1045 if (method_exists($pdf,
'AliasNbPages')) {
1046 $pdf->AliasNbPages();
1054 $pdf->Output($file,
'F');
1057 $hookmanager->initHooks(array(
'pdfgeneration'));
1058 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1060 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1062 $this->error = $hookmanager->error;
1063 $this->errors = $hookmanager->errors;
1068 $this->result = array(
'fullpath' => $file);
1072 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1076 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1099 $tab3_top = $posy + 8;
1102 if ($this->page_largeur < 210) {
1108 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1110 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1113 $pdf->SetFont(
'',
'', $default_font_size - 3);
1114 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1115 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1117 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1119 $pdf->SetFont(
'',
'', $default_font_size - 4);
1120 $pdf->SetXY($tab3_posx, $tab3_top);
1121 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1122 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1123 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1124 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1125 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1126 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1127 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1129 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1133 $pdf->SetFont(
'',
'', $default_font_size - 4);
1137 $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,";
1138 $sql .=
" re.description, re.fk_facture_source,";
1139 $sql .=
" f.type, f.datef";
1140 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1141 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1142 $resql = $this->db->query($sql);
1144 $num = $this->db->num_rows($resql);
1146 $invoice =
new Facture($this->db);
1149 $obj = $this->db->fetch_object($resql);
1151 if ($obj->type == 2) {
1152 $text = $outputlangs->transnoentities(
"CreditNote");
1153 } elseif ($obj->type == 3) {
1154 $text = $outputlangs->transnoentities(
"Deposit");
1155 } elseif ($obj->type == 0) {
1156 $text = $outputlangs->transnoentities(
"ExcessReceived");
1158 $text = $outputlangs->transnoentities(
"UnknownType");
1161 $invoice->fetch($obj->fk_facture_source);
1163 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1164 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1165 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1166 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1167 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1168 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1169 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1170 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1172 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1177 $this->error = $this->db->lasterror();
1183 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1185 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1186 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1187 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1189 $sql .=
" ORDER BY p.datep";
1191 $resql = $this->db->query($sql);
1193 $num = $this->db->num_rows($resql);
1198 $row = $this->db->fetch_object($resql);
1199 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1200 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1201 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1202 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1203 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1204 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1206 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1207 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1208 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1209 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1210 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1211 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1216 return $tab3_top + $y + 3;
1218 $this->error = $this->db->lasterror();
1236 global $conf, $mysoc, $hookmanager;
1240 $pdf->SetFont(
'',
'', $default_font_size - 1);
1243 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1244 $pdf->SetFont(
'',
'', $default_font_size - 2);
1245 $pdf->SetXY($this->marge_gauche, $posy);
1246 if ($mysoc->forme_juridique_code == 92) {
1247 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1249 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1252 $posy = $pdf->GetY() + 4;
1257 if ($this->page_largeur < 210) {
1263 $pdf->SetFont(
'',
'', $default_font_size - 2);
1264 $pdf->SetXY($this->marge_gauche, $posy);
1265 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1266 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1268 $pdf->SetFont(
'',
'', $default_font_size - 2);
1269 $pdf->SetXY($posxval, $posy);
1270 $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);
1271 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1272 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1274 $posy = $pdf->GetY() + 3;
1278 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1279 $pdf->SetFont(
'',
'', $default_font_size - 2);
1280 $pdf->SetXY($this->marge_gauche, $posy);
1281 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1282 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1284 $pdf->SetFont(
'',
'', $default_font_size - 2);
1285 $pdf->SetXY($posxval, $posy);
1286 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1287 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1289 $posy = $pdf->GetY() + 3;
1294 if (empty(
$object->mode_reglement_code)
1297 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1301 $outputlangs->load(
"errors");
1303 $pdf->SetXY($this->marge_gauche, $posy);
1304 $pdf->SetTextColor(200, 0, 0);
1305 $pdf->SetFont(
'',
'', $default_font_size - 2);
1306 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1307 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1308 $pdf->SetTextColor(0, 0, 0);
1310 $posy = $pdf->GetY() + 1;
1314 if (!empty(
$object->mode_reglement_code)
1315 &&
$object->mode_reglement_code !=
'CHQ'
1316 &&
$object->mode_reglement_code !=
'VIR') {
1317 $pdf->SetFont(
'',
'', $default_font_size - 2);
1318 $pdf->SetXY($this->marge_gauche, $posy);
1319 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1320 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1322 $pdf->SetFont(
'',
'', $default_font_size - 2);
1323 $pdf->SetXY($posxval, $posy);
1324 $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);
1327 if (
$object->mode_reglement_code ==
"PRE") {
1328 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1331 $bac->fetch(0,
'',
$object->thirdparty->id);
1332 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1333 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1336 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1338 $posy = $pdf->GetY();
1344 if ($this->emetteur->country_code ==
'FR') {
1346 $pdf->SetXY($this->marge_gauche, $posy);
1347 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1349 $posy = $pdf->GetY() + 1;
1354 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1355 $useonlinepayment = 0;
1359 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1360 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1361 $useonlinepayment = count($validpaymentmethod);
1366 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1369 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1370 $servicename = $langs->transnoentities(
'Online');
1371 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1372 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1374 $pdf->SetXY($this->marge_gauche, $posy);
1375 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1377 $posy = $pdf->GetY() + 1;
1382 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1385 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1388 $account =
new Account($this->db);
1391 $pdf->SetXY($this->marge_gauche, $posy);
1392 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1393 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1394 $posy = $pdf->GetY() + 1;
1397 $pdf->SetXY($this->marge_gauche, $posy);
1398 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1399 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1400 $posy = $pdf->GetY() + 2;
1403 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1404 $pdf->SetXY($this->marge_gauche, $posy);
1405 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1406 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1407 $posy = $pdf->GetY() + 1;
1410 $pdf->SetXY($this->marge_gauche, $posy);
1411 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1412 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1413 $posy = $pdf->GetY() + 2;
1420 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1426 $account =
new Account($this->db);
1427 $account->fetch($bankid);
1429 $curx = $this->marge_gauche;
1432 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1440 $qrCodeColor = array(
'25',
'25',
'25');
1444 'fgcolor' => $qrCodeColor,
1446 'module_width' => 1,
1447 'module_height' => 1
1450 $EPCQrCodeString =
$object->buildEPCQrCodeString();
1451 $pdf->write2DBarcode($EPCQrCodeString,
'QRCODE,M', $qrPosX, $qrPosY, 25, 25, $styleQr,
'N');
1453 $pdf->SetXY($qrPosX + 30, $posy + 5);
1454 $pdf->SetFont(
'',
'', $default_font_size - 5);
1455 $pdf->MultiCell(30, 3, $outputlangs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
1456 $posy = $pdf->GetY() + 2;
1461 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1464 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L', 0);
1487 global $conf, $mysoc, $hookmanager;
1498 if (is_object($outputlangsbis)) {
1499 $pdf->SetFont(
'',
'', $default_font_size - 2);
1501 $pdf->SetFont(
'',
'', $default_font_size - 1);
1507 if ($this->page_largeur < 210) {
1511 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1517 $parameters = array(
1519 'outputlangs' => $outputlangs,
1521 $hookmanager->executeHooks(
'beforePercentCalculation', $parameters, $this);
1526 foreach (
$object->lines as $line) {
1527 if ($line->product_type != 9) {
1528 $percent += $line->situation_percent;
1534 $avancementGlobal = $percent / $i;
1536 $avancementGlobal = 0;
1539 $object->fetchPreviousNextSituationInvoice();
1540 $TPreviousIncoice =
$object->tab_previous_situation_invoice;
1543 $total_a_payer_ttc = 0;
1544 foreach ($TPreviousIncoice as &$fac) {
1545 $total_a_payer += $fac->total_ht;
1546 $total_a_payer_ttc += $fac->total_ttc;
1548 $total_a_payer +=
$object->total_ht;
1549 $total_a_payer_ttc +=
$object->total_ttc;
1551 if (!empty($avancementGlobal)) {
1552 $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
1553 $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
1556 $total_a_payer_ttc = 0;
1560 if (!empty($TPreviousIncoice)) {
1561 $pdf->setY($tab2_top);
1562 $posy = $pdf->GetY();
1564 foreach ($TPreviousIncoice as &$fac) {
1565 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1570 $pdf->setY($this->tab_top_newpage);
1572 $pdf->setY($this->marge_haute);
1574 $posy = $pdf->GetY();
1579 $pdf->SetFillColor(255, 255, 255);
1580 $pdf->SetXY($col1x, $posy);
1581 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $fac->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1583 $pdf->SetXY($col2x, $posy);
1587 $facSign = $fac->total_ht >= 0 ?
'+' :
'';
1590 $displayAmount =
' '.$facSign.
' '.
price($fac->total_ht, 0, $outputlangs);
1592 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1601 $pdf->SetFillColor(255, 255, 255);
1602 $pdf->SetXY($col1x, $posy);
1603 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle",
$object->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1605 $pdf->SetXY($col2x, $posy);
1608 $facSign =
$object->total_ht >= 0 ?
'+' :
'';
1616 $displayAmount =
' '.$facSign.
' '.
price(
$object->total_ht, 0, $outputlangs);
1617 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1622 $pdf->SetFont(
'',
'', $default_font_size - 1);
1623 $pdf->SetFillColor(255, 255, 255);
1624 $pdf->SetXY($col1x, $posy);
1625 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"SituationTotalProgress", $avancementGlobal), 0,
'L', 1);
1627 $pdf->SetXY($col2x, $posy);
1628 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0,
'R', 1);
1629 $pdf->SetFont(
'',
'', $default_font_size - 2);
1633 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1637 $pdf->setY($this->tab_top_newpage);
1639 $pdf->setY($this->marge_haute);
1642 $posy = $pdf->GetY();
1653 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1656 $total_line_remise = 0;
1657 foreach (
$object->lines as $i => $line) {
1659 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1661 if ($line->total_ht < 0) {
1662 $total_line_remise += -$line->total_ht;
1665 if ($total_line_remise > 0) {
1666 $pdf->SetFillColor(255, 255, 255);
1667 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1668 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1669 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1670 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1675 $pdf->SetFillColor(255, 255, 255);
1676 $pdf->SetXY($col1x, $tab2_top);
1677 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1678 $pdf->SetXY($col2x, $tab2_top);
1679 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1685 $pdf->SetFillColor(255, 255, 255);
1686 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1687 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') ?
"TotalHT" :
"Total").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') ?
"TotalHT" :
"Total") :
''), 0,
'L', 1);
1689 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1690 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1691 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1694 $pdf->SetFillColor(248, 248, 248);
1696 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1698 $this->atleastoneratenotnull = 0;
1700 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1701 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1705 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1706 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1710 foreach ($localtax_rate as $tvakey => $tvaval) {
1715 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1718 if (preg_match(
'/\*/', (
string) $tvakey)) {
1719 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1720 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1723 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1727 $totalvat .= $tvacompl;
1729 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1732 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1734 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1736 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1737 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1743 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1744 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1748 foreach ($localtax_rate as $tvakey => $tvaval) {
1753 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1756 if (preg_match(
'/\*/', (
string) $tvakey)) {
1757 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1758 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1760 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1764 $totalvat .= $tvacompl;
1766 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1769 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1771 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1773 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1774 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1782 foreach ($this->tva as $tvakey => $tvaval) {
1783 $sum_pdf_tva += $tvaval;
1786 if ($sum_pdf_tva !=
$object->total_tva) {
1787 if (!empty($sum_pdf_tva)) {
1788 $coef_fix_tva =
$object->total_tva / $sum_pdf_tva;
1794 foreach ($this->tva as $tvakey => $tvaval) {
1795 $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1797 foreach ($this->tva_array as $tvakey => $tvaval) {
1798 $this->tva_array[$tvakey][
'amount'] = $tvaval[
'amount'] * $coef_fix_tva;
1804 foreach ($this->tva_array as $tvakey => $tvaval) {
1806 $this->atleastoneratenotnull++;
1809 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1812 if (preg_match(
'/\*/', $tvakey)) {
1813 $tvakey = str_replace(
'*',
'', $tvakey);
1814 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1816 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1819 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1821 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1823 $totalvat .= $tvacompl;
1825 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1827 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1829 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1830 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1835 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1836 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1840 foreach ($localtax_rate as $tvakey => $tvaval) {
1845 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1848 if (preg_match(
'/\*/', (
string) $tvakey)) {
1849 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1850 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1852 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1856 $totalvat .= $tvacompl;
1858 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1861 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1863 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1865 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1866 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1872 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1873 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1877 foreach ($localtax_rate as $tvakey => $tvaval) {
1883 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1886 if (preg_match(
'/\*/', (
string) $tvakey)) {
1887 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1888 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1890 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1894 $totalvat .= $tvacompl;
1896 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1899 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1901 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1903 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1904 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1912 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1913 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1915 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1916 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1921 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1922 $pdf->SetTextColor(0, 0, 60);
1923 $pdf->SetFillColor(224, 224, 224);
1924 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1926 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1927 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1931 if (
$object->displayRetainedWarranty()) {
1932 $pdf->SetTextColor(40, 40, 40);
1933 $pdf->SetFillColor(255, 255, 255);
1935 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1936 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1940 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1941 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1943 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1944 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1948 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1950 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1951 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1953 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1954 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1955 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1960 $pdf->SetTextColor(0, 0, 0);
1962 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1963 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1965 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1970 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1973 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1974 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"Paid") :
''), 0,
'L', 0);
1975 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1976 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1979 if ($creditnoteamount) {
1980 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1981 $labeltouse .= (is_object($outputlangsbis) ? (
' / '.(($outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities(
"CreditNotes"))) :
'');
1983 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1984 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1985 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1986 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1989 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1991 $pdf->SetFillColor(255, 255, 255);
1993 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1994 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"EscompteOfferedShort") :
''), $useborder,
'L', 1);
1995 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1996 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT'), 0, $outputlangs), $useborder,
'R', 1);
2002 $pdf->SetTextColor(0, 0, 60);
2003 $pdf->SetFillColor(224, 224, 224);
2004 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
2005 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
2006 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
2007 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
2009 $pdf->SetFont(
'',
'', $default_font_size - 1);
2010 $pdf->SetTextColor(0, 0, 0);
2013 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
2015 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
2017 $this->error = $hookmanager->error;
2018 $this->errors = $hookmanager->errors;
2022 return ($tab2_top + ($tab2_hl * $index));
2118 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2121 global $conf, $langs;
2123 $ltrdirection =
'L';
2124 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2125 $ltrdirection =
'R';
2129 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2135 $pdf->SetTextColor(0, 0, 60);
2136 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2140 $posy = $this->marge_haute;
2141 $posx = $this->page_largeur - $this->marge_droite - $w;
2143 $pdf->SetXY($this->marge_gauche, $posy);
2147 if ($this->emetteur->logo) {
2148 $logodir = $conf->mycompany->dir_output;
2149 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
2150 $logodir = $conf->mycompany->multidir_output[
$object->entity];
2153 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2155 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2157 if (is_readable($logo)) {
2159 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2161 $pdf->SetTextColor(200, 0, 0);
2162 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2163 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2164 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2167 $text = $this->emetteur->name;
2168 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2172 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2173 $pdf->SetXY($posx, $posy);
2174 $pdf->SetTextColor(0, 0, 60);
2175 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2177 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2180 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2183 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2186 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2188 if ($this->situationinvoice) {
2189 $langs->loadLangs(array(
"other"));
2190 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
2192 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2195 if ($this->situationinvoice) {
2196 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2198 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2199 } elseif (
$object->type == 1) {
2200 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2201 } elseif (
$object->type == 2) {
2202 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2203 } elseif (
$object->type == 3) {
2204 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2205 } elseif (
$object->type == 4) {
2206 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2209 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2210 if (
$object->status == $object::STATUS_DRAFT) {
2211 $pdf->SetTextColor(128, 0, 0);
2212 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2215 $pdf->MultiCell($w, 3, $title,
'',
'R');
2217 $pdf->SetFont(
'',
'B', $default_font_size);
2231 $pdf->SetFont(
'',
'', $default_font_size - 2);
2235 $pdf->SetXY($posx, $posy);
2236 $pdf->SetTextColor(0, 0, 60);
2237 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2242 if (!empty(
$object->project->ref)) {
2244 $pdf->SetXY($posx, $posy);
2245 $pdf->SetTextColor(0, 0, 60);
2246 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2252 if (!empty(
$object->project->ref)) {
2253 $outputlangs->load(
"projects");
2255 $pdf->SetXY($posx, $posy);
2256 $pdf->SetTextColor(0, 0, 60);
2257 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2261 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2262 if (
$object->type == 0 && $objectidnext) {
2263 $objectreplacing =
new Facture($this->db);
2264 $objectreplacing->fetch($objectidnext);
2267 $pdf->SetXY($posx, $posy);
2268 $pdf->SetTextColor(0, 0, 60);
2269 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2272 $objectreplaced =
new Facture($this->db);
2273 $objectreplaced->fetch(
$object->fk_facture_source);
2276 $pdf->SetXY($posx, $posy);
2277 $pdf->SetTextColor(0, 0, 60);
2278 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2281 $objectreplaced =
new Facture($this->db);
2282 $objectreplaced->fetch(
$object->fk_facture_source);
2285 $pdf->SetXY($posx, $posy);
2286 $pdf->SetTextColor(0, 0, 60);
2287 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2291 $pdf->SetXY($posx, $posy);
2292 $pdf->SetTextColor(0, 0, 60);
2294 $title = $outputlangs->transnoentities(
"DateInvoice");
2295 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2296 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2298 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2302 $pdf->SetXY($posx, $posy);
2303 $pdf->SetTextColor(0, 0, 60);
2304 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2309 $pdf->SetXY($posx, $posy);
2310 $pdf->SetTextColor(0, 0, 60);
2311 $title = $outputlangs->transnoentities(
"DateDue");
2312 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2313 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2315 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2320 $pdf->SetXY($posx, $posy);
2321 $pdf->SetTextColor(0, 0, 60);
2322 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2327 $pdf->SetXY($posx, $posy);
2328 $pdf->SetTextColor(0, 0, 60);
2329 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
2334 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2335 if (count($arrayidcontact) > 0) {
2336 $usertmp =
new User($this->db);
2337 $usertmp->fetch($arrayidcontact[0]);
2339 $pdf->SetXY($posx, $posy);
2340 $pdf->SetTextColor(0, 0, 60);
2341 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2350 $current_y = $pdf->getY();
2352 if ($current_y < $pdf->getY()) {
2353 $top_shift = $pdf->getY() - $current_y;
2358 $carac_emetteur =
'';
2360 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2361 if (count($arrayidcontact) > 0) {
2362 $object->fetch_user($arrayidcontact[0]);
2363 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2364 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2365 $carac_emetteur .=
"\n";
2372 $posy += $top_shift;
2373 $posx = $this->marge_gauche;
2375 $posx = $this->page_largeur - $this->marge_droite - 80;
2383 $pdf->SetTextColor(0, 0, 0);
2384 $pdf->SetFont(
'',
'', $default_font_size - 2);
2385 $pdf->SetXY($posx, $posy - 5);
2386 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2387 $pdf->SetXY($posx, $posy);
2388 $pdf->SetFillColor(230, 230, 230);
2389 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2390 $pdf->SetTextColor(0, 0, 60);
2395 $pdf->SetXY($posx + 2, $posy + 3);
2396 $pdf->SetFont(
'',
'B', $default_font_size);
2397 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2398 $posy = $pdf->getY();
2402 $pdf->SetXY($posx + 2, $posy);
2403 $pdf->SetFont(
'',
'', $default_font_size - 1);
2404 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2407 $usecontact =
false;
2408 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2409 if (count($arrayidcontact) > 0) {
2411 $result =
$object->fetch_contact($arrayidcontact[0]);
2415 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2416 $thirdparty =
$object->contact;
2418 $thirdparty =
$object->thirdparty;
2428 if ($this->page_largeur < 210) {
2432 $posy += $top_shift;
2433 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2435 $posx = $this->marge_gauche;
2440 $pdf->SetTextColor(0, 0, 0);
2441 $pdf->SetFont(
'',
'', $default_font_size - 2);
2442 $pdf->SetXY($posx + 2, $posy - 5);
2443 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2444 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2448 $pdf->SetXY($posx + 2, $posy + 3);
2449 $pdf->SetFont(
'',
'B', $default_font_size);
2451 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2453 $posy = $pdf->getY();
2456 $pdf->SetFont(
'',
'', $default_font_size - 1);
2457 $pdf->SetXY($posx + 2, $posy);
2459 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2463 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2465 if (!empty($idaddressshipping)) {
2466 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2467 $companystatic =
new Societe($this->db);
2468 $companystatic->fetch(
$object->contact->fk_soc);
2470 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
2475 if (!empty($carac_client_shipping)) {
2476 $posy += $hautcadre;
2481 $pdf->SetXY($posx + 2, $posy - 5);
2482 $pdf->SetFont(
'',
'', $default_font_size - 2);
2483 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2484 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2487 $pdf->SetXY($posx + 2, $posy + 3);
2488 $pdf->SetFont(
'',
'B', $default_font_size);
2489 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2491 $posy = $pdf->getY();
2494 $pdf->SetXY($posx + 2, $posy);
2495 $pdf->SetFont(
'',
'', $default_font_size - 1);
2496 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2498 $shipp_shift += $hautcadre + 10;
2503 $pdf->SetTextColor(0, 0, 0);
2505 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);