202 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
205 global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
207 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
209 if (!is_object($outputlangs)) {
210 $outputlangs = $langs;
214 $outputlangs->charset_output =
'ISO-8859-1';
218 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
225 global $outputlangsbis;
226 $outputlangsbis =
null;
228 $outputlangsbis =
new Translate(
'', $conf);
230 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
233 $nblines = count(
$object->lines);
236 $realpatharray = array();
238 for ($i = 0; $i < $nblines; $i++) {
239 if (empty(
$object->lines[$i]->fk_product)) {
243 $objphoto =
new Product($this->db);
244 $objphoto->fetch(
$object->lines[$i]->fk_product);
246 $pdir =
get_exdir(
$object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
247 $dir = $conf->product->dir_output.
'/'.$pdir;
250 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
251 $filename = $obj[
'photo'];
253 $realpath = $dir.$filename;
258 $realpatharray[$i] = $realpath;
262 if (count($realpatharray) == 0) {
263 $this->posxpicture = $this->posxtva;
266 if ($conf->facture->dir_output) {
269 $deja_regle =
$object->getSommePaiement((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
270 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
271 $amount_deposits_included =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
275 $dir = empty($conf->facture->multidir_output[
$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[
$object->entity];
276 $file = $dir.
"/SPECIMEN.pdf";
279 $dir = (empty($conf->facture->multidir_output[
$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[
$object->entity]).
"/".$objectref;
280 $file = $dir.
"/".$objectref.
".pdf";
282 if (!file_exists($dir)) {
284 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
289 if (file_exists($dir)) {
291 if (!is_object($hookmanager)) {
292 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
295 $hookmanager->initHooks(array(
'pdfgeneration'));
296 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
298 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
301 $nblines = count(
$object->lines);
302 $nbpayments = count(
$object->getListOfPayments());
307 $pdf->SetAutoPageBreak(1, 0);
309 $heightforinfotot = 50 + (4 * $nbpayments);
310 if ($heightforinfotot > 220) {
311 $heightforinfotot = 220;
314 $heightforfooter = $this->marge_basse + 8;
316 $heightforfooter += 6;
319 $heightforqrinvoice_firstpage = 0;
322 if ($heightforqrinvoice_firstpage > 0) {
324 $heightforinfotot = 30 + (4 * $nbpayments);
328 if (class_exists(
'TCPDF')) {
329 $pdf->setPrintHeader(
false);
330 $pdf->setPrintFooter(
false);
336 $logodir = $conf->mycompany->dir_output;
337 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
338 $logodir = $conf->mycompany->multidir_output[
$object->entity];
340 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
341 $tplidx = $pdf->importPage(1);
346 $pdf->SetDrawColor(128, 128, 128);
348 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
349 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
350 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
351 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
352 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
354 $pdf->SetCompression(
false);
358 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
359 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
365 $certprivate = !
getDolGlobalString(
'CERTIFICATE_CRT_PRIVATE') ?
'' : $conf->global->CERTIFICATE_CRT_PRIVATE;
370 'Name' => $this->emetteur->name,
371 'Location' =>
getCountry($this->emetteur->country_code,
''),
372 'Reason' =>
'INVOICE',
373 'ContactInfo' => $this->emetteur->email
375 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
379 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
383 $categoryOfOperation = 0;
386 for ($i = 0; $i < $nblines; $i++) {
387 if (
$object->lines[$i]->remise_percent) {
388 $this->atleastonediscount++;
392 if ($categoryOfOperation < 2) {
393 $lineProductType =
$object->lines[$i]->product_type;
399 if ($nbProduct > 0 && $nbService > 0) {
401 $categoryOfOperation = 2;
406 if ($categoryOfOperation <= 0) {
408 if ($nbProduct == 0 && $nbService > 0) {
409 $categoryOfOperation = 1;
412 $this->categoryOfOperation = $categoryOfOperation;
413 if (empty($this->atleastonediscount)) {
414 $delta = ($this->posxprogress - $this->posxdiscount);
415 $this->posxpicture += $delta;
416 $this->posxtva += $delta;
417 $this->posxup += $delta;
418 $this->posxqty += $delta;
419 $this->posxunit += $delta;
420 $this->posxdiscount += $delta;
427 $this->situationinvoice =
true;
428 $progress_width = 10;
429 $this->posxpicture -= $progress_width;
430 $this->posxtva -= $progress_width;
431 $this->posxup -= $progress_width;
432 $this->posxqty -= $progress_width;
433 $this->posxunit -= $progress_width;
434 $this->posxdiscount -= $progress_width;
435 $this->posxprogress -= $progress_width;
440 if (!empty($tplidx)) {
441 $pdf->useTemplate($tplidx);
447 $pdf->SetFont(
'',
'', $default_font_size - 1);
448 $pdf->MultiCell(0, 3,
'');
449 $pdf->SetTextColor(0, 0, 0);
454 $tab_top = 90 + $top_shift;
455 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
458 $extra_under_address_shift = 0;
461 $qrcodestring =
$object->buildZATCAQRString();
464 $qrcodestring =
$object->buildSwitzerlandQRString();
468 $qrcodestring =
$object->buildEPCQrCodeString();
473 $qrcodecolor = array(
'25',
'25',
'25');
478 'fgcolor' => $qrcodecolor,
483 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr,
'N');
487 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
488 $pdf->SetFont(
'',
'', $default_font_size - 4);
489 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
493 $extra_under_address_shift += 25;
501 'outputlangs' => $outputlangs,
502 'hidedetails' => $hidedetails
504 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
505 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
506 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
509 $tab_top += $extra_under_address_shift;
510 $tab_top_newpage += 0;
513 $height_incoterms = 0;
514 if (isModEnabled(
'incoterm')) {
515 $desc_incoterms =
$object->getIncotermsForPDF();
516 if ($desc_incoterms) {
519 $pdf->SetFont(
'',
'', $default_font_size - 1);
520 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
521 $nexY = $pdf->GetY();
522 $height_incoterms = $nexY - $tab_top;
525 $pdf->SetDrawColor(192, 192, 192);
526 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius,
'1234',
'D');
528 $tab_top = $nexY + 6;
533 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
536 if (is_object(
$object->thirdparty)) {
537 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
538 $salerepobj =
new User($this->db);
539 $salerepobj->fetch($salereparray[0][
'id']);
540 if (!empty($salerepobj->signature)) {
541 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
546 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
547 if (!empty($extranote)) {
559 $pdf->SetFont(
'',
'', $default_font_size - 1);
560 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
561 $nexY = $pdf->GetY();
562 $height_note = $nexY - $tab_top;
565 $pdf->SetDrawColor(192, 192, 192);
566 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1, $this->corner_radius,
'1234',
'D');
568 $tab_top = $nexY + 6;
571 $iniY = $tab_top + 7;
572 $curY = $tab_top + 7;
573 $nexY = $tab_top + 7;
576 for ($i = 0; $i < $nblines; $i++) {
578 $pdf->SetFont(
'',
'', $default_font_size - 1);
579 $pdf->SetTextColor(0, 0, 0);
582 $imglinesize = array();
583 if (!empty($realpatharray[$i])) {
587 $pdf->setTopMargin($tab_top_newpage);
588 $page_bottom_margin = $heightforfooter + $heightforfreetext + $heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(),
$object, $langs);
589 $pdf->setPageOrientation(
'', 1, $page_bottom_margin);
590 $pageposbefore = $pdf->getPage();
592 $showpricebeforepagebreak = 1;
594 $posYAfterDescription = 0;
597 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
598 $pdf->AddPage(
'',
'',
true);
599 if (!empty($tplidx)) {
600 $pdf->useTemplate($tplidx);
604 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
606 $pdf->setPage($pageposbefore + 1);
608 $curY = $tab_top_newpage;
612 $showpricebeforepagebreak = 1;
614 $showpricebeforepagebreak = 0;
618 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
619 $curX = $this->posxpicture - 1;
620 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
622 $posYAfterImage = $curY + $imglinesize[
'height'];
626 $curX = $this->posxdesc - 1;
628 $pdf->startTransaction();
629 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
630 $pageposafter = $pdf->getPage();
631 if ($pageposafter > $pageposbefore) {
632 $pdf->rollbackTransaction(
true);
633 $pageposafter = $pageposbefore;
635 $pdf->setPageOrientation(
'', 1, $heightforfooter);
636 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
637 $pageposafter = $pdf->getPage();
638 $posyafter = $pdf->GetY();
640 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
641 if ($i == ($nblines - 1)) {
642 $pdf->AddPage(
'',
'',
true);
643 if (!empty($tplidx)) {
644 $pdf->useTemplate($tplidx);
648 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
650 $pdf->setPage($pageposafter + 1);
657 $showpricebeforepagebreak = 1;
659 $showpricebeforepagebreak = 0;
663 $pdf->commitTransaction();
665 $posYAfterDescription = $pdf->GetY();
667 $nexY = $pdf->GetY();
668 $pageposafter = $pdf->getPage();
669 $pdf->setPage($pageposbefore);
670 $pdf->setTopMargin($this->marge_haute);
671 $pdf->setPageOrientation(
'', 1, 0);
674 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
675 $pdf->setPage($pageposafter);
676 $curY = $tab_top_newpage;
679 $pdf->SetFont(
'',
'', $default_font_size - 1);
684 $pdf->SetXY($this->posxtva - 5, $curY);
685 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
690 $pdf->SetXY($this->posxup, $curY);
691 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
695 $pdf->SetXY($this->posxqty, $curY);
696 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
701 $pdf->SetXY($this->posxunit, $curY);
702 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
706 if (
$object->lines[$i]->remise_percent) {
707 $pdf->SetXY($this->posxdiscount - 2, $curY);
709 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
713 if ($this->situationinvoice) {
715 $pdf->SetXY($this->posxprogress, $curY);
716 $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0,
'R');
721 $pdf->SetXY($this->postotalht, $curY);
722 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
730 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
731 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
732 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
733 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
735 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
738 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
739 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
741 $tvaligne = $sign *
$object->lines[$i]->total_tva;
745 $localtax1ligne =
$object->lines[$i]->total_localtax1;
746 $localtax2ligne =
$object->lines[$i]->total_localtax2;
747 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
748 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
749 $localtax1_type =
$object->lines[$i]->localtax1_type;
750 $localtax2_type =
$object->lines[$i]->localtax2_type;
763 $vatrate = (string)
$object->lines[$i]->tva_tx;
766 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
767 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
769 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
770 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
774 if ($localtax1_type && $localtax1ligne != 0) {
775 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
776 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
778 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
781 if ($localtax2_type && $localtax2ligne != 0) {
782 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
783 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
785 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
789 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
794 if (!isset($this->tva[$vatrate])) {
795 $this->tva[$vatrate] = 0;
797 $this->tva[$vatrate] += $tvaligne;
798 $vatcode =
$object->lines[$i]->vat_src_code;
799 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
800 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
802 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
804 if ($posYAfterImage > $posYAfterDescription) {
805 $nexY = $posYAfterImage;
810 $pdf->setPage($pageposafter);
811 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
813 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
814 $pdf->SetLineStyle(array(
'dash' => 0));
820 while ($pagenb < $pageposafter) {
821 $pdf->setPage($pagenb);
823 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
825 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
829 $pdf->setPage($pagenb);
830 $pdf->setPageOrientation(
'', 1, 0);
833 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
835 if (!empty($tplidx)) {
836 $pdf->useTemplate($tplidx);
839 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
841 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
843 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
848 if (!empty($tplidx)) {
849 $pdf->useTemplate($tplidx);
854 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
861 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
862 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage + 1;
864 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
865 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
867 dol_syslog(
"bottomlasttab=".$bottomlasttab.
" this->page_hauteur=".$this->page_hauteur.
" heightforinfotot=".$heightforinfotot.
" heightforfreetext=".$heightforfreetext.
" heightforfooter=".$heightforfooter);
873 $posy = $this->
_tableau_tot($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
876 $listofpayments =
$object->getListOfPayments(
'', 0, 1);
877 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
883 if (method_exists($pdf,
'AliasNbPages')) {
884 $pdf->AliasNbPages();
896 $pdf->Output($file,
'F');
899 $hookmanager->initHooks(array(
'pdfgeneration'));
900 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
902 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
904 $this->error = $hookmanager->error;
905 $this->errors = $hookmanager->errors;
910 $this->result = array(
'fullpath' => $file);
914 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
918 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
945 $current_page = $pdf->getPage();
947 $tab3_top = $posy + 8;
950 if ($this->page_largeur < 210) {
960 $pdf->SetFont(
'',
'', $default_font_size - 4);
964 $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,";
965 $sql .=
" re.description, re.fk_facture_source,";
966 $sql .=
" f.type, f.datef";
967 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
968 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
969 $resql = $this->db->query($sql);
971 $num = $this->db->num_rows($resql);
973 $invoice =
new Facture($this->db);
976 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
979 $pdf->AddPage(
'',
'',
true);
985 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
987 $pdf->setPage($current_page);
991 $obj = $this->db->fetch_object($resql);
993 if ($obj->type == 2) {
994 $text = $outputlangs->transnoentities(
"CreditNote");
995 } elseif ($obj->type == 3) {
996 $text = $outputlangs->transnoentities(
"Deposit");
997 } elseif ($obj->type == 0) {
998 $text = $outputlangs->transnoentities(
"ExcessReceived");
1000 $text = $outputlangs->transnoentities(
"UnknownType");
1003 $invoice->fetch($obj->fk_facture_source);
1005 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1006 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1007 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1008 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1009 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1010 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1011 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1012 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1014 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1019 $this->error = $this->db->lasterror();
1025 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1027 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1028 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1029 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1031 $sql .=
" ORDER BY p.datep";
1033 $resql = $this->db->query($sql);
1035 $num = $this->db->num_rows($resql);
1040 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1043 $pdf->AddPage(
'',
'',
true);
1049 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1051 $pdf->setPage($current_page);
1055 $row = $this->db->fetch_object($resql);
1057 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1058 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1059 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1060 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1061 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1062 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1064 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1065 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1066 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1067 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1068 $y = $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1069 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1074 return $tab3_top + $y + 3;
1076 $this->error = $this->db->lasterror();
1138 global $conf, $mysoc, $hookmanager;
1142 $pdf->SetFont(
'',
'', $default_font_size - 1);
1145 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1146 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1147 $pdf->SetXY($this->marge_gauche, $posy);
1148 if ($mysoc->forme_juridique_code == 92) {
1149 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1151 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1154 $posy = $pdf->GetY() + 4;
1159 if ($this->page_largeur < 210) {
1165 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1166 $pdf->SetXY($this->marge_gauche, $posy);
1167 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1168 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1170 $pdf->SetFont(
'',
'', $default_font_size - 2);
1171 $pdf->SetXY($posxval, $posy);
1172 $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);
1173 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1174 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1176 $posy = $pdf->GetY() + 3;
1180 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1181 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1182 $pdf->SetXY($this->marge_gauche, $posy);
1183 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1184 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1186 $pdf->SetFont(
'',
'', $default_font_size - 2);
1187 $pdf->SetXY($posxval, $posy);
1188 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1189 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1191 $posy = $pdf->GetY() + 3;
1196 if (empty(
$object->mode_reglement_code)
1199 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1203 $outputlangs->load(
"errors");
1205 $pdf->SetXY($this->marge_gauche, $posy);
1206 $pdf->SetTextColor(200, 0, 0);
1207 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1208 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1209 $pdf->MultiCell(80, 3, $this->error, 0,
'L', 0);
1210 $pdf->SetTextColor(0, 0, 0);
1212 $posy = $pdf->GetY() + 1;
1216 if (!empty(
$object->mode_reglement_code)
1217 &&
$object->mode_reglement_code !=
'CHQ'
1218 &&
$object->mode_reglement_code !=
'VIR') {
1219 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1220 $pdf->SetXY($this->marge_gauche, $posy);
1221 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1222 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1224 $pdf->SetFont(
'',
'', $default_font_size - 2);
1225 $pdf->SetXY($posxval, $posy);
1226 $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);
1228 if (
$object->mode_reglement_code ==
"PRE") {
1229 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1232 $bac->fetch(0,
'',
$object->thirdparty->id);
1233 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1234 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1236 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1238 $posy = $pdf->GetY();
1244 if ($this->emetteur->country_code ==
'FR') {
1246 $pdf->SetXY($this->marge_gauche, $posy);
1247 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1249 $posy = $pdf->GetY() + 1;
1254 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1255 $useonlinepayment = 0;
1259 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1260 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1261 $useonlinepayment = count($validpaymentmethod);
1265 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1268 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1269 $servicename = $langs->transnoentities(
'Online');
1270 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1271 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1273 $pdf->SetXY($this->marge_gauche, $posy);
1276 $posy = $pdf->GetY() + 1;
1281 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1284 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1287 $account =
new Account($this->db);
1290 $pdf->SetXY($this->marge_gauche, $posy);
1291 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1292 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1293 $posy = $pdf->GetY() + 1;
1296 $pdf->SetXY($this->marge_gauche, $posy);
1297 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1298 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1299 $posy = $pdf->GetY() + 2;
1302 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1303 $pdf->SetXY($this->marge_gauche, $posy);
1304 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1305 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1306 $posy = $pdf->GetY() + 1;
1309 $pdf->SetXY($this->marge_gauche, $posy);
1310 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1311 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1312 $posy = $pdf->GetY() + 2;
1319 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1321 $bankid = (
$object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1325 $account =
new Account($this->db);
1326 $account->fetch($bankid);
1328 $curx = $this->marge_gauche;
1331 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1336 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1339 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L', 0);
1365 global $conf, $mysoc, $hookmanager;
1374 $outputlangsbis =
null;
1376 $outputlangsbis =
new Translate(
'', $conf);
1378 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1379 $default_font_size--;
1384 $pdf->SetFont(
'',
'', $default_font_size - 1);
1389 if ($this->page_largeur < 210) {
1393 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1399 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1402 $total_line_remise = 0;
1403 foreach (
$object->lines as $i => $line) {
1405 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1407 if ($line->total_ht < 0) {
1408 $total_line_remise += -$line->total_ht;
1411 if ($total_line_remise > 0) {
1412 $pdf->SetFillColor(255, 255, 255);
1413 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1414 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1415 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1416 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1421 $pdf->SetFillColor(255, 255, 255);
1422 $pdf->SetXY($col1x, $tab2_top);
1423 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1424 $pdf->SetXY($col2x, $tab2_top);
1425 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1431 $pdf->SetFillColor(255, 255, 255);
1432 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1433 $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);
1435 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1436 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1437 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1440 $pdf->SetFillColor(248, 248, 248);
1442 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1444 $this->atleastoneratenotnull = 0;
1446 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1447 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1451 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1452 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1456 foreach ($localtax_rate as $tvakey => $tvaval) {
1461 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1464 if (preg_match(
'/\*/', (
string) $tvakey)) {
1465 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1466 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1469 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1473 $totalvat .= $tvacompl;
1475 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1478 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1480 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1482 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1483 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1489 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1490 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1494 foreach ($localtax_rate as $tvakey => $tvaval) {
1499 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1502 if (preg_match(
'/\*/', (
string) $tvakey)) {
1503 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1504 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1506 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1510 $totalvat .= $tvacompl;
1512 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1515 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1517 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1519 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1520 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1526 foreach ($this->tva_array as $tvakey => $tvaval) {
1528 $this->atleastoneratenotnull++;
1531 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1534 if (preg_match(
'/\*/', $tvakey)) {
1535 $tvakey = str_replace(
'*',
'', $tvakey);
1536 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1538 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1541 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1543 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1545 $totalvat .= $tvacompl;
1547 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1549 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1551 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1552 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1557 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1558 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1562 foreach ($localtax_rate as $tvakey => $tvaval) {
1567 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1570 if (preg_match(
'/\*/', (
string) $tvakey)) {
1571 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1572 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1574 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1577 $totalvat .= $tvacompl;
1579 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1582 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1584 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1586 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1587 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1593 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1594 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1598 foreach ($localtax_rate as $tvakey => $tvaval) {
1602 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1605 if (preg_match(
'/\*/', (
string) $tvakey)) {
1606 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1607 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1609 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1612 $totalvat .= $tvacompl;
1614 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1617 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1619 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1621 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1622 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1629 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1630 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp"), $useborder,
'L', 1);
1632 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1633 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1638 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1639 $pdf->SetTextColor(0, 0, 60);
1640 $pdf->SetFillColor(224, 224, 224);
1641 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1643 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1644 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1647 if (
$object->displayRetainedWarranty()) {
1648 $pdf->SetTextColor(40, 40, 40);
1649 $pdf->SetFillColor(255, 255, 255);
1651 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1652 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1656 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1657 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1659 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1660 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1664 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1666 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").
' ('.
$object->retained_warranty.
'%)';
1667 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1669 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1670 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1671 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1676 $pdf->SetTextColor(0, 0, 0);
1677 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1678 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1680 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1685 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1688 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1689 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L', 0);
1690 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1691 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1694 if ($creditnoteamount) {
1695 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1697 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1698 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1699 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1700 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1704 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1706 $pdf->SetFillColor(255, 255, 255);
1708 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1709 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L', 1);
1710 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1711 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R', 1);
1717 $pdf->SetTextColor(0, 0, 60);
1718 $pdf->SetFillColor(224, 224, 224);
1719 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1720 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1721 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1722 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1724 $pdf->SetFont(
'',
'', $default_font_size - 1);
1725 $pdf->SetTextColor(0, 0, 0);
1733 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1734 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $conf->global->BILL_TEXT_TOTAL_FOOTER, 0,
'L', 0);
1737 return ($tab2_top + ($tab2_hl * $index));
1754 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1764 $currency = !empty($currency) ? $currency : $conf->currency;
1768 $pdf->SetTextColor(0, 0, 0);
1769 $pdf->SetFont(
'',
'', $default_font_size - 2);
1771 if (empty($hidetop)) {
1773 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
1774 $categoryOfOperations = $outputlangs->transnoentities(
"MentionCategoryOfOperations") .
' : ' . $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1775 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
1776 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
1779 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1780 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1781 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1785 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1789 $pdf->SetDrawColor(128, 128, 128);
1790 $pdf->SetFont(
'',
'', $default_font_size - 1);
1793 $this->
printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom,
'D');
1795 if (empty($hidetop)) {
1796 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1798 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1799 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1803 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1804 if (empty($hidetop)) {
1811 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1812 if (empty($hidetop)) {
1813 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1814 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1818 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1819 if (empty($hidetop)) {
1820 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1821 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1824 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1825 if (empty($hidetop)) {
1826 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1827 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1831 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1832 if (empty($hidetop)) {
1833 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1834 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1838 if ($this->atleastonediscount) {
1839 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1840 if (empty($hidetop)) {
1841 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1842 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1846 if ($this->situationinvoice) {
1847 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1848 if (empty($hidetop)) {
1849 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1850 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities(
"ProgressShort"),
'',
'C');
1854 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1855 if (empty($hidetop)) {
1856 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1857 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1872 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1875 global $conf, $langs;
1877 $ltrdirection =
'L';
1878 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1879 $ltrdirection =
'R';
1883 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
1889 $pdf->SetTextColor(0, 0, 60);
1890 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1894 $posy = $this->marge_haute;
1895 $posx = $this->page_largeur - $this->marge_droite - $w;
1897 $pdf->SetXY($this->marge_gauche, $posy);
1901 if ($this->emetteur->logo) {
1902 $logodir = $conf->mycompany->dir_output;
1903 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1904 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1907 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1909 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1911 if (is_readable($logo)) {
1913 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1915 $pdf->SetTextColor(200, 0, 0);
1916 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1917 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1918 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1921 $text = $this->emetteur->name;
1922 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1926 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1927 $pdf->SetXY($posx, $posy);
1928 $pdf->SetTextColor(0, 0, 60);
1929 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
1931 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
1934 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
1937 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
1940 $title = $outputlangs->transnoentities(
"InvoiceProForma");
1942 if ($this->situationinvoice) {
1943 $langs->loadLangs(array(
"other"));
1944 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
1946 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1949 if ($this->situationinvoice) {
1950 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
1952 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
1953 } elseif (
$object->type == 1) {
1954 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
1955 } elseif (
$object->type == 2) {
1956 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
1957 } elseif (
$object->type == 3) {
1958 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
1959 } elseif (
$object->type == 4) {
1960 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
1963 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1964 if (
$object->status == $object::STATUS_DRAFT) {
1965 $pdf->SetTextColor(128, 0, 0);
1966 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1969 $pdf->MultiCell($w, 3, $title,
'',
'R');
1971 $pdf->SetFont(
'',
'B', $default_font_size);
1985 $pdf->SetFont(
'',
'', $default_font_size - 2);
1989 $pdf->SetXY($posx, $posy);
1990 $pdf->SetTextColor(0, 0, 60);
1991 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_customer),
'',
'R');
1996 if (!empty(
$object->project->ref)) {
1998 $pdf->SetXY($posx, $posy);
1999 $pdf->SetTextColor(0, 0, 60);
2000 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2006 if (!empty(
$object->project->ref)) {
2007 $outputlangs->load(
"projects");
2009 $pdf->SetXY($posx, $posy);
2010 $pdf->SetTextColor(0, 0, 60);
2011 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2015 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2016 if (
$object->type == 0 && $objectidnext) {
2017 $objectreplacing =
new Facture($this->db);
2018 $objectreplacing->fetch($objectidnext);
2021 $pdf->SetXY($posx, $posy);
2022 $pdf->SetTextColor(0, 0, 60);
2023 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2026 $objectreplaced =
new Facture($this->db);
2027 $objectreplaced->fetch(
$object->fk_facture_source);
2030 $pdf->SetXY($posx, $posy);
2031 $pdf->SetTextColor(0, 0, 60);
2032 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2035 $objectreplaced =
new Facture($this->db);
2036 $objectreplaced->fetch(
$object->fk_facture_source);
2039 $pdf->SetXY($posx, $posy);
2040 $pdf->SetTextColor(0, 0, 60);
2041 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2045 $pdf->SetXY($posx, $posy);
2046 $pdf->SetTextColor(0, 0, 60);
2047 $title = $outputlangs->transnoentities(
"DateInvoice");
2048 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2049 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2051 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2055 $pdf->SetXY($posx, $posy);
2056 $pdf->SetTextColor(0, 0, 60);
2057 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2062 $pdf->SetXY($posx, $posy);
2063 $pdf->SetTextColor(0, 0, 60);
2064 $title = $outputlangs->transnoentities(
"DateDue");
2065 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2066 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2068 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2073 $pdf->SetXY($posx, $posy);
2074 $pdf->SetTextColor(0, 0, 60);
2075 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2080 $pdf->SetXY($posx, $posy);
2081 $pdf->SetTextColor(0, 0, 60);
2082 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
2087 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2088 if (count($arrayidcontact) > 0) {
2089 $usertmp =
new User($this->db);
2090 $usertmp->fetch($arrayidcontact[0]);
2092 $pdf->SetXY($posx, $posy);
2093 $pdf->SetTextColor(0, 0, 60);
2094 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2102 $current_y = $pdf->getY();
2104 if ($current_y < $pdf->getY()) {
2105 $top_shift = $pdf->getY() - $current_y;
2110 $carac_emetteur =
'';
2112 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2113 if (count($arrayidcontact) > 0) {
2114 $object->fetch_user($arrayidcontact[0]);
2115 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2116 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2117 $carac_emetteur .=
"\n";
2124 $posy += $top_shift;
2125 $posx = $this->marge_gauche;
2127 $posx = $this->page_largeur - $this->marge_droite - 80;
2136 $pdf->SetTextColor(0, 0, 0);
2137 $pdf->SetFont(
'',
'', $default_font_size - 2);
2138 $pdf->SetXY($posx, $posy - 5);
2139 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2140 $pdf->SetXY($posx, $posy);
2141 $pdf->SetFillColor(230, 230, 230);
2142 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2143 $pdf->SetTextColor(0, 0, 60);
2148 $pdf->SetXY($posx + 2, $posy + 3);
2149 $pdf->SetFont(
'',
'B', $default_font_size);
2150 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2151 $posy = $pdf->getY();
2155 $pdf->SetXY($posx + 2, $posy);
2156 $pdf->SetFont(
'',
'', $default_font_size - 1);
2157 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2161 $usecontact =
false;
2162 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2163 if (count($arrayidcontact) > 0) {
2165 $result =
$object->fetch_contact($arrayidcontact[0]);
2169 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2170 $thirdparty =
$object->contact;
2172 $thirdparty =
$object->thirdparty;
2182 if ($this->page_largeur < 210) {
2186 $posy += $top_shift;
2187 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2189 $posx = $this->marge_gauche;
2194 $pdf->SetTextColor(0, 0, 0);
2195 $pdf->SetFont(
'',
'', $default_font_size - 2);
2196 $pdf->SetXY($posx + 2, $posy - 5);
2197 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2198 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2202 $pdf->SetXY($posx + 2, $posy + 3);
2203 $pdf->SetFont(
'',
'B', $default_font_size);
2205 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2207 $posy = $pdf->getY();
2210 $pdf->SetFont(
'',
'', $default_font_size - 1);
2211 $pdf->SetXY($posx + 2, $posy);
2213 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2217 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2219 if (!empty($idaddressshipping)) {
2220 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2221 $companystatic =
new Societe($this->db);
2222 $companystatic->fetch(
$object->contact->fk_soc);
2224 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
2229 if (!empty($carac_client_shipping)) {
2230 $posy += $hautcadre;
2235 $pdf->SetXY($posx + 2, $posy - 5);
2236 $pdf->SetFont(
'',
'', $default_font_size - 2);
2237 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2238 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2241 $pdf->SetXY($posx + 2, $posy + 3);
2242 $pdf->SetFont(
'',
'B', $default_font_size);
2243 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2245 $posy = $pdf->getY();
2248 $pdf->SetXY($posx + 2, $posy);
2249 $pdf->SetFont(
'',
'', $default_font_size - 1);
2250 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2252 $top_shift += $hautcadre + 10;
2257 $pdf->SetTextColor(0, 0, 0);