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++;
412 if (preg_match(
'/^\((.*)\)$/',
$object->lines[$i]->desc, $reg)) {
413 if ($reg[1] ==
'DEPOSIT') {
424 if ($categoryOfOperation < 2) {
425 $lineProductType =
$object->lines[$i]->product_type;
431 if ($nbProduct > 0 && $nbService > 0) {
433 $categoryOfOperation = 2;
438 if ($categoryOfOperation <= 0) {
440 if ($nbProduct == 0 && $nbService > 0) {
441 $categoryOfOperation = 1;
444 $this->categoryOfOperation = $categoryOfOperation;
447 if (
$object->situation_cycle_ref) {
448 $this->situationinvoice =
true;
453 if (!empty($tplidx)) {
454 $pdf->useTemplate($tplidx);
459 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
460 $top_shift = $pagehead[
'top_shift'];
461 $shipp_shift = $pagehead[
'shipp_shift'];
462 $pdf->SetFont(
'',
'', $default_font_size - 1);
463 $pdf->MultiCell(0, 3,
'');
464 $pdf->SetTextColor(0, 0, 0);
469 $this->tab_top = 90 + $top_shift + $shipp_shift;
470 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
473 $extra_under_address_shift = 0;
476 $qrcodestring =
$object->buildZATCAQRString();
479 $qrcodestring =
$object->buildSwitzerlandQRString();
483 $qrcodestring =
$object->buildEPCQrCodeString();
488 $qrcodecolor = array(
'25',
'25',
'25');
493 'fgcolor' => $qrcodecolor,
498 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
502 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
503 $pdf->SetFont(
'',
'', $default_font_size - 4);
504 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
508 $extra_under_address_shift += 25;
516 'outputlangs' => $outputlangs,
517 'hidedetails' => $hidedetails
519 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
520 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
521 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
524 $this->tab_top += $extra_under_address_shift;
525 $this->tab_top_newpage += 0;
529 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->
getHeightForQRInvoice(1,
$object, $langs);
531 $nexY = $this->tab_top - 1;
534 $height_incoterms = 0;
535 if (isModEnabled(
'incoterm')) {
536 $desc_incoterms =
$object->getIncotermsForPDF();
537 if ($desc_incoterms) {
540 $pdf->SetFont(
'',
'', $default_font_size - 1);
541 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
542 $nexY = max($pdf->GetY(), $nexY);
543 $height_incoterms = $nexY - $this->tab_top;
546 $pdf->SetDrawColor(192, 192, 192);
547 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
549 $this->tab_top = $nexY + 6;
550 $height_incoterms += 4;
555 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
558 if (is_object(
$object->thirdparty)) {
559 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
560 $salerepobj =
new User($this->db);
561 $salerepobj->fetch($salereparray[0][
'id']);
562 if (!empty($salerepobj->signature)) {
563 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
569 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
570 if (!empty($extranote)) {
574 $pagenb = $pdf->getPage();
578 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
579 $pageposbeforenote = $pagenb;
586 $pdf->startTransaction();
588 $pdf->SetFont(
'',
'', $default_font_size - 1);
589 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
591 $pageposafternote = $pdf->getPage();
592 $posyafter = $pdf->GetY();
594 if ($pageposafternote > $pageposbeforenote) {
595 $pdf->rollbackTransaction(
true);
598 while ($pagenb < $pageposafternote) {
601 if (!empty($tplidx)) {
602 $pdf->useTemplate($tplidx);
607 $pdf->setTopMargin($this->tab_top_newpage);
609 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
613 $pdf->setPage($pageposbeforenote);
614 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
615 $pdf->SetFont(
'',
'', $default_font_size - 1);
616 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
617 $pageposafternote = $pdf->getPage();
619 $posyafter = $pdf->GetY();
621 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
622 $pdf->AddPage(
'',
'',
true);
625 $pdf->setPage($pageposafternote);
626 $pdf->setTopMargin($this->tab_top_newpage);
628 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
634 $i = $pageposbeforenote;
635 while ($i < $pageposafternote) {
639 $pdf->SetDrawColor(128, 128, 128);
641 if ($i > $pageposbeforenote) {
642 $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
643 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
645 $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
646 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
650 $pdf->setPageOrientation(
'', 1, 0);
657 $pdf->setPage($pageposafternote);
658 if (!empty($tplidx)) {
659 $pdf->useTemplate($tplidx);
664 $height_note = $posyafter - $this->tab_top_newpage;
665 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
668 $pdf->commitTransaction();
669 $posyafter = $pdf->GetY();
670 $height_note = $posyafter - $this->tab_top;
671 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
674 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
676 $pdf->AddPage(
'',
'',
true);
679 $pdf->setPage($pageposafternote);
680 if (!empty($tplidx)) {
681 $pdf->useTemplate($tplidx);
687 $posyafter = $this->tab_top_newpage;
691 $tab_height = $tab_height - $height_note;
692 $this->tab_top = $posyafter + 6;
701 $pdf->startTransaction();
702 $this->
pdfTabTitles($pdf, $this->tab_top, $tab_height, $outputlangs, $hidetop);
703 $pdf->rollbackTransaction(
true);
705 $nexY = $this->tab_top + $this->tabTitleHeight;
708 $pageposbeforeprintlines = $pdf->getPage();
709 $pagenb = $pageposbeforeprintlines;
710 for ($i = 0; $i < $nblines; $i++) {
712 $pdf->SetFont(
'',
'', $default_font_size - 1);
713 $pdf->SetTextColor(0, 0, 0);
716 $imglinesize = array();
717 if (!empty($realpatharray[$i])) {
721 $pdf->setTopMargin($this->tab_top_newpage);
722 $page_bottom_margin = $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(),
$object, $langs);
723 $pdf->setPageOrientation(
'', 1, $page_bottom_margin);
724 $pageposbefore = $pdf->getPage();
726 $showpricebeforepagebreak = 1;
728 $posYAfterDescription = 0;
732 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
733 $pdf->AddPage(
'',
'',
true);
734 if (!empty($tplidx)) {
735 $pdf->useTemplate($tplidx);
737 $pdf->setPage($pageposbefore + 1);
739 $curY = $this->tab_top_newpage;
743 $showpricebeforepagebreak = 1;
745 $showpricebeforepagebreak = 0;
749 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
750 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
752 $posYAfterImage = $curY + $imglinesize[
'height'];
758 $pdf->startTransaction();
761 $pageposafter = $pdf->getPage();
763 if ($pageposafter > $pageposbefore) {
764 $pdf->rollbackTransaction(
true);
765 $pageposafter = $pageposbefore;
766 $pdf->setPageOrientation(
'', 1, $this->heightforfooter);
770 $pageposafter = $pdf->getPage();
771 $posyafter = $pdf->GetY();
773 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
774 if ($i == ($nblines - 1)) {
775 $pdf->AddPage(
'',
'',
true);
776 if (!empty($tplidx)) {
777 $pdf->useTemplate($tplidx);
779 $pdf->setPage($pageposafter + 1);
785 $showpricebeforepagebreak = 1;
787 $showpricebeforepagebreak = 0;
791 $pdf->commitTransaction();
793 $posYAfterDescription = $pdf->GetY();
796 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
798 $pageposafter = $pdf->getPage();
799 $pdf->setPage($pageposbefore);
800 $pdf->setTopMargin($this->marge_haute);
801 $pdf->setPageOrientation(
'', 1, 0);
804 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
805 $pdf->setPage($pageposafter);
806 $curY = $this->tab_top_newpage;
809 $pdf->SetFont(
'',
'', $default_font_size - 1);
820 $nexY = max($pdf->GetY(), $nexY);
827 $nexY = max($pdf->GetY(), $nexY);
835 $nexY = max($pdf->GetY(), $nexY);
842 $nexY = max($pdf->GetY(), $nexY);
849 $nexY = max($pdf->GetY(), $nexY);
856 $nexY = max($pdf->GetY(), $nexY);
863 $nexY = max($pdf->GetY(), $nexY);
870 $nexY = max($pdf->GetY(), $nexY);
874 if (!empty(
$object->lines[$i]->array_options)) {
875 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
879 $nexY = max($pdf->GetY(), $nexY);
891 'outputlangs' => $outputlangs,
892 'hidedetails' => $hidedetails
894 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
902 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
903 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
904 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
905 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
907 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
910 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
911 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
913 $tvaligne = $sign *
$object->lines[$i]->total_tva;
917 $localtax1ligne =
$object->lines[$i]->total_localtax1;
918 $localtax2ligne =
$object->lines[$i]->total_localtax2;
919 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
920 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
921 $localtax1_type =
$object->lines[$i]->localtax1_type;
922 $localtax2_type =
$object->lines[$i]->localtax2_type;
935 $vatrate = (string)
$object->lines[$i]->tva_tx;
938 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
939 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
941 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
942 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
946 if ($localtax1_type && $localtax1ligne != 0) {
947 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
948 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
950 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
953 if ($localtax2_type && $localtax2ligne != 0) {
954 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
955 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
957 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
961 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
966 if (!isset($this->tva[$vatrate])) {
967 $this->tva[$vatrate] = 0;
969 $this->tva[$vatrate] += $tvaligne;
970 $vatcode =
$object->lines[$i]->vat_src_code;
971 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
972 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
974 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
976 $nexY = max($nexY, $posYAfterImage);
980 $pdf->setPage($pageposafter);
981 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
983 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
984 $pdf->SetLineStyle(array(
'dash' => 0));
988 while ($pagenb < $pageposafter) {
989 $pdf->setPage($pagenb);
991 if ($pagenb == $pageposbeforeprintlines) {
992 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
994 $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);
998 $pdf->setPage($pagenb);
999 $pdf->setPageOrientation(
'', 1, 0);
1003 if (!empty($tplidx)) {
1004 $pdf->useTemplate($tplidx);
1008 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
1010 if ($pagenb == $pageposafter) {
1011 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
1013 $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);
1018 if (!empty($tplidx)) {
1019 $pdf->useTemplate($tplidx);
1030 if ($pagenb == $pageposbeforeprintlines) {
1031 $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);
1032 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1034 $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);
1035 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1042 $posy = $this->
drawTotalTable($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1045 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1051 if (method_exists($pdf,
'AliasNbPages')) {
1052 $pdf->AliasNbPages();
1060 $pdf->Output($file,
'F');
1063 $hookmanager->initHooks(array(
'pdfgeneration'));
1064 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
1066 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1068 $this->error = $hookmanager->error;
1069 $this->errors = $hookmanager->errors;
1074 $this->result = array(
'fullpath' => $file);
1078 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1082 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1107 $tab3_top = $posy + 8;
1110 if ($this->page_largeur < 210) {
1116 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1118 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1121 $pdf->SetFont(
'',
'', $default_font_size - 3);
1122 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1123 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1125 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1127 $pdf->SetFont(
'',
'', $default_font_size - 4);
1128 $pdf->SetXY($tab3_posx, $tab3_top);
1129 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1130 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1131 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1132 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1133 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1134 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1135 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1137 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1141 $pdf->SetFont(
'',
'', $default_font_size - 4);
1145 $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,";
1146 $sql .=
" re.description, re.fk_facture_source,";
1147 $sql .=
" f.type, f.datef";
1148 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1149 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1150 $resql = $this->db->query($sql);
1152 $num = $this->db->num_rows($resql);
1154 $invoice =
new Facture($this->db);
1157 $obj = $this->db->fetch_object($resql);
1159 if ($obj->type == 2) {
1160 $text = $outputlangs->transnoentities(
"CreditNote");
1161 } elseif ($obj->type == 3) {
1162 $text = $outputlangs->transnoentities(
"Deposit");
1163 } elseif ($obj->type == 0) {
1164 $text = $outputlangs->transnoentities(
"ExcessReceived");
1166 $text = $outputlangs->transnoentities(
"UnknownType");
1169 $invoice->fetch($obj->fk_facture_source);
1171 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1172 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1173 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1174 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1175 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1176 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1177 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1178 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1180 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1185 $this->error = $this->db->lasterror();
1191 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1193 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1194 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1195 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1197 $sql .=
" ORDER BY p.datep";
1199 $resql = $this->db->query($sql);
1201 $num = $this->db->num_rows($resql);
1206 $row = $this->db->fetch_object($resql);
1207 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1208 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1209 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1210 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1211 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1212 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1214 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1215 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1216 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1217 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1218 $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
1219 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1224 return $tab3_top + $y + 3;
1226 $this->error = $this->db->lasterror();
1244 global $conf, $mysoc, $hookmanager;
1248 $pdf->SetFont(
'',
'', $default_font_size - 1);
1251 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1252 $pdf->SetFont(
'',
'', $default_font_size - 2);
1253 $pdf->SetXY($this->marge_gauche, $posy);
1254 if ($mysoc->forme_juridique_code == 92) {
1255 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1257 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1260 $posy = $pdf->GetY() + 4;
1265 if ($this->page_largeur < 210) {
1271 $pdf->SetFont(
'',
'', $default_font_size - 2);
1272 $pdf->SetXY($this->marge_gauche, $posy);
1273 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1274 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1276 $pdf->SetFont(
'',
'', $default_font_size - 2);
1277 $pdf->SetXY($posxval, $posy);
1278 $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);
1279 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1280 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1282 $posy = $pdf->GetY() + 3;
1286 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1287 $pdf->SetFont(
'',
'', $default_font_size - 2);
1288 $pdf->SetXY($this->marge_gauche, $posy);
1289 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1290 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1292 $pdf->SetFont(
'',
'', $default_font_size - 2);
1293 $pdf->SetXY($posxval, $posy);
1294 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1295 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1297 $posy = $pdf->GetY() + 3;
1302 if (empty(
$object->mode_reglement_code)
1305 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1309 $outputlangs->load(
"errors");
1311 $pdf->SetXY($this->marge_gauche, $posy);
1312 $pdf->SetTextColor(200, 0, 0);
1313 $pdf->SetFont(
'',
'', $default_font_size - 2);
1314 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1315 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1316 $pdf->SetTextColor(0, 0, 0);
1318 $posy = $pdf->GetY() + 1;
1322 if (!empty(
$object->mode_reglement_code)
1323 &&
$object->mode_reglement_code !=
'CHQ'
1324 &&
$object->mode_reglement_code !=
'VIR') {
1325 $pdf->SetFont(
'',
'', $default_font_size - 2);
1326 $pdf->SetXY($this->marge_gauche, $posy);
1327 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1328 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1330 $pdf->SetFont(
'',
'', $default_font_size - 2);
1331 $pdf->SetXY($posxval, $posy);
1332 $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);
1335 if (
$object->mode_reglement_code ==
"PRE") {
1336 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1339 $bac->fetch(0,
'',
$object->thirdparty->id);
1340 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1341 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1344 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1346 $posy = $pdf->GetY();
1352 if ($this->emetteur->country_code ==
'FR') {
1354 $pdf->SetXY($this->marge_gauche, $posy);
1355 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1357 $posy = $pdf->GetY() + 1;
1362 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1363 $useonlinepayment = 0;
1367 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1368 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1369 $useonlinepayment = count($validpaymentmethod);
1374 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1377 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1378 $servicename = $langs->transnoentities(
'Online');
1379 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref,
'',
'',
'');
1380 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1382 $pdf->SetXY($this->marge_gauche, $posy);
1383 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1385 $posy = $pdf->GetY() + 1;
1390 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1393 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1396 $account =
new Account($this->db);
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', $account->owner_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($account->owner_address), 0,
'L', 0);
1408 $posy = $pdf->GetY() + 2;
1411 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1412 $pdf->SetXY($this->marge_gauche, $posy);
1413 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1414 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1415 $posy = $pdf->GetY() + 1;
1418 $pdf->SetXY($this->marge_gauche, $posy);
1419 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1420 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1421 $posy = $pdf->GetY() + 2;
1428 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1434 $account =
new Account($this->db);
1435 $account->fetch($bankid);
1437 $curx = $this->marge_gauche;
1440 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1448 $qrCodeColor = array(
'25',
'25',
'25');
1452 'fgcolor' => $qrCodeColor,
1454 'module_width' => 1,
1455 'module_height' => 1
1458 $EPCQrCodeString =
$object->buildEPCQrCodeString();
1459 $pdf->write2DBarcode($EPCQrCodeString,
'QRCODE,M', $qrPosX, $qrPosY, 25, 25, $styleQr,
'N');
1461 $pdf->SetXY($qrPosX + 30, $posy + 5);
1462 $pdf->SetFont(
'',
'', $default_font_size - 5);
1463 $pdf->MultiCell(30, 3, $outputlangs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
1464 $posy = $pdf->GetY() + 2;
1487 global $conf, $mysoc, $hookmanager;
1498 if (is_object($outputlangsbis)) {
1499 $pdf->SetFont(
'',
'', $default_font_size - 2);
1501 $pdf->SetFont(
'',
'', $default_font_size - 1);
1507 if ($this->page_largeur < 210) {
1511 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1517 $parameters = array(
1519 'outputlangs' => $outputlangs,
1521 $hookmanager->executeHooks(
'beforePercentCalculation', $parameters, $this);
1526 foreach (
$object->lines as $line) {
1527 if ($line->product_type != 9) {
1528 $percent += $line->situation_percent;
1534 $avancementGlobal = $percent / $i;
1536 $avancementGlobal = 0;
1539 $object->fetchPreviousNextSituationInvoice();
1540 $TPreviousIncoice =
$object->tab_previous_situation_invoice;
1543 $total_a_payer_ttc = 0;
1544 foreach ($TPreviousIncoice as &$fac) {
1545 $total_a_payer += $fac->total_ht;
1546 $total_a_payer_ttc += $fac->total_ttc;
1548 $total_a_payer +=
$object->total_ht;
1549 $total_a_payer_ttc +=
$object->total_ttc;
1551 if (!empty($avancementGlobal)) {
1552 $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
1553 $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
1556 $total_a_payer_ttc = 0;
1560 if (!empty($TPreviousIncoice)) {
1561 $pdf->setY($tab2_top);
1562 $posy = $pdf->GetY();
1564 foreach ($TPreviousIncoice as &$fac) {
1565 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1570 $pdf->setY($this->tab_top_newpage);
1572 $pdf->setY($this->marge_haute);
1574 $posy = $pdf->GetY();
1579 $pdf->SetFillColor(255, 255, 255);
1580 $pdf->SetXY($col1x, $posy);
1581 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $fac->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1583 $pdf->SetXY($col2x, $posy);
1587 $facSign = $fac->total_ht >= 0 ?
'+' :
'';
1590 $displayAmount =
' '.$facSign.
' '.
price($fac->total_ht, 0, $outputlangs);
1592 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1601 $pdf->SetFillColor(255, 255, 255);
1602 $pdf->SetXY($col1x, $posy);
1603 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle",
$object->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1605 $pdf->SetXY($col2x, $posy);
1608 $facSign =
$object->total_ht >= 0 ?
'+' :
'';
1616 $displayAmount =
' '.$facSign.
' '.
price(
$object->total_ht, 0, $outputlangs);
1617 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1622 $pdf->SetFont(
'',
'', $default_font_size - 1);
1623 $pdf->SetFillColor(255, 255, 255);
1624 $pdf->SetXY($col1x, $posy);
1625 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"SituationTotalProgress", $avancementGlobal), 0,
'L', 1);
1627 $pdf->SetXY($col2x, $posy);
1628 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0,
'R', 1);
1629 $pdf->SetFont(
'',
'', $default_font_size - 2);
1633 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1637 $pdf->setY($this->tab_top_newpage);
1639 $pdf->setY($this->marge_haute);
1642 $posy = $pdf->GetY();
1653 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1656 $total_line_remise = 0;
1657 foreach (
$object->lines as $i => $line) {
1659 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1661 if ($line->total_ht < 0) {
1662 $total_line_remise += -$line->total_ht;
1664 $usemc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1);
1665 $total_line_remise_print = $total_line_remise;
1667 $ratio = (!empty(
$object->total_ht) ? (float)
$object->multicurrency_total_ht / (
float)
$object->total_ht : 0);
1668 if (!empty($ratio)) $total_line_remise_print =
price2num($total_line_remise * $ratio,
'MT');
1671 if ($total_line_remise > 0) {
1673 $pdf->SetFillColor(255, 255, 255);
1674 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1675 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1676 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1677 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise_print, 0, $outputlangs), 0,
'R', 1);
1682 $pdf->SetFillColor(255, 255, 255);
1683 $pdf->SetXY($col1x, $tab2_top);
1684 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1685 $pdf->SetXY($col2x, $tab2_top);
1686 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise_print + $total_ht, 0, $outputlangs), 0,
'R', 1);
1692 $pdf->SetFillColor(255, 255, 255);
1693 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1694 $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);
1696 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1697 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1698 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1701 $pdf->SetFillColor(248, 248, 248);
1703 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1705 $this->atleastoneratenotnull = 0;
1707 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1708 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1712 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1713 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1717 foreach ($localtax_rate as $tvakey => $tvaval) {
1722 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1725 if (preg_match(
'/\*/', (
string) $tvakey)) {
1726 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1727 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1730 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1734 $totalvat .= $tvacompl;
1736 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1739 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1741 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1743 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1744 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1750 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1751 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1755 foreach ($localtax_rate as $tvakey => $tvaval) {
1760 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1763 if (preg_match(
'/\*/', (
string) $tvakey)) {
1764 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1765 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1767 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1771 $totalvat .= $tvacompl;
1773 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1776 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1778 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1780 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1781 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1789 foreach ($this->tva as $tvakey => $tvaval) {
1790 $sum_pdf_tva += $tvaval;
1793 if ($sum_pdf_tva !=
$object->total_tva) {
1794 if (!empty($sum_pdf_tva)) {
1795 $coef_fix_tva =
$object->total_tva / $sum_pdf_tva;
1801 foreach ($this->tva as $tvakey => $tvaval) {
1802 $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1804 foreach ($this->tva_array as $tvakey => $tvaval) {
1805 $this->tva_array[$tvakey][
'amount'] = $tvaval[
'amount'] * $coef_fix_tva;
1811 foreach ($this->tva_array as $tvakey => $tvaval) {
1813 $this->atleastoneratenotnull++;
1816 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1819 if (preg_match(
'/\*/', $tvakey)) {
1820 $tvakey = str_replace(
'*',
'', $tvakey);
1821 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1823 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1826 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1828 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1830 $totalvat .= $tvacompl;
1832 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1834 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1836 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1837 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1842 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1843 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1847 foreach ($localtax_rate as $tvakey => $tvaval) {
1852 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1855 if (preg_match(
'/\*/', (
string) $tvakey)) {
1856 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1857 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1859 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1863 $totalvat .= $tvacompl;
1865 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1868 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1870 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1872 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1873 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1879 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1880 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1884 foreach ($localtax_rate as $tvakey => $tvaval) {
1890 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1893 if (preg_match(
'/\*/', (
string) $tvakey)) {
1894 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1895 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1897 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1901 $totalvat .= $tvacompl;
1903 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1906 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1908 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1910 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1911 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1919 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1920 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1922 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1923 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1928 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1929 $pdf->SetTextColor(0, 0, 60);
1930 $pdf->SetFillColor(224, 224, 224);
1931 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1933 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1934 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1938 if (
$object->displayRetainedWarranty()) {
1939 $pdf->SetTextColor(40, 40, 40);
1940 $pdf->SetFillColor(255, 255, 255);
1942 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1943 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1947 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1948 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1950 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1951 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1955 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1957 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.
$object->retained_warranty.
'%)';
1958 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1960 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1961 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1962 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1967 $pdf->SetTextColor(0, 0, 0);
1969 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1970 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1972 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1977 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1980 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1981 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"Paid") :
''), 0,
'L', 0);
1982 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1983 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1986 if ($creditnoteamount) {
1987 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1988 $labeltouse .= (is_object($outputlangsbis) ? (
' / '.(($outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities(
"CreditNotes"))) :
'');
1990 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1991 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1992 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1993 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1996 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1998 $pdf->SetFillColor(255, 255, 255);
2000 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
2001 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"EscompteOfferedShort") :
''), $useborder,
'L', 1);
2002 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
2003 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT'), 0, $outputlangs), $useborder,
'R', 1);
2009 $pdf->SetTextColor(0, 0, 60);
2010 $pdf->SetFillColor(224, 224, 224);
2011 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
2012 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
2013 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
2014 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
2016 $pdf->SetFont(
'',
'', $default_font_size - 1);
2017 $pdf->SetTextColor(0, 0, 0);
2020 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
2022 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
2024 $this->error = $hookmanager->error;
2025 $this->errors = $hookmanager->errors;
2029 return ($tab2_top + ($tab2_hl * $index));
2125 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
2128 global $conf, $langs;
2130 $ltrdirection =
'L';
2131 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2132 $ltrdirection =
'R';
2136 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2142 $pdf->SetTextColor(0, 0, 60);
2143 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2147 $posy = $this->marge_haute;
2148 $posx = $this->page_largeur - $this->marge_droite - $w;
2150 $pdf->SetXY($this->marge_gauche, $posy);
2154 if ($this->emetteur->logo) {
2155 $logodir = $conf->mycompany->dir_output;
2156 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
2157 $logodir = $conf->mycompany->multidir_output[
$object->entity];
2160 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2162 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2164 if (is_readable($logo)) {
2166 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2168 $pdf->SetTextColor(200, 0, 0);
2169 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2170 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2171 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2174 $text = $this->emetteur->name;
2175 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2179 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2180 $pdf->SetXY($posx, $posy);
2181 $pdf->SetTextColor(0, 0, 60);
2182 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2184 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2187 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2190 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2193 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2195 if ($this->situationinvoice) {
2196 $outputlangs->loadLangs(array(
"other"));
2197 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
2199 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2202 if ($this->situationinvoice) {
2203 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2205 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2206 } elseif (
$object->type == 1) {
2207 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2208 } elseif (
$object->type == 2) {
2209 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2210 } elseif (
$object->type == 3) {
2211 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2212 } elseif (
$object->type == 4) {
2213 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2216 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2217 if (
$object->statut == $object::STATUS_DRAFT) {
2218 $pdf->SetTextColor(128, 0, 0);
2219 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2222 $pdf->MultiCell($w, 3, $title,
'',
'R');
2224 $pdf->SetFont(
'',
'B', $default_font_size);
2238 $pdf->SetFont(
'',
'', $default_font_size - 2);
2242 $pdf->SetXY($posx, $posy);
2243 $pdf->SetTextColor(0, 0, 60);
2244 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_customer), 65),
'',
'R');
2249 if (!empty(
$object->project->ref)) {
2251 $pdf->SetXY($posx, $posy);
2252 $pdf->SetTextColor(0, 0, 60);
2253 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2259 if (!empty(
$object->project->ref)) {
2260 $outputlangs->load(
"projects");
2262 $pdf->SetXY($posx, $posy);
2263 $pdf->SetTextColor(0, 0, 60);
2264 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2268 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2269 if (
$object->type == 0 && $objectidnext) {
2270 $objectreplacing =
new Facture($this->db);
2271 $objectreplacing->fetch($objectidnext);
2274 $pdf->SetXY($posx, $posy);
2275 $pdf->SetTextColor(0, 0, 60);
2276 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2279 $objectreplaced =
new Facture($this->db);
2280 $objectreplaced->fetch(
$object->fk_facture_source);
2283 $pdf->SetXY($posx, $posy);
2284 $pdf->SetTextColor(0, 0, 60);
2285 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2288 $objectreplaced =
new Facture($this->db);
2289 $objectreplaced->fetch(
$object->fk_facture_source);
2292 $pdf->SetXY($posx, $posy);
2293 $pdf->SetTextColor(0, 0, 60);
2294 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2298 $pdf->SetXY($posx, $posy);
2299 $pdf->SetTextColor(0, 0, 60);
2301 $title = $outputlangs->transnoentities(
"DateInvoice");
2302 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2303 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2305 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2309 $pdf->SetXY($posx, $posy);
2310 $pdf->SetTextColor(0, 0, 60);
2311 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2316 $pdf->SetXY($posx, $posy);
2317 $pdf->SetTextColor(0, 0, 60);
2318 $title = $outputlangs->transnoentities(
"DateDue");
2319 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2320 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2322 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2327 $pdf->SetXY($posx, $posy);
2328 $pdf->SetTextColor(0, 0, 60);
2329 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2334 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2335 if (count($arrayidcontact) > 0) {
2336 $usertmp =
new User($this->db);
2337 $usertmp->fetch($arrayidcontact[0]);
2339 $pdf->SetXY($posx, $posy);
2340 $pdf->SetTextColor(0, 0, 60);
2341 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2350 $current_y = $pdf->getY();
2352 if ($current_y < $pdf->getY()) {
2353 $top_shift = $pdf->getY() - $current_y;
2358 $carac_emetteur =
'';
2360 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2361 if (count($arrayidcontact) > 0) {
2362 $object->fetch_user($arrayidcontact[0]);
2363 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2364 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2365 $carac_emetteur .=
"\n";
2372 $posy += $top_shift;
2373 $posx = $this->marge_gauche;
2375 $posx = $this->page_largeur - $this->marge_droite - 80;
2383 $pdf->SetTextColor(0, 0, 0);
2384 $pdf->SetFont(
'',
'', $default_font_size - 2);
2385 $pdf->SetXY($posx, $posy - 5);
2386 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2387 $pdf->SetXY($posx, $posy);
2388 $pdf->SetFillColor(230, 230, 230);
2389 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2390 $pdf->SetTextColor(0, 0, 60);
2395 $pdf->SetXY($posx + 2, $posy + 3);
2396 $pdf->SetFont(
'',
'B', $default_font_size);
2397 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2398 $posy = $pdf->getY();
2402 $pdf->SetXY($posx + 2, $posy);
2403 $pdf->SetFont(
'',
'', $default_font_size - 1);
2404 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2407 $usecontact =
false;
2408 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2409 if (count($arrayidcontact) > 0) {
2411 $result =
$object->fetch_contact($arrayidcontact[0]);
2415 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2416 $thirdparty =
$object->contact;
2418 $thirdparty =
$object->thirdparty;
2428 if ($this->page_largeur < 210) {
2432 $posy += $top_shift;
2433 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2435 $posx = $this->marge_gauche;
2440 $pdf->SetTextColor(0, 0, 0);
2441 $pdf->SetFont(
'',
'', $default_font_size - 2);
2442 $pdf->SetXY($posx + 2, $posy - 5);
2443 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2444 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2448 $pdf->SetXY($posx + 2, $posy + 3);
2449 $pdf->SetFont(
'',
'B', $default_font_size);
2451 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2453 $posy = $pdf->getY();
2456 $pdf->SetFont(
'',
'', $default_font_size - 1);
2457 $pdf->SetXY($posx + 2, $posy);
2459 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2463 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2465 if (!empty($idaddressshipping)) {
2466 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2467 $companystatic =
new Societe($this->db);
2468 $companystatic->fetch(
$object->contact->fk_soc);
2475 if (!empty($carac_client_shipping)) {
2476 $posy += $hautcadre;
2478 $hautcadre = $hautcadre - 10;
2481 $pdf->SetXY($posx + 2, $posy - 5);
2482 $pdf->SetFont(
'',
'', $default_font_size - 2);
2483 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2484 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2487 $pdf->SetXY($posx + 2, $posy + 3);
2488 $pdf->SetFont(
'',
'B', $default_font_size);
2489 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2491 $posy = $pdf->getY();
2494 $pdf->SetXY($posx + 2, $posy);
2495 $pdf->SetFont(
'',
'', $default_font_size - 1);
2496 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2498 $shipp_shift += $hautcadre + 10;
2503 $pdf->SetTextColor(0, 0, 0);
2505 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);