194 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
197 global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
199 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
201 if (!is_object($outputlangs)) {
202 $outputlangs = $langs;
206 $outputlangs->charset_output =
'ISO-8859-1';
210 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
213 if ($object->statut == $object::STATUS_DRAFT && (
getDolGlobalString(
'FACTURE_DRAFT_WATERMARK'))) {
214 $this->watermark = $conf->global->FACTURE_DRAFT_WATERMARK;
217 global $outputlangsbis;
218 $outputlangsbis =
null;
219 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
220 $outputlangsbis =
new Translate(
'', $conf);
221 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
222 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
225 $nblines = count($object->lines);
228 $realpatharray = array();
230 for ($i = 0; $i < $nblines; $i++) {
231 if (empty($object->lines[$i]->fk_product)) {
235 $objphoto =
new Product($this->db);
236 $objphoto->fetch($object->lines[$i]->fk_product);
238 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
239 $dir = $conf->product->dir_output.
'/'.$pdir;
242 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
243 $filename = $obj[
'photo'];
245 $realpath = $dir.$filename;
250 $realpatharray[$i] = $realpath;
254 if (count($realpatharray) == 0) {
255 $this->posxpicture = $this->posxtva;
258 if ($conf->facture->dir_output) {
259 $object->fetch_thirdparty();
261 $deja_regle = $object->getSommePaiement((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
262 $amount_credit_notes_included = $object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
263 $amount_deposits_included = $object->getSumDepositsUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
266 if ($object->specimen) {
267 $dir = empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity];
268 $file = $dir.
"/SPECIMEN.pdf";
271 $dir = (empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity]).
"/".$objectref;
272 $file = $dir.
"/".$objectref.
".pdf";
274 if (!file_exists($dir)) {
276 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
281 if (file_exists($dir)) {
283 if (!is_object($hookmanager)) {
284 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
287 $hookmanager->initHooks(array(
'pdfgeneration'));
288 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
290 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
293 $nblines = count($object->lines);
294 $nbpayments = count($object->getListOfPayments());
299 $pdf->SetAutoPageBreak(1, 0);
301 $heightforinfotot = 50 + (4 * $nbpayments);
302 if ($heightforinfotot > 220) {
303 $heightforinfotot = 220;
305 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
306 $heightforfooter = $this->marge_basse + 8;
308 $heightforfooter += 6;
311 $heightforqrinvoice_firstpage = 0;
314 if ($heightforqrinvoice_firstpage > 0) {
316 $heightforinfotot = 30 + (4 * $nbpayments);
320 if (class_exists(
'TCPDF')) {
321 $pdf->setPrintHeader(
false);
322 $pdf->setPrintFooter(
false);
328 $logodir = $conf->mycompany->dir_output;
329 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
330 $logodir = $conf->mycompany->multidir_output[$object->entity];
332 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
333 $tplidx = $pdf->importPage(1);
338 $pdf->SetDrawColor(128, 128, 128);
340 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
341 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
342 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
343 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
344 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
346 $pdf->SetCompression(
false);
350 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
351 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
357 $certprivate = !
getDolGlobalString(
'CERTIFICATE_CRT_PRIVATE') ?
'' : $conf->global->CERTIFICATE_CRT_PRIVATE;
362 'Name' => $this->emetteur->name,
363 'Location' =>
getCountry($this->emetteur->country_code, 0),
364 'Reason' =>
'INVOICE',
365 'ContactInfo' => $this->emetteur->email
367 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
370 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
374 $categoryOfOperation = 0;
377 for ($i = 0; $i < $nblines; $i++) {
378 if ($object->lines[$i]->remise_percent) {
379 $this->atleastonediscount++;
383 if ($categoryOfOperation < 2) {
384 $lineProductType = $object->lines[$i]->product_type;
390 if ($nbProduct > 0 && $nbService > 0) {
392 $categoryOfOperation = 2;
397 if ($categoryOfOperation <= 0) {
399 if ($nbProduct == 0 && $nbService > 0) {
400 $categoryOfOperation = 1;
403 $this->categoryOfOperation = $categoryOfOperation;
404 if (empty($this->atleastonediscount)) {
405 $delta = ($this->posxprogress - $this->posxdiscount);
406 $this->posxpicture += $delta;
407 $this->posxtva += $delta;
408 $this->posxup += $delta;
409 $this->posxqty += $delta;
410 $this->posxunit += $delta;
411 $this->posxdiscount += $delta;
418 $this->situationinvoice =
true;
419 $progress_width = 10;
420 $this->posxpicture -= $progress_width;
421 $this->posxtva -= $progress_width;
422 $this->posxup -= $progress_width;
423 $this->posxqty -= $progress_width;
424 $this->posxunit -= $progress_width;
425 $this->posxdiscount -= $progress_width;
426 $this->posxprogress -= $progress_width;
431 if (!empty($tplidx)) {
432 $pdf->useTemplate($tplidx);
437 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
438 $pdf->SetFont(
'',
'', $default_font_size - 1);
439 $pdf->MultiCell(0, 3,
'');
440 $pdf->SetTextColor(0, 0, 0);
445 $tab_top = 90 + $top_shift;
446 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
449 $extra_under_address_shift = 0;
452 $qrcodestring = $object->buildZATCAQRString();
454 $qrcodestring = $object->buildSwitzerlandQRString();
458 $qrcodecolor = array(
'25',
'25',
'25');
463 'fgcolor' => $qrcodecolor,
468 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr,
'N');
469 $extra_under_address_shift += 25;
477 'outputlangs' => $outputlangs,
478 'hidedetails' => $hidedetails
480 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
481 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
482 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
485 $tab_top += $extra_under_address_shift;
486 $tab_top_newpage += 0;
489 $height_incoterms = 0;
490 if (isModEnabled(
'incoterm')) {
491 $desc_incoterms = $object->getIncotermsForPDF();
492 if ($desc_incoterms) {
495 $pdf->SetFont(
'',
'', $default_font_size - 1);
496 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
497 $nexY = $pdf->GetY();
498 $height_incoterms = $nexY - $tab_top;
501 $pdf->SetDrawColor(192, 192, 192);
502 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
504 $tab_top = $nexY + 6;
509 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
512 if (is_object($object->thirdparty)) {
513 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
514 $salerepobj =
new User($this->db);
515 $salerepobj->fetch($salereparray[0][
'id']);
516 if (!empty($salerepobj->signature)) {
517 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
522 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
523 if (!empty($extranote)) {
535 $pdf->SetFont(
'',
'', $default_font_size - 1);
536 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
537 $nexY = $pdf->GetY();
538 $height_note = $nexY - $tab_top;
541 $pdf->SetDrawColor(192, 192, 192);
542 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
544 $tab_top = $nexY + 6;
547 $iniY = $tab_top + 7;
548 $curY = $tab_top + 7;
549 $nexY = $tab_top + 7;
552 for ($i = 0; $i < $nblines; $i++) {
554 $pdf->SetFont(
'',
'', $default_font_size - 1);
555 $pdf->SetTextColor(0, 0, 0);
558 $imglinesize = array();
559 if (!empty($realpatharray[$i])) {
563 $pdf->setTopMargin($tab_top_newpage);
564 $page_bottom_margin = $heightforfooter + $heightforfreetext + $heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(), $object, $langs);
565 $pdf->setPageOrientation(
'', 1, $page_bottom_margin);
566 $pageposbefore = $pdf->getPage();
568 $showpricebeforepagebreak = 1;
570 $posYAfterDescription = 0;
573 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
574 $pdf->AddPage(
'',
'',
true);
575 if (!empty($tplidx)) {
576 $pdf->useTemplate($tplidx);
579 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
580 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
582 $pdf->setPage($pageposbefore + 1);
584 $curY = $tab_top_newpage;
588 $showpricebeforepagebreak = 1;
590 $showpricebeforepagebreak = 0;
594 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
595 $curX = $this->posxpicture - 1;
596 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
598 $posYAfterImage = $curY + $imglinesize[
'height'];
602 $curX = $this->posxdesc - 1;
604 $pdf->startTransaction();
605 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
606 $pageposafter = $pdf->getPage();
607 if ($pageposafter > $pageposbefore) {
608 $pdf->rollbackTransaction(
true);
609 $pageposafter = $pageposbefore;
611 $pdf->setPageOrientation(
'', 1, $heightforfooter);
612 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
613 $pageposafter = $pdf->getPage();
614 $posyafter = $pdf->GetY();
616 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
617 if ($i == ($nblines - 1)) {
618 $pdf->AddPage(
'',
'',
true);
619 if (!empty($tplidx)) {
620 $pdf->useTemplate($tplidx);
623 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
624 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
626 $pdf->setPage($pageposafter + 1);
633 $showpricebeforepagebreak = 1;
635 $showpricebeforepagebreak = 0;
639 $pdf->commitTransaction();
641 $posYAfterDescription = $pdf->GetY();
643 $nexY = $pdf->GetY();
644 $pageposafter = $pdf->getPage();
645 $pdf->setPage($pageposbefore);
646 $pdf->setTopMargin($this->marge_haute);
647 $pdf->setPageOrientation(
'', 1, 0);
650 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
651 $pdf->setPage($pageposafter);
652 $curY = $tab_top_newpage;
655 $pdf->SetFont(
'',
'', $default_font_size - 1);
660 $pdf->SetXY($this->posxtva - 5, $curY);
661 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
666 $pdf->SetXY($this->posxup, $curY);
667 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
671 $pdf->SetXY($this->posxqty, $curY);
672 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
676 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
677 $pdf->SetXY($this->posxunit, $curY);
678 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
682 if ($object->lines[$i]->remise_percent) {
683 $pdf->SetXY($this->posxdiscount - 2, $curY);
685 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
689 if ($this->situationinvoice) {
691 $pdf->SetXY($this->posxprogress, $curY);
692 $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0,
'R');
697 $pdf->SetXY($this->postotalht, $curY);
698 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
702 if (isset($object->type) && $object->type == 2 &&
getDolGlobalString(
'INVOICE_POSITIVE_CREDIT_NOTE')) {
706 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
707 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
708 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
709 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
711 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
714 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
715 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
717 $tvaligne = $sign * $object->lines[$i]->total_tva;
721 $localtax1ligne = $object->lines[$i]->total_localtax1;
722 $localtax2ligne = $object->lines[$i]->total_localtax2;
723 $localtax1_rate = $object->lines[$i]->localtax1_tx;
724 $localtax2_rate = $object->lines[$i]->localtax2_tx;
725 $localtax1_type = $object->lines[$i]->localtax1_type;
726 $localtax2_type = $object->lines[$i]->localtax2_type;
739 $vatrate = (string) $object->lines[$i]->tva_tx;
742 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
743 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
745 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
746 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
750 if ($localtax1_type && $localtax1ligne != 0) {
751 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
752 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
754 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
757 if ($localtax2_type && $localtax2ligne != 0) {
758 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
759 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
761 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
765 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
770 if (!isset($this->tva[$vatrate])) {
771 $this->tva[$vatrate] = 0;
773 $this->tva[$vatrate] += $tvaligne;
774 $vatcode = $object->lines[$i]->vat_src_code;
775 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
776 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
778 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
780 if ($posYAfterImage > $posYAfterDescription) {
781 $nexY = $posYAfterImage;
786 $pdf->setPage($pageposafter);
787 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
789 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
790 $pdf->SetLineStyle(array(
'dash'=>0));
796 while ($pagenb < $pageposafter) {
797 $pdf->setPage($pagenb);
799 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1, $object->multicurrency_code);
801 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
805 $pdf->setPage($pagenb);
806 $pdf->setPageOrientation(
'', 1, 0);
808 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
809 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
811 if (!empty($tplidx)) {
812 $pdf->useTemplate($tplidx);
815 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
817 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1, $object->multicurrency_code);
819 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
824 if (!empty($tplidx)) {
825 $pdf->useTemplate($tplidx);
829 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
830 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
837 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 0, $object->multicurrency_code);
838 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage + 1;
840 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
841 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
843 dol_syslog(
"bottomlasttab=".$bottomlasttab.
" this->page_hauteur=".$this->page_hauteur.
" heightforinfotot=".$heightforinfotot.
" heightforfreetext=".$heightforfreetext.
" heightforfooter=".$heightforfooter);
846 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
849 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
852 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
858 if (method_exists($pdf,
'AliasNbPages')) {
859 $pdf->AliasNbPages();
871 $pdf->Output($file,
'F');
874 $hookmanager->initHooks(array(
'pdfgeneration'));
875 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
877 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
879 $this->error = $hookmanager->error;
880 $this->errors = $hookmanager->errors;
885 $this->result = array(
'fullpath'=>$file);
889 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
893 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
921 $current_page = $pdf->getPage();
923 $tab3_top = $posy + 8;
926 if ($this->page_largeur < 210) {
932 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height);
936 $pdf->SetFont(
'',
'', $default_font_size - 4);
940 $sql =
"SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,";
941 $sql .=
" re.description, re.fk_facture_source,";
942 $sql .=
" f.type, f.datef";
943 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
944 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int) $object->id);
945 $resql = $this->db->query($sql);
947 $num = $this->db->num_rows($resql);
949 $invoice =
new Facture($this->db);
952 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
955 $pdf->AddPage(
'',
'',
true);
960 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
961 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
963 $pdf->setPage($current_page);
964 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
967 $obj = $this->db->fetch_object($resql);
969 if ($obj->type == 2) {
970 $text = $outputlangs->transnoentities(
"CreditNote");
971 } elseif ($obj->type == 3) {
972 $text = $outputlangs->transnoentities(
"Deposit");
973 } elseif ($obj->type == 0) {
974 $text = $outputlangs->transnoentities(
"ExcessReceived");
976 $text = $outputlangs->transnoentities(
"UnknownType");
979 $invoice->fetch($obj->fk_facture_source);
981 $pdf->SetXY($tab3_posx, $tab3_top + $y);
982 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
983 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
984 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
985 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
986 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
987 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
988 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
990 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
995 $this->error = $this->db->lasterror();
1001 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1003 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1004 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1005 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
1007 $sql .=
" ORDER BY p.datep";
1009 $resql = $this->db->query($sql);
1011 $num = $this->db->num_rows($resql);
1016 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1019 $pdf->AddPage(
'',
'',
true);
1024 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
1025 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1027 $pdf->setPage($current_page);
1028 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
1031 $row = $this->db->fetch_object($resql);
1033 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1034 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1035 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1036 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1037 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1038 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1040 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1041 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1042 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1043 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1044 $y = $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1045 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1050 return $tab3_top + $y + 3;
1052 $this->error = $this->db->lasterror();
1111 protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
1114 global $conf, $mysoc;
1118 $pdf->SetFont(
'',
'', $default_font_size - 1);
1121 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1122 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1123 $pdf->SetXY($this->marge_gauche, $posy);
1124 if ($mysoc->forme_juridique_code == 92) {
1125 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1127 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1130 $posy = $pdf->GetY() + 4;
1135 if ($this->page_largeur < 210) {
1140 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
1141 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1142 $pdf->SetXY($this->marge_gauche, $posy);
1143 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1144 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1146 $pdf->SetFont(
'',
'', $default_font_size - 2);
1147 $pdf->SetXY($posxval, $posy);
1148 $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);
1149 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1150 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1152 $posy = $pdf->GetY() + 3;
1156 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1157 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1158 $pdf->SetXY($this->marge_gauche, $posy);
1159 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1160 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1162 $pdf->SetFont(
'',
'', $default_font_size - 2);
1163 $pdf->SetXY($posxval, $posy);
1164 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1165 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1167 $posy = $pdf->GetY() + 3;
1170 if ($object->type != 2) {
1172 if (empty($object->mode_reglement_code)
1175 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1176 } elseif (($object->mode_reglement_code ==
'CHQ' && !
getDolGlobalInt(
'FACTURE_CHQ_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))
1177 || ($object->mode_reglement_code ==
'VIR' && !
getDolGlobalInt(
'FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
1179 $outputlangs->load(
"errors");
1181 $pdf->SetXY($this->marge_gauche, $posy);
1182 $pdf->SetTextColor(200, 0, 0);
1183 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1184 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1185 $pdf->MultiCell(80, 3, $this->error, 0,
'L', 0);
1186 $pdf->SetTextColor(0, 0, 0);
1188 $posy = $pdf->GetY() + 1;
1192 if (!empty($object->mode_reglement_code)
1193 && $object->mode_reglement_code !=
'CHQ'
1194 && $object->mode_reglement_code !=
'VIR') {
1195 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1196 $pdf->SetXY($this->marge_gauche, $posy);
1197 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1198 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1200 $pdf->SetFont(
'',
'', $default_font_size - 2);
1201 $pdf->SetXY($posxval, $posy);
1202 $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);
1204 if ($object->mode_reglement_code ==
"PRE") {
1205 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1207 $bac->fetch(0, $object->thirdparty->id);
1208 $iban= $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1209 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1211 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1213 $posy = $pdf->GetY();
1219 if ($this->emetteur->country_code ==
'FR') {
1221 $pdf->SetXY($this->marge_gauche, $posy);
1222 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1224 $posy = $pdf->GetY() + 1;
1229 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CB' || $object->mode_reglement_code ==
'VAD') {
1230 $useonlinepayment = 0;
1232 if (isModEnabled(
'paypal')) {
1233 $useonlinepayment++;
1235 if (isModEnabled(
'stripe')) {
1236 $useonlinepayment++;
1238 if (isModEnabled(
'paybox')) {
1239 $useonlinepayment++;
1244 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1247 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1248 $servicename = $langs->transnoentities(
'Online');
1249 $paiement_url = getOnlinePaymentUrl(
'',
'invoice', $object->ref,
'',
'',
'');
1250 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1252 $pdf->SetXY($this->marge_gauche, $posy);
1255 $posy = $pdf->GetY() + 1;
1260 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1263 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1266 $account =
new Account($this->db);
1269 $pdf->SetXY($this->marge_gauche, $posy);
1270 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1271 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1272 $posy = $pdf->GetY() + 1;
1275 $pdf->SetXY($this->marge_gauche, $posy);
1276 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1277 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1278 $posy = $pdf->GetY() + 2;
1281 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1282 $pdf->SetXY($this->marge_gauche, $posy);
1283 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1284 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1285 $posy = $pdf->GetY() + 1;
1288 $pdf->SetXY($this->marge_gauche, $posy);
1289 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1290 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1291 $posy = $pdf->GetY() + 2;
1298 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1299 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1300 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1301 if ($object->fk_bank > 0) {
1302 $bankid = $object->fk_bank;
1304 $account =
new Account($this->db);
1305 $account->fetch($bankid);
1307 $curx = $this->marge_gauche;
1310 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1334 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
1337 global $conf, $mysoc, $hookmanager;
1346 $outputlangsbis =
null;
1347 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1348 $outputlangsbis =
new Translate(
'', $conf);
1349 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1350 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1351 $default_font_size--;
1356 $pdf->SetFont(
'',
'', $default_font_size - 1);
1361 if ($this->page_largeur < 210) {
1365 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1371 $pdf->SetFillColor(255, 255, 255);
1372 $pdf->SetXY($col1x, $tab2_top);
1373 $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);
1375 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1376 $pdf->SetXY($col2x, $tab2_top);
1377 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1380 $pdf->SetFillColor(248, 248, 248);
1382 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1384 $this->atleastoneratenotnull = 0;
1386 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1387 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1393 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1394 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1398 foreach ($localtax_rate as $tvakey => $tvaval) {
1403 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1406 if (preg_match(
'/\*/', $tvakey)) {
1407 $tvakey = str_replace(
'*',
'', $tvakey);
1408 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1411 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1413 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1414 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1416 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1418 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1419 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1427 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1428 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1432 foreach ($localtax_rate as $tvakey => $tvaval) {
1437 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1440 if (preg_match(
'/\*/', $tvakey)) {
1441 $tvakey = str_replace(
'*',
'', $tvakey);
1442 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1444 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1446 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1447 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1449 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1451 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1452 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1460 foreach ($this->tva_array as $tvakey => $tvaval) {
1462 $this->atleastoneratenotnull++;
1465 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1468 if (preg_match(
'/\*/', $tvakey)) {
1469 $tvakey = str_replace(
'*',
'', $tvakey);
1470 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1472 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1475 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1477 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1479 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1481 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1483 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1484 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1491 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1492 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1496 foreach ($localtax_rate as $tvakey => $tvaval) {
1501 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1504 if (preg_match(
'/\*/', $tvakey)) {
1505 $tvakey = str_replace(
'*',
'', $tvakey);
1506 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1508 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1509 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1511 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1513 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1515 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1516 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1524 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1525 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1529 foreach ($localtax_rate as $tvakey => $tvaval) {
1533 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1536 if (preg_match(
'/\*/', $tvakey)) {
1537 $tvakey = str_replace(
'*',
'', $tvakey);
1538 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1540 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1542 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1543 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1545 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1547 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1548 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1554 if (
price2num($object->revenuestamp) != 0) {
1556 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1557 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp"), $useborder,
'L', 1);
1559 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1560 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $object->revenuestamp), $useborder,
'R', 1);
1565 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1566 $pdf->SetTextColor(0, 0, 60);
1567 $pdf->SetFillColor(224, 224, 224);
1568 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1570 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1571 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1574 if ($object->displayRetainedWarranty()) {
1575 $pdf->SetTextColor(40, 40, 40);
1576 $pdf->SetFillColor(255, 255, 255);
1578 $retainedWarranty = $object->getRetainedWarrantyAmount();
1579 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1583 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1584 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date($object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1586 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1587 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1591 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1593 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").
' ('.$object->retained_warranty.
'%)';
1594 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date($object->retained_warranty_date_limit,
'day')) :
'';
1596 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1597 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1598 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1603 $pdf->SetTextColor(0, 0, 0);
1604 $creditnoteamount = $object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1605 $depositsamount = $object->getSumDepositsUsed((isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1607 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1608 if (!empty($object->paye)) {
1612 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1615 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1616 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L', 0);
1617 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1618 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1621 if ($creditnoteamount) {
1622 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1624 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1625 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1626 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1627 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1631 if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1633 $pdf->SetFillColor(255, 255, 255);
1635 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1636 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L', 1);
1637 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1638 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R', 1);
1644 $pdf->SetTextColor(0, 0, 60);
1645 $pdf->SetFillColor(224, 224, 224);
1646 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1647 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1648 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1649 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1651 $pdf->SetFont(
'',
'', $default_font_size - 1);
1652 $pdf->SetTextColor(0, 0, 0);
1660 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1661 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $conf->global->BILL_TEXT_TOTAL_FOOTER, 0,
'L', 0);
1664 return ($tab2_top + ($tab2_hl * $index));
1681 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1691 $currency = !empty($currency) ? $currency : $conf->currency;
1695 $pdf->SetTextColor(0, 0, 0);
1696 $pdf->SetFont(
'',
'', $default_font_size - 2);
1698 if (empty($hidetop)) {
1700 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
1701 $categoryOfOperations = $outputlangs->transnoentities(
"MentionCategoryOfOperations") .
' : ' . $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1702 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
1703 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
1706 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1707 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1708 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1712 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1716 $pdf->SetDrawColor(128, 128, 128);
1717 $pdf->SetFont(
'',
'', $default_font_size - 1);
1720 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1722 if (empty($hidetop)) {
1723 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1725 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1726 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1730 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1731 if (empty($hidetop)) {
1738 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1739 if (empty($hidetop)) {
1740 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1741 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1745 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1746 if (empty($hidetop)) {
1747 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1748 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1751 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1752 if (empty($hidetop)) {
1753 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1754 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1758 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1759 if (empty($hidetop)) {
1760 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1761 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1765 if ($this->atleastonediscount) {
1766 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1767 if (empty($hidetop)) {
1768 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1769 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1773 if ($this->situationinvoice) {
1774 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1775 if (empty($hidetop)) {
1776 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1777 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities(
"ProgressShort"),
'',
'C');
1781 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1782 if (empty($hidetop)) {
1783 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1784 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1799 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
1802 global $conf, $langs;
1804 $ltrdirection =
'L';
1805 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1806 $ltrdirection =
'R';
1810 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
1816 $pdf->SetTextColor(0, 0, 60);
1817 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1821 $posy = $this->marge_haute;
1822 $posx = $this->page_largeur - $this->marge_droite - $w;
1824 $pdf->SetXY($this->marge_gauche, $posy);
1828 if ($this->emetteur->logo) {
1829 $logodir = $conf->mycompany->dir_output;
1830 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1831 $logodir = $conf->mycompany->multidir_output[$object->entity];
1834 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1836 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1838 if (is_readable($logo)) {
1840 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1842 $pdf->SetTextColor(200, 0, 0);
1843 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1844 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1845 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1848 $text = $this->emetteur->name;
1849 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1853 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1854 $pdf->SetXY($posx, $posy);
1855 $pdf->SetTextColor(0, 0, 60);
1856 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
1857 if ($object->type == 1) {
1858 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
1860 if ($object->type == 2) {
1861 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
1863 if ($object->type == 3) {
1864 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
1866 if ($object->type == 4) {
1867 $title = $outputlangs->transnoentities(
"InvoiceProForma");
1869 if ($this->situationinvoice) {
1870 $langs->loadLangs(array(
"other"));
1871 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") . $object->situation_counter .
" -";
1873 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1875 if ($object->type == 0) {
1876 if ($this->situationinvoice) {
1877 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
1879 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
1880 } elseif ($object->type == 1) {
1881 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
1882 } elseif ($object->type == 2) {
1883 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
1884 } elseif ($object->type == 3) {
1885 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
1886 } elseif ($object->type == 4) {
1887 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
1890 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1891 if ($object->statut == $object::STATUS_DRAFT) {
1892 $pdf->SetTextColor(128, 0, 0);
1893 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1896 $pdf->MultiCell($w, 3, $title,
'',
'R');
1898 $pdf->SetFont(
'',
'B', $default_font_size);
1912 $pdf->SetFont(
'',
'', $default_font_size - 2);
1914 if ($object->ref_customer) {
1916 $pdf->SetXY($posx, $posy);
1917 $pdf->SetTextColor(0, 0, 60);
1918 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_customer),
'',
'R');
1922 $object->fetch_projet();
1923 if (!empty($object->project->ref)) {
1925 $pdf->SetXY($posx, $posy);
1926 $pdf->SetTextColor(0, 0, 60);
1927 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1932 $object->fetch_projet();
1933 if (!empty($object->project->ref)) {
1934 $outputlangs->load(
"projects");
1936 $pdf->SetXY($posx, $posy);
1937 $pdf->SetTextColor(0, 0, 60);
1938 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1942 $objectidnext = $object->getIdReplacingInvoice(
'validated');
1943 if ($object->type == 0 && $objectidnext) {
1944 $objectreplacing =
new Facture($this->db);
1945 $objectreplacing->fetch($objectidnext);
1948 $pdf->SetXY($posx, $posy);
1949 $pdf->SetTextColor(0, 0, 60);
1950 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
1952 if ($object->type == 1) {
1953 $objectreplaced =
new Facture($this->db);
1954 $objectreplaced->fetch($object->fk_facture_source);
1957 $pdf->SetXY($posx, $posy);
1958 $pdf->SetTextColor(0, 0, 60);
1959 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
1961 if ($object->type == 2 && !empty($object->fk_facture_source)) {
1962 $objectreplaced =
new Facture($this->db);
1963 $objectreplaced->fetch($object->fk_facture_source);
1966 $pdf->SetXY($posx, $posy);
1967 $pdf->SetTextColor(0, 0, 60);
1968 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
1972 $pdf->SetXY($posx, $posy);
1973 $pdf->SetTextColor(0, 0, 60);
1974 $title = $outputlangs->transnoentities(
"DateInvoice");
1975 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1976 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1978 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1982 $pdf->SetXY($posx, $posy);
1983 $pdf->SetTextColor(0, 0, 60);
1984 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date($object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
1987 if ($object->type != 2) {
1989 $pdf->SetXY($posx, $posy);
1990 $pdf->SetTextColor(0, 0, 60);
1991 $title = $outputlangs->transnoentities(
"DateDue");
1992 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1993 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
1995 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
1998 if (!
getDolGlobalString(
'MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
2000 $pdf->SetXY($posx, $posy);
2001 $pdf->SetTextColor(0, 0, 60);
2002 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
2007 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
2008 if (count($arrayidcontact) > 0) {
2009 $usertmp =
new User($this->db);
2010 $usertmp->fetch($arrayidcontact[0]);
2012 $pdf->SetXY($posx, $posy);
2013 $pdf->SetTextColor(0, 0, 60);
2014 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2022 $current_y = $pdf->getY();
2023 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
2024 if ($current_y < $pdf->getY()) {
2025 $top_shift = $pdf->getY() - $current_y;
2030 $carac_emetteur =
'';
2032 $arrayidcontact = $object->getIdContact(
'internal',
'BILLING');
2033 if (count($arrayidcontact) > 0) {
2034 $object->fetch_user($arrayidcontact[0]);
2035 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2036 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
2037 $carac_emetteur .=
"\n";
2040 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
2044 $posy += $top_shift;
2045 $posx = $this->marge_gauche;
2047 $posx = $this->page_largeur - $this->marge_droite - 80;
2056 $pdf->SetTextColor(0, 0, 0);
2057 $pdf->SetFont(
'',
'', $default_font_size - 2);
2058 $pdf->SetXY($posx, $posy - 5);
2059 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2060 $pdf->SetXY($posx, $posy);
2061 $pdf->SetFillColor(230, 230, 230);
2062 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2063 $pdf->SetTextColor(0, 0, 60);
2068 $pdf->SetXY($posx + 2, $posy + 3);
2069 $pdf->SetFont(
'',
'B', $default_font_size);
2070 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2071 $posy = $pdf->getY();
2075 $pdf->SetXY($posx + 2, $posy);
2076 $pdf->SetFont(
'',
'', $default_font_size - 1);
2077 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2081 $usecontact =
false;
2082 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
2083 if (count($arrayidcontact) > 0) {
2085 $result = $object->fetch_contact($arrayidcontact[0]);
2089 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2090 $thirdparty = $object->contact;
2092 $thirdparty = $object->thirdparty;
2098 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
2102 if ($this->page_largeur < 210) {
2106 $posy += $top_shift;
2107 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2109 $posx = $this->marge_gauche;
2114 $pdf->SetTextColor(0, 0, 0);
2115 $pdf->SetFont(
'',
'', $default_font_size - 2);
2116 $pdf->SetXY($posx + 2, $posy - 5);
2117 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2118 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2122 $pdf->SetXY($posx + 2, $posy + 3);
2123 $pdf->SetFont(
'',
'B', $default_font_size);
2124 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2126 $posy = $pdf->getY();
2129 $pdf->SetFont(
'',
'', $default_font_size - 1);
2130 $pdf->SetXY($posx + 2, $posy);
2131 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2135 $idaddressshipping = $object->getIdContact(
'external',
'SHIPPING');
2137 if (!empty($idaddressshipping)) {
2138 $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
2139 $companystatic =
new Societe($this->db);
2140 $companystatic->fetch($object->contact->fk_soc);
2142 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact,
'target', $object);
2145 $carac_client_shipping=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'target', $object);
2147 if (!empty($carac_client_shipping)) {
2148 $posy += $hautcadre;
2151 $pdf->SetXY($posx + 2, $posy - 5);
2152 $pdf->SetFont(
'',
'', $default_font_size - 2);
2153 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2154 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2157 $pdf->SetXY($posx + 2, $posy + 3);
2158 $pdf->SetFont(
'',
'B', $default_font_size);
2159 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2161 $posy = $pdf->getY();
2164 $pdf->SetXY($posx+2, $posy);
2165 $pdf->SetFont(
'',
'', $default_font_size - 1);
2166 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2167 $top_shift += $hautcadre;
2172 $pdf->SetTextColor(0, 0, 0);