197 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
200 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
202 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
204 if (!is_object($outputlangs)) {
205 $outputlangs = $langs;
209 $outputlangs->charset_output =
'ISO-8859-1';
213 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
215 global $outputlangsbis;
216 $outputlangsbis =
null;
218 $outputlangsbis =
new Translate(
'', $conf);
220 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
228 $nblines = count(
$object->lines);
236 $realpatharray = array();
237 $this->atleastonephoto =
false;
239 $objphoto =
new Product($this->db);
241 for ($i = 0; $i < $nblines; $i++) {
242 if (empty(
$object->lines[$i]->fk_product)) {
246 $objphoto->fetch(
$object->lines[$i]->fk_product);
250 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
251 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
253 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
254 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
258 foreach ($pdir as $midir) {
260 if ($conf->entity != $objphoto->entity) {
261 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
263 $dir = $conf->product->dir_output.
'/'.$midir;
266 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
268 if ($obj[
'photo_vignette']) {
269 $filename = $obj[
'photo_vignette'];
271 $filename = $obj[
'photo'];
274 $filename = $obj[
'photo'];
277 $realpath = $dir.$filename;
279 $this->atleastonephoto =
true;
284 if ($realpath && $arephoto) {
285 $realpatharray[$i] = $realpath;
292 if ($conf->facture->multidir_output[$conf->entity]) {
295 $deja_regle =
$object->getSommePaiement((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
296 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
297 $amount_deposits_included =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
301 $dir = $conf->facture->multidir_output[$conf->entity];
302 $file = $dir.
"/SPECIMEN.pdf";
305 $dir = $conf->facture->multidir_output[
$object->entity].
"/".$objectref;
306 $file = $dir.
"/".$objectref.
".pdf";
308 if (!file_exists($dir)) {
310 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
315 if (file_exists($dir)) {
317 if (!is_object($hookmanager)) {
318 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
321 $hookmanager->initHooks(array(
'pdfgeneration'));
322 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
324 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
327 $nblines = count(
$object->lines);
328 $nbpayments = count(
$object->getListOfPayments());
333 $pdf->SetAutoPageBreak(1, 0);
335 $this->heightforinfotot = 50 + (4 * $nbpayments);
336 $this->heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
337 $this->heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
339 $heightforqrinvoice = $heightforqrinvoice_firstpage = 0;
343 $this->heightforinfotot = 30 + (4 * $nbpayments);
347 if (class_exists(
'TCPDF')) {
348 $pdf->setPrintHeader(
false);
349 $pdf->setPrintFooter(
false);
355 $logodir = $conf->mycompany->dir_output;
356 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
357 $logodir = $conf->mycompany->multidir_output[
$object->entity];
359 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
360 $tplidx = $pdf->importPage(1);
365 $pdf->SetDrawColor(128, 128, 128);
367 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
368 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
369 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
370 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
371 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
373 $pdf->SetCompression(
false);
377 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
378 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
384 $certprivate = !
getDolGlobalString(
'CERTIFICATE_CRT_PRIVATE') ?
'' : $conf->global->CERTIFICATE_CRT_PRIVATE;
389 'Name' => $this->emetteur->name,
390 'Location' =>
getCountry($this->emetteur->country_code, 0),
391 'Reason' =>
'INVOICE',
392 'ContactInfo' => $this->emetteur->email
394 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
398 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
402 $categoryOfOperation = 0;
405 for ($i = 0; $i < $nblines; $i++) {
406 if (
$object->lines[$i]->remise_percent) {
407 $this->atleastonediscount++;
411 if ($categoryOfOperation < 2) {
412 $lineProductType =
$object->lines[$i]->product_type;
418 if ($nbProduct > 0 && $nbService > 0) {
420 $categoryOfOperation = 2;
425 if ($categoryOfOperation <= 0) {
427 if ($nbProduct == 0 && $nbService > 0) {
428 $categoryOfOperation = 1;
431 $this->categoryOfOperation = $categoryOfOperation;
434 if (
$object->situation_cycle_ref) {
435 $this->situationinvoice =
true;
440 if (!empty($tplidx)) {
441 $pdf->useTemplate($tplidx);
446 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
447 $top_shift = $pagehead[
'top_shift'];
448 $shipp_shift = $pagehead[
'shipp_shift'];
449 $pdf->SetFont(
'',
'', $default_font_size - 1);
450 $pdf->MultiCell(0, 3,
'');
451 $pdf->SetTextColor(0, 0, 0);
456 $this->tab_top = 90 + $top_shift + $shipp_shift;
457 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
460 $extra_under_address_shift = 0;
463 $qrcodestring =
$object->buildZATCAQRString();
466 $qrcodestring =
$object->buildSwitzerlandQRString();
470 $qrcodestring =
$object->buildEPCQrCodeString();
475 $qrcodecolor = array(
'25',
'25',
'25');
480 'fgcolor' => $qrcodecolor,
485 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
489 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
490 $pdf->SetFont(
'',
'', $default_font_size - 4);
491 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
495 $extra_under_address_shift += 25;
503 'outputlangs' => $outputlangs,
504 'hidedetails' => $hidedetails
506 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
507 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
508 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
511 $this->tab_top += $extra_under_address_shift;
512 $this->tab_top_newpage += 0;
516 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->
getHeightForQRInvoice(1,
$object, $langs);
518 $nexY = $this->tab_top - 1;
521 $height_incoterms = 0;
522 if (isModEnabled(
'incoterm')) {
523 $desc_incoterms =
$object->getIncotermsForPDF();
524 if ($desc_incoterms) {
527 $pdf->SetFont(
'',
'', $default_font_size - 1);
528 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
529 $nexY = max($pdf->GetY(), $nexY);
530 $height_incoterms = $nexY - $this->tab_top;
533 $pdf->SetDrawColor(192, 192, 192);
534 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
536 $this->tab_top = $nexY + 6;
537 $height_incoterms += 4;
542 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
545 if (is_object(
$object->thirdparty)) {
546 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
547 $salerepobj =
new User($this->db);
548 $salerepobj->fetch($salereparray[0][
'id']);
549 if (!empty($salerepobj->signature)) {
550 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
556 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
557 if (!empty($extranote)) {
561 $pagenb = $pdf->getPage();
565 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
566 $pageposbeforenote = $pagenb;
573 $pdf->startTransaction();
575 $pdf->SetFont(
'',
'', $default_font_size - 1);
576 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
578 $pageposafternote = $pdf->getPage();
579 $posyafter = $pdf->GetY();
581 if ($pageposafternote > $pageposbeforenote) {
582 $pdf->rollbackTransaction(
true);
585 while ($pagenb < $pageposafternote) {
588 if (!empty($tplidx)) {
589 $pdf->useTemplate($tplidx);
594 $pdf->setTopMargin($this->tab_top_newpage);
596 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
600 $pdf->setPage($pageposbeforenote);
601 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
602 $pdf->SetFont(
'',
'', $default_font_size - 1);
603 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
604 $pageposafternote = $pdf->getPage();
606 $posyafter = $pdf->GetY();
608 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
609 $pdf->AddPage(
'',
'',
true);
612 $pdf->setPage($pageposafternote);
613 $pdf->setTopMargin($this->tab_top_newpage);
615 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
621 $i = $pageposbeforenote;
622 while ($i < $pageposafternote) {
626 $pdf->SetDrawColor(128, 128, 128);
628 if ($i > $pageposbeforenote) {
629 $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
630 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
632 $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
633 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
637 $pdf->setPageOrientation(
'', 1, 0);
644 $pdf->setPage($pageposafternote);
645 if (!empty($tplidx)) {
646 $pdf->useTemplate($tplidx);
651 $height_note = $posyafter - $this->tab_top_newpage;
652 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
655 $pdf->commitTransaction();
656 $posyafter = $pdf->GetY();
657 $height_note = $posyafter - $this->tab_top;
658 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
661 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
663 $pdf->AddPage(
'',
'',
true);
666 $pdf->setPage($pageposafternote);
667 if (!empty($tplidx)) {
668 $pdf->useTemplate($tplidx);
674 $posyafter = $this->tab_top_newpage;
678 $tab_height = $tab_height - $height_note;
679 $this->tab_top = $posyafter + 6;
688 $pdf->startTransaction();
689 $this->
pdfTabTitles($pdf, $this->tab_top, $tab_height, $outputlangs, $hidetop);
690 $pdf->rollbackTransaction(
true);
692 $nexY = $this->tab_top + $this->tabTitleHeight;
695 $pageposbeforeprintlines = $pdf->getPage();
696 $pagenb = $pageposbeforeprintlines;
697 for ($i = 0; $i < $nblines; $i++) {
699 $pdf->SetFont(
'',
'', $default_font_size - 1);
700 $pdf->SetTextColor(0, 0, 0);
703 $imglinesize = array();
704 if (!empty($realpatharray[$i])) {
708 $pdf->setTopMargin($this->tab_top_newpage);
709 $page_bottom_margin = $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(),
$object, $langs);
710 $pdf->setPageOrientation(
'', 1, $page_bottom_margin);
711 $pageposbefore = $pdf->getPage();
713 $showpricebeforepagebreak = 1;
715 $posYAfterDescription = 0;
723 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
724 $pdf->AddPage(
'',
'',
true);
725 if (!empty($tplidx)) {
726 $pdf->useTemplate($tplidx);
728 $pdf->setPage($pageposbefore + 1);
730 $curY = $this->tab_top_newpage;
734 $showpricebeforepagebreak = 1;
736 $showpricebeforepagebreak = 0;
740 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
741 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
743 $posYAfterImage = $curY + $imglinesize[
'height'];
749 $pdf->startTransaction();
752 $pageposafter = $pdf->getPage();
754 if ($pageposafter > $pageposbefore) {
755 $pdf->rollbackTransaction(
true);
756 $pageposafter = $pageposbefore;
757 $pdf->setPageOrientation(
'', 1, $this->heightforfooter);
761 $pageposafter = $pdf->getPage();
762 $posyafter = $pdf->GetY();
764 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
765 if ($i == ($nblines - 1)) {
766 $pdf->AddPage(
'',
'',
true);
767 if (!empty($tplidx)) {
768 $pdf->useTemplate($tplidx);
770 $pdf->setPage($pageposafter + 1);
776 $showpricebeforepagebreak = 1;
778 $showpricebeforepagebreak = 0;
782 $pdf->commitTransaction();
784 $posYAfterDescription = $pdf->GetY();
787 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
789 $pageposafter = $pdf->getPage();
790 $pdf->setPage($pageposbefore);
791 $pdf->setTopMargin($this->marge_haute);
792 $pdf->setPageOrientation(
'', 1, 0);
795 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
796 $pdf->setPage($pageposafter);
797 $curY = $this->tab_top_newpage;
800 $pdf->SetFont(
'',
'', $default_font_size - 1);
806 $nexY = max($pdf->GetY(), $nexY);
813 $nexY = max($pdf->GetY(), $nexY);
821 $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);
860 if (!empty(
$object->lines[$i]->array_options)) {
861 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
865 $nexY = max($pdf->GetY(), $nexY);
877 'outputlangs' => $outputlangs,
878 'hidedetails' => $hidedetails
880 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
888 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
889 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
890 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
891 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
893 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
896 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
897 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
899 $tvaligne = $sign *
$object->lines[$i]->total_tva;
903 $localtax1ligne =
$object->lines[$i]->total_localtax1;
904 $localtax2ligne =
$object->lines[$i]->total_localtax2;
905 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
906 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
907 $localtax1_type =
$object->lines[$i]->localtax1_type;
908 $localtax2_type =
$object->lines[$i]->localtax2_type;
921 $vatrate = (string)
$object->lines[$i]->tva_tx;
924 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
925 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
927 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
928 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
932 if ($localtax1_type && $localtax1ligne != 0) {
933 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
934 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
936 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
939 if ($localtax2_type && $localtax2ligne != 0) {
940 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
941 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
943 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
947 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
952 if (!isset($this->tva[$vatrate])) {
953 $this->tva[$vatrate] = 0;
955 $this->tva[$vatrate] += $tvaligne;
956 $vatcode =
$object->lines[$i]->vat_src_code;
957 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
958 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
960 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
962 $nexY = max($nexY, $posYAfterImage);
966 $pdf->setPage($pageposafter);
967 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
969 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
970 $pdf->SetLineStyle(array(
'dash' => 0));
974 while ($pagenb < $pageposafter) {
975 $pdf->setPage($pagenb);
977 if ($pagenb == $pageposbeforeprintlines) {
978 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
980 $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);
984 $pdf->setPage($pagenb);
985 $pdf->setPageOrientation(
'', 1, 0);
989 if (!empty($tplidx)) {
990 $pdf->useTemplate($tplidx);
994 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
996 if ($pagenb == $pageposafter) {
997 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
999 $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);
1004 if (!empty($tplidx)) {
1005 $pdf->useTemplate($tplidx);
1016 if ($pagenb == $pageposbeforeprintlines) {
1017 $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);
1018 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1020 $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);
1021 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1028 $posy = $this->
drawTotalTable($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1031 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1037 if (method_exists($pdf,
'AliasNbPages')) {
1038 $pdf->AliasNbPages();
1046 $pdf->Output($file,
'F');
1049 $hookmanager->initHooks(array(
'pdfgeneration'));
1050 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1052 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1054 $this->error = $hookmanager->error;
1055 $this->errors = $hookmanager->errors;
1060 $this->result = array(
'fullpath' => $file);
1064 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1068 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1093 $tab3_top = $posy + 8;
1096 if ($this->page_largeur < 210) {
1102 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1104 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1107 $pdf->SetFont(
'',
'', $default_font_size - 3);
1108 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1109 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1111 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1113 $pdf->SetFont(
'',
'', $default_font_size - 4);
1114 $pdf->SetXY($tab3_posx, $tab3_top);
1115 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1116 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1117 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1118 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1119 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1120 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1121 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1123 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1127 $pdf->SetFont(
'',
'', $default_font_size - 4);
1131 $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,";
1132 $sql .=
" re.description, re.fk_facture_source,";
1133 $sql .=
" f.type, f.datef";
1134 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1135 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1136 $resql = $this->db->query($sql);
1138 $num = $this->db->num_rows($resql);
1140 $invoice =
new Facture($this->db);
1143 $obj = $this->db->fetch_object($resql);
1145 if ($obj->type == 2) {
1146 $text = $outputlangs->transnoentities(
"CreditNote");
1147 } elseif ($obj->type == 3) {
1148 $text = $outputlangs->transnoentities(
"Deposit");
1149 } elseif ($obj->type == 0) {
1150 $text = $outputlangs->transnoentities(
"ExcessReceived");
1152 $text = $outputlangs->transnoentities(
"UnknownType");
1155 $invoice->fetch($obj->fk_facture_source);
1157 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1158 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1159 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1160 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1161 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1162 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1163 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1164 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1166 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1171 $this->error = $this->db->lasterror();
1177 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1179 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1180 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1181 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1183 $sql .=
" ORDER BY p.datep";
1185 $resql = $this->db->query($sql);
1187 $num = $this->db->num_rows($resql);
1192 $row = $this->db->fetch_object($resql);
1193 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1194 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1195 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1196 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1197 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1198 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1200 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1201 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1202 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1203 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1204 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1205 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1210 return $tab3_top + $y + 3;
1212 $this->error = $this->db->lasterror();
1230 global $conf, $mysoc, $hookmanager;
1234 $pdf->SetFont(
'',
'', $default_font_size - 1);
1237 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1238 $pdf->SetFont(
'',
'', $default_font_size - 2);
1239 $pdf->SetXY($this->marge_gauche, $posy);
1240 if ($mysoc->forme_juridique_code == 92) {
1241 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1243 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1246 $posy = $pdf->GetY() + 4;
1251 if ($this->page_largeur < 210) {
1257 $pdf->SetFont(
'',
'', $default_font_size - 2);
1258 $pdf->SetXY($this->marge_gauche, $posy);
1259 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1260 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1262 $pdf->SetFont(
'',
'', $default_font_size - 2);
1263 $pdf->SetXY($posxval, $posy);
1264 $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);
1265 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1266 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1268 $posy = $pdf->GetY() + 3;
1272 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1273 $pdf->SetFont(
'',
'', $default_font_size - 2);
1274 $pdf->SetXY($this->marge_gauche, $posy);
1275 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1276 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1278 $pdf->SetFont(
'',
'', $default_font_size - 2);
1279 $pdf->SetXY($posxval, $posy);
1280 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1281 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1283 $posy = $pdf->GetY() + 3;
1288 if (empty(
$object->mode_reglement_code)
1291 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1295 $outputlangs->load(
"errors");
1297 $pdf->SetXY($this->marge_gauche, $posy);
1298 $pdf->SetTextColor(200, 0, 0);
1299 $pdf->SetFont(
'',
'', $default_font_size - 2);
1300 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1301 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1302 $pdf->SetTextColor(0, 0, 0);
1304 $posy = $pdf->GetY() + 1;
1308 if (!empty(
$object->mode_reglement_code)
1309 &&
$object->mode_reglement_code !=
'CHQ'
1310 &&
$object->mode_reglement_code !=
'VIR') {
1311 $pdf->SetFont(
'',
'', $default_font_size - 2);
1312 $pdf->SetXY($this->marge_gauche, $posy);
1313 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1314 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1316 $pdf->SetFont(
'',
'', $default_font_size - 2);
1317 $pdf->SetXY($posxval, $posy);
1318 $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);
1321 if (
$object->mode_reglement_code ==
"PRE") {
1322 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1325 $bac->fetch(0,
'',
$object->thirdparty->id);
1326 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1327 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1330 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1332 $posy = $pdf->GetY();
1338 if ($this->emetteur->country_code ==
'FR') {
1340 $pdf->SetXY($this->marge_gauche, $posy);
1341 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1343 $posy = $pdf->GetY() + 1;
1348 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1349 $useonlinepayment = 0;
1353 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1354 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1355 $useonlinepayment = count($validpaymentmethod);
1360 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1363 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1364 $servicename = $langs->transnoentities(
'Online');
1365 $paiement_url = getOnlinePaymentUrl(
'',
'invoice',
$object->ref,
'',
'',
'');
1366 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1368 $pdf->SetXY($this->marge_gauche, $posy);
1369 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1371 $posy = $pdf->GetY() + 1;
1376 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1379 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1382 $account =
new Account($this->db);
1385 $pdf->SetXY($this->marge_gauche, $posy);
1386 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1387 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1388 $posy = $pdf->GetY() + 1;
1391 $pdf->SetXY($this->marge_gauche, $posy);
1392 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1393 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1394 $posy = $pdf->GetY() + 2;
1397 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1398 $pdf->SetXY($this->marge_gauche, $posy);
1399 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1400 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1401 $posy = $pdf->GetY() + 1;
1404 $pdf->SetXY($this->marge_gauche, $posy);
1405 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1406 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1407 $posy = $pdf->GetY() + 2;
1414 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1420 $account =
new Account($this->db);
1421 $account->fetch($bankid);
1423 $curx = $this->marge_gauche;
1426 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1434 $qrCodeColor = array(
'25',
'25',
'25');
1438 'fgcolor' => $qrCodeColor,
1440 'module_width' => 1,
1441 'module_height' => 1
1444 $EPCQrCodeString =
$object->buildEPCQrCodeString();
1445 $pdf->write2DBarcode($EPCQrCodeString,
'QRCODE,M', $qrPosX, $qrPosY, 25, 25, $styleQr,
'N');
1447 $pdf->SetXY($qrPosX + 5, $posy);
1448 $pdf->SetFont(
'',
'', $default_font_size - 5);
1449 $pdf->MultiCell(30, 3, $langs->trans(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
1450 $posy = $pdf->GetY() + 2;
1473 global $conf, $mysoc, $hookmanager;
1484 if (is_object($outputlangsbis)) {
1485 $pdf->SetFont(
'',
'', $default_font_size - 2);
1487 $pdf->SetFont(
'',
'', $default_font_size - 1);
1493 if ($this->page_largeur < 210) {
1497 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1503 $parameters = array(
1505 'outputlangs' => $outputlangs,
1507 $hookmanager->executeHooks(
'beforePercentCalculation', $parameters, $this);
1512 foreach (
$object->lines as $line) {
1513 if ($line->product_type != 9) {
1514 $percent += $line->situation_percent;
1520 $avancementGlobal = $percent / $i;
1522 $avancementGlobal = 0;
1525 $object->fetchPreviousNextSituationInvoice();
1526 $TPreviousIncoice =
$object->tab_previous_situation_invoice;
1529 $total_a_payer_ttc = 0;
1530 foreach ($TPreviousIncoice as &$fac) {
1531 $total_a_payer += $fac->total_ht;
1532 $total_a_payer_ttc += $fac->total_ttc;
1534 $total_a_payer +=
$object->total_ht;
1535 $total_a_payer_ttc +=
$object->total_ttc;
1537 if (!empty($avancementGlobal)) {
1538 $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
1539 $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
1542 $total_a_payer_ttc = 0;
1546 if (!empty($TPreviousIncoice)) {
1547 $pdf->setY($tab2_top);
1548 $posy = $pdf->GetY();
1550 foreach ($TPreviousIncoice as &$fac) {
1551 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1556 $pdf->setY($this->tab_top_newpage);
1558 $pdf->setY($this->marge_haute);
1560 $posy = $pdf->GetY();
1565 $pdf->SetFillColor(255, 255, 255);
1566 $pdf->SetXY($col1x, $posy);
1567 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $fac->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1569 $pdf->SetXY($col2x, $posy);
1573 $facSign = $fac->total_ht >= 0 ?
'+' :
'';
1576 $displayAmount =
' '.$facSign.
' '.
price($fac->total_ht, 0, $outputlangs);
1578 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1587 $pdf->SetFillColor(255, 255, 255);
1588 $pdf->SetXY($col1x, $posy);
1589 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle",
$object->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1591 $pdf->SetXY($col2x, $posy);
1594 $facSign =
$object->total_ht >= 0 ?
'+' :
'';
1602 $displayAmount =
' '.$facSign.
' '.
price(
$object->total_ht, 0, $outputlangs);
1603 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1608 $pdf->SetFont(
'',
'', $default_font_size - 1);
1609 $pdf->SetFillColor(255, 255, 255);
1610 $pdf->SetXY($col1x, $posy);
1611 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"SituationTotalProgress", $avancementGlobal), 0,
'L', 1);
1613 $pdf->SetXY($col2x, $posy);
1614 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0,
'R', 1);
1615 $pdf->SetFont(
'',
'', $default_font_size - 2);
1619 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1623 $pdf->setY($this->tab_top_newpage);
1625 $pdf->setY($this->marge_haute);
1628 $posy = $pdf->GetY();
1639 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1642 $total_line_remise = 0;
1643 foreach (
$object->lines as $i => $line) {
1645 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1647 if ($line->total_ht < 0) {
1648 $total_line_remise += -$line->total_ht;
1651 if ($total_line_remise > 0) {
1653 $pdf->SetFillColor(255, 255, 255);
1654 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1655 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1656 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1657 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1663 $pdf->SetFillColor(255, 255, 255);
1664 $pdf->SetXY($col1x, $tab2_top);
1665 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1666 $pdf->SetXY($col2x, $tab2_top);
1667 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1674 $pdf->SetFillColor(255, 255, 255);
1675 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1676 $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);
1678 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1679 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1680 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1683 $pdf->SetFillColor(248, 248, 248);
1685 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1687 $this->atleastoneratenotnull = 0;
1689 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1690 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1694 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1695 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1699 foreach ($localtax_rate as $tvakey => $tvaval) {
1704 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1707 if (preg_match(
'/\*/', (
string) $tvakey)) {
1708 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1709 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1712 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1716 $totalvat .= $tvacompl;
1718 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1721 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1723 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1725 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1726 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1732 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1733 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1737 foreach ($localtax_rate as $tvakey => $tvaval) {
1742 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1745 if (preg_match(
'/\*/', (
string) $tvakey)) {
1746 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1747 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1749 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1753 $totalvat .= $tvacompl;
1755 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1758 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1760 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1762 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1763 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1771 foreach ($this->tva as $tvakey => $tvaval) {
1772 $sum_pdf_tva += $tvaval;
1775 if ($sum_pdf_tva !=
$object->total_tva) {
1776 if (!empty($sum_pdf_tva)) {
1777 $coef_fix_tva =
$object->total_tva / $sum_pdf_tva;
1783 foreach ($this->tva as $tvakey => $tvaval) {
1784 $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1786 foreach ($this->tva_array as $tvakey => $tvaval) {
1787 $this->tva_array[$tvakey][
'amount'] = $tvaval[
'amount'] * $coef_fix_tva;
1793 foreach ($this->tva_array as $tvakey => $tvaval) {
1795 $this->atleastoneratenotnull++;
1798 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1801 if (preg_match(
'/\*/', $tvakey)) {
1802 $tvakey = str_replace(
'*',
'', $tvakey);
1803 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1805 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1808 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1810 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1812 $totalvat .= $tvacompl;
1814 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1816 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1818 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1819 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1824 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1825 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1829 foreach ($localtax_rate as $tvakey => $tvaval) {
1834 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1837 if (preg_match(
'/\*/', (
string) $tvakey)) {
1838 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1839 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1841 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1845 $totalvat .= $tvacompl;
1847 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1850 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1852 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1854 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1855 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1861 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1862 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1866 foreach ($localtax_rate as $tvakey => $tvaval) {
1872 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1875 if (preg_match(
'/\*/', (
string) $tvakey)) {
1876 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1877 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1879 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1883 $totalvat .= $tvacompl;
1885 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1888 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1890 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1892 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1893 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1901 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1902 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1904 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1905 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1910 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1911 $pdf->SetTextColor(0, 0, 60);
1912 $pdf->SetFillColor(224, 224, 224);
1913 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1915 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1916 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1920 if (
$object->displayRetainedWarranty()) {
1921 $pdf->SetTextColor(40, 40, 40);
1922 $pdf->SetFillColor(255, 255, 255);
1924 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1925 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1929 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1930 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1932 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1933 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1937 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1939 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1940 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1942 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1943 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1944 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1949 $pdf->SetTextColor(0, 0, 0);
1951 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1952 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1954 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1959 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1962 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1963 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"Paid") :
''), 0,
'L', 0);
1964 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1965 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1968 if ($creditnoteamount) {
1969 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1970 $labeltouse .= (is_object($outputlangsbis) ? (
' / '.(($outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities(
"CreditNotes"))) :
'');
1972 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1973 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1974 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1975 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1978 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1980 $pdf->SetFillColor(255, 255, 255);
1982 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1983 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"EscompteOfferedShort") :
''), $useborder,
'L', 1);
1984 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1985 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT'), 0, $outputlangs), $useborder,
'R', 1);
1991 $pdf->SetTextColor(0, 0, 60);
1992 $pdf->SetFillColor(224, 224, 224);
1993 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1994 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1995 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1996 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1998 $pdf->SetFont(
'',
'', $default_font_size - 1);
1999 $pdf->SetTextColor(0, 0, 0);
2002 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
2004 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
2006 $this->error = $hookmanager->error;
2007 $this->errors = $hookmanager->errors;
2011 return ($tab2_top + ($tab2_hl * $index));
2107 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2110 global $conf, $langs;
2112 $ltrdirection =
'L';
2113 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2114 $ltrdirection =
'R';
2118 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2124 $pdf->SetTextColor(0, 0, 60);
2125 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2129 $posy = $this->marge_haute;
2130 $posx = $this->page_largeur - $this->marge_droite - $w;
2132 $pdf->SetXY($this->marge_gauche, $posy);
2136 if ($this->emetteur->logo) {
2137 $logodir = $conf->mycompany->dir_output;
2138 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
2139 $logodir = $conf->mycompany->multidir_output[
$object->entity];
2142 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2144 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2146 if (is_readable($logo)) {
2148 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2150 $pdf->SetTextColor(200, 0, 0);
2151 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2152 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2153 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2156 $text = $this->emetteur->name;
2157 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2161 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2162 $pdf->SetXY($posx, $posy);
2163 $pdf->SetTextColor(0, 0, 60);
2164 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2166 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2169 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2172 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2175 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2177 if ($this->situationinvoice) {
2178 $langs->loadLangs(array(
"other"));
2179 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
2181 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2184 if ($this->situationinvoice) {
2185 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2187 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2188 } elseif (
$object->type == 1) {
2189 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2190 } elseif (
$object->type == 2) {
2191 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2192 } elseif (
$object->type == 3) {
2193 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2194 } elseif (
$object->type == 4) {
2195 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2198 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2199 if (
$object->statut == $object::STATUS_DRAFT) {
2200 $pdf->SetTextColor(128, 0, 0);
2201 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2204 $pdf->MultiCell($w, 3, $title,
'',
'R');
2206 $pdf->SetFont(
'',
'B', $default_font_size);
2220 $pdf->SetFont(
'',
'', $default_font_size - 2);
2224 $pdf->SetXY($posx, $posy);
2225 $pdf->SetTextColor(0, 0, 60);
2226 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2231 if (!empty(
$object->project->ref)) {
2233 $pdf->SetXY($posx, $posy);
2234 $pdf->SetTextColor(0, 0, 60);
2235 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2241 if (!empty(
$object->project->ref)) {
2242 $outputlangs->load(
"projects");
2244 $pdf->SetXY($posx, $posy);
2245 $pdf->SetTextColor(0, 0, 60);
2246 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2250 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2251 if (
$object->type == 0 && $objectidnext) {
2252 $objectreplacing =
new Facture($this->db);
2253 $objectreplacing->fetch($objectidnext);
2256 $pdf->SetXY($posx, $posy);
2257 $pdf->SetTextColor(0, 0, 60);
2258 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2261 $objectreplaced =
new Facture($this->db);
2262 $objectreplaced->fetch(
$object->fk_facture_source);
2265 $pdf->SetXY($posx, $posy);
2266 $pdf->SetTextColor(0, 0, 60);
2267 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2270 $objectreplaced =
new Facture($this->db);
2271 $objectreplaced->fetch(
$object->fk_facture_source);
2274 $pdf->SetXY($posx, $posy);
2275 $pdf->SetTextColor(0, 0, 60);
2276 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2280 $pdf->SetXY($posx, $posy);
2281 $pdf->SetTextColor(0, 0, 60);
2283 $title = $outputlangs->transnoentities(
"DateInvoice");
2284 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2285 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2287 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2291 $pdf->SetXY($posx, $posy);
2292 $pdf->SetTextColor(0, 0, 60);
2293 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2298 $pdf->SetXY($posx, $posy);
2299 $pdf->SetTextColor(0, 0, 60);
2300 $title = $outputlangs->transnoentities(
"DateDue");
2301 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2302 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2304 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2309 $pdf->SetXY($posx, $posy);
2310 $pdf->SetTextColor(0, 0, 60);
2311 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2316 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2317 if (count($arrayidcontact) > 0) {
2318 $usertmp =
new User($this->db);
2319 $usertmp->fetch($arrayidcontact[0]);
2321 $pdf->SetXY($posx, $posy);
2322 $pdf->SetTextColor(0, 0, 60);
2323 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2332 $current_y = $pdf->getY();
2334 if ($current_y < $pdf->getY()) {
2335 $top_shift = $pdf->getY() - $current_y;
2340 $carac_emetteur =
'';
2342 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2343 if (count($arrayidcontact) > 0) {
2344 $object->fetch_user($arrayidcontact[0]);
2345 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2346 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2347 $carac_emetteur .=
"\n";
2354 $posy += $top_shift;
2355 $posx = $this->marge_gauche;
2357 $posx = $this->page_largeur - $this->marge_droite - 80;
2365 $pdf->SetTextColor(0, 0, 0);
2366 $pdf->SetFont(
'',
'', $default_font_size - 2);
2367 $pdf->SetXY($posx, $posy - 5);
2368 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2369 $pdf->SetXY($posx, $posy);
2370 $pdf->SetFillColor(230, 230, 230);
2371 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2372 $pdf->SetTextColor(0, 0, 60);
2377 $pdf->SetXY($posx + 2, $posy + 3);
2378 $pdf->SetFont(
'',
'B', $default_font_size);
2379 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2380 $posy = $pdf->getY();
2384 $pdf->SetXY($posx + 2, $posy);
2385 $pdf->SetFont(
'',
'', $default_font_size - 1);
2386 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2389 $usecontact =
false;
2390 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2391 if (count($arrayidcontact) > 0) {
2393 $result =
$object->fetch_contact($arrayidcontact[0]);
2397 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2398 $thirdparty =
$object->contact;
2400 $thirdparty =
$object->thirdparty;
2410 if ($this->page_largeur < 210) {
2414 $posy += $top_shift;
2415 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2417 $posx = $this->marge_gauche;
2422 $pdf->SetTextColor(0, 0, 0);
2423 $pdf->SetFont(
'',
'', $default_font_size - 2);
2424 $pdf->SetXY($posx + 2, $posy - 5);
2425 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2426 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2430 $pdf->SetXY($posx + 2, $posy + 3);
2431 $pdf->SetFont(
'',
'B', $default_font_size);
2433 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2435 $posy = $pdf->getY();
2438 $pdf->SetFont(
'',
'', $default_font_size - 1);
2439 $pdf->SetXY($posx + 2, $posy);
2441 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2445 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2447 if (!empty($idaddressshipping)) {
2448 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2449 $companystatic =
new Societe($this->db);
2450 $companystatic->fetch(
$object->contact->fk_soc);
2457 if (!empty($carac_client_shipping)) {
2458 $posy += $hautcadre;
2460 $hautcadre = $hautcadre - 10;
2463 $pdf->SetXY($posx + 2, $posy - 5);
2464 $pdf->SetFont(
'',
'', $default_font_size - 2);
2465 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2466 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2469 $pdf->SetXY($posx + 2, $posy + 3);
2470 $pdf->SetFont(
'',
'B', $default_font_size);
2471 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2473 $posy = $pdf->getY();
2476 $pdf->SetXY($posx + 2, $posy);
2477 $pdf->SetFont(
'',
'', $default_font_size - 1);
2478 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2480 $shipp_shift += $hautcadre + 10;
2485 $pdf->SetTextColor(0, 0, 0);
2487 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);