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;
719 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
720 $pdf->AddPage(
'',
'',
true);
721 if (!empty($tplidx)) {
722 $pdf->useTemplate($tplidx);
724 $pdf->setPage($pageposbefore + 1);
726 $curY = $this->tab_top_newpage;
730 $showpricebeforepagebreak = 1;
732 $showpricebeforepagebreak = 0;
736 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
737 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
739 $posYAfterImage = $curY + $imglinesize[
'height'];
745 $pdf->startTransaction();
748 $pageposafter = $pdf->getPage();
750 if ($pageposafter > $pageposbefore) {
751 $pdf->rollbackTransaction(
true);
752 $pageposafter = $pageposbefore;
753 $pdf->setPageOrientation(
'', 1, $this->heightforfooter);
757 $pageposafter = $pdf->getPage();
758 $posyafter = $pdf->GetY();
760 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
761 if ($i == ($nblines - 1)) {
762 $pdf->AddPage(
'',
'',
true);
763 if (!empty($tplidx)) {
764 $pdf->useTemplate($tplidx);
766 $pdf->setPage($pageposafter + 1);
772 $showpricebeforepagebreak = 1;
774 $showpricebeforepagebreak = 0;
778 $pdf->commitTransaction();
780 $posYAfterDescription = $pdf->GetY();
783 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
785 $pageposafter = $pdf->getPage();
786 $pdf->setPage($pageposbefore);
787 $pdf->setTopMargin($this->marge_haute);
788 $pdf->setPageOrientation(
'', 1, 0);
791 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
792 $pdf->setPage($pageposafter);
793 $curY = $this->tab_top_newpage;
796 $pdf->SetFont(
'',
'', $default_font_size - 1);
807 $nexY = max($pdf->GetY(), $nexY);
814 $nexY = max($pdf->GetY(), $nexY);
822 $nexY = max($pdf->GetY(), $nexY);
829 $nexY = max($pdf->GetY(), $nexY);
836 $nexY = max($pdf->GetY(), $nexY);
843 $nexY = max($pdf->GetY(), $nexY);
850 $nexY = max($pdf->GetY(), $nexY);
857 $nexY = max($pdf->GetY(), $nexY);
861 if (!empty(
$object->lines[$i]->array_options)) {
862 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
866 $nexY = max($pdf->GetY(), $nexY);
878 'outputlangs' => $outputlangs,
879 'hidedetails' => $hidedetails
881 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
889 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
890 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
891 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
892 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
894 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
897 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
898 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
900 $tvaligne = $sign *
$object->lines[$i]->total_tva;
904 $localtax1ligne =
$object->lines[$i]->total_localtax1;
905 $localtax2ligne =
$object->lines[$i]->total_localtax2;
906 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
907 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
908 $localtax1_type =
$object->lines[$i]->localtax1_type;
909 $localtax2_type =
$object->lines[$i]->localtax2_type;
922 $vatrate = (string)
$object->lines[$i]->tva_tx;
925 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
926 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
928 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
929 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
933 if ($localtax1_type && $localtax1ligne != 0) {
934 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
935 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
937 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
940 if ($localtax2_type && $localtax2ligne != 0) {
941 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
942 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
944 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
948 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
953 if (!isset($this->tva[$vatrate])) {
954 $this->tva[$vatrate] = 0;
956 $this->tva[$vatrate] += $tvaligne;
957 $vatcode =
$object->lines[$i]->vat_src_code;
958 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
959 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
961 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
963 $nexY = max($nexY, $posYAfterImage);
967 $pdf->setPage($pageposafter);
968 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
970 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
971 $pdf->SetLineStyle(array(
'dash' => 0));
975 while ($pagenb < $pageposafter) {
976 $pdf->setPage($pagenb);
978 if ($pagenb == $pageposbeforeprintlines) {
979 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
981 $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);
985 $pdf->setPage($pagenb);
986 $pdf->setPageOrientation(
'', 1, 0);
990 if (!empty($tplidx)) {
991 $pdf->useTemplate($tplidx);
995 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
997 if ($pagenb == $pageposafter) {
998 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1000 $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);
1005 if (!empty($tplidx)) {
1006 $pdf->useTemplate($tplidx);
1017 if ($pagenb == $pageposbeforeprintlines) {
1018 $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);
1019 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1021 $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);
1022 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1029 $posy = $this->
drawTotalTable($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1032 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1038 if (method_exists($pdf,
'AliasNbPages')) {
1039 $pdf->AliasNbPages();
1047 $pdf->Output($file,
'F');
1050 $hookmanager->initHooks(array(
'pdfgeneration'));
1051 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1053 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1055 $this->error = $hookmanager->error;
1056 $this->errors = $hookmanager->errors;
1061 $this->result = array(
'fullpath' => $file);
1065 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1069 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1094 $tab3_top = $posy + 8;
1097 if ($this->page_largeur < 210) {
1103 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1105 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1108 $pdf->SetFont(
'',
'', $default_font_size - 3);
1109 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1110 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1112 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1114 $pdf->SetFont(
'',
'', $default_font_size - 4);
1115 $pdf->SetXY($tab3_posx, $tab3_top);
1116 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1117 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1118 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1119 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1120 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1121 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1122 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1124 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1128 $pdf->SetFont(
'',
'', $default_font_size - 4);
1132 $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,";
1133 $sql .=
" re.description, re.fk_facture_source,";
1134 $sql .=
" f.type, f.datef";
1135 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1136 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1137 $resql = $this->db->query($sql);
1139 $num = $this->db->num_rows($resql);
1141 $invoice =
new Facture($this->db);
1144 $obj = $this->db->fetch_object($resql);
1146 if ($obj->type == 2) {
1147 $text = $outputlangs->transnoentities(
"CreditNote");
1148 } elseif ($obj->type == 3) {
1149 $text = $outputlangs->transnoentities(
"Deposit");
1150 } elseif ($obj->type == 0) {
1151 $text = $outputlangs->transnoentities(
"ExcessReceived");
1153 $text = $outputlangs->transnoentities(
"UnknownType");
1156 $invoice->fetch($obj->fk_facture_source);
1158 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1159 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1160 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1161 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1162 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1163 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1164 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1165 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1167 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1172 $this->error = $this->db->lasterror();
1178 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1180 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1181 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1182 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1184 $sql .=
" ORDER BY p.datep";
1186 $resql = $this->db->query($sql);
1188 $num = $this->db->num_rows($resql);
1193 $row = $this->db->fetch_object($resql);
1194 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1195 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1196 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1197 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1198 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1199 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1201 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1202 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1203 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1204 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1205 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1206 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1211 return $tab3_top + $y + 3;
1213 $this->error = $this->db->lasterror();
1231 global $conf, $mysoc, $hookmanager;
1235 $pdf->SetFont(
'',
'', $default_font_size - 1);
1238 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1239 $pdf->SetFont(
'',
'', $default_font_size - 2);
1240 $pdf->SetXY($this->marge_gauche, $posy);
1241 if ($mysoc->forme_juridique_code == 92) {
1242 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1244 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1247 $posy = $pdf->GetY() + 4;
1252 if ($this->page_largeur < 210) {
1258 $pdf->SetFont(
'',
'', $default_font_size - 2);
1259 $pdf->SetXY($this->marge_gauche, $posy);
1260 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1261 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1263 $pdf->SetFont(
'',
'', $default_font_size - 2);
1264 $pdf->SetXY($posxval, $posy);
1265 $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);
1266 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1267 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1269 $posy = $pdf->GetY() + 3;
1273 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1274 $pdf->SetFont(
'',
'', $default_font_size - 2);
1275 $pdf->SetXY($this->marge_gauche, $posy);
1276 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1277 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1279 $pdf->SetFont(
'',
'', $default_font_size - 2);
1280 $pdf->SetXY($posxval, $posy);
1281 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1282 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1284 $posy = $pdf->GetY() + 3;
1289 if (empty(
$object->mode_reglement_code)
1292 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1296 $outputlangs->load(
"errors");
1298 $pdf->SetXY($this->marge_gauche, $posy);
1299 $pdf->SetTextColor(200, 0, 0);
1300 $pdf->SetFont(
'',
'', $default_font_size - 2);
1301 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1302 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1303 $pdf->SetTextColor(0, 0, 0);
1305 $posy = $pdf->GetY() + 1;
1309 if (!empty(
$object->mode_reglement_code)
1310 &&
$object->mode_reglement_code !=
'CHQ'
1311 &&
$object->mode_reglement_code !=
'VIR') {
1312 $pdf->SetFont(
'',
'', $default_font_size - 2);
1313 $pdf->SetXY($this->marge_gauche, $posy);
1314 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1315 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1317 $pdf->SetFont(
'',
'', $default_font_size - 2);
1318 $pdf->SetXY($posxval, $posy);
1319 $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);
1322 if (
$object->mode_reglement_code ==
"PRE") {
1323 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1326 $bac->fetch(0,
'',
$object->thirdparty->id);
1327 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1328 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1331 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1333 $posy = $pdf->GetY();
1339 if ($this->emetteur->country_code ==
'FR') {
1341 $pdf->SetXY($this->marge_gauche, $posy);
1342 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1344 $posy = $pdf->GetY() + 1;
1349 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1350 $useonlinepayment = 0;
1354 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1355 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1356 $useonlinepayment = count($validpaymentmethod);
1361 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1364 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1365 $servicename = $langs->transnoentities(
'Online');
1366 $paiement_url = getOnlinePaymentUrl(
'',
'invoice',
$object->ref,
'',
'',
'');
1367 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1369 $pdf->SetXY($this->marge_gauche, $posy);
1370 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1372 $posy = $pdf->GetY() + 1;
1377 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1380 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1383 $account =
new Account($this->db);
1386 $pdf->SetXY($this->marge_gauche, $posy);
1387 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1388 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1389 $posy = $pdf->GetY() + 1;
1392 $pdf->SetXY($this->marge_gauche, $posy);
1393 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1394 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1395 $posy = $pdf->GetY() + 2;
1398 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1399 $pdf->SetXY($this->marge_gauche, $posy);
1400 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1401 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1402 $posy = $pdf->GetY() + 1;
1405 $pdf->SetXY($this->marge_gauche, $posy);
1406 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1407 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1408 $posy = $pdf->GetY() + 2;
1415 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1421 $account =
new Account($this->db);
1422 $account->fetch($bankid);
1424 $curx = $this->marge_gauche;
1427 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1435 $qrCodeColor = array(
'25',
'25',
'25');
1439 'fgcolor' => $qrCodeColor,
1441 'module_width' => 1,
1442 'module_height' => 1
1445 $EPCQrCodeString =
$object->buildEPCQrCodeString();
1446 $pdf->write2DBarcode($EPCQrCodeString,
'QRCODE,M', $qrPosX, $qrPosY, 25, 25, $styleQr,
'N');
1448 $pdf->SetXY($qrPosX + 30, $posy + 5);
1449 $pdf->SetFont(
'',
'', $default_font_size - 5);
1450 $pdf->MultiCell(30, 3, $outputlangs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
1451 $posy = $pdf->GetY() + 2;
1474 global $conf, $mysoc, $hookmanager;
1485 if (is_object($outputlangsbis)) {
1486 $pdf->SetFont(
'',
'', $default_font_size - 2);
1488 $pdf->SetFont(
'',
'', $default_font_size - 1);
1494 if ($this->page_largeur < 210) {
1498 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1504 $parameters = array(
1506 'outputlangs' => $outputlangs,
1508 $hookmanager->executeHooks(
'beforePercentCalculation', $parameters, $this);
1513 foreach (
$object->lines as $line) {
1514 if ($line->product_type != 9) {
1515 $percent += $line->situation_percent;
1521 $avancementGlobal = $percent / $i;
1523 $avancementGlobal = 0;
1526 $object->fetchPreviousNextSituationInvoice();
1527 $TPreviousIncoice =
$object->tab_previous_situation_invoice;
1530 $total_a_payer_ttc = 0;
1531 foreach ($TPreviousIncoice as &$fac) {
1532 $total_a_payer += $fac->total_ht;
1533 $total_a_payer_ttc += $fac->total_ttc;
1535 $total_a_payer +=
$object->total_ht;
1536 $total_a_payer_ttc +=
$object->total_ttc;
1538 if (!empty($avancementGlobal)) {
1539 $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
1540 $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
1543 $total_a_payer_ttc = 0;
1547 if (!empty($TPreviousIncoice)) {
1548 $pdf->setY($tab2_top);
1549 $posy = $pdf->GetY();
1551 foreach ($TPreviousIncoice as &$fac) {
1552 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1557 $pdf->setY($this->tab_top_newpage);
1559 $pdf->setY($this->marge_haute);
1561 $posy = $pdf->GetY();
1566 $pdf->SetFillColor(255, 255, 255);
1567 $pdf->SetXY($col1x, $posy);
1568 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $fac->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1570 $pdf->SetXY($col2x, $posy);
1574 $facSign = $fac->total_ht >= 0 ?
'+' :
'';
1577 $displayAmount =
' '.$facSign.
' '.
price($fac->total_ht, 0, $outputlangs);
1579 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1588 $pdf->SetFillColor(255, 255, 255);
1589 $pdf->SetXY($col1x, $posy);
1590 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle",
$object->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1592 $pdf->SetXY($col2x, $posy);
1595 $facSign =
$object->total_ht >= 0 ?
'+' :
'';
1603 $displayAmount =
' '.$facSign.
' '.
price(
$object->total_ht, 0, $outputlangs);
1604 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1609 $pdf->SetFont(
'',
'', $default_font_size - 1);
1610 $pdf->SetFillColor(255, 255, 255);
1611 $pdf->SetXY($col1x, $posy);
1612 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"SituationTotalProgress", $avancementGlobal), 0,
'L', 1);
1614 $pdf->SetXY($col2x, $posy);
1615 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0,
'R', 1);
1616 $pdf->SetFont(
'',
'', $default_font_size - 2);
1620 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1624 $pdf->setY($this->tab_top_newpage);
1626 $pdf->setY($this->marge_haute);
1629 $posy = $pdf->GetY();
1640 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1643 $total_line_remise = 0;
1644 foreach (
$object->lines as $i => $line) {
1646 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1648 if ($line->total_ht < 0) {
1649 $total_line_remise += -$line->total_ht;
1652 if ($total_line_remise > 0) {
1654 $pdf->SetFillColor(255, 255, 255);
1655 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1656 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1657 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1658 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1664 $pdf->SetFillColor(255, 255, 255);
1665 $pdf->SetXY($col1x, $tab2_top);
1666 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1667 $pdf->SetXY($col2x, $tab2_top);
1668 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1675 $pdf->SetFillColor(255, 255, 255);
1676 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1677 $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);
1679 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1680 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1681 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1684 $pdf->SetFillColor(248, 248, 248);
1686 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1688 $this->atleastoneratenotnull = 0;
1690 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1691 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1695 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1696 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1700 foreach ($localtax_rate as $tvakey => $tvaval) {
1705 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1708 if (preg_match(
'/\*/', (
string) $tvakey)) {
1709 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1710 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1713 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1717 $totalvat .= $tvacompl;
1719 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1722 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1724 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1726 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1727 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1733 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1734 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1738 foreach ($localtax_rate as $tvakey => $tvaval) {
1743 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1746 if (preg_match(
'/\*/', (
string) $tvakey)) {
1747 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1748 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1750 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1754 $totalvat .= $tvacompl;
1756 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1759 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1761 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1763 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1764 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1772 foreach ($this->tva as $tvakey => $tvaval) {
1773 $sum_pdf_tva += $tvaval;
1776 if ($sum_pdf_tva !=
$object->total_tva) {
1777 if (!empty($sum_pdf_tva)) {
1778 $coef_fix_tva =
$object->total_tva / $sum_pdf_tva;
1784 foreach ($this->tva as $tvakey => $tvaval) {
1785 $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1787 foreach ($this->tva_array as $tvakey => $tvaval) {
1788 $this->tva_array[$tvakey][
'amount'] = $tvaval[
'amount'] * $coef_fix_tva;
1794 foreach ($this->tva_array as $tvakey => $tvaval) {
1796 $this->atleastoneratenotnull++;
1799 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1802 if (preg_match(
'/\*/', $tvakey)) {
1803 $tvakey = str_replace(
'*',
'', $tvakey);
1804 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1806 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1809 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1811 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1813 $totalvat .= $tvacompl;
1815 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1817 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1819 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1820 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1825 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1826 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1830 foreach ($localtax_rate as $tvakey => $tvaval) {
1835 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1838 if (preg_match(
'/\*/', (
string) $tvakey)) {
1839 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1840 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1842 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1846 $totalvat .= $tvacompl;
1848 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1851 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1853 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1855 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1856 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1862 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1863 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1867 foreach ($localtax_rate as $tvakey => $tvaval) {
1873 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1876 if (preg_match(
'/\*/', (
string) $tvakey)) {
1877 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1878 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1880 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1884 $totalvat .= $tvacompl;
1886 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1889 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1891 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1893 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1894 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1902 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1903 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1905 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1906 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1911 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1912 $pdf->SetTextColor(0, 0, 60);
1913 $pdf->SetFillColor(224, 224, 224);
1914 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1916 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1917 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1921 if (
$object->displayRetainedWarranty()) {
1922 $pdf->SetTextColor(40, 40, 40);
1923 $pdf->SetFillColor(255, 255, 255);
1925 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1926 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1930 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1931 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1933 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1934 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1938 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1940 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1941 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1943 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1944 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1945 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1950 $pdf->SetTextColor(0, 0, 0);
1952 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1953 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1955 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1960 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1963 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1964 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"Paid") :
''), 0,
'L', 0);
1965 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1966 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1969 if ($creditnoteamount) {
1970 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1971 $labeltouse .= (is_object($outputlangsbis) ? (
' / '.(($outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities(
"CreditNotes"))) :
'');
1973 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1974 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1975 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1976 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1979 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1981 $pdf->SetFillColor(255, 255, 255);
1983 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1984 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"EscompteOfferedShort") :
''), $useborder,
'L', 1);
1985 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1986 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT'), 0, $outputlangs), $useborder,
'R', 1);
1992 $pdf->SetTextColor(0, 0, 60);
1993 $pdf->SetFillColor(224, 224, 224);
1994 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1995 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1996 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1997 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1999 $pdf->SetFont(
'',
'', $default_font_size - 1);
2000 $pdf->SetTextColor(0, 0, 0);
2003 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
2005 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
2007 $this->error = $hookmanager->error;
2008 $this->errors = $hookmanager->errors;
2012 return ($tab2_top + ($tab2_hl * $index));
2108 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2111 global $conf, $langs;
2113 $ltrdirection =
'L';
2114 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2115 $ltrdirection =
'R';
2119 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2125 $pdf->SetTextColor(0, 0, 60);
2126 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2130 $posy = $this->marge_haute;
2131 $posx = $this->page_largeur - $this->marge_droite - $w;
2133 $pdf->SetXY($this->marge_gauche, $posy);
2137 if ($this->emetteur->logo) {
2138 $logodir = $conf->mycompany->dir_output;
2139 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
2140 $logodir = $conf->mycompany->multidir_output[
$object->entity];
2143 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2145 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2147 if (is_readable($logo)) {
2149 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2151 $pdf->SetTextColor(200, 0, 0);
2152 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2153 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2154 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2157 $text = $this->emetteur->name;
2158 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2162 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2163 $pdf->SetXY($posx, $posy);
2164 $pdf->SetTextColor(0, 0, 60);
2165 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2167 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2170 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2173 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2176 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2178 if ($this->situationinvoice) {
2179 $langs->loadLangs(array(
"other"));
2180 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
2182 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2185 if ($this->situationinvoice) {
2186 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2188 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2189 } elseif (
$object->type == 1) {
2190 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2191 } elseif (
$object->type == 2) {
2192 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2193 } elseif (
$object->type == 3) {
2194 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2195 } elseif (
$object->type == 4) {
2196 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2199 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2200 if (
$object->statut == $object::STATUS_DRAFT) {
2201 $pdf->SetTextColor(128, 0, 0);
2202 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2205 $pdf->MultiCell($w, 3, $title,
'',
'R');
2207 $pdf->SetFont(
'',
'B', $default_font_size);
2221 $pdf->SetFont(
'',
'', $default_font_size - 2);
2225 $pdf->SetXY($posx, $posy);
2226 $pdf->SetTextColor(0, 0, 60);
2227 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2232 if (!empty(
$object->project->ref)) {
2234 $pdf->SetXY($posx, $posy);
2235 $pdf->SetTextColor(0, 0, 60);
2236 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2242 if (!empty(
$object->project->ref)) {
2243 $outputlangs->load(
"projects");
2245 $pdf->SetXY($posx, $posy);
2246 $pdf->SetTextColor(0, 0, 60);
2247 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2251 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2252 if (
$object->type == 0 && $objectidnext) {
2253 $objectreplacing =
new Facture($this->db);
2254 $objectreplacing->fetch($objectidnext);
2257 $pdf->SetXY($posx, $posy);
2258 $pdf->SetTextColor(0, 0, 60);
2259 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2262 $objectreplaced =
new Facture($this->db);
2263 $objectreplaced->fetch(
$object->fk_facture_source);
2266 $pdf->SetXY($posx, $posy);
2267 $pdf->SetTextColor(0, 0, 60);
2268 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2271 $objectreplaced =
new Facture($this->db);
2272 $objectreplaced->fetch(
$object->fk_facture_source);
2275 $pdf->SetXY($posx, $posy);
2276 $pdf->SetTextColor(0, 0, 60);
2277 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2281 $pdf->SetXY($posx, $posy);
2282 $pdf->SetTextColor(0, 0, 60);
2284 $title = $outputlangs->transnoentities(
"DateInvoice");
2285 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2286 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2288 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2292 $pdf->SetXY($posx, $posy);
2293 $pdf->SetTextColor(0, 0, 60);
2294 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2299 $pdf->SetXY($posx, $posy);
2300 $pdf->SetTextColor(0, 0, 60);
2301 $title = $outputlangs->transnoentities(
"DateDue");
2302 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2303 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2305 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2310 $pdf->SetXY($posx, $posy);
2311 $pdf->SetTextColor(0, 0, 60);
2312 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2317 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2318 if (count($arrayidcontact) > 0) {
2319 $usertmp =
new User($this->db);
2320 $usertmp->fetch($arrayidcontact[0]);
2322 $pdf->SetXY($posx, $posy);
2323 $pdf->SetTextColor(0, 0, 60);
2324 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2333 $current_y = $pdf->getY();
2335 if ($current_y < $pdf->getY()) {
2336 $top_shift = $pdf->getY() - $current_y;
2341 $carac_emetteur =
'';
2343 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2344 if (count($arrayidcontact) > 0) {
2345 $object->fetch_user($arrayidcontact[0]);
2346 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2347 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2348 $carac_emetteur .=
"\n";
2355 $posy += $top_shift;
2356 $posx = $this->marge_gauche;
2358 $posx = $this->page_largeur - $this->marge_droite - 80;
2366 $pdf->SetTextColor(0, 0, 0);
2367 $pdf->SetFont(
'',
'', $default_font_size - 2);
2368 $pdf->SetXY($posx, $posy - 5);
2369 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2370 $pdf->SetXY($posx, $posy);
2371 $pdf->SetFillColor(230, 230, 230);
2372 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2373 $pdf->SetTextColor(0, 0, 60);
2378 $pdf->SetXY($posx + 2, $posy + 3);
2379 $pdf->SetFont(
'',
'B', $default_font_size);
2380 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2381 $posy = $pdf->getY();
2385 $pdf->SetXY($posx + 2, $posy);
2386 $pdf->SetFont(
'',
'', $default_font_size - 1);
2387 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2390 $usecontact =
false;
2391 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2392 if (count($arrayidcontact) > 0) {
2394 $result =
$object->fetch_contact($arrayidcontact[0]);
2398 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2399 $thirdparty =
$object->contact;
2401 $thirdparty =
$object->thirdparty;
2411 if ($this->page_largeur < 210) {
2415 $posy += $top_shift;
2416 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2418 $posx = $this->marge_gauche;
2423 $pdf->SetTextColor(0, 0, 0);
2424 $pdf->SetFont(
'',
'', $default_font_size - 2);
2425 $pdf->SetXY($posx + 2, $posy - 5);
2426 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2427 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2431 $pdf->SetXY($posx + 2, $posy + 3);
2432 $pdf->SetFont(
'',
'B', $default_font_size);
2434 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2436 $posy = $pdf->getY();
2439 $pdf->SetFont(
'',
'', $default_font_size - 1);
2440 $pdf->SetXY($posx + 2, $posy);
2442 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2446 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2448 if (!empty($idaddressshipping)) {
2449 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2450 $companystatic =
new Societe($this->db);
2451 $companystatic->fetch(
$object->contact->fk_soc);
2458 if (!empty($carac_client_shipping)) {
2459 $posy += $hautcadre;
2461 $hautcadre = $hautcadre - 10;
2464 $pdf->SetXY($posx + 2, $posy - 5);
2465 $pdf->SetFont(
'',
'', $default_font_size - 2);
2466 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2467 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2470 $pdf->SetXY($posx + 2, $posy + 3);
2471 $pdf->SetFont(
'',
'B', $default_font_size);
2472 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2474 $posy = $pdf->getY();
2477 $pdf->SetXY($posx + 2, $posy);
2478 $pdf->SetFont(
'',
'', $default_font_size - 1);
2479 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2481 $shipp_shift += $hautcadre + 10;
2486 $pdf->SetTextColor(0, 0, 0);
2488 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);