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 =
getDolGlobalInt(
'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;
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");
1091 $tab3_top = $posy + 8;
1094 if ($this->page_largeur < 210) {
1100 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1102 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1105 $pdf->SetFont(
'',
'', $default_font_size - 3);
1106 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1107 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1109 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1111 $pdf->SetFont(
'',
'', $default_font_size - 4);
1112 $pdf->SetXY($tab3_posx, $tab3_top);
1113 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1114 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1115 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1116 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1117 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1118 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1119 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1121 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1125 $pdf->SetFont(
'',
'', $default_font_size - 4);
1129 $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,";
1130 $sql .=
" re.description, re.fk_facture_source,";
1131 $sql .=
" f.type, f.datef";
1132 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1133 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1134 $resql = $this->db->query($sql);
1136 $num = $this->db->num_rows($resql);
1138 $invoice =
new Facture($this->db);
1141 $obj = $this->db->fetch_object($resql);
1143 if ($obj->type == 2) {
1144 $text = $outputlangs->transnoentities(
"CreditNote");
1145 } elseif ($obj->type == 3) {
1146 $text = $outputlangs->transnoentities(
"Deposit");
1147 } elseif ($obj->type == 0) {
1148 $text = $outputlangs->transnoentities(
"ExcessReceived");
1150 $text = $outputlangs->transnoentities(
"UnknownType");
1153 $invoice->fetch($obj->fk_facture_source);
1155 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1156 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1157 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1158 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1159 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1160 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1161 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1162 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1164 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1169 $this->error = $this->db->lasterror();
1175 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1177 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1178 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1179 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1181 $sql .=
" ORDER BY p.datep";
1183 $resql = $this->db->query($sql);
1185 $num = $this->db->num_rows($resql);
1190 $row = $this->db->fetch_object($resql);
1191 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1192 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1193 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1194 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1195 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1196 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1198 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1199 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1200 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1201 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1202 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1203 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1208 return $tab3_top + $y + 3;
1210 $this->error = $this->db->lasterror();
1228 global $conf, $mysoc, $hookmanager;
1232 $pdf->SetFont(
'',
'', $default_font_size - 1);
1235 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1236 $pdf->SetFont(
'',
'', $default_font_size - 2);
1237 $pdf->SetXY($this->marge_gauche, $posy);
1238 if ($mysoc->forme_juridique_code == 92) {
1239 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1241 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1244 $posy = $pdf->GetY() + 4;
1249 if ($this->page_largeur < 210) {
1255 $pdf->SetFont(
'',
'', $default_font_size - 2);
1256 $pdf->SetXY($this->marge_gauche, $posy);
1257 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1258 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1260 $pdf->SetFont(
'',
'', $default_font_size - 2);
1261 $pdf->SetXY($posxval, $posy);
1262 $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);
1263 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1264 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1266 $posy = $pdf->GetY() + 3;
1270 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1271 $pdf->SetFont(
'',
'', $default_font_size - 2);
1272 $pdf->SetXY($this->marge_gauche, $posy);
1273 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1274 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1276 $pdf->SetFont(
'',
'', $default_font_size - 2);
1277 $pdf->SetXY($posxval, $posy);
1278 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1279 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1281 $posy = $pdf->GetY() + 3;
1286 if (empty(
$object->mode_reglement_code)
1289 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1293 $outputlangs->load(
"errors");
1295 $pdf->SetXY($this->marge_gauche, $posy);
1296 $pdf->SetTextColor(200, 0, 0);
1297 $pdf->SetFont(
'',
'', $default_font_size - 2);
1298 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1299 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1300 $pdf->SetTextColor(0, 0, 0);
1302 $posy = $pdf->GetY() + 1;
1306 if (!empty(
$object->mode_reglement_code)
1307 &&
$object->mode_reglement_code !=
'CHQ'
1308 &&
$object->mode_reglement_code !=
'VIR') {
1309 $pdf->SetFont(
'',
'', $default_font_size - 2);
1310 $pdf->SetXY($this->marge_gauche, $posy);
1311 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1312 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1314 $pdf->SetFont(
'',
'', $default_font_size - 2);
1315 $pdf->SetXY($posxval, $posy);
1316 $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);
1319 if (
$object->mode_reglement_code ==
"PRE") {
1320 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1323 $bac->fetch(0,
'',
$object->thirdparty->id);
1324 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1325 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1328 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1330 $posy = $pdf->GetY();
1336 if ($this->emetteur->country_code ==
'FR') {
1338 $pdf->SetXY($this->marge_gauche, $posy);
1339 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1341 $posy = $pdf->GetY() + 1;
1346 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1347 $useonlinepayment = 0;
1351 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1352 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1353 $useonlinepayment = count($validpaymentmethod);
1358 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1361 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1362 $servicename = $langs->transnoentities(
'Online');
1363 $paiement_url = getOnlinePaymentUrl(
'',
'invoice',
$object->ref, 0,
'',
'');
1364 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1366 $pdf->SetXY($this->marge_gauche, $posy);
1367 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1369 $posy = $pdf->GetY() + 1;
1374 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1377 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1380 $account =
new Account($this->db);
1383 $pdf->SetXY($this->marge_gauche, $posy);
1384 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1385 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1386 $posy = $pdf->GetY() + 1;
1389 $pdf->SetXY($this->marge_gauche, $posy);
1390 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1391 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1392 $posy = $pdf->GetY() + 2;
1395 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1396 $pdf->SetXY($this->marge_gauche, $posy);
1397 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1398 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1399 $posy = $pdf->GetY() + 1;
1402 $pdf->SetXY($this->marge_gauche, $posy);
1403 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1404 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1405 $posy = $pdf->GetY() + 2;
1412 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1418 $account =
new Account($this->db);
1419 $account->fetch($bankid);
1421 $curx = $this->marge_gauche;
1424 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1432 $qrCodeColor = array(
'25',
'25',
'25');
1436 'fgcolor' => $qrCodeColor,
1438 'module_width' => 1,
1439 'module_height' => 1
1442 $EPCQrCodeString =
$object->buildEPCQrCodeString();
1443 $pdf->write2DBarcode($EPCQrCodeString,
'QRCODE,M', $qrPosX, $qrPosY, 25, 25, $styleQr,
'N');
1445 $pdf->SetXY($qrPosX + 5, $posy);
1446 $pdf->SetFont(
'',
'', $default_font_size - 5);
1447 $pdf->MultiCell(30, 3, $langs->trans(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
1448 $posy = $pdf->GetY() + 2;
1471 global $conf, $mysoc, $hookmanager;
1482 if (is_object($outputlangsbis)) {
1483 $pdf->SetFont(
'',
'', $default_font_size - 2);
1485 $pdf->SetFont(
'',
'', $default_font_size - 1);
1491 if ($this->page_largeur < 210) {
1495 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1501 $parameters = array(
1503 'outputlangs' => $outputlangs,
1505 $hookmanager->executeHooks(
'beforePercentCalculation', $parameters, $this);
1510 foreach (
$object->lines as $line) {
1511 if ($line->product_type != 9) {
1512 $percent += $line->situation_percent;
1518 $avancementGlobal = $percent / $i;
1520 $avancementGlobal = 0;
1523 $object->fetchPreviousNextSituationInvoice();
1524 $TPreviousIncoice =
$object->tab_previous_situation_invoice;
1527 $total_a_payer_ttc = 0;
1528 foreach ($TPreviousIncoice as &$fac) {
1529 $total_a_payer += $fac->total_ht;
1530 $total_a_payer_ttc += $fac->total_ttc;
1532 $total_a_payer +=
$object->total_ht;
1533 $total_a_payer_ttc +=
$object->total_ttc;
1535 if (!empty($avancementGlobal)) {
1536 $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
1537 $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
1540 $total_a_payer_ttc = 0;
1544 if (!empty($TPreviousIncoice)) {
1545 $pdf->setY($tab2_top);
1546 $posy = $pdf->GetY();
1548 foreach ($TPreviousIncoice as &$fac) {
1549 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1554 $pdf->setY($this->tab_top_newpage);
1556 $pdf->setY($this->marge_haute);
1558 $posy = $pdf->GetY();
1563 $pdf->SetFillColor(255, 255, 255);
1564 $pdf->SetXY($col1x, $posy);
1565 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $fac->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1567 $pdf->SetXY($col2x, $posy);
1571 $facSign = $fac->total_ht >= 0 ?
'+' :
'';
1574 $displayAmount =
' '.$facSign.
' '.
price($fac->total_ht, 0, $outputlangs);
1576 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1585 $pdf->SetFillColor(255, 255, 255);
1586 $pdf->SetXY($col1x, $posy);
1587 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle",
$object->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1589 $pdf->SetXY($col2x, $posy);
1592 $facSign =
$object->total_ht >= 0 ?
'+' :
'';
1600 $displayAmount =
' '.$facSign.
' '.
price(
$object->total_ht, 0, $outputlangs);
1601 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1606 $pdf->SetFont(
'',
'', $default_font_size - 1);
1607 $pdf->SetFillColor(255, 255, 255);
1608 $pdf->SetXY($col1x, $posy);
1609 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"SituationTotalProgress", $avancementGlobal), 0,
'L', 1);
1611 $pdf->SetXY($col2x, $posy);
1612 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0,
'R', 1);
1613 $pdf->SetFont(
'',
'', $default_font_size - 2);
1617 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1621 $pdf->setY($this->tab_top_newpage);
1623 $pdf->setY($this->marge_haute);
1626 $posy = $pdf->GetY();
1637 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1640 $total_line_remise = 0;
1641 foreach (
$object->lines as $i => $line) {
1643 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1645 if ($line->total_ht < 0) {
1646 $total_line_remise += -$line->total_ht;
1649 if ($total_line_remise > 0) {
1651 $pdf->SetFillColor(255, 255, 255);
1652 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1653 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1654 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1655 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1661 $pdf->SetFillColor(255, 255, 255);
1662 $pdf->SetXY($col1x, $tab2_top);
1663 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1664 $pdf->SetXY($col2x, $tab2_top);
1665 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1672 $pdf->SetFillColor(255, 255, 255);
1673 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1674 $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);
1676 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1677 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1678 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1681 $pdf->SetFillColor(248, 248, 248);
1683 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1685 $this->atleastoneratenotnull = 0;
1687 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1688 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1692 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1693 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1697 foreach ($localtax_rate as $tvakey => $tvaval) {
1702 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1705 if (preg_match(
'/\*/', (
string) $tvakey)) {
1706 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1707 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1710 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1714 $totalvat .= $tvacompl;
1716 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1719 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1721 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1723 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1724 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1730 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1731 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1735 foreach ($localtax_rate as $tvakey => $tvaval) {
1740 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1743 if (preg_match(
'/\*/', (
string) $tvakey)) {
1744 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1745 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1747 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1751 $totalvat .= $tvacompl;
1753 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1756 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1758 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1760 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1761 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1769 foreach ($this->tva as $tvakey => $tvaval) {
1770 $sum_pdf_tva += $tvaval;
1773 if ($sum_pdf_tva !=
$object->total_tva) {
1774 if (!empty($sum_pdf_tva)) {
1775 $coef_fix_tva =
$object->total_tva / $sum_pdf_tva;
1781 foreach ($this->tva as $tvakey => $tvaval) {
1782 $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1784 foreach ($this->tva_array as $tvakey => $tvaval) {
1785 $this->tva_array[$tvakey][
'amount'] = $tvaval[
'amount'] * $coef_fix_tva;
1791 foreach ($this->tva_array as $tvakey => $tvaval) {
1793 $this->atleastoneratenotnull++;
1796 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1799 if (preg_match(
'/\*/', $tvakey)) {
1800 $tvakey = str_replace(
'*',
'', $tvakey);
1801 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1803 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1806 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1808 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1810 $totalvat .= $tvacompl;
1812 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1814 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1816 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1817 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1822 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1823 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1827 foreach ($localtax_rate as $tvakey => $tvaval) {
1832 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1835 if (preg_match(
'/\*/', (
string) $tvakey)) {
1836 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1837 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1839 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1843 $totalvat .= $tvacompl;
1845 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1848 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1850 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1852 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1853 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1859 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1860 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1864 foreach ($localtax_rate as $tvakey => $tvaval) {
1870 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1873 if (preg_match(
'/\*/', (
string) $tvakey)) {
1874 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1875 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1877 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1881 $totalvat .= $tvacompl;
1883 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1886 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1888 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1890 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1891 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1899 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1900 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1902 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1903 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1908 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1909 $pdf->SetTextColor(0, 0, 60);
1910 $pdf->SetFillColor(224, 224, 224);
1911 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1913 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1914 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1918 if (
$object->displayRetainedWarranty()) {
1919 $pdf->SetTextColor(40, 40, 40);
1920 $pdf->SetFillColor(255, 255, 255);
1922 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1923 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1927 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1928 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1930 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1931 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1935 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1937 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1938 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1940 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1941 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1942 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1947 $pdf->SetTextColor(0, 0, 0);
1949 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1950 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1952 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1957 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1960 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1961 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"Paid") :
''), 0,
'L', 0);
1962 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1963 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1966 if ($creditnoteamount) {
1967 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1968 $labeltouse .= (is_object($outputlangsbis) ? (
' / '.(($outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities(
"CreditNotes"))) :
'');
1970 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1971 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1972 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1973 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1976 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1978 $pdf->SetFillColor(255, 255, 255);
1980 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1981 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"EscompteOfferedShort") :
''), $useborder,
'L', 1);
1982 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1983 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT'), 0, $outputlangs), $useborder,
'R', 1);
1989 $pdf->SetTextColor(0, 0, 60);
1990 $pdf->SetFillColor(224, 224, 224);
1991 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1992 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1993 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1994 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1996 $pdf->SetFont(
'',
'', $default_font_size - 1);
1997 $pdf->SetTextColor(0, 0, 0);
2000 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index);
2002 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
2004 $this->error = $hookmanager->error;
2005 $this->errors = $hookmanager->errors;
2009 return ($tab2_top + ($tab2_hl * $index));
2105 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2108 global $conf, $langs;
2110 $ltrdirection =
'L';
2111 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2112 $ltrdirection =
'R';
2116 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2122 $pdf->SetTextColor(0, 0, 60);
2123 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2127 $posy = $this->marge_haute;
2128 $posx = $this->page_largeur - $this->marge_droite - $w;
2130 $pdf->SetXY($this->marge_gauche, $posy);
2134 if ($this->emetteur->logo) {
2135 $logodir = $conf->mycompany->dir_output;
2136 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
2137 $logodir = $conf->mycompany->multidir_output[
$object->entity];
2140 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2142 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2144 if (is_readable($logo)) {
2146 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2148 $pdf->SetTextColor(200, 0, 0);
2149 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2150 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2151 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2154 $text = $this->emetteur->name;
2155 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2159 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2160 $pdf->SetXY($posx, $posy);
2161 $pdf->SetTextColor(0, 0, 60);
2162 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2164 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2167 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2170 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2173 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2175 if ($this->situationinvoice) {
2176 $langs->loadLangs(array(
"other"));
2177 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
2179 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2182 if ($this->situationinvoice) {
2183 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2185 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2186 } elseif (
$object->type == 1) {
2187 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2188 } elseif (
$object->type == 2) {
2189 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2190 } elseif (
$object->type == 3) {
2191 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2192 } elseif (
$object->type == 4) {
2193 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2196 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2197 if (
$object->status == $object::STATUS_DRAFT) {
2198 $pdf->SetTextColor(128, 0, 0);
2199 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2202 $pdf->MultiCell($w, 3, $title,
'',
'R');
2204 $pdf->SetFont(
'',
'B', $default_font_size);
2218 $pdf->SetFont(
'',
'', $default_font_size - 2);
2222 $pdf->SetXY($posx, $posy);
2223 $pdf->SetTextColor(0, 0, 60);
2224 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2229 if (!empty(
$object->project->ref)) {
2231 $pdf->SetXY($posx, $posy);
2232 $pdf->SetTextColor(0, 0, 60);
2233 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2239 if (!empty(
$object->project->ref)) {
2240 $outputlangs->load(
"projects");
2242 $pdf->SetXY($posx, $posy);
2243 $pdf->SetTextColor(0, 0, 60);
2244 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2248 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2249 if (
$object->type == 0 && $objectidnext) {
2250 $objectreplacing =
new Facture($this->db);
2251 $objectreplacing->fetch($objectidnext);
2254 $pdf->SetXY($posx, $posy);
2255 $pdf->SetTextColor(0, 0, 60);
2256 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2259 $objectreplaced =
new Facture($this->db);
2260 $objectreplaced->fetch(
$object->fk_facture_source);
2263 $pdf->SetXY($posx, $posy);
2264 $pdf->SetTextColor(0, 0, 60);
2265 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2268 $objectreplaced =
new Facture($this->db);
2269 $objectreplaced->fetch(
$object->fk_facture_source);
2272 $pdf->SetXY($posx, $posy);
2273 $pdf->SetTextColor(0, 0, 60);
2274 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2278 $pdf->SetXY($posx, $posy);
2279 $pdf->SetTextColor(0, 0, 60);
2281 $title = $outputlangs->transnoentities(
"DateInvoice");
2282 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2283 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2285 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2289 $pdf->SetXY($posx, $posy);
2290 $pdf->SetTextColor(0, 0, 60);
2291 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2296 $pdf->SetXY($posx, $posy);
2297 $pdf->SetTextColor(0, 0, 60);
2298 $title = $outputlangs->transnoentities(
"DateDue");
2299 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2300 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2302 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2307 $pdf->SetXY($posx, $posy);
2308 $pdf->SetTextColor(0, 0, 60);
2309 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2314 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2315 if (count($arrayidcontact) > 0) {
2316 $usertmp =
new User($this->db);
2317 $usertmp->fetch($arrayidcontact[0]);
2319 $pdf->SetXY($posx, $posy);
2320 $pdf->SetTextColor(0, 0, 60);
2321 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2330 $current_y = $pdf->getY();
2332 if ($current_y < $pdf->getY()) {
2333 $top_shift = $pdf->getY() - $current_y;
2338 $carac_emetteur =
'';
2340 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2341 if (count($arrayidcontact) > 0) {
2342 $object->fetch_user($arrayidcontact[0]);
2343 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2344 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2345 $carac_emetteur .=
"\n";
2352 $posy += $top_shift;
2353 $posx = $this->marge_gauche;
2355 $posx = $this->page_largeur - $this->marge_droite - 80;
2363 $pdf->SetTextColor(0, 0, 0);
2364 $pdf->SetFont(
'',
'', $default_font_size - 2);
2365 $pdf->SetXY($posx, $posy - 5);
2366 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2367 $pdf->SetXY($posx, $posy);
2368 $pdf->SetFillColor(230, 230, 230);
2369 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2370 $pdf->SetTextColor(0, 0, 60);
2375 $pdf->SetXY($posx + 2, $posy + 3);
2376 $pdf->SetFont(
'',
'B', $default_font_size);
2377 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2378 $posy = $pdf->getY();
2382 $pdf->SetXY($posx + 2, $posy);
2383 $pdf->SetFont(
'',
'', $default_font_size - 1);
2384 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2387 $usecontact =
false;
2388 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2389 if (count($arrayidcontact) > 0) {
2391 $result =
$object->fetch_contact($arrayidcontact[0]);
2395 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2396 $thirdparty =
$object->contact;
2398 $thirdparty =
$object->thirdparty;
2408 if ($this->page_largeur < 210) {
2412 $posy += $top_shift;
2413 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2415 $posx = $this->marge_gauche;
2420 $pdf->SetTextColor(0, 0, 0);
2421 $pdf->SetFont(
'',
'', $default_font_size - 2);
2422 $pdf->SetXY($posx + 2, $posy - 5);
2423 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2424 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2428 $pdf->SetXY($posx + 2, $posy + 3);
2429 $pdf->SetFont(
'',
'B', $default_font_size);
2431 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2433 $posy = $pdf->getY();
2436 $pdf->SetFont(
'',
'', $default_font_size - 1);
2437 $pdf->SetXY($posx + 2, $posy);
2439 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2443 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2445 if (!empty($idaddressshipping)) {
2446 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2447 $companystatic =
new Societe($this->db);
2448 $companystatic->fetch(
$object->contact->fk_soc);
2450 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
2455 if (!empty($carac_client_shipping)) {
2456 $posy += $hautcadre;
2459 $pdf->SetXY($posx + 2, $posy - 5);
2460 $pdf->SetFont(
'',
'', $default_font_size - 2);
2461 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2462 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2465 $pdf->SetXY($posx + 2, $posy + 3);
2466 $pdf->SetFont(
'',
'B', $default_font_size);
2467 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2469 $posy = $pdf->getY();
2472 $pdf->SetXY($posx + 2, $posy);
2473 $pdf->SetFont(
'',
'', $default_font_size - 1);
2474 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2475 $shipp_shift += $hautcadre;
2480 $pdf->SetTextColor(0, 0, 0);
2482 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);