196 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
199 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
201 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
203 if (!is_object($outputlangs)) {
204 $outputlangs = $langs;
208 $outputlangs->charset_output =
'ISO-8859-1';
212 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
214 global $outputlangsbis;
215 $outputlangsbis =
null;
216 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
217 $outputlangsbis =
new Translate(
'', $conf);
218 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
219 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
223 if ($object->statut == $object::STATUS_DRAFT && (
getDolGlobalString(
'FACTURE_DRAFT_WATERMARK'))) {
224 $this->watermark = $conf->global->FACTURE_DRAFT_WATERMARK;
227 $nblines = count($object->lines);
231 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
235 $realpatharray = array();
236 $this->atleastonephoto =
false;
238 $objphoto =
new Product($this->db);
240 for ($i = 0; $i < $nblines; $i++) {
241 if (empty($object->lines[$i]->fk_product)) {
245 $objphoto->fetch($object->lines[$i]->fk_product);
248 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
249 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
251 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
252 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
256 foreach ($pdir as $midir) {
258 if ($conf->entity != $objphoto->entity) {
259 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
261 $dir = $conf->product->dir_output.
'/'.$midir;
264 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
266 if ($obj[
'photo_vignette']) {
267 $filename = $obj[
'photo_vignette'];
269 $filename = $obj[
'photo'];
272 $filename = $obj[
'photo'];
275 $realpath = $dir.$filename;
277 $this->atleastonephoto =
true;
282 if ($realpath && $arephoto) {
283 $realpatharray[$i] = $realpath;
290 if ($conf->facture->multidir_output[$conf->entity]) {
291 $object->fetch_thirdparty();
293 $deja_regle = $object->getSommePaiement((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
294 $amount_credit_notes_included = $object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
295 $amount_deposits_included = $object->getSumDepositsUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
298 if ($object->specimen) {
299 $dir = $conf->facture->multidir_output[$conf->entity];
300 $file = $dir.
"/SPECIMEN.pdf";
303 $dir = $conf->facture->multidir_output[$object->entity].
"/".$objectref;
304 $file = $dir.
"/".$objectref.
".pdf";
306 if (!file_exists($dir)) {
308 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
313 if (file_exists($dir)) {
315 if (!is_object($hookmanager)) {
316 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
319 $hookmanager->initHooks(array(
'pdfgeneration'));
320 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
322 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
325 $nblines = count($object->lines);
326 $nbpayments = count($object->getListOfPayments());
331 $pdf->SetAutoPageBreak(1, 0);
333 $this->heightforinfotot = 50 + (4 * $nbpayments);
334 $this->heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
335 $this->heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
337 $heightforqrinvoice = $heightforqrinvoice_firstpage = 0;
341 $this->heightforinfotot = 30 + (4 * $nbpayments);
345 if (class_exists(
'TCPDF')) {
346 $pdf->setPrintHeader(
false);
347 $pdf->setPrintFooter(
false);
353 $logodir = $conf->mycompany->dir_output;
354 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
355 $logodir = $conf->mycompany->multidir_output[$object->entity];
357 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
358 $tplidx = $pdf->importPage(1);
363 $pdf->SetDrawColor(128, 128, 128);
365 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
366 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
367 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
368 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
369 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
371 $pdf->SetCompression(
false);
375 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
376 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
382 $certprivate = !
getDolGlobalString(
'CERTIFICATE_CRT_PRIVATE') ?
'' : $conf->global->CERTIFICATE_CRT_PRIVATE;
387 'Name' => $this->emetteur->name,
388 'Location' =>
getCountry($this->emetteur->country_code, 0),
389 'Reason' =>
'INVOICE',
390 'ContactInfo' => $this->emetteur->email
392 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
395 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
399 $categoryOfOperation = 0;
402 for ($i = 0; $i < $nblines; $i++) {
403 if ($object->lines[$i]->remise_percent) {
404 $this->atleastonediscount++;
408 if ($categoryOfOperation < 2) {
409 $lineProductType = $object->lines[$i]->product_type;
415 if ($nbProduct > 0 && $nbService > 0) {
417 $categoryOfOperation = 2;
422 if ($categoryOfOperation <= 0) {
424 if ($nbProduct == 0 && $nbService > 0) {
425 $categoryOfOperation = 1;
428 $this->categoryOfOperation = $categoryOfOperation;
431 if ($object->situation_cycle_ref) {
432 $this->situationinvoice =
true;
437 if (!empty($tplidx)) {
438 $pdf->useTemplate($tplidx);
443 $pagehead = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
444 $top_shift = $pagehead[
'top_shift'];
445 $shipp_shift = $pagehead[
'shipp_shift'];
446 $pdf->SetFont(
'',
'', $default_font_size - 1);
447 $pdf->MultiCell(0, 3,
'');
448 $pdf->SetTextColor(0, 0, 0);
453 $this->tab_top = 90 + $top_shift + $shipp_shift;
454 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
457 $extra_under_address_shift = 0;
460 $qrcodestring = $object->buildZATCAQRString();
462 $qrcodestring = $object->buildSwitzerlandQRString();
465 $qrcodecolor = array(
'25',
'25',
'25');
470 'fgcolor' => $qrcodecolor,
475 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
476 $extra_under_address_shift += 25;
484 'outputlangs' => $outputlangs,
485 'hidedetails' => $hidedetails
487 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
488 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
489 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
492 $this->tab_top += $extra_under_address_shift;
493 $this->tab_top_newpage += 0;
497 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->
getHeightForQRInvoice(1, $object, $langs);
499 $nexY = $this->tab_top - 1;
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, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
510 $nexY = max($pdf->GetY(), $nexY);
511 $height_incoterms = $nexY - $this->tab_top;
514 $pdf->SetDrawColor(192, 192, 192);
515 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
517 $this->tab_top = $nexY + 6;
518 $height_incoterms += 4;
523 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
526 if (is_object($object->thirdparty)) {
527 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
528 $salerepobj =
new User($this->db);
529 $salerepobj->fetch($salereparray[0][
'id']);
530 if (!empty($salerepobj->signature)) {
531 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
537 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
538 if (!empty($extranote)) {
542 $pagenb = $pdf->getPage();
546 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
547 $pageposbeforenote = $pagenb;
554 $pdf->startTransaction();
556 $pdf->SetFont(
'',
'', $default_font_size - 1);
557 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
559 $pageposafternote = $pdf->getPage();
560 $posyafter = $pdf->GetY();
562 if ($pageposafternote > $pageposbeforenote) {
563 $pdf->rollbackTransaction(
true);
566 while ($pagenb < $pageposafternote) {
569 if (!empty($tplidx)) {
570 $pdf->useTemplate($tplidx);
573 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
575 $pdf->setTopMargin($this->tab_top_newpage);
577 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
581 $pdf->setPage($pageposbeforenote);
582 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
583 $pdf->SetFont(
'',
'', $default_font_size - 1);
584 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
585 $pageposafternote = $pdf->getPage();
587 $posyafter = $pdf->GetY();
589 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
590 $pdf->AddPage(
'',
'',
true);
593 $pdf->setPage($pageposafternote);
594 $pdf->setTopMargin($this->tab_top_newpage);
596 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
602 $i = $pageposbeforenote;
603 while ($i < $pageposafternote) {
607 $pdf->SetDrawColor(128, 128, 128);
609 if ($i > $pageposbeforenote) {
610 $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
611 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
613 $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
614 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
618 $pdf->setPageOrientation(
'', 1, 0);
625 $pdf->setPage($pageposafternote);
626 if (!empty($tplidx)) {
627 $pdf->useTemplate($tplidx);
630 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
632 $height_note = $posyafter - $this->tab_top_newpage;
633 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
636 $pdf->commitTransaction();
637 $posyafter = $pdf->GetY();
638 $height_note = $posyafter - $this->tab_top;
639 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
642 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
644 $pdf->AddPage(
'',
'',
true);
647 $pdf->setPage($pageposafternote);
648 if (!empty($tplidx)) {
649 $pdf->useTemplate($tplidx);
652 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
655 $posyafter = $this->tab_top_newpage;
659 $tab_height = $tab_height - $height_note;
660 $this->tab_top = $posyafter + 6;
669 $pdf->startTransaction();
670 $this->
pdfTabTitles($pdf, $this->tab_top, $tab_height, $outputlangs, $hidetop);
671 $pdf->rollbackTransaction(
true);
673 $nexY = $this->tab_top + $this->tabTitleHeight;
676 $pageposbeforeprintlines = $pdf->getPage();
677 $pagenb = $pageposbeforeprintlines;
678 for ($i = 0; $i < $nblines; $i++) {
680 $pdf->SetFont(
'',
'', $default_font_size - 1);
681 $pdf->SetTextColor(0, 0, 0);
684 $imglinesize = array();
685 if (!empty($realpatharray[$i])) {
689 $pdf->setTopMargin($this->tab_top_newpage);
690 $page_bottom_margin = $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(), $object, $langs);
691 $pdf->setPageOrientation(
'', 1, $page_bottom_margin);
692 $pageposbefore = $pdf->getPage();
694 $showpricebeforepagebreak = 1;
696 $posYAfterDescription = 0;
700 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
701 $pdf->AddPage(
'',
'',
true);
702 if (!empty($tplidx)) {
703 $pdf->useTemplate($tplidx);
705 $pdf->setPage($pageposbefore + 1);
707 $curY = $this->tab_top_newpage;
711 $showpricebeforepagebreak = 1;
713 $showpricebeforepagebreak = 0;
717 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
718 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
720 $posYAfterImage = $curY + $imglinesize[
'height'];
726 $pdf->startTransaction();
728 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
729 $pageposafter = $pdf->getPage();
731 if ($pageposafter > $pageposbefore) {
732 $pdf->rollbackTransaction(
true);
733 $pageposafter = $pageposbefore;
734 $pdf->setPageOrientation(
'', 1, $this->heightforfooter);
736 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
738 $pageposafter = $pdf->getPage();
739 $posyafter = $pdf->GetY();
741 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
742 if ($i == ($nblines - 1)) {
743 $pdf->AddPage(
'',
'',
true);
744 if (!empty($tplidx)) {
745 $pdf->useTemplate($tplidx);
747 $pdf->setPage($pageposafter + 1);
753 $showpricebeforepagebreak = 1;
755 $showpricebeforepagebreak = 0;
759 $pdf->commitTransaction();
761 $posYAfterDescription = $pdf->GetY();
764 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
766 $pageposafter = $pdf->getPage();
767 $pdf->setPage($pageposbefore);
768 $pdf->setTopMargin($this->marge_haute);
769 $pdf->setPageOrientation(
'', 1, 0);
772 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
773 $pdf->setPage($pageposafter);
774 $curY = $this->tab_top_newpage;
777 $pdf->SetFont(
'',
'', $default_font_size - 1);
783 $nexY = max($pdf->GetY(), $nexY);
790 $nexY = max($pdf->GetY(), $nexY);
798 $nexY = max($pdf->GetY(), $nexY);
805 $nexY = max($pdf->GetY(), $nexY);
810 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
812 $nexY = max($pdf->GetY(), $nexY);
816 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
819 $nexY = max($pdf->GetY(), $nexY);
826 $nexY = max($pdf->GetY(), $nexY);
833 $nexY = max($pdf->GetY(), $nexY);
837 if (!empty($object->lines[$i]->array_options)) {
838 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
840 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
842 $nexY = max($pdf->GetY(), $nexY);
854 'outputlangs' => $outputlangs,
855 'hidedetails' => $hidedetails
857 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
861 if (isset($object->type) && $object->type == 2 &&
getDolGlobalString(
'INVOICE_POSITIVE_CREDIT_NOTE')) {
865 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
866 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
867 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
868 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
870 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
873 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
874 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
876 $tvaligne = $sign * $object->lines[$i]->total_tva;
880 $localtax1ligne = $object->lines[$i]->total_localtax1;
881 $localtax2ligne = $object->lines[$i]->total_localtax2;
882 $localtax1_rate = $object->lines[$i]->localtax1_tx;
883 $localtax2_rate = $object->lines[$i]->localtax2_tx;
884 $localtax1_type = $object->lines[$i]->localtax1_type;
885 $localtax2_type = $object->lines[$i]->localtax2_type;
898 $vatrate = (string) $object->lines[$i]->tva_tx;
901 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
902 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
904 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
905 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
909 if ($localtax1_type && $localtax1ligne != 0) {
910 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
911 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
913 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
916 if ($localtax2_type && $localtax2ligne != 0) {
917 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
918 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
920 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
924 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
929 if (!isset($this->tva[$vatrate])) {
930 $this->tva[$vatrate] = 0;
932 $this->tva[$vatrate] += $tvaligne;
933 $vatcode = $object->lines[$i]->vat_src_code;
934 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
935 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
937 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
939 $nexY = max($nexY, $posYAfterImage);
943 $pdf->setPage($pageposafter);
944 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
946 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
947 $pdf->SetLineStyle(array(
'dash'=>0));
951 while ($pagenb < $pageposafter) {
952 $pdf->setPage($pagenb);
954 if ($pagenb == $pageposbeforeprintlines) {
955 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
957 $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);
961 $pdf->setPage($pagenb);
962 $pdf->setPageOrientation(
'', 1, 0);
964 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
966 if (!empty($tplidx)) {
967 $pdf->useTemplate($tplidx);
971 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
973 if ($pagenb == $pageposafter) {
974 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
976 $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);
981 if (!empty($tplidx)) {
982 $pdf->useTemplate($tplidx);
986 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
993 if ($pagenb == $pageposbeforeprintlines) {
994 $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);
995 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
997 $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);
998 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1002 $posy = $this->
drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
1005 $posy = $this->
drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1008 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1014 if (method_exists($pdf,
'AliasNbPages')) {
1015 $pdf->AliasNbPages();
1023 $pdf->Output($file,
'F');
1026 $hookmanager->initHooks(array(
'pdfgeneration'));
1027 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
1029 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1031 $this->error = $hookmanager->error;
1032 $this->errors = $hookmanager->errors;
1037 $this->result = array(
'fullpath'=>$file);
1041 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1045 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1205 protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
1207 global $conf, $mysoc;
1211 $pdf->SetFont(
'',
'', $default_font_size - 1);
1214 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1215 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1216 $pdf->SetXY($this->marge_gauche, $posy);
1217 if ($mysoc->forme_juridique_code == 92) {
1218 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1220 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1223 $posy = $pdf->GetY() + 4;
1228 if ($this->page_largeur < 210) {
1233 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
1234 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1235 $pdf->SetXY($this->marge_gauche, $posy);
1236 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1237 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1239 $pdf->SetFont(
'',
'', $default_font_size - 2);
1240 $pdf->SetXY($posxval, $posy);
1241 $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);
1242 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1243 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1245 $posy = $pdf->GetY() + 3;
1249 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1250 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1251 $pdf->SetXY($this->marge_gauche, $posy);
1252 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1253 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1255 $pdf->SetFont(
'',
'', $default_font_size - 2);
1256 $pdf->SetXY($posxval, $posy);
1257 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1258 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1260 $posy = $pdf->GetY() + 3;
1263 if ($object->type != 2) {
1265 if (empty($object->mode_reglement_code)
1268 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1269 } elseif (($object->mode_reglement_code ==
'CHQ' && !
getDolGlobalInt(
'FACTURE_CHQ_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))
1270 || ($object->mode_reglement_code ==
'VIR' && !
getDolGlobalInt(
'FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
1272 $outputlangs->load(
"errors");
1274 $pdf->SetXY($this->marge_gauche, $posy);
1275 $pdf->SetTextColor(200, 0, 0);
1276 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1277 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1278 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1279 $pdf->SetTextColor(0, 0, 0);
1281 $posy = $pdf->GetY() + 1;
1285 if (!empty($object->mode_reglement_code)
1286 && $object->mode_reglement_code !=
'CHQ'
1287 && $object->mode_reglement_code !=
'VIR') {
1288 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1289 $pdf->SetXY($this->marge_gauche, $posy);
1290 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1291 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1293 $pdf->SetFont(
'',
'', $default_font_size - 2);
1294 $pdf->SetXY($posxval, $posy);
1295 $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);
1298 if ($object->mode_reglement_code ==
"PRE") {
1299 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1301 $bac->fetch(0, $object->thirdparty->id);
1302 $iban= $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1303 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1306 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1308 $posy = $pdf->GetY();
1314 if ($this->emetteur->country_code ==
'FR') {
1316 $pdf->SetXY($this->marge_gauche, $posy);
1317 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1319 $posy = $pdf->GetY() + 1;
1324 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CB' || $object->mode_reglement_code ==
'VAD') {
1325 $useonlinepayment = 0;
1327 if (isModEnabled(
'paypal')) {
1328 $useonlinepayment++;
1330 if (isModEnabled(
'stripe')) {
1331 $useonlinepayment++;
1333 if (isModEnabled(
'paybox')) {
1334 $useonlinepayment++;
1340 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1343 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1344 $servicename = $langs->transnoentities(
'Online');
1345 $paiement_url = getOnlinePaymentUrl(
'',
'invoice', $object->ref,
'',
'',
'');
1346 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1348 $pdf->SetXY($this->marge_gauche, $posy);
1349 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1351 $posy = $pdf->GetY() + 1;
1356 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1359 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1362 $account =
new Account($this->db);
1365 $pdf->SetXY($this->marge_gauche, $posy);
1366 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1367 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1368 $posy = $pdf->GetY() + 1;
1371 $pdf->SetXY($this->marge_gauche, $posy);
1372 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1373 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1374 $posy = $pdf->GetY() + 2;
1377 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1378 $pdf->SetXY($this->marge_gauche, $posy);
1379 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1380 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1381 $posy = $pdf->GetY() + 1;
1384 $pdf->SetXY($this->marge_gauche, $posy);
1385 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1386 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1387 $posy = $pdf->GetY() + 2;
1394 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1395 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1396 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1397 if ($object->fk_bank > 0) {
1398 $bankid = $object->fk_bank;
1400 $account =
new Account($this->db);
1401 $account->fetch($bankid);
1403 $curx = $this->marge_gauche;
1406 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1428 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
1430 global $conf, $mysoc, $hookmanager;
1441 if (is_object($outputlangsbis)) {
1442 $pdf->SetFont(
'',
'', $default_font_size - 2);
1444 $pdf->SetFont(
'',
'', $default_font_size - 1);
1450 if ($this->page_largeur < 210) {
1454 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1460 $parameters = array(
1461 'object' => &$object,
1462 'outputlangs' => $outputlangs,
1464 $hookmanager->executeHooks(
'beforePercentCalculation', $parameters, $this);
1469 foreach ($object->lines as $line) {
1470 if ($line->product_type != 9) {
1471 $percent += $line->situation_percent;
1477 $avancementGlobal = $percent / $i;
1479 $avancementGlobal = 0;
1482 $object->fetchPreviousNextSituationInvoice();
1483 $TPreviousIncoice = $object->tab_previous_situation_invoice;
1486 $total_a_payer_ttc = 0;
1487 foreach ($TPreviousIncoice as &$fac) {
1488 $total_a_payer += $fac->total_ht;
1489 $total_a_payer_ttc += $fac->total_ttc;
1491 $total_a_payer += $object->total_ht;
1492 $total_a_payer_ttc += $object->total_ttc;
1494 if (!empty($avancementGlobal)) {
1495 $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
1496 $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
1499 $total_a_payer_ttc = 0;
1503 if (!empty($TPreviousIncoice)) {
1504 $pdf->setY($tab2_top);
1505 $posy = $pdf->GetY();
1507 foreach ($TPreviousIncoice as &$fac) {
1508 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1512 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1513 $pdf->setY($this->tab_top_newpage);
1515 $pdf->setY($this->marge_haute);
1517 $posy = $pdf->GetY();
1522 $pdf->SetFillColor(255, 255, 255);
1523 $pdf->SetXY($col1x, $posy);
1524 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $fac->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1526 $pdf->SetXY($col2x, $posy);
1530 $facSign = $fac->total_ht >= 0 ?
'+' :
'';
1533 $displayAmount =
' '.$facSign.
' '.
price($fac->total_ht, 0, $outputlangs);
1535 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1544 $pdf->SetFillColor(255, 255, 255);
1545 $pdf->SetXY($col1x, $posy);
1546 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $object->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1548 $pdf->SetXY($col2x, $posy);
1551 $facSign = $object->total_ht >= 0 ?
'+' :
'';
1559 $displayAmount =
' '.$facSign.
' '.
price($object->total_ht, 0, $outputlangs);
1560 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1565 $pdf->SetFont(
'',
'', $default_font_size - 1);
1566 $pdf->SetFillColor(255, 255, 255);
1567 $pdf->SetXY($col1x, $posy);
1568 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"SituationTotalProgress", $avancementGlobal), 0,
'L', 1);
1570 $pdf->SetXY($col2x, $posy);
1571 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0,
'R', 1);
1572 $pdf->SetFont(
'',
'', $default_font_size - 2);
1576 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1579 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1580 $pdf->setY($this->tab_top_newpage);
1582 $pdf->setY($this->marge_haute);
1585 $posy = $pdf->GetY();
1596 $total_ht = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1599 $total_line_remise = 0;
1600 foreach ($object->lines as $i => $line) {
1602 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1604 if ($line->total_ht < 0) {
1605 $total_line_remise += -$line->total_ht;
1608 if ($total_line_remise > 0) {
1610 $pdf->SetFillColor(255, 255, 255);
1611 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1612 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1613 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1614 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1620 $pdf->SetFillColor(255, 255, 255);
1621 $pdf->SetXY($col1x, $tab2_top);
1622 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1623 $pdf->SetXY($col2x, $tab2_top);
1624 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1631 $pdf->SetFillColor(255, 255, 255);
1632 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1633 $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);
1635 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1636 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1637 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1640 $pdf->SetFillColor(248, 248, 248);
1642 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1644 $this->atleastoneratenotnull = 0;
1646 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1647 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1653 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1654 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1658 foreach ($localtax_rate as $tvakey => $tvaval) {
1663 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1666 if (preg_match(
'/\*/', $tvakey)) {
1667 $tvakey = str_replace(
'*',
'', $tvakey);
1668 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1671 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1673 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1674 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1676 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1678 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1679 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1687 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1688 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1692 foreach ($localtax_rate as $tvakey => $tvaval) {
1697 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1700 if (preg_match(
'/\*/', $tvakey)) {
1701 $tvakey = str_replace(
'*',
'', $tvakey);
1702 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1704 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1706 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1707 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1709 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1711 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1712 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1719 if (
getDolGlobalInt(
'INVOICE_USE_SITUATION') == 1 && $object->situation_cycle_ref && $object->situation_counter > 1) {
1721 foreach ($this->tva as $tvakey => $tvaval) {
1722 $sum_pdf_tva += $tvaval;
1725 if ($sum_pdf_tva != $object->total_tva) {
1726 if (!empty($sum_pdf_tva)) {
1727 $coef_fix_tva = $object->total_tva / $sum_pdf_tva;
1733 foreach ($this->tva as $tvakey => $tvaval) {
1734 $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1736 foreach ($this->tva_array as $tvakey => $tvaval) {
1737 $this->tva_array[$tvakey][
'amount'] = $tvaval[
'amount'] * $coef_fix_tva;
1743 foreach ($this->tva_array as $tvakey => $tvaval) {
1745 $this->atleastoneratenotnull++;
1748 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1751 if (preg_match(
'/\*/', $tvakey)) {
1752 $tvakey = str_replace(
'*',
'', $tvakey);
1753 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1755 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1758 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1760 $totalvat .= ($tvaval[
'vatcode'] ? $tvaval[
'vatcode'] :
vatrate($tvaval[
'vatrate'], 1)).$tvacompl;
1762 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1764 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1766 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1767 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1774 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1775 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1779 foreach ($localtax_rate as $tvakey => $tvaval) {
1784 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1787 if (preg_match(
'/\*/', $tvakey)) {
1788 $tvakey = str_replace(
'*',
'', $tvakey);
1789 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1791 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1793 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1795 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1797 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1799 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1800 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1808 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1809 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1813 foreach ($localtax_rate as $tvakey => $tvaval) {
1819 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1822 if (preg_match(
'/\*/', $tvakey)) {
1823 $tvakey = str_replace(
'*',
'', $tvakey);
1824 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1826 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1829 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1830 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1832 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1834 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1835 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1842 if (
price2num($object->revenuestamp) != 0) {
1844 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1845 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1847 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1848 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $object->revenuestamp), $useborder,
'R', 1);
1853 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1854 $pdf->SetTextColor(0, 0, 60);
1855 $pdf->SetFillColor(224, 224, 224);
1856 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1858 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1859 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1863 if ($object->displayRetainedWarranty()) {
1864 $pdf->SetTextColor(40, 40, 40);
1865 $pdf->SetFillColor(255, 255, 255);
1867 $retainedWarranty = $object->getRetainedWarrantyAmount();
1868 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1872 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1873 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date($object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1875 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1876 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1880 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1882 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.$object->retained_warranty.
'%)';
1883 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date($object->retained_warranty_date_limit,
'day')) :
'';
1885 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1886 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1887 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1892 $pdf->SetTextColor(0, 0, 0);
1894 $creditnoteamount = $object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1895 $depositsamount = $object->getSumDepositsUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1897 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1898 if (!empty($object->paye)) {
1902 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1905 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1906 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"Paid") :
''), 0,
'L', 0);
1907 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1908 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1911 if ($creditnoteamount) {
1912 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1913 $labeltouse .= (is_object($outputlangsbis) ? (
' / '.($outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities(
"CreditNotes")) :
'');
1915 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1916 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1917 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1918 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1937 $pdf->SetTextColor(0, 0, 60);
1938 $pdf->SetFillColor(224, 224, 224);
1939 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1940 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1941 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1942 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1944 $pdf->SetFont(
'',
'', $default_font_size - 1);
1945 $pdf->SetTextColor(0, 0, 0);
1949 return ($tab2_top + ($tab2_hl * $index));
2045 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
2048 global $conf, $langs;
2050 $ltrdirection =
'L';
2051 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2052 $ltrdirection =
'R';
2056 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2062 $pdf->SetTextColor(0, 0, 60);
2063 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2067 $posy = $this->marge_haute;
2068 $posx = $this->page_largeur - $this->marge_droite - $w;
2070 $pdf->SetXY($this->marge_gauche, $posy);
2074 if ($this->emetteur->logo) {
2075 $logodir = $conf->mycompany->dir_output;
2076 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
2077 $logodir = $conf->mycompany->multidir_output[$object->entity];
2080 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2082 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2084 if (is_readable($logo)) {
2086 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2088 $pdf->SetTextColor(200, 0, 0);
2089 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2090 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2091 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2094 $text = $this->emetteur->name;
2095 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2099 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2100 $pdf->SetXY($posx, $posy);
2101 $pdf->SetTextColor(0, 0, 60);
2102 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2103 if ($object->type == 1) {
2104 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2106 if ($object->type == 2) {
2107 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2109 if ($object->type == 3) {
2110 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2112 if ($object->type == 4) {
2113 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2115 if ($this->situationinvoice) {
2116 $langs->loadLangs(array(
"other"));
2117 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") . $object->situation_counter .
" -";
2119 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2121 if ($object->type == 0) {
2122 if ($this->situationinvoice) {
2123 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2125 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2126 } elseif ($object->type == 1) {
2127 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2128 } elseif ($object->type == 2) {
2129 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2130 } elseif ($object->type == 3) {
2131 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2132 } elseif ($object->type == 4) {
2133 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2136 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
2137 if ($object->statut == $object::STATUS_DRAFT) {
2138 $pdf->SetTextColor(128, 0, 0);
2139 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2142 $pdf->MultiCell($w, 3, $title,
'',
'R');
2144 $pdf->SetFont(
'',
'B', $default_font_size);
2158 $pdf->SetFont(
'',
'', $default_font_size - 2);
2160 if ($object->ref_customer) {
2162 $pdf->SetXY($posx, $posy);
2163 $pdf->SetTextColor(0, 0, 60);
2164 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($object->ref_customer), 65),
'',
'R');
2168 $object->fetch_projet();
2169 if (!empty($object->project->ref)) {
2171 $pdf->SetXY($posx, $posy);
2172 $pdf->SetTextColor(0, 0, 60);
2173 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
2178 $object->fetch_projet();
2179 if (!empty($object->project->ref)) {
2180 $outputlangs->load(
"projects");
2182 $pdf->SetXY($posx, $posy);
2183 $pdf->SetTextColor(0, 0, 60);
2184 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
2188 $objectidnext = $object->getIdReplacingInvoice(
'validated');
2189 if ($object->type == 0 && $objectidnext) {
2190 $objectreplacing =
new Facture($this->db);
2191 $objectreplacing->fetch($objectidnext);
2194 $pdf->SetXY($posx, $posy);
2195 $pdf->SetTextColor(0, 0, 60);
2196 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2198 if ($object->type == 1) {
2199 $objectreplaced =
new Facture($this->db);
2200 $objectreplaced->fetch($object->fk_facture_source);
2203 $pdf->SetXY($posx, $posy);
2204 $pdf->SetTextColor(0, 0, 60);
2205 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2207 if ($object->type == 2 && !empty($object->fk_facture_source)) {
2208 $objectreplaced =
new Facture($this->db);
2209 $objectreplaced->fetch($object->fk_facture_source);
2212 $pdf->SetXY($posx, $posy);
2213 $pdf->SetTextColor(0, 0, 60);
2214 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2218 $pdf->SetXY($posx, $posy);
2219 $pdf->SetTextColor(0, 0, 60);
2221 $title = $outputlangs->transnoentities(
"DateInvoice");
2222 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2223 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2225 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2229 $pdf->SetXY($posx, $posy);
2230 $pdf->SetTextColor(0, 0, 60);
2231 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date($object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2234 if ($object->type != 2) {
2236 $pdf->SetXY($posx, $posy);
2237 $pdf->SetTextColor(0, 0, 60);
2238 $title = $outputlangs->transnoentities(
"DateDue");
2239 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2240 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2242 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2245 if (!
getDolGlobalString(
'MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
2247 $pdf->SetXY($posx, $posy);
2248 $pdf->SetTextColor(0, 0, 60);
2249 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
2254 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
2255 if (count($arrayidcontact) > 0) {
2256 $usertmp =
new User($this->db);
2257 $usertmp->fetch($arrayidcontact[0]);
2259 $pdf->SetXY($posx, $posy);
2260 $pdf->SetTextColor(0, 0, 60);
2261 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2270 $current_y = $pdf->getY();
2271 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
2272 if ($current_y < $pdf->getY()) {
2273 $top_shift = $pdf->getY() - $current_y;
2278 $carac_emetteur =
'';
2280 $arrayidcontact = $object->getIdContact(
'internal',
'BILLING');
2281 if (count($arrayidcontact) > 0) {
2282 $object->fetch_user($arrayidcontact[0]);
2283 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2284 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
2285 $carac_emetteur .=
"\n";
2288 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
2292 $posy += $top_shift;
2293 $posx = $this->marge_gauche;
2295 $posx = $this->page_largeur - $this->marge_droite - 80;
2303 $pdf->SetTextColor(0, 0, 0);
2304 $pdf->SetFont(
'',
'', $default_font_size - 2);
2305 $pdf->SetXY($posx, $posy - 5);
2306 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2307 $pdf->SetXY($posx, $posy);
2308 $pdf->SetFillColor(230, 230, 230);
2309 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2310 $pdf->SetTextColor(0, 0, 60);
2315 $pdf->SetXY($posx + 2, $posy + 3);
2316 $pdf->SetFont(
'',
'B', $default_font_size);
2317 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2318 $posy = $pdf->getY();
2322 $pdf->SetXY($posx + 2, $posy);
2323 $pdf->SetFont(
'',
'', $default_font_size - 1);
2324 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2327 $usecontact =
false;
2328 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
2329 if (count($arrayidcontact) > 0) {
2331 $result = $object->fetch_contact($arrayidcontact[0]);
2335 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2336 $thirdparty = $object->contact;
2338 $thirdparty = $object->thirdparty;
2344 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
2348 if ($this->page_largeur < 210) {
2352 $posy += $top_shift;
2353 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2355 $posx = $this->marge_gauche;
2360 $pdf->SetTextColor(0, 0, 0);
2361 $pdf->SetFont(
'',
'', $default_font_size - 2);
2362 $pdf->SetXY($posx + 2, $posy - 5);
2363 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2364 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2368 $pdf->SetXY($posx + 2, $posy + 3);
2369 $pdf->SetFont(
'',
'B', $default_font_size);
2370 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2372 $posy = $pdf->getY();
2375 $pdf->SetFont(
'',
'', $default_font_size - 1);
2376 $pdf->SetXY($posx + 2, $posy);
2377 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2381 $idaddressshipping = $object->getIdContact(
'external',
'SHIPPING');
2383 if (!empty($idaddressshipping)) {
2384 $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
2385 $companystatic =
new Societe($this->db);
2386 $companystatic->fetch($object->contact->fk_soc);
2388 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact,
'target', $object);
2391 $carac_client_shipping=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'target', $object);
2393 if (!empty($carac_client_shipping)) {
2394 $posy += $hautcadre;
2397 $pdf->SetXY($posx + 2, $posy - 5);
2398 $pdf->SetFont(
'',
'', $default_font_size - 2);
2399 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2400 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2403 $pdf->SetXY($posx + 2, $posy + 3);
2404 $pdf->SetFont(
'',
'B', $default_font_size);
2405 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2407 $posy = $pdf->getY();
2410 $pdf->SetXY($posx+2, $posy);
2411 $pdf->SetFont(
'',
'', $default_font_size - 1);
2412 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2413 $shipp_shift += $hautcadre;
2418 $pdf->SetTextColor(0, 0, 0);
2420 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);