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++;
409 if (preg_match(
'/^\((.*)\)$/', $object->lines[$i]->desc, $reg)) {
410 if ($reg[1] ==
'DEPOSIT') {
421 if ($categoryOfOperation < 2) {
422 $lineProductType = $object->lines[$i]->product_type;
428 if ($nbProduct > 0 && $nbService > 0) {
430 $categoryOfOperation = 2;
435 if ($categoryOfOperation <= 0) {
437 if ($nbProduct == 0 && $nbService > 0) {
438 $categoryOfOperation = 1;
441 $this->categoryOfOperation = $categoryOfOperation;
444 if ($object->situation_cycle_ref) {
445 $this->situationinvoice =
true;
450 if (!empty($tplidx)) {
451 $pdf->useTemplate($tplidx);
456 $pagehead = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
457 $top_shift = $pagehead[
'top_shift'];
458 $shipp_shift = $pagehead[
'shipp_shift'];
459 $pdf->SetFont(
'',
'', $default_font_size - 1);
460 $pdf->MultiCell(0, 3,
'');
461 $pdf->SetTextColor(0, 0, 0);
466 $this->tab_top = 90 + $top_shift + $shipp_shift;
467 $this->tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
470 $extra_under_address_shift = 0;
473 $qrcodestring = $object->buildZATCAQRString();
475 $qrcodestring = $object->buildSwitzerlandQRString();
478 $qrcodecolor = array(
'25',
'25',
'25');
483 'fgcolor' => $qrcodecolor,
488 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr,
'N');
489 $extra_under_address_shift += 25;
497 'outputlangs' => $outputlangs,
498 'hidedetails' => $hidedetails
500 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
501 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
502 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
505 $this->tab_top += $extra_under_address_shift;
506 $this->tab_top_newpage += 0;
510 $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->
getHeightForQRInvoice(1, $object, $langs);
512 $nexY = $this->tab_top - 1;
515 $height_incoterms = 0;
516 if (isModEnabled(
'incoterm')) {
517 $desc_incoterms = $object->getIncotermsForPDF();
518 if ($desc_incoterms) {
521 $pdf->SetFont(
'',
'', $default_font_size - 1);
522 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
523 $nexY = max($pdf->GetY(), $nexY);
524 $height_incoterms = $nexY - $this->tab_top;
527 $pdf->SetDrawColor(192, 192, 192);
528 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
530 $this->tab_top = $nexY + 6;
531 $height_incoterms += 4;
536 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
539 if (is_object($object->thirdparty)) {
540 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
541 $salerepobj =
new User($this->db);
542 $salerepobj->fetch($salereparray[0][
'id']);
543 if (!empty($salerepobj->signature)) {
544 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
550 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
551 if (!empty($extranote)) {
555 $pagenb = $pdf->getPage();
559 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
560 $pageposbeforenote = $pagenb;
567 $pdf->startTransaction();
569 $pdf->SetFont(
'',
'', $default_font_size - 1);
570 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
572 $pageposafternote = $pdf->getPage();
573 $posyafter = $pdf->GetY();
575 if ($pageposafternote > $pageposbeforenote) {
576 $pdf->rollbackTransaction(
true);
579 while ($pagenb < $pageposafternote) {
582 if (!empty($tplidx)) {
583 $pdf->useTemplate($tplidx);
586 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
588 $pdf->setTopMargin($this->tab_top_newpage);
590 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
594 $pdf->setPage($pageposbeforenote);
595 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
596 $pdf->SetFont(
'',
'', $default_font_size - 1);
597 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
598 $pageposafternote = $pdf->getPage();
600 $posyafter = $pdf->GetY();
602 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
603 $pdf->AddPage(
'',
'',
true);
606 $pdf->setPage($pageposafternote);
607 $pdf->setTopMargin($this->tab_top_newpage);
609 $pdf->setPageOrientation(
'', 1, $this->heightforfooter + $this->heightforfreetext);
615 $i = $pageposbeforenote;
616 while ($i < $pageposafternote) {
620 $pdf->SetDrawColor(128, 128, 128);
622 if ($i > $pageposbeforenote) {
623 $height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
624 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
626 $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
627 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
631 $pdf->setPageOrientation(
'', 1, 0);
638 $pdf->setPage($pageposafternote);
639 if (!empty($tplidx)) {
640 $pdf->useTemplate($tplidx);
643 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
645 $height_note = $posyafter - $this->tab_top_newpage;
646 $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
649 $pdf->commitTransaction();
650 $posyafter = $pdf->GetY();
651 $height_note = $posyafter - $this->tab_top;
652 $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
655 if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
657 $pdf->AddPage(
'',
'',
true);
660 $pdf->setPage($pageposafternote);
661 if (!empty($tplidx)) {
662 $pdf->useTemplate($tplidx);
665 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
668 $posyafter = $this->tab_top_newpage;
672 $tab_height = $tab_height - $height_note;
673 $this->tab_top = $posyafter + 6;
682 $pdf->startTransaction();
683 $this->
pdfTabTitles($pdf, $this->tab_top, $tab_height, $outputlangs, $hidetop);
684 $pdf->rollbackTransaction(
true);
686 $nexY = $this->tab_top + $this->tabTitleHeight;
689 $pageposbeforeprintlines = $pdf->getPage();
690 $pagenb = $pageposbeforeprintlines;
691 for ($i = 0; $i < $nblines; $i++) {
693 $pdf->SetFont(
'',
'', $default_font_size - 1);
694 $pdf->SetTextColor(0, 0, 0);
697 $imglinesize = array();
698 if (!empty($realpatharray[$i])) {
702 $pdf->setTopMargin($this->tab_top_newpage);
703 $page_bottom_margin = $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(), $object, $langs);
704 $pdf->setPageOrientation(
'', 1, $page_bottom_margin);
705 $pageposbefore = $pdf->getPage();
707 $showpricebeforepagebreak = 1;
709 $posYAfterDescription = 0;
713 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
714 $pdf->AddPage(
'',
'',
true);
715 if (!empty($tplidx)) {
716 $pdf->useTemplate($tplidx);
718 $pdf->setPage($pageposbefore + 1);
720 $curY = $this->tab_top_newpage;
724 $showpricebeforepagebreak = 1;
726 $showpricebeforepagebreak = 0;
730 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
731 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
733 $posYAfterImage = $curY + $imglinesize[
'height'];
739 $pdf->startTransaction();
741 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
742 $pageposafter = $pdf->getPage();
744 if ($pageposafter > $pageposbefore) {
745 $pdf->rollbackTransaction(
true);
746 $pageposafter = $pageposbefore;
747 $pdf->setPageOrientation(
'', 1, $this->heightforfooter);
749 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
751 $pageposafter = $pdf->getPage();
752 $posyafter = $pdf->GetY();
754 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
755 if ($i == ($nblines - 1)) {
756 $pdf->AddPage(
'',
'',
true);
757 if (!empty($tplidx)) {
758 $pdf->useTemplate($tplidx);
760 $pdf->setPage($pageposafter + 1);
766 $showpricebeforepagebreak = 1;
768 $showpricebeforepagebreak = 0;
772 $pdf->commitTransaction();
774 $posYAfterDescription = $pdf->GetY();
777 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
779 $pageposafter = $pdf->getPage();
780 $pdf->setPage($pageposbefore);
781 $pdf->setTopMargin($this->marge_haute);
782 $pdf->setPageOrientation(
'', 1, 0);
785 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
786 $pdf->setPage($pageposafter);
787 $curY = $this->tab_top_newpage;
790 $pdf->SetFont(
'',
'', $default_font_size - 1);
796 $nexY = max($pdf->GetY(), $nexY);
803 $nexY = max($pdf->GetY(), $nexY);
811 $nexY = max($pdf->GetY(), $nexY);
818 $nexY = max($pdf->GetY(), $nexY);
823 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
825 $nexY = max($pdf->GetY(), $nexY);
829 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
832 $nexY = max($pdf->GetY(), $nexY);
839 $nexY = max($pdf->GetY(), $nexY);
846 $nexY = max($pdf->GetY(), $nexY);
850 if (!empty($object->lines[$i]->array_options)) {
851 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
853 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
855 $nexY = max($pdf->GetY(), $nexY);
867 'outputlangs' => $outputlangs,
868 'hidedetails' => $hidedetails
870 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
874 if (isset($object->type) && $object->type == 2 &&
getDolGlobalString(
'INVOICE_POSITIVE_CREDIT_NOTE')) {
878 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
879 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
880 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
881 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
883 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
886 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
887 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
889 $tvaligne = $sign * $object->lines[$i]->total_tva;
893 $localtax1ligne = $object->lines[$i]->total_localtax1;
894 $localtax2ligne = $object->lines[$i]->total_localtax2;
895 $localtax1_rate = $object->lines[$i]->localtax1_tx;
896 $localtax2_rate = $object->lines[$i]->localtax2_tx;
897 $localtax1_type = $object->lines[$i]->localtax1_type;
898 $localtax2_type = $object->lines[$i]->localtax2_type;
911 $vatrate = (string) $object->lines[$i]->tva_tx;
914 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
915 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
917 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
918 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
922 if ($localtax1_type && $localtax1ligne != 0) {
923 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
924 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
926 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
929 if ($localtax2_type && $localtax2ligne != 0) {
930 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
931 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
933 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
937 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
942 if (!isset($this->tva[$vatrate])) {
943 $this->tva[$vatrate] = 0;
945 $this->tva[$vatrate] += $tvaligne;
946 $vatcode = $object->lines[$i]->vat_src_code;
947 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
948 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
950 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
952 $nexY = max($nexY, $posYAfterImage);
956 $pdf->setPage($pageposafter);
957 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
959 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
960 $pdf->SetLineStyle(array(
'dash'=>0));
964 while ($pagenb < $pageposafter) {
965 $pdf->setPage($pagenb);
967 if ($pagenb == $pageposbeforeprintlines) {
968 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
970 $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);
974 $pdf->setPage($pagenb);
975 $pdf->setPageOrientation(
'', 1, 0);
977 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
979 if (!empty($tplidx)) {
980 $pdf->useTemplate($tplidx);
984 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
986 if ($pagenb == $pageposafter) {
987 $this->
_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
989 $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);
994 if (!empty($tplidx)) {
995 $pdf->useTemplate($tplidx);
999 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1006 if ($pagenb == $pageposbeforeprintlines) {
1007 $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);
1008 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1010 $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);
1011 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
1015 $posy = $this->
drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
1018 $posy = $this->
drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
1021 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1027 if (method_exists($pdf,
'AliasNbPages')) {
1028 $pdf->AliasNbPages();
1036 $pdf->Output($file,
'F');
1039 $hookmanager->initHooks(array(
'pdfgeneration'));
1040 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
1042 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
1044 $this->error = $hookmanager->error;
1045 $this->errors = $hookmanager->errors;
1050 $this->result = array(
'fullpath'=>$file);
1054 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
1058 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
1218 protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
1220 global $conf, $mysoc;
1224 $pdf->SetFont(
'',
'', $default_font_size - 1);
1227 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1228 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1229 $pdf->SetXY($this->marge_gauche, $posy);
1230 if ($mysoc->forme_juridique_code == 92) {
1231 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1233 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1236 $posy = $pdf->GetY() + 4;
1241 if ($this->page_largeur < 210) {
1246 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
1247 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1248 $pdf->SetXY($this->marge_gauche, $posy);
1249 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1250 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0,
'L');
1252 $pdf->SetFont(
'',
'', $default_font_size - 2);
1253 $pdf->SetXY($posxval, $posy);
1254 $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);
1255 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1256 $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0,
'L');
1258 $posy = $pdf->GetY() + 3;
1262 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1263 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1264 $pdf->SetXY($this->marge_gauche, $posy);
1265 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1266 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1268 $pdf->SetFont(
'',
'', $default_font_size - 2);
1269 $pdf->SetXY($posxval, $posy);
1270 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1271 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1273 $posy = $pdf->GetY() + 3;
1276 if ($object->type != 2) {
1278 if (empty($object->mode_reglement_code)
1281 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1282 } elseif (($object->mode_reglement_code ==
'CHQ' && !
getDolGlobalInt(
'FACTURE_CHQ_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))
1283 || ($object->mode_reglement_code ==
'VIR' && !
getDolGlobalInt(
'FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
1285 $outputlangs->load(
"errors");
1287 $pdf->SetXY($this->marge_gauche, $posy);
1288 $pdf->SetTextColor(200, 0, 0);
1289 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1290 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1291 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0,
'L', 0);
1292 $pdf->SetTextColor(0, 0, 0);
1294 $posy = $pdf->GetY() + 1;
1298 if (!empty($object->mode_reglement_code)
1299 && $object->mode_reglement_code !=
'CHQ'
1300 && $object->mode_reglement_code !=
'VIR') {
1301 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1302 $pdf->SetXY($this->marge_gauche, $posy);
1303 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1304 $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0,
'L');
1306 $pdf->SetFont(
'',
'', $default_font_size - 2);
1307 $pdf->SetXY($posxval, $posy);
1308 $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);
1311 if ($object->mode_reglement_code ==
"PRE") {
1312 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1314 $bac->fetch(0, $object->thirdparty->id);
1315 $iban= $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1316 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1319 $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0,
'L');
1321 $posy = $pdf->GetY();
1327 if ($this->emetteur->country_code ==
'FR') {
1329 $pdf->SetXY($this->marge_gauche, $posy);
1330 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1332 $posy = $pdf->GetY() + 1;
1337 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CB' || $object->mode_reglement_code ==
'VAD') {
1338 $useonlinepayment = 0;
1340 if (isModEnabled(
'paypal')) {
1341 $useonlinepayment++;
1343 if (isModEnabled(
'stripe')) {
1344 $useonlinepayment++;
1346 if (isModEnabled(
'paybox')) {
1347 $useonlinepayment++;
1353 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1356 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1357 $servicename = $langs->transnoentities(
'Online');
1358 $paiement_url = getOnlinePaymentUrl(
'',
'invoice', $object->ref,
'',
'',
'');
1359 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1361 $pdf->SetXY($this->marge_gauche, $posy);
1362 $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5,
'',
'',
dol_htmlentitiesbr($linktopay), 0, 1);
1364 $posy = $pdf->GetY() + 1;
1369 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1372 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1375 $account =
new Account($this->db);
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', $account->proprio), 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($account->owner_address), 0,
'L', 0);
1387 $posy = $pdf->GetY() + 2;
1390 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1391 $pdf->SetXY($this->marge_gauche, $posy);
1392 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1393 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1394 $posy = $pdf->GetY() + 1;
1397 $pdf->SetXY($this->marge_gauche, $posy);
1398 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1399 $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1400 $posy = $pdf->GetY() + 2;
1407 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1408 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1409 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1410 if ($object->fk_bank > 0) {
1411 $bankid = $object->fk_bank;
1413 $account =
new Account($this->db);
1414 $account->fetch($bankid);
1416 $curx = $this->marge_gauche;
1419 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1441 protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
1443 global $conf, $mysoc, $hookmanager;
1454 if (is_object($outputlangsbis)) {
1455 $pdf->SetFont(
'',
'', $default_font_size - 2);
1457 $pdf->SetFont(
'',
'', $default_font_size - 1);
1463 if ($this->page_largeur < 210) {
1467 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1473 $parameters = array(
1474 'object' => &$object,
1475 'outputlangs' => $outputlangs,
1477 $hookmanager->executeHooks(
'beforePercentCalculation', $parameters, $this);
1482 foreach ($object->lines as $line) {
1483 if ($line->product_type != 9) {
1484 $percent += $line->situation_percent;
1490 $avancementGlobal = $percent / $i;
1492 $avancementGlobal = 0;
1495 $object->fetchPreviousNextSituationInvoice();
1496 $TPreviousIncoice = $object->tab_previous_situation_invoice;
1499 $total_a_payer_ttc = 0;
1500 foreach ($TPreviousIncoice as &$fac) {
1501 $total_a_payer += $fac->total_ht;
1502 $total_a_payer_ttc += $fac->total_ttc;
1504 $total_a_payer += $object->total_ht;
1505 $total_a_payer_ttc += $object->total_ttc;
1507 if (!empty($avancementGlobal)) {
1508 $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
1509 $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
1512 $total_a_payer_ttc = 0;
1516 if (!empty($TPreviousIncoice)) {
1517 $pdf->setY($tab2_top);
1518 $posy = $pdf->GetY();
1520 foreach ($TPreviousIncoice as &$fac) {
1521 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1525 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1526 $pdf->setY($this->tab_top_newpage);
1528 $pdf->setY($this->marge_haute);
1530 $posy = $pdf->GetY();
1535 $pdf->SetFillColor(255, 255, 255);
1536 $pdf->SetXY($col1x, $posy);
1537 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $fac->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1539 $pdf->SetXY($col2x, $posy);
1543 $facSign = $fac->total_ht >= 0 ?
'+' :
'';
1546 $displayAmount =
' '.$facSign.
' '.
price($fac->total_ht, 0, $outputlangs);
1548 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1557 $pdf->SetFillColor(255, 255, 255);
1558 $pdf->SetXY($col1x, $posy);
1559 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $object->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1561 $pdf->SetXY($col2x, $posy);
1564 $facSign = $object->total_ht >= 0 ?
'+' :
'';
1572 $displayAmount =
' '.$facSign.
' '.
price($object->total_ht, 0, $outputlangs);
1573 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1578 $pdf->SetFont(
'',
'', $default_font_size - 1);
1579 $pdf->SetFillColor(255, 255, 255);
1580 $pdf->SetXY($col1x, $posy);
1581 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"SituationTotalProgress", $avancementGlobal), 0,
'L', 1);
1583 $pdf->SetXY($col2x, $posy);
1584 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0,
'R', 1);
1585 $pdf->SetFont(
'',
'', $default_font_size - 2);
1589 if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
1592 $this->
_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
1593 $pdf->setY($this->tab_top_newpage);
1595 $pdf->setY($this->marge_haute);
1598 $posy = $pdf->GetY();
1609 $total_ht = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1612 $total_line_remise = 0;
1613 foreach ($object->lines as $i => $line) {
1615 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1617 if ($line->total_ht < 0) {
1618 $total_line_remise += -$line->total_ht;
1621 if ($total_line_remise > 0) {
1623 $pdf->SetFillColor(255, 255, 255);
1624 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1625 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1626 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1627 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1633 $pdf->SetFillColor(255, 255, 255);
1634 $pdf->SetXY($col1x, $tab2_top);
1635 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1636 $pdf->SetXY($col2x, $tab2_top);
1637 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1644 $pdf->SetFillColor(255, 255, 255);
1645 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1646 $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);
1648 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1649 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1650 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1653 $pdf->SetFillColor(248, 248, 248);
1655 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1657 $this->atleastoneratenotnull = 0;
1659 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1660 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1666 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1667 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1671 foreach ($localtax_rate as $tvakey => $tvaval) {
1676 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1679 if (preg_match(
'/\*/', $tvakey)) {
1680 $tvakey = str_replace(
'*',
'', $tvakey);
1681 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1684 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1686 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1687 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1689 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1691 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1692 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1700 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1701 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1705 foreach ($localtax_rate as $tvakey => $tvaval) {
1710 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1713 if (preg_match(
'/\*/', $tvakey)) {
1714 $tvakey = str_replace(
'*',
'', $tvakey);
1715 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1717 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1719 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1720 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1722 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1724 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1725 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1732 if (
getDolGlobalInt(
'INVOICE_USE_SITUATION') == 1 && $object->situation_cycle_ref && $object->situation_counter > 1) {
1734 foreach ($this->tva as $tvakey => $tvaval) {
1735 $sum_pdf_tva += $tvaval;
1738 if ($sum_pdf_tva != $object->total_tva) {
1739 if (!empty($sum_pdf_tva)) {
1740 $coef_fix_tva = $object->total_tva / $sum_pdf_tva;
1746 foreach ($this->tva as $tvakey => $tvaval) {
1747 $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1749 foreach ($this->tva_array as $tvakey => $tvaval) {
1750 $this->tva_array[$tvakey][
'amount'] = $tvaval[
'amount'] * $coef_fix_tva;
1756 foreach ($this->tva_array as $tvakey => $tvaval) {
1758 $this->atleastoneratenotnull++;
1761 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1764 if (preg_match(
'/\*/', $tvakey)) {
1765 $tvakey = str_replace(
'*',
'', $tvakey);
1766 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1768 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1771 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1773 $totalvat .= ($tvaval[
'vatcode'] ? $tvaval[
'vatcode'] :
vatrate($tvaval[
'vatrate'], 1)).$tvacompl;
1775 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1777 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1779 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1780 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1787 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1788 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1792 foreach ($localtax_rate as $tvakey => $tvaval) {
1797 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1800 if (preg_match(
'/\*/', $tvakey)) {
1801 $tvakey = str_replace(
'*',
'', $tvakey);
1802 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1804 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1806 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1808 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1810 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1812 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1813 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1821 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1822 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1826 foreach ($localtax_rate as $tvakey => $tvaval) {
1832 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1835 if (preg_match(
'/\*/', $tvakey)) {
1836 $tvakey = str_replace(
'*',
'', $tvakey);
1837 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1839 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1842 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1843 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1845 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1847 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1848 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1855 if (
price2num($object->revenuestamp) != 0) {
1857 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1858 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1860 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1861 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $object->revenuestamp), $useborder,
'R', 1);
1866 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1867 $pdf->SetTextColor(0, 0, 60);
1868 $pdf->SetFillColor(224, 224, 224);
1869 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1871 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1872 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1876 if ($object->displayRetainedWarranty()) {
1877 $pdf->SetTextColor(40, 40, 40);
1878 $pdf->SetFillColor(255, 255, 255);
1880 $retainedWarranty = $object->getRetainedWarrantyAmount();
1881 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1885 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1886 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date($object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1888 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1889 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1893 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1895 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.$object->retained_warranty.
'%)';
1896 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date($object->retained_warranty_date_limit,
'day')) :
'';
1898 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1899 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1900 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1905 $pdf->SetTextColor(0, 0, 0);
1907 $creditnoteamount = $object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1908 $depositsamount = $object->getSumDepositsUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1910 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1911 if (!empty($object->paye)) {
1915 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1918 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1919 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"Paid") :
''), 0,
'L', 0);
1920 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1921 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1924 if ($creditnoteamount) {
1925 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1926 $labeltouse .= (is_object($outputlangsbis) ? (
' / '.($outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities(
"CreditNotes")) :
'');
1928 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1929 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1930 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1931 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1950 $pdf->SetTextColor(0, 0, 60);
1951 $pdf->SetFillColor(224, 224, 224);
1952 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1953 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1954 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1955 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1957 $pdf->SetFont(
'',
'', $default_font_size - 1);
1958 $pdf->SetTextColor(0, 0, 0);
1962 return ($tab2_top + ($tab2_hl * $index));
2058 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
2061 global $conf, $langs;
2063 $ltrdirection =
'L';
2064 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
2065 $ltrdirection =
'R';
2069 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2075 $pdf->SetTextColor(0, 0, 60);
2076 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2080 $posy = $this->marge_haute;
2081 $posx = $this->page_largeur - $this->marge_droite - $w;
2083 $pdf->SetXY($this->marge_gauche, $posy);
2087 if ($this->emetteur->logo) {
2088 $logodir = $conf->mycompany->dir_output;
2089 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
2090 $logodir = $conf->mycompany->multidir_output[$object->entity];
2093 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2095 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2097 if (is_readable($logo)) {
2099 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2101 $pdf->SetTextColor(200, 0, 0);
2102 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2103 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2104 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2107 $text = $this->emetteur->name;
2108 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2112 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2113 $pdf->SetXY($posx, $posy);
2114 $pdf->SetTextColor(0, 0, 60);
2115 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2116 if ($object->type == 1) {
2117 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2119 if ($object->type == 2) {
2120 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2122 if ($object->type == 3) {
2123 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2125 if ($object->type == 4) {
2126 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2128 if ($this->situationinvoice) {
2129 $outputlangs->loadLangs(array(
"other"));
2130 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") . $object->situation_counter .
" -";
2132 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2134 if ($object->type == 0) {
2135 if ($this->situationinvoice) {
2136 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2138 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2139 } elseif ($object->type == 1) {
2140 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2141 } elseif ($object->type == 2) {
2142 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2143 } elseif ($object->type == 3) {
2144 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2145 } elseif ($object->type == 4) {
2146 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2149 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
2150 if ($object->statut == $object::STATUS_DRAFT) {
2151 $pdf->SetTextColor(128, 0, 0);
2152 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2155 $pdf->MultiCell($w, 3, $title,
'',
'R');
2157 $pdf->SetFont(
'',
'B', $default_font_size);
2171 $pdf->SetFont(
'',
'', $default_font_size - 2);
2173 if ($object->ref_customer) {
2175 $pdf->SetXY($posx, $posy);
2176 $pdf->SetTextColor(0, 0, 60);
2177 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".
dol_trunc($outputlangs->convToOutputCharset($object->ref_customer), 65),
'',
'R');
2181 $object->fetch_projet();
2182 if (!empty($object->project->ref)) {
2184 $pdf->SetXY($posx, $posy);
2185 $pdf->SetTextColor(0, 0, 60);
2186 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
2191 $object->fetch_projet();
2192 if (!empty($object->project->ref)) {
2193 $outputlangs->load(
"projects");
2195 $pdf->SetXY($posx, $posy);
2196 $pdf->SetTextColor(0, 0, 60);
2197 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
2201 $objectidnext = $object->getIdReplacingInvoice(
'validated');
2202 if ($object->type == 0 && $objectidnext) {
2203 $objectreplacing =
new Facture($this->db);
2204 $objectreplacing->fetch($objectidnext);
2207 $pdf->SetXY($posx, $posy);
2208 $pdf->SetTextColor(0, 0, 60);
2209 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2211 if ($object->type == 1) {
2212 $objectreplaced =
new Facture($this->db);
2213 $objectreplaced->fetch($object->fk_facture_source);
2216 $pdf->SetXY($posx, $posy);
2217 $pdf->SetTextColor(0, 0, 60);
2218 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2220 if ($object->type == 2 && !empty($object->fk_facture_source)) {
2221 $objectreplaced =
new Facture($this->db);
2222 $objectreplaced->fetch($object->fk_facture_source);
2225 $pdf->SetXY($posx, $posy);
2226 $pdf->SetTextColor(0, 0, 60);
2227 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2231 $pdf->SetXY($posx, $posy);
2232 $pdf->SetTextColor(0, 0, 60);
2234 $title = $outputlangs->transnoentities(
"DateInvoice");
2235 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2236 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2238 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2242 $pdf->SetXY($posx, $posy);
2243 $pdf->SetTextColor(0, 0, 60);
2244 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date($object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2247 if ($object->type != 2) {
2249 $pdf->SetXY($posx, $posy);
2250 $pdf->SetTextColor(0, 0, 60);
2251 $title = $outputlangs->transnoentities(
"DateDue");
2252 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2253 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2255 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2258 if (!
getDolGlobalString(
'MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
2260 $pdf->SetXY($posx, $posy);
2261 $pdf->SetTextColor(0, 0, 60);
2262 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
2267 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
2268 if (count($arrayidcontact) > 0) {
2269 $usertmp =
new User($this->db);
2270 $usertmp->fetch($arrayidcontact[0]);
2272 $pdf->SetXY($posx, $posy);
2273 $pdf->SetTextColor(0, 0, 60);
2274 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2283 $current_y = $pdf->getY();
2284 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
2285 if ($current_y < $pdf->getY()) {
2286 $top_shift = $pdf->getY() - $current_y;
2291 $carac_emetteur =
'';
2293 $arrayidcontact = $object->getIdContact(
'internal',
'BILLING');
2294 if (count($arrayidcontact) > 0) {
2295 $object->fetch_user($arrayidcontact[0]);
2296 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2297 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
2298 $carac_emetteur .=
"\n";
2301 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
2305 $posy += $top_shift;
2306 $posx = $this->marge_gauche;
2308 $posx = $this->page_largeur - $this->marge_droite - 80;
2316 $pdf->SetTextColor(0, 0, 0);
2317 $pdf->SetFont(
'',
'', $default_font_size - 2);
2318 $pdf->SetXY($posx, $posy - 5);
2319 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2320 $pdf->SetXY($posx, $posy);
2321 $pdf->SetFillColor(230, 230, 230);
2322 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2323 $pdf->SetTextColor(0, 0, 60);
2328 $pdf->SetXY($posx + 2, $posy + 3);
2329 $pdf->SetFont(
'',
'B', $default_font_size);
2330 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2331 $posy = $pdf->getY();
2335 $pdf->SetXY($posx + 2, $posy);
2336 $pdf->SetFont(
'',
'', $default_font_size - 1);
2337 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2340 $usecontact =
false;
2341 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
2342 if (count($arrayidcontact) > 0) {
2344 $result = $object->fetch_contact($arrayidcontact[0]);
2348 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2349 $thirdparty = $object->contact;
2351 $thirdparty = $object->thirdparty;
2357 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
2361 if ($this->page_largeur < 210) {
2365 $posy += $top_shift;
2366 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2368 $posx = $this->marge_gauche;
2373 $pdf->SetTextColor(0, 0, 0);
2374 $pdf->SetFont(
'',
'', $default_font_size - 2);
2375 $pdf->SetXY($posx + 2, $posy - 5);
2376 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2377 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2381 $pdf->SetXY($posx + 2, $posy + 3);
2382 $pdf->SetFont(
'',
'B', $default_font_size);
2383 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2385 $posy = $pdf->getY();
2388 $pdf->SetFont(
'',
'', $default_font_size - 1);
2389 $pdf->SetXY($posx + 2, $posy);
2390 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2394 $idaddressshipping = $object->getIdContact(
'external',
'SHIPPING');
2396 if (!empty($idaddressshipping)) {
2397 $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
2398 $companystatic =
new Societe($this->db);
2399 $companystatic->fetch($object->contact->fk_soc);
2401 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact,
'target', $object);
2404 $carac_client_shipping=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'target', $object);
2406 if (!empty($carac_client_shipping)) {
2407 $posy += $hautcadre;
2410 $pdf->SetXY($posx + 2, $posy - 5);
2411 $pdf->SetFont(
'',
'', $default_font_size - 2);
2412 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2413 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2416 $pdf->SetXY($posx + 2, $posy + 3);
2417 $pdf->SetFont(
'',
'B', $default_font_size);
2418 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2420 $posy = $pdf->getY();
2423 $pdf->SetXY($posx+2, $posy);
2424 $pdf->SetFont(
'',
'', $default_font_size - 1);
2425 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2426 $shipp_shift += $hautcadre;
2431 $pdf->SetTextColor(0, 0, 0);
2433 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);