195 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
198 global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
200 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
202 if (!is_object($outputlangs)) {
203 $outputlangs = $langs;
207 $outputlangs->charset_output =
'ISO-8859-1';
211 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
218 global $outputlangsbis;
219 $outputlangsbis =
null;
221 $outputlangsbis =
new Translate(
'', $conf);
223 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
226 $nblines = count(
$object->lines);
229 $realpatharray = array();
231 for ($i = 0; $i < $nblines; $i++) {
232 if (empty(
$object->lines[$i]->fk_product)) {
236 $objphoto =
new Product($this->db);
237 $objphoto->fetch(
$object->lines[$i]->fk_product);
239 $pdir =
get_exdir(
$object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
240 $dir = $conf->product->dir_output.
'/'.$pdir;
243 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
244 $filename = $obj[
'photo'];
246 $realpath = $dir.$filename;
251 $realpatharray[$i] = $realpath;
255 if (count($realpatharray) == 0) {
256 $this->posxpicture = $this->posxtva;
259 if ($conf->facture->dir_output) {
262 $deja_regle =
$object->getSommePaiement((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
263 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
264 $amount_deposits_included =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
268 $dir = empty($conf->facture->multidir_output[
$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[
$object->entity];
269 $file = $dir.
"/SPECIMEN.pdf";
272 $dir = (empty($conf->facture->multidir_output[
$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[
$object->entity]).
"/".$objectref;
273 $file = $dir.
"/".$objectref.
".pdf";
275 if (!file_exists($dir)) {
277 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
282 if (file_exists($dir)) {
284 if (!is_object($hookmanager)) {
285 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
288 $hookmanager->initHooks(array(
'pdfgeneration'));
289 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
291 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
294 $nblines = count(
$object->lines);
295 $nbpayments = count(
$object->getListOfPayments());
300 $pdf->SetAutoPageBreak(1, 0);
302 $heightforinfotot = 50 + (4 * $nbpayments);
303 if ($heightforinfotot > 220) {
304 $heightforinfotot = 220;
306 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
307 $heightforfooter = $this->marge_basse + 8;
309 $heightforfooter += 6;
312 $heightforqrinvoice_firstpage = 0;
315 if ($heightforqrinvoice_firstpage > 0) {
317 $heightforinfotot = 30 + (4 * $nbpayments);
321 if (class_exists(
'TCPDF')) {
322 $pdf->setPrintHeader(
false);
323 $pdf->setPrintFooter(
false);
329 $logodir = $conf->mycompany->dir_output;
330 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
331 $logodir = $conf->mycompany->multidir_output[
$object->entity];
333 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
334 $tplidx = $pdf->importPage(1);
339 $pdf->SetDrawColor(128, 128, 128);
341 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
342 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
343 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
344 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
345 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
347 $pdf->SetCompression(
false);
351 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
352 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
358 $certprivate = !
getDolGlobalString(
'CERTIFICATE_CRT_PRIVATE') ?
'' : $conf->global->CERTIFICATE_CRT_PRIVATE;
363 'Name' => $this->emetteur->name,
364 'Location' =>
getCountry($this->emetteur->country_code, 0),
365 'Reason' =>
'INVOICE',
366 'ContactInfo' => $this->emetteur->email
368 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
372 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
376 $categoryOfOperation = 0;
379 for ($i = 0; $i < $nblines; $i++) {
380 if (
$object->lines[$i]->remise_percent) {
381 $this->atleastonediscount++;
386 if (preg_match(
'/^\((.*)\)$/',
$object->lines[$i]->desc, $reg)) {
387 if ($reg[1] ==
'DEPOSIT') {
398 if ($categoryOfOperation < 2) {
399 $lineProductType =
$object->lines[$i]->product_type;
405 if ($nbProduct > 0 && $nbService > 0) {
407 $categoryOfOperation = 2;
412 if ($categoryOfOperation <= 0) {
414 if ($nbProduct == 0 && $nbService > 0) {
415 $categoryOfOperation = 1;
418 $this->categoryOfOperation = $categoryOfOperation;
419 if (empty($this->atleastonediscount)) {
420 $delta = ($this->posxprogress - $this->posxdiscount);
421 $this->posxpicture += $delta;
422 $this->posxtva += $delta;
423 $this->posxup += $delta;
424 $this->posxqty += $delta;
425 $this->posxunit += $delta;
426 $this->posxdiscount += $delta;
433 $this->situationinvoice =
true;
434 $progress_width = 10;
435 $this->posxpicture -= $progress_width;
436 $this->posxtva -= $progress_width;
437 $this->posxup -= $progress_width;
438 $this->posxqty -= $progress_width;
439 $this->posxunit -= $progress_width;
440 $this->posxdiscount -= $progress_width;
441 $this->posxprogress -= $progress_width;
446 if (!empty($tplidx)) {
447 $pdf->useTemplate($tplidx);
453 $pdf->SetFont(
'',
'', $default_font_size - 1);
454 $pdf->MultiCell(0, 3,
'');
455 $pdf->SetTextColor(0, 0, 0);
460 $tab_top = 90 + $top_shift;
461 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
464 $extra_under_address_shift = 0;
467 $qrcodestring =
$object->buildZATCAQRString();
470 $qrcodestring =
$object->buildSwitzerlandQRString();
474 $qrcodestring =
$object->buildEPCQrCodeString();
479 $qrcodecolor = array(
'25',
'25',
'25');
484 'fgcolor' => $qrcodecolor,
489 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr,
'N');
493 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
494 $pdf->SetFont(
'',
'', $default_font_size - 4);
495 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
499 $extra_under_address_shift += 25;
507 'outputlangs' => $outputlangs,
508 'hidedetails' => $hidedetails
510 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
511 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
512 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
515 $tab_top += $extra_under_address_shift;
516 $tab_top_newpage += 0;
519 $height_incoterms = 0;
520 if (isModEnabled(
'incoterm')) {
521 $desc_incoterms =
$object->getIncotermsForPDF();
522 if ($desc_incoterms) {
525 $pdf->SetFont(
'',
'', $default_font_size - 1);
526 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
527 $nexY = $pdf->GetY();
528 $height_incoterms = $nexY - $tab_top;
531 $pdf->SetDrawColor(192, 192, 192);
532 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
534 $tab_top = $nexY + 6;
539 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
542 if (is_object(
$object->thirdparty)) {
543 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
544 $salerepobj =
new User($this->db);
545 $salerepobj->fetch($salereparray[0][
'id']);
546 if (!empty($salerepobj->signature)) {
547 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
552 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
553 if (!empty($extranote)) {
565 $pdf->SetFont(
'',
'', $default_font_size - 1);
566 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
567 $nexY = $pdf->GetY();
568 $height_note = $nexY - $tab_top;
571 $pdf->SetDrawColor(192, 192, 192);
572 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
574 $tab_top = $nexY + 6;
577 $iniY = $tab_top + 7;
578 $curY = $tab_top + 7;
579 $nexY = $tab_top + 7;
582 for ($i = 0; $i < $nblines; $i++) {
584 $pdf->SetFont(
'',
'', $default_font_size - 1);
585 $pdf->SetTextColor(0, 0, 0);
588 $imglinesize = array();
589 if (!empty($realpatharray[$i])) {
593 $pdf->setTopMargin($tab_top_newpage);
594 $page_bottom_margin = $heightforfooter + $heightforfreetext + $heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(),
$object, $langs);
595 $pdf->setPageOrientation(
'', 1, $page_bottom_margin);
596 $pageposbefore = $pdf->getPage();
598 $showpricebeforepagebreak = 1;
600 $posYAfterDescription = 0;
603 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
604 $pdf->AddPage(
'',
'',
true);
605 if (!empty($tplidx)) {
606 $pdf->useTemplate($tplidx);
610 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
612 $pdf->setPage($pageposbefore + 1);
614 $curY = $tab_top_newpage;
618 $showpricebeforepagebreak = 1;
620 $showpricebeforepagebreak = 0;
624 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
625 $curX = $this->posxpicture - 1;
626 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
628 $posYAfterImage = $curY + $imglinesize[
'height'];
632 $curX = $this->posxdesc - 1;
634 $pdf->startTransaction();
635 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
636 $pageposafter = $pdf->getPage();
637 if ($pageposafter > $pageposbefore) {
638 $pdf->rollbackTransaction(
true);
639 $pageposafter = $pageposbefore;
641 $pdf->setPageOrientation(
'', 1, $heightforfooter);
642 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
643 $pageposafter = $pdf->getPage();
644 $posyafter = $pdf->GetY();
646 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
647 if ($i == ($nblines - 1)) {
648 $pdf->AddPage(
'',
'',
true);
649 if (!empty($tplidx)) {
650 $pdf->useTemplate($tplidx);
654 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
656 $pdf->setPage($pageposafter + 1);
663 $showpricebeforepagebreak = 1;
665 $showpricebeforepagebreak = 0;
669 $pdf->commitTransaction();
671 $posYAfterDescription = $pdf->GetY();
673 $nexY = $pdf->GetY();
674 $pageposafter = $pdf->getPage();
675 $pdf->setPage($pageposbefore);
676 $pdf->setTopMargin($this->marge_haute);
677 $pdf->setPageOrientation(
'', 1, 0);
680 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
681 $pdf->setPage($pageposafter);
682 $curY = $tab_top_newpage;
685 $pdf->SetFont(
'',
'', $default_font_size - 1);
690 $pdf->SetXY($this->posxtva - 5, $curY);
691 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
696 $pdf->SetXY($this->posxup, $curY);
697 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
701 $pdf->SetXY($this->posxqty, $curY);
702 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
707 $pdf->SetXY($this->posxunit, $curY);
708 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
712 if (
$object->lines[$i]->remise_percent) {
713 $pdf->SetXY($this->posxdiscount - 2, $curY);
715 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
719 if ($this->situationinvoice) {
721 $pdf->SetXY($this->posxprogress, $curY);
722 $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0,
'R');
727 $pdf->SetXY($this->postotalht, $curY);
728 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
736 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
737 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
738 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
739 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
741 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
744 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
745 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
747 $tvaligne = $sign *
$object->lines[$i]->total_tva;
751 $localtax1ligne =
$object->lines[$i]->total_localtax1;
752 $localtax2ligne =
$object->lines[$i]->total_localtax2;
753 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
754 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
755 $localtax1_type =
$object->lines[$i]->localtax1_type;
756 $localtax2_type =
$object->lines[$i]->localtax2_type;
769 $vatrate = (string)
$object->lines[$i]->tva_tx;
772 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
773 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
775 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
776 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
780 if ($localtax1_type && $localtax1ligne != 0) {
781 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
782 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
784 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
787 if ($localtax2_type && $localtax2ligne != 0) {
788 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
789 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
791 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
795 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
800 if (!isset($this->tva[$vatrate])) {
801 $this->tva[$vatrate] = 0;
803 $this->tva[$vatrate] += $tvaligne;
804 $vatcode =
$object->lines[$i]->vat_src_code;
805 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
806 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
808 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
810 if ($posYAfterImage > $posYAfterDescription) {
811 $nexY = $posYAfterImage;
816 $pdf->setPage($pageposafter);
817 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
819 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
820 $pdf->SetLineStyle(array(
'dash' => 0));
826 while ($pagenb < $pageposafter) {
827 $pdf->setPage($pagenb);
829 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
831 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
835 $pdf->setPage($pagenb);
836 $pdf->setPageOrientation(
'', 1, 0);
839 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
841 if (!empty($tplidx)) {
842 $pdf->useTemplate($tplidx);
845 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
847 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
849 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
854 if (!empty($tplidx)) {
855 $pdf->useTemplate($tplidx);
860 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
867 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
868 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage + 1;
870 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
871 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
873 dol_syslog(
"bottomlasttab=".$bottomlasttab.
" this->page_hauteur=".$this->page_hauteur.
" heightforinfotot=".$heightforinfotot.
" heightforfreetext=".$heightforfreetext.
" heightforfooter=".$heightforfooter);
879 $posy = $this->
_tableau_tot($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
882 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
888 if (method_exists($pdf,
'AliasNbPages')) {
889 $pdf->AliasNbPages();
901 $pdf->Output($file,
'F');
904 $hookmanager->initHooks(array(
'pdfgeneration'));
905 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
907 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
909 $this->error = $hookmanager->error;
910 $this->errors = $hookmanager->errors;
915 $this->result = array(
'fullpath' => $file);
919 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
923 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
950 $current_page = $pdf->getPage();
952 $tab3_top = $posy + 8;
955 if ($this->page_largeur < 210) {
965 $pdf->SetFont(
'',
'', $default_font_size - 4);
969 $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,";
970 $sql .=
" re.description, re.fk_facture_source,";
971 $sql .=
" f.type, f.datef";
972 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
973 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
974 $resql = $this->db->query($sql);
976 $num = $this->db->num_rows($resql);
978 $invoice =
new Facture($this->db);
981 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
984 $pdf->AddPage(
'',
'',
true);
990 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
992 $pdf->setPage($current_page);
996 $obj = $this->db->fetch_object($resql);
998 if ($obj->type == 2) {
999 $text = $outputlangs->transnoentities(
"CreditNote");
1000 } elseif ($obj->type == 3) {
1001 $text = $outputlangs->transnoentities(
"Deposit");
1002 } elseif ($obj->type == 0) {
1003 $text = $outputlangs->transnoentities(
"ExcessReceived");
1005 $text = $outputlangs->transnoentities(
"UnknownType");
1008 $invoice->fetch($obj->fk_facture_source);
1010 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1011 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1012 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1013 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1014 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1015 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1016 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1017 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1019 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1024 $this->error = $this->db->lasterror();
1030 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1032 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1033 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1034 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1036 $sql .=
" ORDER BY p.datep";
1038 $resql = $this->db->query($sql);
1040 $num = $this->db->num_rows($resql);
1045 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1048 $pdf->AddPage(
'',
'',
true);
1054 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1056 $pdf->setPage($current_page);
1060 $row = $this->db->fetch_object($resql);
1062 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1063 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1064 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1065 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1066 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1067 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1069 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1070 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1071 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1072 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1073 $y = $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1074 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1079 return $tab3_top + $y + 3;
1081 $this->error = $this->db->lasterror();
1143 global $conf, $mysoc, $hookmanager;
1147 $pdf->SetFont(
'',
'', $default_font_size - 1);
1150 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1151 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1152 $pdf->SetXY($this->marge_gauche, $posy);
1153 if ($mysoc->forme_juridique_code == 92) {
1154 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1156 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1159 $posy = $pdf->GetY() + 4;
1164 if ($this->page_largeur < 210) {
1170 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1171 $pdf->SetXY($this->marge_gauche, $posy);
1172 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1173 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1175 $pdf->SetFont(
'',
'', $default_font_size - 2);
1176 $pdf->SetXY($posxval, $posy);
1177 $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);
1178 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1179 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1181 $posy = $pdf->GetY() + 3;
1185 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1186 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1187 $pdf->SetXY($this->marge_gauche, $posy);
1188 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1189 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1191 $pdf->SetFont(
'',
'', $default_font_size - 2);
1192 $pdf->SetXY($posxval, $posy);
1193 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1194 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1196 $posy = $pdf->GetY() + 3;
1201 if (empty(
$object->mode_reglement_code)
1204 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1208 $outputlangs->load(
"errors");
1210 $pdf->SetXY($this->marge_gauche, $posy);
1211 $pdf->SetTextColor(200, 0, 0);
1212 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1213 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1214 $pdf->MultiCell(80, 3, $this->error, 0,
'L', 0);
1215 $pdf->SetTextColor(0, 0, 0);
1217 $posy = $pdf->GetY() + 1;
1221 if (!empty(
$object->mode_reglement_code)
1222 &&
$object->mode_reglement_code !=
'CHQ'
1223 &&
$object->mode_reglement_code !=
'VIR') {
1224 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1225 $pdf->SetXY($this->marge_gauche, $posy);
1226 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1227 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1229 $pdf->SetFont(
'',
'', $default_font_size - 2);
1230 $pdf->SetXY($posxval, $posy);
1231 $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);
1233 if (
$object->mode_reglement_code ==
"PRE") {
1234 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1237 $bac->fetch(0,
'',
$object->thirdparty->id);
1238 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1239 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1241 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1243 $posy = $pdf->GetY();
1249 if ($this->emetteur->country_code ==
'FR') {
1251 $pdf->SetXY($this->marge_gauche, $posy);
1252 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1254 $posy = $pdf->GetY() + 1;
1259 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1260 $useonlinepayment = 0;
1264 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1265 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1266 $useonlinepayment = count($validpaymentmethod);
1270 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1273 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1274 $servicename = $langs->transnoentities(
'Online');
1275 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref,
'',
'',
'');
1276 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1278 $pdf->SetXY($this->marge_gauche, $posy);
1281 $posy = $pdf->GetY() + 1;
1286 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1289 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1292 $account =
new Account($this->db);
1295 $pdf->SetXY($this->marge_gauche, $posy);
1296 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1297 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1298 $posy = $pdf->GetY() + 1;
1301 $pdf->SetXY($this->marge_gauche, $posy);
1302 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1303 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1304 $posy = $pdf->GetY() + 2;
1307 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1308 $pdf->SetXY($this->marge_gauche, $posy);
1309 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1310 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1311 $posy = $pdf->GetY() + 1;
1314 $pdf->SetXY($this->marge_gauche, $posy);
1315 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1316 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1317 $posy = $pdf->GetY() + 2;
1324 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1326 $bankid = (
$object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1330 $account =
new Account($this->db);
1331 $account->fetch($bankid);
1333 $curx = $this->marge_gauche;
1336 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1363 global $conf, $mysoc, $hookmanager;
1372 $outputlangsbis =
null;
1374 $outputlangsbis =
new Translate(
'', $conf);
1376 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1377 $default_font_size--;
1382 $pdf->SetFont(
'',
'', $default_font_size - 1);
1387 if ($this->page_largeur < 210) {
1391 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1397 $pdf->SetFillColor(255, 255, 255);
1398 $pdf->SetXY($col1x, $tab2_top);
1399 $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);
1401 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1402 $pdf->SetXY($col2x, $tab2_top);
1403 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1406 $pdf->SetFillColor(248, 248, 248);
1408 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1410 $this->atleastoneratenotnull = 0;
1412 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1413 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1417 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1418 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1422 foreach ($localtax_rate as $tvakey => $tvaval) {
1427 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1430 if (preg_match(
'/\*/', (
string) $tvakey)) {
1431 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1432 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1435 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1439 $totalvat .= $tvacompl;
1441 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1444 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1446 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1448 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1449 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1455 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1456 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1460 foreach ($localtax_rate as $tvakey => $tvaval) {
1465 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1468 if (preg_match(
'/\*/', (
string) $tvakey)) {
1469 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1470 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1472 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1476 $totalvat .= $tvacompl;
1478 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1481 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1483 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1485 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1486 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1492 foreach ($this->tva_array as $tvakey => $tvaval) {
1494 $this->atleastoneratenotnull++;
1497 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1500 if (preg_match(
'/\*/', $tvakey)) {
1501 $tvakey = str_replace(
'*',
'', $tvakey);
1502 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1504 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1507 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1509 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1511 $totalvat .= $tvacompl;
1513 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1515 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1517 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1518 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1523 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1524 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1528 foreach ($localtax_rate as $tvakey => $tvaval) {
1533 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1536 if (preg_match(
'/\*/', (
string) $tvakey)) {
1537 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1538 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1540 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1543 $totalvat .= $tvacompl;
1545 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1548 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1550 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1552 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1553 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1559 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1560 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1564 foreach ($localtax_rate as $tvakey => $tvaval) {
1568 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1571 if (preg_match(
'/\*/', (
string) $tvakey)) {
1572 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1573 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1575 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1578 $totalvat .= $tvacompl;
1580 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1583 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1585 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1587 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1588 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1595 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1596 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp"), $useborder,
'L', 1);
1598 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1599 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1604 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1605 $pdf->SetTextColor(0, 0, 60);
1606 $pdf->SetFillColor(224, 224, 224);
1607 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1609 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1610 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1613 if (
$object->displayRetainedWarranty()) {
1614 $pdf->SetTextColor(40, 40, 40);
1615 $pdf->SetFillColor(255, 255, 255);
1617 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1618 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1622 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1623 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1625 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1626 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1630 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1632 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").
' ('.
$object->retained_warranty.
'%)';
1633 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1635 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1636 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1637 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1642 $pdf->SetTextColor(0, 0, 0);
1643 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1644 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1646 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1651 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1654 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1655 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L', 0);
1656 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1657 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1660 if ($creditnoteamount) {
1661 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1663 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1664 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1665 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1666 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1670 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1672 $pdf->SetFillColor(255, 255, 255);
1674 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1675 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L', 1);
1676 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1677 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R', 1);
1683 $pdf->SetTextColor(0, 0, 60);
1684 $pdf->SetFillColor(224, 224, 224);
1685 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1686 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1687 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1688 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1690 $pdf->SetFont(
'',
'', $default_font_size - 1);
1691 $pdf->SetTextColor(0, 0, 0);
1699 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1700 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $conf->global->BILL_TEXT_TOTAL_FOOTER, 0,
'L', 0);
1703 return ($tab2_top + ($tab2_hl * $index));
1720 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1730 $currency = !empty($currency) ? $currency : $conf->currency;
1734 $pdf->SetTextColor(0, 0, 0);
1735 $pdf->SetFont(
'',
'', $default_font_size - 2);
1737 if (empty($hidetop)) {
1739 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
1740 $categoryOfOperations = $outputlangs->transnoentities(
"MentionCategoryOfOperations") .
' : ' . $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1741 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
1742 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
1745 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1746 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1747 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1751 $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')));
1755 $pdf->SetDrawColor(128, 128, 128);
1756 $pdf->SetFont(
'',
'', $default_font_size - 1);
1759 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1761 if (empty($hidetop)) {
1762 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1764 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1765 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1769 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1770 if (empty($hidetop)) {
1777 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1778 if (empty($hidetop)) {
1779 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1780 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1784 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1785 if (empty($hidetop)) {
1786 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1787 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1790 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1791 if (empty($hidetop)) {
1792 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1793 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1797 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1798 if (empty($hidetop)) {
1799 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1800 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1804 if ($this->atleastonediscount) {
1805 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1806 if (empty($hidetop)) {
1807 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1808 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1812 if ($this->situationinvoice) {
1813 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1814 if (empty($hidetop)) {
1815 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1816 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities(
"ProgressShort"),
'',
'C');
1820 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1821 if (empty($hidetop)) {
1822 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1823 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1838 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1841 global $conf, $langs;
1843 $ltrdirection =
'L';
1844 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1845 $ltrdirection =
'R';
1849 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
1855 $pdf->SetTextColor(0, 0, 60);
1856 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1860 $posy = $this->marge_haute;
1861 $posx = $this->page_largeur - $this->marge_droite - $w;
1863 $pdf->SetXY($this->marge_gauche, $posy);
1867 if ($this->emetteur->logo) {
1868 $logodir = $conf->mycompany->dir_output;
1869 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1870 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1873 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1875 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1877 if (is_readable($logo)) {
1879 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1881 $pdf->SetTextColor(200, 0, 0);
1882 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1883 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1884 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1887 $text = $this->emetteur->name;
1888 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1892 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1893 $pdf->SetXY($posx, $posy);
1894 $pdf->SetTextColor(0, 0, 60);
1895 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
1897 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
1900 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
1903 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
1906 $title = $outputlangs->transnoentities(
"InvoiceProForma");
1908 if ($this->situationinvoice) {
1909 $langs->loadLangs(array(
"other"));
1910 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
1912 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1915 if ($this->situationinvoice) {
1916 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
1918 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
1919 } elseif (
$object->type == 1) {
1920 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
1921 } elseif (
$object->type == 2) {
1922 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
1923 } elseif (
$object->type == 3) {
1924 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
1925 } elseif (
$object->type == 4) {
1926 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
1929 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1930 if (
$object->statut == $object::STATUS_DRAFT) {
1931 $pdf->SetTextColor(128, 0, 0);
1932 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1935 $pdf->MultiCell($w, 3, $title,
'',
'R');
1937 $pdf->SetFont(
'',
'B', $default_font_size);
1951 $pdf->SetFont(
'',
'', $default_font_size - 2);
1955 $pdf->SetXY($posx, $posy);
1956 $pdf->SetTextColor(0, 0, 60);
1957 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_customer),
'',
'R');
1962 if (!empty(
$object->project->ref)) {
1964 $pdf->SetXY($posx, $posy);
1965 $pdf->SetTextColor(0, 0, 60);
1966 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1972 if (!empty(
$object->project->ref)) {
1973 $outputlangs->load(
"projects");
1975 $pdf->SetXY($posx, $posy);
1976 $pdf->SetTextColor(0, 0, 60);
1977 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1981 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
1982 if (
$object->type == 0 && $objectidnext) {
1983 $objectreplacing =
new Facture($this->db);
1984 $objectreplacing->fetch($objectidnext);
1987 $pdf->SetXY($posx, $posy);
1988 $pdf->SetTextColor(0, 0, 60);
1989 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
1992 $objectreplaced =
new Facture($this->db);
1993 $objectreplaced->fetch(
$object->fk_facture_source);
1996 $pdf->SetXY($posx, $posy);
1997 $pdf->SetTextColor(0, 0, 60);
1998 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2001 $objectreplaced =
new Facture($this->db);
2002 $objectreplaced->fetch(
$object->fk_facture_source);
2005 $pdf->SetXY($posx, $posy);
2006 $pdf->SetTextColor(0, 0, 60);
2007 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2011 $pdf->SetXY($posx, $posy);
2012 $pdf->SetTextColor(0, 0, 60);
2013 $title = $outputlangs->transnoentities(
"DateInvoice");
2014 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2015 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2017 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2021 $pdf->SetXY($posx, $posy);
2022 $pdf->SetTextColor(0, 0, 60);
2023 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2028 $pdf->SetXY($posx, $posy);
2029 $pdf->SetTextColor(0, 0, 60);
2030 $title = $outputlangs->transnoentities(
"DateDue");
2031 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2032 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2034 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2039 $pdf->SetXY($posx, $posy);
2040 $pdf->SetTextColor(0, 0, 60);
2041 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2046 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2047 if (count($arrayidcontact) > 0) {
2048 $usertmp =
new User($this->db);
2049 $usertmp->fetch($arrayidcontact[0]);
2051 $pdf->SetXY($posx, $posy);
2052 $pdf->SetTextColor(0, 0, 60);
2053 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2061 $current_y = $pdf->getY();
2063 if ($current_y < $pdf->getY()) {
2064 $top_shift = $pdf->getY() - $current_y;
2069 $carac_emetteur =
'';
2071 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2072 if (count($arrayidcontact) > 0) {
2073 $object->fetch_user($arrayidcontact[0]);
2074 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2075 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2076 $carac_emetteur .=
"\n";
2083 $posy += $top_shift;
2084 $posx = $this->marge_gauche;
2086 $posx = $this->page_largeur - $this->marge_droite - 80;
2095 $pdf->SetTextColor(0, 0, 0);
2096 $pdf->SetFont(
'',
'', $default_font_size - 2);
2097 $pdf->SetXY($posx, $posy - 5);
2098 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2099 $pdf->SetXY($posx, $posy);
2100 $pdf->SetFillColor(230, 230, 230);
2101 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2102 $pdf->SetTextColor(0, 0, 60);
2107 $pdf->SetXY($posx + 2, $posy + 3);
2108 $pdf->SetFont(
'',
'B', $default_font_size);
2109 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2110 $posy = $pdf->getY();
2114 $pdf->SetXY($posx + 2, $posy);
2115 $pdf->SetFont(
'',
'', $default_font_size - 1);
2116 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2120 $usecontact =
false;
2121 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2122 if (count($arrayidcontact) > 0) {
2124 $result =
$object->fetch_contact($arrayidcontact[0]);
2128 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2129 $thirdparty =
$object->contact;
2131 $thirdparty =
$object->thirdparty;
2141 if ($this->page_largeur < 210) {
2145 $posy += $top_shift;
2146 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2148 $posx = $this->marge_gauche;
2153 $pdf->SetTextColor(0, 0, 0);
2154 $pdf->SetFont(
'',
'', $default_font_size - 2);
2155 $pdf->SetXY($posx + 2, $posy - 5);
2156 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2157 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2161 $pdf->SetXY($posx + 2, $posy + 3);
2162 $pdf->SetFont(
'',
'B', $default_font_size);
2164 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2166 $posy = $pdf->getY();
2169 $pdf->SetFont(
'',
'', $default_font_size - 1);
2170 $pdf->SetXY($posx + 2, $posy);
2172 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2176 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2178 if (!empty($idaddressshipping)) {
2179 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2180 $companystatic =
new Societe($this->db);
2181 $companystatic->fetch(
$object->contact->fk_soc);
2188 if (!empty($carac_client_shipping)) {
2189 $posy += $hautcadre;
2194 $pdf->SetXY($posx + 2, $posy - 5);
2195 $pdf->SetFont(
'',
'', $default_font_size - 2);
2196 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2197 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2200 $pdf->SetXY($posx + 2, $posy + 3);
2201 $pdf->SetFont(
'',
'B', $default_font_size);
2202 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2204 $posy = $pdf->getY();
2207 $pdf->SetXY($posx + 2, $posy);
2208 $pdf->SetFont(
'',
'', $default_font_size - 1);
2209 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2211 $top_shift += $hautcadre + 10;
2216 $pdf->SetTextColor(0, 0, 0);