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;
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;
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++;
393 if (preg_match(
'/^\((.*)\)$/',
$object->lines[$i]->desc, $reg)) {
394 if ($reg[1] ==
'DEPOSIT') {
405 if ($categoryOfOperation < 2) {
406 $lineProductType =
$object->lines[$i]->product_type;
412 if ($nbProduct > 0 && $nbService > 0) {
414 $categoryOfOperation = 2;
419 if ($categoryOfOperation <= 0) {
421 if ($nbProduct == 0 && $nbService > 0) {
422 $categoryOfOperation = 1;
425 $this->categoryOfOperation = $categoryOfOperation;
426 if (empty($this->atleastonediscount)) {
427 $delta = ($this->posxprogress - $this->posxdiscount);
428 $this->posxpicture += $delta;
429 $this->posxtva += $delta;
430 $this->posxup += $delta;
431 $this->posxqty += $delta;
432 $this->posxunit += $delta;
433 $this->posxdiscount += $delta;
440 $this->situationinvoice =
true;
441 $progress_width = 10;
442 $this->posxpicture -= $progress_width;
443 $this->posxtva -= $progress_width;
444 $this->posxup -= $progress_width;
445 $this->posxqty -= $progress_width;
446 $this->posxunit -= $progress_width;
447 $this->posxdiscount -= $progress_width;
448 $this->posxprogress -= $progress_width;
453 if (!empty($tplidx)) {
454 $pdf->useTemplate($tplidx);
460 $pdf->SetFont(
'',
'', $default_font_size - 1);
461 $pdf->MultiCell(0, 3,
'');
462 $pdf->SetTextColor(0, 0, 0);
467 $tab_top = 90 + $top_shift;
468 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
471 $extra_under_address_shift = 0;
474 $qrcodestring =
$object->buildZATCAQRString();
477 $qrcodestring =
$object->buildSwitzerlandQRString();
481 $qrcodestring =
$object->buildEPCQrCodeString();
486 $qrcodecolor = array(
'25',
'25',
'25');
491 'fgcolor' => $qrcodecolor,
496 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr,
'N');
500 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
501 $pdf->SetFont(
'',
'', $default_font_size - 4);
502 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
506 $extra_under_address_shift += 25;
514 'outputlangs' => $outputlangs,
515 'hidedetails' => $hidedetails
517 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
518 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
519 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
522 $tab_top += $extra_under_address_shift;
523 $tab_top_newpage += 0;
526 $height_incoterms = 0;
527 if (isModEnabled(
'incoterm')) {
528 $desc_incoterms =
$object->getIncotermsForPDF();
529 if ($desc_incoterms) {
532 $pdf->SetFont(
'',
'', $default_font_size - 1);
533 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
534 $nexY = $pdf->GetY();
535 $height_incoterms = $nexY - $tab_top;
538 $pdf->SetDrawColor(192, 192, 192);
539 $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');
541 $tab_top = $nexY + 6;
546 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
549 if (is_object(
$object->thirdparty)) {
550 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
551 $salerepobj =
new User($this->db);
552 $salerepobj->fetch($salereparray[0][
'id']);
553 if (!empty($salerepobj->signature)) {
554 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
559 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
560 if (!empty($extranote)) {
572 $pdf->SetFont(
'',
'', $default_font_size - 1);
573 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
574 $nexY = $pdf->GetY();
575 $height_note = $nexY - $tab_top;
578 $pdf->SetDrawColor(192, 192, 192);
579 $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');
581 $tab_top = $nexY + 6;
584 $iniY = $tab_top + 7;
585 $curY = $tab_top + 7;
586 $nexY = $tab_top + 7;
589 for ($i = 0; $i < $nblines; $i++) {
591 $pdf->SetFont(
'',
'', $default_font_size - 1);
592 $pdf->SetTextColor(0, 0, 0);
595 $imglinesize = array();
596 if (!empty($realpatharray[$i])) {
600 $pdf->setTopMargin($tab_top_newpage);
601 $page_bottom_margin = $heightforfooter + $heightforfreetext + $heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(),
$object, $langs);
602 $pdf->setPageOrientation(
'', 1, $page_bottom_margin);
603 $pageposbefore = $pdf->getPage();
605 $showpricebeforepagebreak = 1;
607 $posYAfterDescription = 0;
610 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
611 $pdf->AddPage(
'',
'',
true);
612 if (!empty($tplidx)) {
613 $pdf->useTemplate($tplidx);
617 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
619 $pdf->setPage($pageposbefore + 1);
621 $curY = $tab_top_newpage;
625 $showpricebeforepagebreak = 1;
627 $showpricebeforepagebreak = 0;
631 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
632 $curX = $this->posxpicture - 1;
633 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
635 $posYAfterImage = $curY + $imglinesize[
'height'];
639 $curX = $this->posxdesc - 1;
641 $pdf->startTransaction();
642 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
643 $pageposafter = $pdf->getPage();
644 if ($pageposafter > $pageposbefore) {
645 $pdf->rollbackTransaction(
true);
646 $pageposafter = $pageposbefore;
648 $pdf->setPageOrientation(
'', 1, $heightforfooter);
649 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
650 $pageposafter = $pdf->getPage();
651 $posyafter = $pdf->GetY();
653 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
654 if ($i == ($nblines - 1)) {
655 $pdf->AddPage(
'',
'',
true);
656 if (!empty($tplidx)) {
657 $pdf->useTemplate($tplidx);
661 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
663 $pdf->setPage($pageposafter + 1);
670 $showpricebeforepagebreak = 1;
672 $showpricebeforepagebreak = 0;
676 $pdf->commitTransaction();
678 $posYAfterDescription = $pdf->GetY();
680 $nexY = $pdf->GetY();
681 $pageposafter = $pdf->getPage();
682 $pdf->setPage($pageposbefore);
683 $pdf->setTopMargin($this->marge_haute);
684 $pdf->setPageOrientation(
'', 1, 0);
687 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
688 $pdf->setPage($pageposafter);
689 $curY = $tab_top_newpage;
692 $pdf->SetFont(
'',
'', $default_font_size - 1);
697 $pdf->SetXY($this->posxtva - 5, $curY);
698 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
703 $pdf->SetXY($this->posxup, $curY);
704 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
708 $pdf->SetXY($this->posxqty, $curY);
709 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
714 $pdf->SetXY($this->posxunit, $curY);
715 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
719 if (
$object->lines[$i]->remise_percent) {
720 $pdf->SetXY($this->posxdiscount - 2, $curY);
722 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
726 if ($this->situationinvoice) {
728 $pdf->SetXY($this->posxprogress, $curY);
729 $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0,
'R');
734 $pdf->SetXY($this->postotalht, $curY);
735 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
743 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
744 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
745 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
746 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
748 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
751 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
752 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
754 $tvaligne = $sign *
$object->lines[$i]->total_tva;
758 $localtax1ligne =
$object->lines[$i]->total_localtax1;
759 $localtax2ligne =
$object->lines[$i]->total_localtax2;
760 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
761 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
762 $localtax1_type =
$object->lines[$i]->localtax1_type;
763 $localtax2_type =
$object->lines[$i]->localtax2_type;
776 $vatrate = (string)
$object->lines[$i]->tva_tx;
779 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
780 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
782 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
783 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
787 if ($localtax1_type && $localtax1ligne != 0) {
788 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
789 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
791 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
794 if ($localtax2_type && $localtax2ligne != 0) {
795 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
796 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
798 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
802 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
807 if (!isset($this->tva[$vatrate])) {
808 $this->tva[$vatrate] = 0;
810 $this->tva[$vatrate] += $tvaligne;
811 $vatcode =
$object->lines[$i]->vat_src_code;
813 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'tot_ht'])) {
814 $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'tot_ht'] = 0;
816 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne,
'tot_ht'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'tot_ht'] +
$object->lines[$i]->total_ht);
818 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
819 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
821 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
824 if ($posYAfterImage > $posYAfterDescription) {
825 $nexY = $posYAfterImage;
830 $pdf->setPage($pageposafter);
831 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
833 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
834 $pdf->SetLineStyle(array(
'dash' => 0));
840 while ($pagenb < $pageposafter) {
841 $pdf->setPage($pagenb);
843 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
845 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
849 $pdf->setPage($pagenb);
850 $pdf->setPageOrientation(
'', 1, 0);
853 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
855 if (!empty($tplidx)) {
856 $pdf->useTemplate($tplidx);
859 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
861 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
863 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
868 if (!empty($tplidx)) {
869 $pdf->useTemplate($tplidx);
874 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
881 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
882 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage + 1;
884 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
885 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
887 dol_syslog(
"bottomlasttab=".$bottomlasttab.
" this->page_hauteur=".$this->page_hauteur.
" heightforinfotot=".$heightforinfotot.
" heightforfreetext=".$heightforfreetext.
" heightforfooter=".$heightforfooter);
893 $posy = $this->
_tableau_tot($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
896 $listofpayments =
$object->getListOfPayments(
'', 0, 1);
897 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
903 if (method_exists($pdf,
'AliasNbPages')) {
904 $pdf->AliasNbPages();
908 if (!empty($mysoc->termsofsale) &&
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_INVOICE')) {
909 $termsofsale =
$conf->mycompany->dir_output.
'/'.$mysoc->termsofsale;
910 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
911 $termsofsale =
$conf->mycompany->multidir_output[
$object->entity].
'/'.$mysoc->termsofsale;
913 if (file_exists($termsofsale) && is_readable($termsofsale)) {
914 $pagecount = $pdf->setSourceFile($termsofsale);
915 for ($i = 1; $i <= $pagecount; $i++) {
916 $tplIdx = $pdf->importPage($i);
917 if ($tplIdx!==
false) {
918 $s = $pdf->getTemplatesize($tplIdx);
919 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
920 $pdf->useTemplate($tplIdx);
922 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
936 $pdf->Output($file,
'F');
939 $hookmanager->initHooks(array(
'pdfgeneration'));
940 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
942 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
944 $this->error = $hookmanager->error;
945 $this->errors = $hookmanager->errors;
950 $this->result = array(
'fullpath' => $file);
954 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
958 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
985 $current_page = $pdf->getPage();
987 $tab3_top = $posy + 8;
990 if ($this->page_largeur < 210) {
1000 $pdf->SetFont(
'',
'', $default_font_size - 4);
1004 $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,";
1005 $sql .=
" re.description, re.fk_facture_source,";
1006 $sql .=
" f.type, f.datef";
1007 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1008 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1009 $resql = $this->db->query($sql);
1011 $num = $this->db->num_rows($resql);
1013 $invoice =
new Facture($this->db);
1016 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1019 $pdf->AddPage(
'',
'',
true);
1025 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1027 $pdf->setPage($current_page);
1031 $obj = $this->db->fetch_object($resql);
1033 if ($obj->type == 2) {
1034 $text = $outputlangs->transnoentities(
"CreditNote");
1035 } elseif ($obj->type == 3) {
1036 $text = $outputlangs->transnoentities(
"Deposit");
1037 } elseif ($obj->type == 0) {
1038 $text = $outputlangs->transnoentities(
"ExcessReceived");
1040 $text = $outputlangs->transnoentities(
"UnknownType");
1043 $invoice->fetch($obj->fk_facture_source);
1045 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1046 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1047 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1048 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1049 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1050 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1051 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1052 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1054 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1059 $this->error = $this->db->lasterror();
1065 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1067 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1068 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1069 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1071 $sql .=
" ORDER BY p.datep";
1073 $resql = $this->db->query($sql);
1075 $num = $this->db->num_rows($resql);
1080 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1083 $pdf->AddPage(
'',
'',
true);
1089 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1091 $pdf->setPage($current_page);
1095 $row = $this->db->fetch_object($resql);
1097 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1098 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1099 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1100 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1101 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1102 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1104 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1105 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1106 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1107 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1108 $y = $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1109 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1114 return $tab3_top + $y + 3;
1116 $this->error = $this->db->lasterror();
1178 global $mysoc, $hookmanager;
1182 $pdf->SetFont(
'',
'', $default_font_size - 1);
1184 krsort($this->tva_array);
1191 $pdf->SetFillColor(224, 224, 224);
1193 $pdf->SetFont(
'',
'', $default_font_size - 2);
1194 $pdf->SetXY($this->marge_gauche, $posy);
1195 $titre = $outputlangs->transnoentities(
"VAT");
1196 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1198 $pdf->SetFont(
'',
'', $default_font_size - 2);
1199 $pdf->SetXY($this->marge_gauche + 25, $posy);
1200 $titre = $outputlangs->transnoentities(
"NetTotal");
1201 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1203 $pdf->SetFont(
'',
'', $default_font_size - 2);
1204 $pdf->SetXY($this->marge_gauche + 50, $posy);
1205 $titre = $outputlangs->transnoentities(
"VATAmount");
1206 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1208 $pdf->SetFont(
'',
'', $default_font_size - 2);
1209 $pdf->SetXY($this->marge_gauche + 75, $posy);
1210 $titre = $outputlangs->transnoentities(
"AmountTotal");
1211 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1213 $posy = $pdf->GetY();
1218 foreach ($this->tva_array as $tvakey => $tvaval) {
1219 $pdf->SetFont(
'',
'', $default_font_size - 2);
1220 $pdf->SetXY($this->marge_gauche, $posy);
1221 $titre = round((
float) $tvakey, 2) .
"%";
1222 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1224 $pdf->SetFont(
'',
'', $default_font_size - 2);
1225 $pdf->SetXY($this->marge_gauche + 25, $posy);
1226 $titre =
price($tvaval[
'tot_ht']);
1227 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1228 $tot_ht += $tvaval[
'tot_ht'];
1230 $pdf->SetFont(
'',
'', $default_font_size - 2);
1231 $pdf->SetXY($this->marge_gauche + 50, $posy);
1232 $titre =
price($tvaval[
'amount']);
1233 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1234 $tot_tva += $tvaval[
'amount'];
1236 $pdf->SetFont(
'',
'', $default_font_size - 2);
1237 $pdf->SetXY($this->marge_gauche + 75, $posy);
1238 $titre =
price($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1239 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1240 $tot_ttc += ($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1242 $posy = $pdf->GetY();
1247 if (in_array($this->emetteur->country_code, array(
'FR')) && empty(
$object->total_tva)) {
1248 $pdf->SetFont(
'',
'', $default_font_size - 2);
1249 $pdf->SetXY($this->marge_gauche, $posy);
1250 if (empty($mysoc->tva_assuj)) {
1251 if ($mysoc->forme_juridique_code == 92) {
1252 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1254 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1256 } elseif (
getDolGlobalString(
"INVOICE_VAT_SHOW_REVERSE_CHARGE_MENTION") && $this->emetteur->country_code !=
$object->thirdparty->country_code && $this->emetteur->isInEEC() &&
$object->thirdparty->isInEEC()) {
1257 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedReverseChargeProcedure"), 0,
'L', 0);
1259 $posy = $pdf->GetY() + 4;
1264 if ($this->page_largeur < 210) {
1270 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1271 $pdf->SetXY($this->marge_gauche, $posy);
1272 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1273 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1275 $pdf->SetFont(
'',
'', $default_font_size - 2);
1276 $pdf->SetXY($posxval, $posy);
1277 $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);
1278 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1279 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1281 $posy = $pdf->GetY() + 3;
1285 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1286 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1287 $pdf->SetXY($this->marge_gauche, $posy);
1288 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1289 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1291 $pdf->SetFont(
'',
'', $default_font_size - 2);
1292 $pdf->SetXY($posxval, $posy);
1293 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1294 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1296 $posy = $pdf->GetY() + 3;
1301 if (empty(
$object->mode_reglement_code)
1304 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1308 $outputlangs->load(
"errors");
1310 $pdf->SetXY($this->marge_gauche, $posy);
1311 $pdf->SetTextColor(200, 0, 0);
1312 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1313 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1314 $pdf->MultiCell(80, 3, $this->error, 0,
'L', 0);
1315 $pdf->SetTextColor(0, 0, 0);
1317 $posy = $pdf->GetY() + 1;
1321 if (!empty(
$object->mode_reglement_code)
1322 &&
$object->mode_reglement_code !=
'CHQ'
1323 &&
$object->mode_reglement_code !=
'VIR') {
1324 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1325 $pdf->SetXY($this->marge_gauche, $posy);
1326 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1327 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1329 $pdf->SetFont(
'',
'', $default_font_size - 2);
1330 $pdf->SetXY($posxval, $posy);
1331 $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);
1333 if (
$object->mode_reglement_code ==
"PRE") {
1334 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1337 $bac->fetch(0,
'',
$object->thirdparty->id);
1338 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1339 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1341 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1343 $posy = $pdf->GetY();
1349 if ($this->emetteur->country_code ==
'FR') {
1351 $pdf->SetXY($this->marge_gauche, $posy);
1352 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1354 $posy = $pdf->GetY() + 1;
1359 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1360 $useonlinepayment = 0;
1364 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1365 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1366 $useonlinepayment = count($validpaymentmethod);
1370 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1373 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1374 $servicename = $langs->transnoentities(
'Online');
1376 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1377 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1379 $pdf->SetXY($this->marge_gauche, $posy);
1382 $posy = $pdf->GetY() + 1;
1387 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1393 $account =
new Account($this->db);
1396 $pdf->SetXY($this->marge_gauche, $posy);
1397 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1398 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1399 $posy = $pdf->GetY() + 1;
1402 $pdf->SetXY($this->marge_gauche, $posy);
1403 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1404 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1405 $posy = $pdf->GetY() + 2;
1409 $pdf->SetXY($this->marge_gauche, $posy);
1410 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1411 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1412 $posy = $pdf->GetY() + 1;
1415 $pdf->SetXY($this->marge_gauche, $posy);
1416 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1417 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1418 $posy = $pdf->GetY() + 2;
1425 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1431 $account =
new Account($this->db);
1432 $account->fetch($bankid);
1434 $curx = $this->marge_gauche;
1437 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1442 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1445 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L', 0);
1471 global
$conf, $mysoc, $hookmanager;
1480 $outputlangsbis =
null;
1484 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1485 $default_font_size--;
1490 $pdf->SetFont(
'',
'', $default_font_size - 1);
1495 if ($this->page_largeur < 210) {
1499 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1505 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1508 $total_line_remise = 0;
1509 foreach (
$object->lines as $i => $line) {
1511 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1513 if ($line->total_ht < 0) {
1514 $total_line_remise += -$line->total_ht;
1517 if ($total_line_remise > 0) {
1518 $pdf->SetFillColor(255, 255, 255);
1519 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1520 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1521 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1522 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1527 $pdf->SetFillColor(255, 255, 255);
1528 $pdf->SetXY($col1x, $tab2_top);
1529 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1530 $pdf->SetXY($col2x, $tab2_top);
1531 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1537 $pdf->SetFillColor(255, 255, 255);
1538 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1539 $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);
1541 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1542 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1543 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1547 $pdf->SetFillColor(255, 255, 255);
1548 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1549 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalVAT"), 0,
'L', 1);
1551 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1552 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->total_tva), 0,
'R', 1);
1556 $pdf->SetFillColor(248, 248, 248);
1558 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1560 $this->atleastoneratenotnull = 0;
1562 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1563 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1567 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1568 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1572 foreach ($localtax_rate as $tvakey => $tvaval) {
1577 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1580 if (preg_match(
'/\*/', (
string) $tvakey)) {
1581 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1582 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1585 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1589 $totalvat .= $tvacompl;
1591 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1594 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1596 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1598 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1599 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1605 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1606 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1610 foreach ($localtax_rate as $tvakey => $tvaval) {
1615 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1618 if (preg_match(
'/\*/', (
string) $tvakey)) {
1619 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1620 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1622 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1626 $totalvat .= $tvacompl;
1628 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1631 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1633 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1635 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1636 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1643 foreach ($this->tva_array as $tvakey => $tvaval) {
1645 $this->atleastoneratenotnull++;
1648 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1651 if (preg_match(
'/\*/', $tvakey)) {
1652 $tvakey = str_replace(
'*',
'', $tvakey);
1653 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1655 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1658 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).$tvacompl;
1660 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1662 $totalvat .= $tvacompl;
1664 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1666 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1667 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1668 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1674 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1675 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1679 foreach ($localtax_rate as $tvakey => $tvaval) {
1684 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1687 if (preg_match(
'/\*/', (
string) $tvakey)) {
1688 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1689 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1691 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1694 $totalvat .= $tvacompl;
1696 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1699 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1701 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1703 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1704 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1710 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1711 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1715 foreach ($localtax_rate as $tvakey => $tvaval) {
1719 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1722 if (preg_match(
'/\*/', (
string) $tvakey)) {
1723 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1724 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1726 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1729 $totalvat .= $tvacompl;
1731 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1734 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1736 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1738 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1739 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1746 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1747 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp"), $useborder,
'L', 1);
1749 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1750 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1755 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1756 $pdf->SetTextColor(0, 0, 60);
1757 $pdf->SetFillColor(224, 224, 224);
1758 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1760 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1761 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1764 if (
$object->displayRetainedWarranty()) {
1765 $pdf->SetTextColor(40, 40, 40);
1766 $pdf->SetFillColor(255, 255, 255);
1768 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1769 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1773 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1774 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1776 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1777 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1781 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1783 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").
' ('.
$object->retained_warranty.
'%)';
1784 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1786 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1787 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1788 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1793 $pdf->SetTextColor(0, 0, 0);
1794 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1795 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1797 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1802 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1805 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1806 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L', 0);
1807 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1808 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1811 if ($creditnoteamount) {
1812 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1814 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1815 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1816 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1817 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1821 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1823 $pdf->SetFillColor(255, 255, 255);
1825 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1826 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L', 1);
1827 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1828 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R', 1);
1834 $pdf->SetTextColor(0, 0, 60);
1835 $pdf->SetFillColor(224, 224, 224);
1836 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1837 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1838 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1839 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1841 $pdf->SetFont(
'',
'', $default_font_size - 1);
1842 $pdf->SetTextColor(0, 0, 0);
1850 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1851 $pdf->MultiCell($col2x - $col1x, $tab2_hl,
getDolGlobalString(
'BILL_TEXT_TOTAL_FOOTER'), 0,
'L', 0);
1854 return ($tab2_top + ($tab2_hl * $index));
1871 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1881 $currency = !empty($currency) ? $currency :
$conf->currency;
1885 $pdf->SetTextColor(0, 0, 0);
1886 $pdf->SetFont(
'',
'', $default_font_size - 2);
1888 if (empty($hidetop)) {
1890 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
1891 $categoryOfOperations = $outputlangs->transnoentities(
"MentionCategoryOfOperations") .
' : ' . $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1892 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
1893 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
1896 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1897 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1898 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1901 $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')));
1905 $pdf->SetDrawColor(128, 128, 128);
1906 $pdf->SetFont(
'',
'', $default_font_size - 1);
1909 $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');
1911 if (empty($hidetop)) {
1912 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1914 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1915 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1919 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1920 if (empty($hidetop)) {
1927 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1928 if (empty($hidetop)) {
1929 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1930 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1934 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1935 if (empty($hidetop)) {
1936 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1937 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1940 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1941 if (empty($hidetop)) {
1942 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1943 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1947 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1948 if (empty($hidetop)) {
1949 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1950 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1954 if ($this->atleastonediscount) {
1955 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1956 if (empty($hidetop)) {
1957 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1958 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1962 if ($this->situationinvoice) {
1963 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1964 if (empty($hidetop)) {
1965 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1966 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities(
"ProgressShort"),
'',
'C');
1970 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1971 if (empty($hidetop)) {
1972 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1973 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1988 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1991 global
$conf, $langs;
1993 $ltrdirection =
'L';
1994 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1995 $ltrdirection =
'R';
1999 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2005 $pdf->SetTextColor(0, 0, 60);
2006 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2010 $posy = $this->marge_haute;
2011 $posx = $this->page_largeur - $this->marge_droite - $w;
2013 $pdf->SetXY($this->marge_gauche, $posy);
2017 if ($this->emetteur->logo) {
2018 $logodir =
$conf->mycompany->dir_output;
2019 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
2020 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
2023 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2025 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2027 if (is_readable($logo)) {
2029 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2031 $pdf->SetTextColor(200, 0, 0);
2032 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2033 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2034 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2037 $text = $this->emetteur->name;
2038 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2042 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2043 $pdf->SetXY($posx, $posy);
2044 $pdf->SetTextColor(0, 0, 60);
2045 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2047 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2050 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2053 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2056 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2058 if ($this->situationinvoice) {
2059 $outputlangs->loadLangs(array(
"other"));
2060 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
2062 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2065 if ($this->situationinvoice) {
2066 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2068 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2069 } elseif (
$object->type == 1) {
2070 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2071 } elseif (
$object->type == 2) {
2072 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2073 } elseif (
$object->type == 3) {
2074 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2075 } elseif (
$object->type == 4) {
2076 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2079 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2080 if (
$object->status == $object::STATUS_DRAFT) {
2081 $pdf->SetTextColor(128, 0, 0);
2082 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2085 $pdf->MultiCell($w, 3, $title,
'',
'R');
2087 $pdf->SetFont(
'',
'B', $default_font_size);
2101 $pdf->SetFont(
'',
'', $default_font_size - 2);
2105 $pdf->SetXY($posx, $posy);
2106 $pdf->SetTextColor(0, 0, 60);
2107 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_customer),
'',
'R');
2112 if (!empty(
$object->project->ref)) {
2114 $pdf->SetXY($posx, $posy);
2115 $pdf->SetTextColor(0, 0, 60);
2116 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2122 if (!empty(
$object->project->ref)) {
2123 $outputlangs->load(
"projects");
2125 $pdf->SetXY($posx, $posy);
2126 $pdf->SetTextColor(0, 0, 60);
2127 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2131 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2132 if (
$object->type == 0 && $objectidnext) {
2133 $objectreplacing =
new Facture($this->db);
2134 $objectreplacing->fetch($objectidnext);
2137 $pdf->SetXY($posx, $posy);
2138 $pdf->SetTextColor(0, 0, 60);
2139 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2142 $objectreplaced =
new Facture($this->db);
2143 $objectreplaced->fetch(
$object->fk_facture_source);
2146 $pdf->SetXY($posx, $posy);
2147 $pdf->SetTextColor(0, 0, 60);
2148 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2151 $objectreplaced =
new Facture($this->db);
2152 $objectreplaced->fetch(
$object->fk_facture_source);
2155 $pdf->SetXY($posx, $posy);
2156 $pdf->SetTextColor(0, 0, 60);
2157 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2161 $pdf->SetXY($posx, $posy);
2162 $pdf->SetTextColor(0, 0, 60);
2163 $title = $outputlangs->transnoentities(
"DateInvoice");
2164 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2165 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2167 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2171 $pdf->SetXY($posx, $posy);
2172 $pdf->SetTextColor(0, 0, 60);
2173 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2178 $pdf->SetXY($posx, $posy);
2179 $pdf->SetTextColor(0, 0, 60);
2180 $title = $outputlangs->transnoentities(
"DateDue");
2181 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2182 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2184 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2189 $pdf->SetXY($posx, $posy);
2190 $pdf->SetTextColor(0, 0, 60);
2191 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2196 $pdf->SetXY($posx, $posy);
2197 $pdf->SetTextColor(0, 0, 60);
2198 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
2203 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2204 if (count($arrayidcontact) > 0) {
2205 $usertmp =
new User($this->db);
2206 $usertmp->fetch($arrayidcontact[0]);
2208 $pdf->SetXY($posx, $posy);
2209 $pdf->SetTextColor(0, 0, 60);
2210 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2218 $current_y = $pdf->getY();
2220 if ($current_y < $pdf->getY()) {
2221 $top_shift = $pdf->getY() - $current_y;
2226 $carac_emetteur =
'';
2228 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2229 if (count($arrayidcontact) > 0) {
2230 $object->fetch_user($arrayidcontact[0]);
2231 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2232 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2233 $carac_emetteur .=
"\n";
2240 $posy += $top_shift;
2241 $posx = $this->marge_gauche;
2243 $posx = $this->page_largeur - $this->marge_droite - 80;
2252 $pdf->SetTextColor(0, 0, 0);
2253 $pdf->SetFont(
'',
'', $default_font_size - 2);
2254 $pdf->SetXY($posx, $posy - 5);
2255 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2256 $pdf->SetXY($posx, $posy);
2257 $pdf->SetFillColor(230, 230, 230);
2258 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2259 $pdf->SetTextColor(0, 0, 60);
2264 $pdf->SetXY($posx + 2, $posy + 3);
2265 $pdf->SetFont(
'',
'B', $default_font_size);
2266 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2267 $posy = $pdf->getY();
2271 $pdf->SetXY($posx + 2, $posy);
2272 $pdf->SetFont(
'',
'', $default_font_size - 1);
2273 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2277 $usecontact =
false;
2278 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2279 if (count($arrayidcontact) > 0) {
2281 $result =
$object->fetch_contact($arrayidcontact[0]);
2285 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2286 $thirdparty =
$object->contact;
2288 $thirdparty =
$object->thirdparty;
2298 if ($this->page_largeur < 210) {
2302 $posy += $top_shift;
2303 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2305 $posx = $this->marge_gauche;
2310 $pdf->SetTextColor(0, 0, 0);
2311 $pdf->SetFont(
'',
'', $default_font_size - 2);
2312 $pdf->SetXY($posx + 2, $posy - 5);
2313 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2314 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2318 $pdf->SetXY($posx + 2, $posy + 3);
2319 $pdf->SetFont(
'',
'B', $default_font_size);
2321 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2323 $posy = $pdf->getY();
2326 $pdf->SetFont(
'',
'', $default_font_size - 1);
2327 $pdf->SetXY($posx + 2, $posy);
2329 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2333 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2335 if (!empty($idaddressshipping)) {
2336 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2337 $companystatic =
new Societe($this->db);
2338 $companystatic->fetch(
$object->contact->fk_soc);
2345 if (!empty($carac_client_shipping)) {
2346 $posy += $hautcadre;
2351 $pdf->SetXY($posx + 2, $posy - 5);
2352 $pdf->SetFont(
'',
'', $default_font_size - 2);
2353 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2354 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2357 $pdf->SetXY($posx + 2, $posy + 3);
2358 $pdf->SetFont(
'',
'B', $default_font_size);
2359 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2361 $posy = $pdf->getY();
2364 $pdf->SetXY($posx + 2, $posy);
2365 $pdf->SetFont(
'',
'', $default_font_size - 1);
2366 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2368 $top_shift += $hautcadre + 10;
2373 $pdf->SetTextColor(0, 0, 0);