194 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
197 global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
199 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
201 if (!is_object($outputlangs)) {
202 $outputlangs = $langs;
206 $outputlangs->charset_output =
'ISO-8859-1';
210 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
213 if ($object->statut == $object::STATUS_DRAFT && (
getDolGlobalString(
'FACTURE_DRAFT_WATERMARK'))) {
214 $this->watermark = $conf->global->FACTURE_DRAFT_WATERMARK;
217 global $outputlangsbis;
218 $outputlangsbis =
null;
219 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
220 $outputlangsbis =
new Translate(
'', $conf);
221 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
222 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
225 $nblines = count($object->lines);
228 $realpatharray = array();
230 for ($i = 0; $i < $nblines; $i++) {
231 if (empty($object->lines[$i]->fk_product)) {
235 $objphoto =
new Product($this->db);
236 $objphoto->fetch($object->lines[$i]->fk_product);
238 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
239 $dir = $conf->product->dir_output.
'/'.$pdir;
242 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
243 $filename = $obj[
'photo'];
245 $realpath = $dir.$filename;
250 $realpatharray[$i] = $realpath;
254 if (count($realpatharray) == 0) {
255 $this->posxpicture = $this->posxtva;
258 if ($conf->facture->dir_output) {
259 $object->fetch_thirdparty();
261 $deja_regle = $object->getSommePaiement((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
262 $amount_credit_notes_included = $object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
263 $amount_deposits_included = $object->getSumDepositsUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
266 if ($object->specimen) {
267 $dir = empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity];
268 $file = $dir.
"/SPECIMEN.pdf";
271 $dir = (empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity]).
"/".$objectref;
272 $file = $dir.
"/".$objectref.
".pdf";
274 if (!file_exists($dir)) {
276 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
281 if (file_exists($dir)) {
283 if (!is_object($hookmanager)) {
284 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
287 $hookmanager->initHooks(array(
'pdfgeneration'));
288 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
290 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
293 $nblines = count($object->lines);
294 $nbpayments = count($object->getListOfPayments());
299 $pdf->SetAutoPageBreak(1, 0);
301 $heightforinfotot = 50 + (4 * $nbpayments);
302 if ($heightforinfotot > 220) {
303 $heightforinfotot = 220;
305 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
306 $heightforfooter = $this->marge_basse + 8;
308 $heightforfooter += 6;
311 $heightforqrinvoice_firstpage = 0;
314 if ($heightforqrinvoice_firstpage > 0) {
316 $heightforinfotot = 30 + (4 * $nbpayments);
320 if (class_exists(
'TCPDF')) {
321 $pdf->setPrintHeader(
false);
322 $pdf->setPrintFooter(
false);
328 $logodir = $conf->mycompany->dir_output;
329 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
330 $logodir = $conf->mycompany->multidir_output[$object->entity];
332 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
333 $tplidx = $pdf->importPage(1);
338 $pdf->SetDrawColor(128, 128, 128);
340 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
341 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
342 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
343 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
344 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
346 $pdf->SetCompression(
false);
350 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
351 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
357 $certprivate = !
getDolGlobalString(
'CERTIFICATE_CRT_PRIVATE') ?
'' : $conf->global->CERTIFICATE_CRT_PRIVATE;
362 'Name' => $this->emetteur->name,
363 'Location' =>
getCountry($this->emetteur->country_code, 0),
364 'Reason' =>
'INVOICE',
365 'ContactInfo' => $this->emetteur->email
367 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
370 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
374 $categoryOfOperation = 0;
377 for ($i = 0; $i < $nblines; $i++) {
378 if ($object->lines[$i]->remise_percent) {
379 $this->atleastonediscount++;
384 if (preg_match(
'/^\((.*)\)$/', $object->lines[$i]->desc, $reg)) {
385 if ($reg[1] ==
'DEPOSIT') {
396 if ($categoryOfOperation < 2) {
397 $lineProductType = $object->lines[$i]->product_type;
403 if ($nbProduct > 0 && $nbService > 0) {
405 $categoryOfOperation = 2;
410 if ($categoryOfOperation <= 0) {
412 if ($nbProduct == 0 && $nbService > 0) {
413 $categoryOfOperation = 1;
416 $this->categoryOfOperation = $categoryOfOperation;
417 if (empty($this->atleastonediscount)) {
418 $delta = ($this->posxprogress - $this->posxdiscount);
419 $this->posxpicture += $delta;
420 $this->posxtva += $delta;
421 $this->posxup += $delta;
422 $this->posxqty += $delta;
423 $this->posxunit += $delta;
424 $this->posxdiscount += $delta;
431 $this->situationinvoice =
true;
432 $progress_width = 10;
433 $this->posxpicture -= $progress_width;
434 $this->posxtva -= $progress_width;
435 $this->posxup -= $progress_width;
436 $this->posxqty -= $progress_width;
437 $this->posxunit -= $progress_width;
438 $this->posxdiscount -= $progress_width;
439 $this->posxprogress -= $progress_width;
444 if (!empty($tplidx)) {
445 $pdf->useTemplate($tplidx);
450 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
451 $pdf->SetFont(
'',
'', $default_font_size - 1);
452 $pdf->MultiCell(0, 3,
'');
453 $pdf->SetTextColor(0, 0, 0);
458 $tab_top = 90 + $top_shift;
459 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
462 $extra_under_address_shift = 0;
465 $qrcodestring = $object->buildZATCAQRString();
467 $qrcodestring = $object->buildSwitzerlandQRString();
471 $qrcodecolor = array(
'25',
'25',
'25');
476 'fgcolor' => $qrcodecolor,
481 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr,
'N');
482 $extra_under_address_shift += 25;
490 'outputlangs' => $outputlangs,
491 'hidedetails' => $hidedetails
493 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
494 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
495 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
498 $tab_top += $extra_under_address_shift;
499 $tab_top_newpage += 0;
502 $height_incoterms = 0;
503 if (isModEnabled(
'incoterm')) {
504 $desc_incoterms = $object->getIncotermsForPDF();
505 if ($desc_incoterms) {
508 $pdf->SetFont(
'',
'', $default_font_size - 1);
509 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
510 $nexY = $pdf->GetY();
511 $height_incoterms = $nexY - $tab_top;
514 $pdf->SetDrawColor(192, 192, 192);
515 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
517 $tab_top = $nexY + 6;
522 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
525 if (is_object($object->thirdparty)) {
526 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
527 $salerepobj =
new User($this->db);
528 $salerepobj->fetch($salereparray[0][
'id']);
529 if (!empty($salerepobj->signature)) {
530 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
535 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
536 if (!empty($extranote)) {
548 $pdf->SetFont(
'',
'', $default_font_size - 1);
549 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
550 $nexY = $pdf->GetY();
551 $height_note = $nexY - $tab_top;
554 $pdf->SetDrawColor(192, 192, 192);
555 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
557 $tab_top = $nexY + 6;
560 $iniY = $tab_top + 7;
561 $curY = $tab_top + 7;
562 $nexY = $tab_top + 7;
565 for ($i = 0; $i < $nblines; $i++) {
567 $pdf->SetFont(
'',
'', $default_font_size - 1);
568 $pdf->SetTextColor(0, 0, 0);
571 $imglinesize = array();
572 if (!empty($realpatharray[$i])) {
576 $pdf->setTopMargin($tab_top_newpage);
577 $page_bottom_margin = $heightforfooter + $heightforfreetext + $heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(), $object, $langs);
578 $pdf->setPageOrientation(
'', 1, $page_bottom_margin);
579 $pageposbefore = $pdf->getPage();
581 $showpricebeforepagebreak = 1;
583 $posYAfterDescription = 0;
586 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
587 $pdf->AddPage(
'',
'',
true);
588 if (!empty($tplidx)) {
589 $pdf->useTemplate($tplidx);
592 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
593 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
595 $pdf->setPage($pageposbefore + 1);
597 $curY = $tab_top_newpage;
601 $showpricebeforepagebreak = 1;
603 $showpricebeforepagebreak = 0;
607 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
608 $curX = $this->posxpicture - 1;
609 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
611 $posYAfterImage = $curY + $imglinesize[
'height'];
615 $curX = $this->posxdesc - 1;
617 $pdf->startTransaction();
618 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
619 $pageposafter = $pdf->getPage();
620 if ($pageposafter > $pageposbefore) {
621 $pdf->rollbackTransaction(
true);
622 $pageposafter = $pageposbefore;
624 $pdf->setPageOrientation(
'', 1, $heightforfooter);
625 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
626 $pageposafter = $pdf->getPage();
627 $posyafter = $pdf->GetY();
629 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
630 if ($i == ($nblines - 1)) {
631 $pdf->AddPage(
'',
'',
true);
632 if (!empty($tplidx)) {
633 $pdf->useTemplate($tplidx);
636 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
637 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
639 $pdf->setPage($pageposafter + 1);
646 $showpricebeforepagebreak = 1;
648 $showpricebeforepagebreak = 0;
652 $pdf->commitTransaction();
654 $posYAfterDescription = $pdf->GetY();
656 $nexY = $pdf->GetY();
657 $pageposafter = $pdf->getPage();
658 $pdf->setPage($pageposbefore);
659 $pdf->setTopMargin($this->marge_haute);
660 $pdf->setPageOrientation(
'', 1, 0);
663 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
664 $pdf->setPage($pageposafter);
665 $curY = $tab_top_newpage;
668 $pdf->SetFont(
'',
'', $default_font_size - 1);
673 $pdf->SetXY($this->posxtva - 5, $curY);
674 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
679 $pdf->SetXY($this->posxup, $curY);
680 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
684 $pdf->SetXY($this->posxqty, $curY);
685 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
689 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
690 $pdf->SetXY($this->posxunit, $curY);
691 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
695 if ($object->lines[$i]->remise_percent) {
696 $pdf->SetXY($this->posxdiscount - 2, $curY);
698 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
702 if ($this->situationinvoice) {
704 $pdf->SetXY($this->posxprogress, $curY);
705 $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0,
'R');
710 $pdf->SetXY($this->postotalht, $curY);
711 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
715 if (isset($object->type) && $object->type == 2 &&
getDolGlobalString(
'INVOICE_POSITIVE_CREDIT_NOTE')) {
719 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
720 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
721 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
722 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
724 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
727 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
728 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
730 $tvaligne = $sign * $object->lines[$i]->total_tva;
734 $localtax1ligne = $object->lines[$i]->total_localtax1;
735 $localtax2ligne = $object->lines[$i]->total_localtax2;
736 $localtax1_rate = $object->lines[$i]->localtax1_tx;
737 $localtax2_rate = $object->lines[$i]->localtax2_tx;
738 $localtax1_type = $object->lines[$i]->localtax1_type;
739 $localtax2_type = $object->lines[$i]->localtax2_type;
752 $vatrate = (string) $object->lines[$i]->tva_tx;
755 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
756 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
758 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
759 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
763 if ($localtax1_type && $localtax1ligne != 0) {
764 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
765 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
767 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
770 if ($localtax2_type && $localtax2ligne != 0) {
771 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
772 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
774 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
778 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
783 if (!isset($this->tva[$vatrate])) {
784 $this->tva[$vatrate] = 0;
786 $this->tva[$vatrate] += $tvaligne;
787 $vatcode = $object->lines[$i]->vat_src_code;
788 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
789 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
791 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
793 if ($posYAfterImage > $posYAfterDescription) {
794 $nexY = $posYAfterImage;
799 $pdf->setPage($pageposafter);
800 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
802 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
803 $pdf->SetLineStyle(array(
'dash'=>0));
809 while ($pagenb < $pageposafter) {
810 $pdf->setPage($pagenb);
812 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1, $object->multicurrency_code);
814 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
818 $pdf->setPage($pagenb);
819 $pdf->setPageOrientation(
'', 1, 0);
821 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
822 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
824 if (!empty($tplidx)) {
825 $pdf->useTemplate($tplidx);
828 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
830 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1, $object->multicurrency_code);
832 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
837 if (!empty($tplidx)) {
838 $pdf->useTemplate($tplidx);
842 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
843 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
850 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 0, $object->multicurrency_code);
851 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage + 1;
853 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
854 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
856 dol_syslog(
"bottomlasttab=".$bottomlasttab.
" this->page_hauteur=".$this->page_hauteur.
" heightforinfotot=".$heightforinfotot.
" heightforfreetext=".$heightforfreetext.
" heightforfooter=".$heightforfooter);
859 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
862 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
865 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
871 if (method_exists($pdf,
'AliasNbPages')) {
872 $pdf->AliasNbPages();
884 $pdf->Output($file,
'F');
887 $hookmanager->initHooks(array(
'pdfgeneration'));
888 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
890 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
892 $this->error = $hookmanager->error;
893 $this->errors = $hookmanager->errors;
898 $this->result = array(
'fullpath'=>$file);
902 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
906 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
934 $current_page = $pdf->getPage();
936 $tab3_top = $posy + 8;
939 if ($this->page_largeur < 210) {
945 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height);
949 $pdf->SetFont(
'',
'', $default_font_size - 4);
953 $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,";
954 $sql .=
" re.description, re.fk_facture_source,";
955 $sql .=
" f.type, f.datef";
956 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
957 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int) $object->id);
958 $resql = $this->db->query($sql);
960 $num = $this->db->num_rows($resql);
962 $invoice =
new Facture($this->db);
965 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
968 $pdf->AddPage(
'',
'',
true);
973 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
974 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
976 $pdf->setPage($current_page);
977 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
980 $obj = $this->db->fetch_object($resql);
982 if ($obj->type == 2) {
983 $text = $outputlangs->transnoentities(
"CreditNote");
984 } elseif ($obj->type == 3) {
985 $text = $outputlangs->transnoentities(
"Deposit");
986 } elseif ($obj->type == 0) {
987 $text = $outputlangs->transnoentities(
"ExcessReceived");
989 $text = $outputlangs->transnoentities(
"UnknownType");
992 $invoice->fetch($obj->fk_facture_source);
994 $pdf->SetXY($tab3_posx, $tab3_top + $y);
995 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
996 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
997 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
998 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
999 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1000 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1001 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1003 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1008 $this->error = $this->db->lasterror();
1014 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1016 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1017 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1018 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
1020 $sql .=
" ORDER BY p.datep";
1022 $resql = $this->db->query($sql);
1024 $num = $this->db->num_rows($resql);
1029 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1032 $pdf->AddPage(
'',
'',
true);
1037 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
1038 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1040 $pdf->setPage($current_page);
1041 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
1044 $row = $this->db->fetch_object($resql);
1046 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1047 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1048 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1049 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1050 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1051 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1053 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1054 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1055 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1056 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1057 $y = $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1058 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1063 return $tab3_top + $y + 3;
1065 $this->error = $this->db->lasterror();
1124 protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
1127 global $conf, $mysoc;
1131 $pdf->SetFont(
'',
'', $default_font_size - 1);
1134 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1135 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1136 $pdf->SetXY($this->marge_gauche, $posy);
1137 if ($mysoc->forme_juridique_code == 92) {
1138 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1140 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1143 $posy = $pdf->GetY() + 4;
1148 if ($this->page_largeur < 210) {
1153 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
1154 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1155 $pdf->SetXY($this->marge_gauche, $posy);
1156 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1157 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1159 $pdf->SetFont(
'',
'', $default_font_size - 2);
1160 $pdf->SetXY($posxval, $posy);
1161 $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);
1162 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1163 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1165 $posy = $pdf->GetY() + 3;
1169 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1170 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1171 $pdf->SetXY($this->marge_gauche, $posy);
1172 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1173 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1175 $pdf->SetFont(
'',
'', $default_font_size - 2);
1176 $pdf->SetXY($posxval, $posy);
1177 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1178 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1180 $posy = $pdf->GetY() + 3;
1183 if ($object->type != 2) {
1185 if (empty($object->mode_reglement_code)
1188 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1189 } elseif (($object->mode_reglement_code ==
'CHQ' && !
getDolGlobalInt(
'FACTURE_CHQ_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))
1190 || ($object->mode_reglement_code ==
'VIR' && !
getDolGlobalInt(
'FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
1192 $outputlangs->load(
"errors");
1194 $pdf->SetXY($this->marge_gauche, $posy);
1195 $pdf->SetTextColor(200, 0, 0);
1196 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1197 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1198 $pdf->MultiCell(80, 3, $this->error, 0,
'L', 0);
1199 $pdf->SetTextColor(0, 0, 0);
1201 $posy = $pdf->GetY() + 1;
1205 if (!empty($object->mode_reglement_code)
1206 && $object->mode_reglement_code !=
'CHQ'
1207 && $object->mode_reglement_code !=
'VIR') {
1208 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1209 $pdf->SetXY($this->marge_gauche, $posy);
1210 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1211 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1213 $pdf->SetFont(
'',
'', $default_font_size - 2);
1214 $pdf->SetXY($posxval, $posy);
1215 $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);
1217 if ($object->mode_reglement_code ==
"PRE") {
1218 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1220 $bac->fetch(0, $object->thirdparty->id);
1221 $iban= $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1222 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1224 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1226 $posy = $pdf->GetY();
1232 if ($this->emetteur->country_code ==
'FR') {
1234 $pdf->SetXY($this->marge_gauche, $posy);
1235 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1237 $posy = $pdf->GetY() + 1;
1242 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CB' || $object->mode_reglement_code ==
'VAD') {
1243 $useonlinepayment = 0;
1245 if (isModEnabled(
'paypal')) {
1246 $useonlinepayment++;
1248 if (isModEnabled(
'stripe')) {
1249 $useonlinepayment++;
1251 if (isModEnabled(
'paybox')) {
1252 $useonlinepayment++;
1257 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1260 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1261 $servicename = $langs->transnoentities(
'Online');
1262 $paiement_url = getOnlinePaymentUrl(
'',
'invoice', $object->ref,
'',
'',
'');
1263 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1265 $pdf->SetXY($this->marge_gauche, $posy);
1268 $posy = $pdf->GetY() + 1;
1273 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1276 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1279 $account =
new Account($this->db);
1282 $pdf->SetXY($this->marge_gauche, $posy);
1283 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1284 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1285 $posy = $pdf->GetY() + 1;
1288 $pdf->SetXY($this->marge_gauche, $posy);
1289 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1290 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1291 $posy = $pdf->GetY() + 2;
1294 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1295 $pdf->SetXY($this->marge_gauche, $posy);
1296 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1297 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1298 $posy = $pdf->GetY() + 1;
1301 $pdf->SetXY($this->marge_gauche, $posy);
1302 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1303 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1304 $posy = $pdf->GetY() + 2;
1311 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1312 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1313 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1314 if ($object->fk_bank > 0) {
1315 $bankid = $object->fk_bank;
1317 $account =
new Account($this->db);
1318 $account->fetch($bankid);
1320 $curx = $this->marge_gauche;
1323 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1347 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
1350 global $conf, $mysoc, $hookmanager;
1359 $outputlangsbis =
null;
1360 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1361 $outputlangsbis =
new Translate(
'', $conf);
1362 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1363 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1364 $default_font_size--;
1369 $pdf->SetFont(
'',
'', $default_font_size - 1);
1374 if ($this->page_largeur < 210) {
1378 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1384 $pdf->SetFillColor(255, 255, 255);
1385 $pdf->SetXY($col1x, $tab2_top);
1386 $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);
1388 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1389 $pdf->SetXY($col2x, $tab2_top);
1390 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1393 $pdf->SetFillColor(248, 248, 248);
1395 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1397 $this->atleastoneratenotnull = 0;
1399 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1400 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1406 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1407 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1411 foreach ($localtax_rate as $tvakey => $tvaval) {
1416 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1419 if (preg_match(
'/\*/', $tvakey)) {
1420 $tvakey = str_replace(
'*',
'', $tvakey);
1421 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1424 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1426 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1427 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1429 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1431 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1432 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1440 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1441 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1445 foreach ($localtax_rate as $tvakey => $tvaval) {
1450 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1453 if (preg_match(
'/\*/', $tvakey)) {
1454 $tvakey = str_replace(
'*',
'', $tvakey);
1455 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1457 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1459 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1460 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1462 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1464 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1465 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1473 foreach ($this->tva_array as $tvakey => $tvaval) {
1475 $this->atleastoneratenotnull++;
1478 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1481 if (preg_match(
'/\*/', $tvakey)) {
1482 $tvakey = str_replace(
'*',
'', $tvakey);
1483 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1485 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1488 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1490 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1492 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1494 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1496 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1497 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1504 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1505 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1509 foreach ($localtax_rate as $tvakey => $tvaval) {
1514 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1517 if (preg_match(
'/\*/', $tvakey)) {
1518 $tvakey = str_replace(
'*',
'', $tvakey);
1519 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1521 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1522 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1524 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1526 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1528 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1529 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1537 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1538 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1542 foreach ($localtax_rate as $tvakey => $tvaval) {
1546 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1549 if (preg_match(
'/\*/', $tvakey)) {
1550 $tvakey = str_replace(
'*',
'', $tvakey);
1551 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1553 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1555 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1556 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1558 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1560 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1561 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1567 if (
price2num($object->revenuestamp) != 0) {
1569 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1570 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp"), $useborder,
'L', 1);
1572 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1573 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $object->revenuestamp), $useborder,
'R', 1);
1578 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1579 $pdf->SetTextColor(0, 0, 60);
1580 $pdf->SetFillColor(224, 224, 224);
1581 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1583 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1584 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1587 if ($object->displayRetainedWarranty()) {
1588 $pdf->SetTextColor(40, 40, 40);
1589 $pdf->SetFillColor(255, 255, 255);
1591 $retainedWarranty = $object->getRetainedWarrantyAmount();
1592 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1596 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1597 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date($object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1599 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1600 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1604 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1606 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").
' ('.$object->retained_warranty.
'%)';
1607 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date($object->retained_warranty_date_limit,
'day')) :
'';
1609 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1610 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1611 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1616 $pdf->SetTextColor(0, 0, 0);
1617 $creditnoteamount = $object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1618 $depositsamount = $object->getSumDepositsUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1620 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1621 if (!empty($object->paye)) {
1625 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1628 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1629 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L', 0);
1630 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1631 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1634 if ($creditnoteamount) {
1635 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1637 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1638 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1639 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1640 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1644 if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1646 $pdf->SetFillColor(255, 255, 255);
1648 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1649 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L', 1);
1650 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1651 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R', 1);
1657 $pdf->SetTextColor(0, 0, 60);
1658 $pdf->SetFillColor(224, 224, 224);
1659 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1660 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1661 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1662 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1664 $pdf->SetFont(
'',
'', $default_font_size - 1);
1665 $pdf->SetTextColor(0, 0, 0);
1673 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1674 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $conf->global->BILL_TEXT_TOTAL_FOOTER, 0,
'L', 0);
1677 return ($tab2_top + ($tab2_hl * $index));
1694 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1704 $currency = !empty($currency) ? $currency : $conf->currency;
1708 $pdf->SetTextColor(0, 0, 0);
1709 $pdf->SetFont(
'',
'', $default_font_size - 2);
1711 if (empty($hidetop)) {
1713 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
1714 $categoryOfOperations = $outputlangs->transnoentities(
"MentionCategoryOfOperations") .
' : ' . $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1715 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
1716 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
1719 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1720 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1721 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1725 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1729 $pdf->SetDrawColor(128, 128, 128);
1730 $pdf->SetFont(
'',
'', $default_font_size - 1);
1733 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1735 if (empty($hidetop)) {
1736 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1738 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1739 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1743 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1744 if (empty($hidetop)) {
1751 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1752 if (empty($hidetop)) {
1753 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1754 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1758 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1759 if (empty($hidetop)) {
1760 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1761 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1764 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1765 if (empty($hidetop)) {
1766 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1767 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1771 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1772 if (empty($hidetop)) {
1773 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1774 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1778 if ($this->atleastonediscount) {
1779 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1780 if (empty($hidetop)) {
1781 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1782 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1786 if ($this->situationinvoice) {
1787 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1788 if (empty($hidetop)) {
1789 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1790 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities(
"ProgressShort"),
'',
'C');
1794 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1795 if (empty($hidetop)) {
1796 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1797 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1812 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
1815 global $conf, $langs;
1817 $ltrdirection =
'L';
1818 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1819 $ltrdirection =
'R';
1823 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
1829 $pdf->SetTextColor(0, 0, 60);
1830 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1834 $posy = $this->marge_haute;
1835 $posx = $this->page_largeur - $this->marge_droite - $w;
1837 $pdf->SetXY($this->marge_gauche, $posy);
1841 if ($this->emetteur->logo) {
1842 $logodir = $conf->mycompany->dir_output;
1843 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1844 $logodir = $conf->mycompany->multidir_output[$object->entity];
1847 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1849 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1851 if (is_readable($logo)) {
1853 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1855 $pdf->SetTextColor(200, 0, 0);
1856 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1857 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1858 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1861 $text = $this->emetteur->name;
1862 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1866 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1867 $pdf->SetXY($posx, $posy);
1868 $pdf->SetTextColor(0, 0, 60);
1869 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
1870 if ($object->type == 1) {
1871 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
1873 if ($object->type == 2) {
1874 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
1876 if ($object->type == 3) {
1877 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
1879 if ($object->type == 4) {
1880 $title = $outputlangs->transnoentities(
"InvoiceProForma");
1882 if ($this->situationinvoice) {
1883 $langs->loadLangs(array(
"other"));
1884 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") . $object->situation_counter .
" -";
1886 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1888 if ($object->type == 0) {
1889 if ($this->situationinvoice) {
1890 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
1892 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
1893 } elseif ($object->type == 1) {
1894 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
1895 } elseif ($object->type == 2) {
1896 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
1897 } elseif ($object->type == 3) {
1898 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
1899 } elseif ($object->type == 4) {
1900 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
1903 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1904 if ($object->statut == $object::STATUS_DRAFT) {
1905 $pdf->SetTextColor(128, 0, 0);
1906 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1909 $pdf->MultiCell($w, 3, $title,
'',
'R');
1911 $pdf->SetFont(
'',
'B', $default_font_size);
1925 $pdf->SetFont(
'',
'', $default_font_size - 2);
1927 if ($object->ref_customer) {
1929 $pdf->SetXY($posx, $posy);
1930 $pdf->SetTextColor(0, 0, 60);
1931 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_customer),
'',
'R');
1935 $object->fetch_projet();
1936 if (!empty($object->project->ref)) {
1938 $pdf->SetXY($posx, $posy);
1939 $pdf->SetTextColor(0, 0, 60);
1940 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1945 $object->fetch_projet();
1946 if (!empty($object->project->ref)) {
1947 $outputlangs->load(
"projects");
1949 $pdf->SetXY($posx, $posy);
1950 $pdf->SetTextColor(0, 0, 60);
1951 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1955 $objectidnext = $object->getIdReplacingInvoice(
'validated');
1956 if ($object->type == 0 && $objectidnext) {
1957 $objectreplacing =
new Facture($this->db);
1958 $objectreplacing->fetch($objectidnext);
1961 $pdf->SetXY($posx, $posy);
1962 $pdf->SetTextColor(0, 0, 60);
1963 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
1965 if ($object->type == 1) {
1966 $objectreplaced =
new Facture($this->db);
1967 $objectreplaced->fetch($object->fk_facture_source);
1970 $pdf->SetXY($posx, $posy);
1971 $pdf->SetTextColor(0, 0, 60);
1972 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
1974 if ($object->type == 2 && !empty($object->fk_facture_source)) {
1975 $objectreplaced =
new Facture($this->db);
1976 $objectreplaced->fetch($object->fk_facture_source);
1979 $pdf->SetXY($posx, $posy);
1980 $pdf->SetTextColor(0, 0, 60);
1981 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
1985 $pdf->SetXY($posx, $posy);
1986 $pdf->SetTextColor(0, 0, 60);
1987 $title = $outputlangs->transnoentities(
"DateInvoice");
1988 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1989 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1991 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1995 $pdf->SetXY($posx, $posy);
1996 $pdf->SetTextColor(0, 0, 60);
1997 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date($object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2000 if ($object->type != 2) {
2002 $pdf->SetXY($posx, $posy);
2003 $pdf->SetTextColor(0, 0, 60);
2004 $title = $outputlangs->transnoentities(
"DateDue");
2005 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2006 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2008 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2011 if (!
getDolGlobalString(
'MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
2013 $pdf->SetXY($posx, $posy);
2014 $pdf->SetTextColor(0, 0, 60);
2015 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
2020 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
2021 if (count($arrayidcontact) > 0) {
2022 $usertmp =
new User($this->db);
2023 $usertmp->fetch($arrayidcontact[0]);
2025 $pdf->SetXY($posx, $posy);
2026 $pdf->SetTextColor(0, 0, 60);
2027 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2035 $current_y = $pdf->getY();
2036 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
2037 if ($current_y < $pdf->getY()) {
2038 $top_shift = $pdf->getY() - $current_y;
2043 $carac_emetteur =
'';
2045 $arrayidcontact = $object->getIdContact(
'internal',
'BILLING');
2046 if (count($arrayidcontact) > 0) {
2047 $object->fetch_user($arrayidcontact[0]);
2048 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2049 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
2050 $carac_emetteur .=
"\n";
2053 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
2057 $posy += $top_shift;
2058 $posx = $this->marge_gauche;
2060 $posx = $this->page_largeur - $this->marge_droite - 80;
2069 $pdf->SetTextColor(0, 0, 0);
2070 $pdf->SetFont(
'',
'', $default_font_size - 2);
2071 $pdf->SetXY($posx, $posy - 5);
2072 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2073 $pdf->SetXY($posx, $posy);
2074 $pdf->SetFillColor(230, 230, 230);
2075 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2076 $pdf->SetTextColor(0, 0, 60);
2081 $pdf->SetXY($posx + 2, $posy + 3);
2082 $pdf->SetFont(
'',
'B', $default_font_size);
2083 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2084 $posy = $pdf->getY();
2088 $pdf->SetXY($posx + 2, $posy);
2089 $pdf->SetFont(
'',
'', $default_font_size - 1);
2090 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2094 $usecontact =
false;
2095 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
2096 if (count($arrayidcontact) > 0) {
2098 $result = $object->fetch_contact($arrayidcontact[0]);
2102 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2103 $thirdparty = $object->contact;
2105 $thirdparty = $object->thirdparty;
2111 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
2115 if ($this->page_largeur < 210) {
2119 $posy += $top_shift;
2120 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2122 $posx = $this->marge_gauche;
2127 $pdf->SetTextColor(0, 0, 0);
2128 $pdf->SetFont(
'',
'', $default_font_size - 2);
2129 $pdf->SetXY($posx + 2, $posy - 5);
2130 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2131 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2135 $pdf->SetXY($posx + 2, $posy + 3);
2136 $pdf->SetFont(
'',
'B', $default_font_size);
2137 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2139 $posy = $pdf->getY();
2142 $pdf->SetFont(
'',
'', $default_font_size - 1);
2143 $pdf->SetXY($posx + 2, $posy);
2144 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2148 $idaddressshipping = $object->getIdContact(
'external',
'SHIPPING');
2150 if (!empty($idaddressshipping)) {
2151 $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
2152 $companystatic =
new Societe($this->db);
2153 $companystatic->fetch($object->contact->fk_soc);
2155 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact,
'target', $object);
2158 $carac_client_shipping=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'target', $object);
2160 if (!empty($carac_client_shipping)) {
2161 $posy += $hautcadre;
2164 $pdf->SetXY($posx + 2, $posy - 5);
2165 $pdf->SetFont(
'',
'', $default_font_size - 2);
2166 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2167 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2170 $pdf->SetXY($posx + 2, $posy + 3);
2171 $pdf->SetFont(
'',
'B', $default_font_size);
2172 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2174 $posy = $pdf->getY();
2177 $pdf->SetXY($posx+2, $posy);
2178 $pdf->SetFont(
'',
'', $default_font_size - 1);
2179 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2180 $top_shift += $hautcadre;
2185 $pdf->SetTextColor(0, 0, 0);