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++;
392 if ($categoryOfOperation < 2) {
393 $lineProductType =
$object->lines[$i]->product_type;
399 if ($nbProduct > 0 && $nbService > 0) {
401 $categoryOfOperation = 2;
406 if ($categoryOfOperation <= 0) {
408 if ($nbProduct == 0 && $nbService > 0) {
409 $categoryOfOperation = 1;
412 $this->categoryOfOperation = $categoryOfOperation;
413 if (empty($this->atleastonediscount)) {
414 $delta = ($this->posxprogress - $this->posxdiscount);
415 $this->posxpicture += $delta;
416 $this->posxtva += $delta;
417 $this->posxup += $delta;
418 $this->posxqty += $delta;
419 $this->posxunit += $delta;
420 $this->posxdiscount += $delta;
427 $this->situationinvoice =
true;
428 $progress_width = 10;
429 $this->posxpicture -= $progress_width;
430 $this->posxtva -= $progress_width;
431 $this->posxup -= $progress_width;
432 $this->posxqty -= $progress_width;
433 $this->posxunit -= $progress_width;
434 $this->posxdiscount -= $progress_width;
435 $this->posxprogress -= $progress_width;
440 if (!empty($tplidx)) {
441 $pdf->useTemplate($tplidx);
447 $pdf->SetFont(
'',
'', $default_font_size - 1);
448 $pdf->MultiCell(0, 3,
'');
449 $pdf->SetTextColor(0, 0, 0);
454 $tab_top = 90 + $top_shift;
455 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
458 $extra_under_address_shift = 0;
461 $qrcodestring =
$object->buildZATCAQRString();
464 $qrcodestring =
$object->buildSwitzerlandQRString();
468 $qrcodestring =
$object->buildEPCQrCodeString();
473 $qrcodecolor = array(
'25',
'25',
'25');
478 'fgcolor' => $qrcodecolor,
483 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr,
'N');
487 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
488 $pdf->SetFont(
'',
'', $default_font_size - 4);
489 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L', 0);
493 $extra_under_address_shift += 25;
501 'outputlangs' => $outputlangs,
502 'hidedetails' => $hidedetails
504 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
505 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
506 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
509 $tab_top += $extra_under_address_shift;
510 $tab_top_newpage += 0;
513 $height_incoterms = 0;
514 if (isModEnabled(
'incoterm')) {
515 $desc_incoterms =
$object->getIncotermsForPDF();
516 if ($desc_incoterms) {
519 $pdf->SetFont(
'',
'', $default_font_size - 1);
520 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
521 $nexY = $pdf->GetY();
522 $height_incoterms = $nexY - $tab_top;
525 $pdf->SetDrawColor(192, 192, 192);
526 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius,
'1234',
'D');
528 $tab_top = $nexY + 6;
533 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
536 if (is_object(
$object->thirdparty)) {
537 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
538 $salerepobj =
new User($this->db);
539 $salerepobj->fetch($salereparray[0][
'id']);
540 if (!empty($salerepobj->signature)) {
541 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
546 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
547 if (!empty($extranote)) {
559 $pdf->SetFont(
'',
'', $default_font_size - 1);
560 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
561 $nexY = $pdf->GetY();
562 $height_note = $nexY - $tab_top;
565 $pdf->SetDrawColor(192, 192, 192);
566 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1, $this->corner_radius,
'1234',
'D');
568 $tab_top = $nexY + 6;
571 $iniY = $tab_top + 7;
572 $curY = $tab_top + 7;
573 $nexY = $tab_top + 7;
576 for ($i = 0; $i < $nblines; $i++) {
578 $pdf->SetFont(
'',
'', $default_font_size - 1);
579 $pdf->SetTextColor(0, 0, 0);
582 $imglinesize = array();
583 if (!empty($realpatharray[$i])) {
587 $pdf->setTopMargin($tab_top_newpage);
588 $page_bottom_margin = $heightforfooter + $heightforfreetext + $heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(),
$object, $langs);
589 $pdf->setPageOrientation(
'', 1, $page_bottom_margin);
590 $pageposbefore = $pdf->getPage();
592 $showpricebeforepagebreak = 1;
594 $posYAfterDescription = 0;
597 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
598 $pdf->AddPage(
'',
'',
true);
599 if (!empty($tplidx)) {
600 $pdf->useTemplate($tplidx);
604 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
606 $pdf->setPage($pageposbefore + 1);
608 $curY = $tab_top_newpage;
612 $showpricebeforepagebreak = 1;
614 $showpricebeforepagebreak = 0;
618 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
619 $curX = $this->posxpicture - 1;
620 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
622 $posYAfterImage = $curY + $imglinesize[
'height'];
626 $curX = $this->posxdesc - 1;
628 $pdf->startTransaction();
629 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
630 $pageposafter = $pdf->getPage();
631 if ($pageposafter > $pageposbefore) {
632 $pdf->rollbackTransaction(
true);
633 $pageposafter = $pageposbefore;
635 $pdf->setPageOrientation(
'', 1, $heightforfooter);
636 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
637 $pageposafter = $pdf->getPage();
638 $posyafter = $pdf->GetY();
640 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
641 if ($i == ($nblines - 1)) {
642 $pdf->AddPage(
'',
'',
true);
643 if (!empty($tplidx)) {
644 $pdf->useTemplate($tplidx);
648 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
650 $pdf->setPage($pageposafter + 1);
657 $showpricebeforepagebreak = 1;
659 $showpricebeforepagebreak = 0;
663 $pdf->commitTransaction();
665 $posYAfterDescription = $pdf->GetY();
667 $nexY = $pdf->GetY();
668 $pageposafter = $pdf->getPage();
669 $pdf->setPage($pageposbefore);
670 $pdf->setTopMargin($this->marge_haute);
671 $pdf->setPageOrientation(
'', 1, 0);
674 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
675 $pdf->setPage($pageposafter);
676 $curY = $tab_top_newpage;
679 $pdf->SetFont(
'',
'', $default_font_size - 1);
684 $pdf->SetXY($this->posxtva - 5, $curY);
685 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
690 $pdf->SetXY($this->posxup, $curY);
691 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
695 $pdf->SetXY($this->posxqty, $curY);
696 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
701 $pdf->SetXY($this->posxunit, $curY);
702 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
706 if (
$object->lines[$i]->remise_percent) {
707 $pdf->SetXY($this->posxdiscount - 2, $curY);
709 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
713 if ($this->situationinvoice) {
715 $pdf->SetXY($this->posxprogress, $curY);
716 $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0,
'R');
721 $pdf->SetXY($this->postotalht, $curY);
722 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
730 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
731 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
732 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
733 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
735 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
738 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
739 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
741 $tvaligne = $sign *
$object->lines[$i]->total_tva;
745 $localtax1ligne =
$object->lines[$i]->total_localtax1;
746 $localtax2ligne =
$object->lines[$i]->total_localtax2;
747 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
748 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
749 $localtax1_type =
$object->lines[$i]->localtax1_type;
750 $localtax2_type =
$object->lines[$i]->localtax2_type;
763 $vatrate = (string)
$object->lines[$i]->tva_tx;
766 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
767 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
769 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
770 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
774 if ($localtax1_type && $localtax1ligne != 0) {
775 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
776 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
778 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
781 if ($localtax2_type && $localtax2ligne != 0) {
782 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
783 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
785 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
789 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
794 if (!isset($this->tva[$vatrate])) {
795 $this->tva[$vatrate] = 0;
797 $this->tva[$vatrate] += $tvaligne;
798 $vatcode =
$object->lines[$i]->vat_src_code;
800 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'tot_ht'])) {
801 $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'tot_ht'] = 0;
803 $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);
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);
811 if ($posYAfterImage > $posYAfterDescription) {
812 $nexY = $posYAfterImage;
817 $pdf->setPage($pageposafter);
818 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
820 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
821 $pdf->SetLineStyle(array(
'dash' => 0));
827 while ($pagenb < $pageposafter) {
828 $pdf->setPage($pagenb);
830 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
832 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
836 $pdf->setPage($pagenb);
837 $pdf->setPageOrientation(
'', 1, 0);
840 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
842 if (!empty($tplidx)) {
843 $pdf->useTemplate($tplidx);
846 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
848 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
850 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
855 if (!empty($tplidx)) {
856 $pdf->useTemplate($tplidx);
861 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
868 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
869 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage + 1;
871 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
872 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
874 dol_syslog(
"bottomlasttab=".$bottomlasttab.
" this->page_hauteur=".$this->page_hauteur.
" heightforinfotot=".$heightforinfotot.
" heightforfreetext=".$heightforfreetext.
" heightforfooter=".$heightforfooter);
880 $posy = $this->
_tableau_tot($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
883 $listofpayments =
$object->getListOfPayments(
'', 0, 1);
884 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
890 if (method_exists($pdf,
'AliasNbPages')) {
891 $pdf->AliasNbPages();
895 if (!empty($mysoc->termsofsale) &&
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_INVOICE')) {
896 $termsofsale =
$conf->mycompany->dir_output.
'/'.$mysoc->termsofsale;
897 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
898 $termsofsale =
$conf->mycompany->multidir_output[
$object->entity].
'/'.$mysoc->termsofsale;
900 if (file_exists($termsofsale) && is_readable($termsofsale)) {
901 $pagecount = $pdf->setSourceFile($termsofsale);
902 for ($i = 1; $i <= $pagecount; $i++) {
903 $tplIdx = $pdf->importPage($i);
904 if ($tplIdx!==
false) {
905 $s = $pdf->getTemplatesize($tplIdx);
906 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
907 $pdf->useTemplate($tplIdx);
909 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
923 $pdf->Output($file,
'F');
926 $hookmanager->initHooks(array(
'pdfgeneration'));
927 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
929 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
931 $this->error = $hookmanager->error;
932 $this->errors = $hookmanager->errors;
937 $this->result = array(
'fullpath' => $file);
941 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
945 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
972 $current_page = $pdf->getPage();
974 $tab3_top = $posy + 8;
977 if ($this->page_largeur < 210) {
987 $pdf->SetFont(
'',
'', $default_font_size - 4);
991 $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,";
992 $sql .=
" re.description, re.fk_facture_source,";
993 $sql .=
" f.type, f.datef";
994 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
995 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
996 $resql = $this->db->query($sql);
998 $num = $this->db->num_rows($resql);
1000 $invoice =
new Facture($this->db);
1003 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1006 $pdf->AddPage(
'',
'',
true);
1012 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1014 $pdf->setPage($current_page);
1018 $obj = $this->db->fetch_object($resql);
1020 if ($obj->type == 2) {
1021 $text = $outputlangs->transnoentities(
"CreditNote");
1022 } elseif ($obj->type == 3) {
1023 $text = $outputlangs->transnoentities(
"Deposit");
1024 } elseif ($obj->type == 0) {
1025 $text = $outputlangs->transnoentities(
"ExcessReceived");
1027 $text = $outputlangs->transnoentities(
"UnknownType");
1030 $invoice->fetch($obj->fk_facture_source);
1032 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1033 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1034 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1035 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
1036 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1037 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1038 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1039 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1041 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1046 $this->error = $this->db->lasterror();
1052 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1054 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1055 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1056 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1058 $sql .=
" ORDER BY p.datep";
1060 $resql = $this->db->query($sql);
1062 $num = $this->db->num_rows($resql);
1067 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1070 $pdf->AddPage(
'',
'',
true);
1076 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1078 $pdf->setPage($current_page);
1082 $row = $this->db->fetch_object($resql);
1084 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1085 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1086 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1087 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1088 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1089 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1091 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1092 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1093 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1094 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1095 $y = $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1096 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1101 return $tab3_top + $y + 3;
1103 $this->error = $this->db->lasterror();
1165 global
$conf, $mysoc, $hookmanager;
1169 $pdf->SetFont(
'',
'', $default_font_size - 1);
1171 krsort($this->tva_array);
1175 $pdf->SetFillColor(224, 224, 224);
1177 $pdf->SetFont(
'',
'', $default_font_size - 2);
1178 $pdf->SetXY($this->marge_gauche, $posy);
1179 $titre = $outputlangs->transnoentities(
"VAT");
1180 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1182 $pdf->SetFont(
'',
'', $default_font_size - 2);
1183 $pdf->SetXY($this->marge_gauche + 25, $posy);
1184 $titre = $outputlangs->transnoentities(
"NetTotal");
1185 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1187 $pdf->SetFont(
'',
'', $default_font_size - 2);
1188 $pdf->SetXY($this->marge_gauche + 50, $posy);
1189 $titre = $outputlangs->transnoentities(
"VATAmount");
1190 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1192 $pdf->SetFont(
'',
'', $default_font_size - 2);
1193 $pdf->SetXY($this->marge_gauche + 75, $posy);
1194 $titre = $outputlangs->transnoentities(
"AmountTotal");
1195 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1197 $posy = $pdf->GetY();
1202 foreach ($this->tva_array as $tvakey => $tvaval) {
1203 $pdf->SetFont(
'',
'', $default_font_size - 2);
1204 $pdf->SetXY($this->marge_gauche, $posy);
1205 $titre = round((
float) $tvakey, 2) .
"%";
1206 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1208 $pdf->SetFont(
'',
'', $default_font_size - 2);
1209 $pdf->SetXY($this->marge_gauche + 25, $posy);
1210 $titre =
price($tvaval[
'tot_ht']);
1211 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1212 $tot_ht += $tvaval[
'tot_ht'];
1214 $pdf->SetFont(
'',
'', $default_font_size - 2);
1215 $pdf->SetXY($this->marge_gauche + 50, $posy);
1216 $titre =
price($tvaval[
'amount']);
1217 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1218 $tot_tva += $tvaval[
'amount'];
1220 $pdf->SetFont(
'',
'', $default_font_size - 2);
1221 $pdf->SetXY($this->marge_gauche + 75, $posy);
1222 $titre =
price($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1223 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1224 $tot_ttc += ($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1226 $posy = $pdf->GetY();
1231 if ($this->emetteur->country_code ==
'FR' && empty(
$object->total_tva) && (empty($mysoc->tva_assuj) || ($this->emetteur->isInEEC() &&
$object->thirdparty->isInEEC()))) {
1232 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1233 $pdf->SetXY($this->marge_gauche, $posy);
1234 if ($mysoc->forme_juridique_code == 92) {
1235 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1237 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1240 $posy = $pdf->GetY() + 4;
1245 if ($this->page_largeur < 210) {
1251 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1252 $pdf->SetXY($this->marge_gauche, $posy);
1253 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1254 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1256 $pdf->SetFont(
'',
'', $default_font_size - 2);
1257 $pdf->SetXY($posxval, $posy);
1258 $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);
1259 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1260 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1262 $posy = $pdf->GetY() + 3;
1266 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1267 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1268 $pdf->SetXY($this->marge_gauche, $posy);
1269 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1270 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1272 $pdf->SetFont(
'',
'', $default_font_size - 2);
1273 $pdf->SetXY($posxval, $posy);
1274 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1275 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1277 $posy = $pdf->GetY() + 3;
1282 if (empty(
$object->mode_reglement_code)
1285 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1289 $outputlangs->load(
"errors");
1291 $pdf->SetXY($this->marge_gauche, $posy);
1292 $pdf->SetTextColor(200, 0, 0);
1293 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1294 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1295 $pdf->MultiCell(80, 3, $this->error, 0,
'L', 0);
1296 $pdf->SetTextColor(0, 0, 0);
1298 $posy = $pdf->GetY() + 1;
1302 if (!empty(
$object->mode_reglement_code)
1303 &&
$object->mode_reglement_code !=
'CHQ'
1304 &&
$object->mode_reglement_code !=
'VIR') {
1305 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1306 $pdf->SetXY($this->marge_gauche, $posy);
1307 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1308 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1310 $pdf->SetFont(
'',
'', $default_font_size - 2);
1311 $pdf->SetXY($posxval, $posy);
1312 $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);
1314 if (
$object->mode_reglement_code ==
"PRE") {
1315 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1318 $bac->fetch(0,
'',
$object->thirdparty->id);
1319 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1320 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1322 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1324 $posy = $pdf->GetY();
1330 if ($this->emetteur->country_code ==
'FR') {
1332 $pdf->SetXY($this->marge_gauche, $posy);
1333 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1335 $posy = $pdf->GetY() + 1;
1340 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1341 $useonlinepayment = 0;
1345 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1346 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1347 $useonlinepayment = count($validpaymentmethod);
1351 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1354 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1355 $servicename = $langs->transnoentities(
'Online');
1356 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1357 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1359 $pdf->SetXY($this->marge_gauche, $posy);
1362 $posy = $pdf->GetY() + 1;
1367 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1373 $account =
new Account($this->db);
1376 $pdf->SetXY($this->marge_gauche, $posy);
1377 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1378 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1379 $posy = $pdf->GetY() + 1;
1382 $pdf->SetXY($this->marge_gauche, $posy);
1383 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1384 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1385 $posy = $pdf->GetY() + 2;
1388 if (
$conf->global->FACTURE_CHQ_NUMBER == -1) {
1389 $pdf->SetXY($this->marge_gauche, $posy);
1390 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1391 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1392 $posy = $pdf->GetY() + 1;
1395 $pdf->SetXY($this->marge_gauche, $posy);
1396 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1397 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1398 $posy = $pdf->GetY() + 2;
1405 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1407 $bankid = (
$object->fk_account <= 0 ?
$conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
1411 $account =
new Account($this->db);
1412 $account->fetch($bankid);
1414 $curx = $this->marge_gauche;
1417 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1422 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1425 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L', 0);
1451 global
$conf, $mysoc, $hookmanager;
1460 $outputlangsbis =
null;
1464 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1465 $default_font_size--;
1470 $pdf->SetFont(
'',
'', $default_font_size - 1);
1475 if ($this->page_largeur < 210) {
1479 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1485 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1488 $total_line_remise = 0;
1489 foreach (
$object->lines as $i => $line) {
1491 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1493 if ($line->total_ht < 0) {
1494 $total_line_remise += -$line->total_ht;
1497 if ($total_line_remise > 0) {
1498 $pdf->SetFillColor(255, 255, 255);
1499 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1500 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1501 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1502 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1507 $pdf->SetFillColor(255, 255, 255);
1508 $pdf->SetXY($col1x, $tab2_top);
1509 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1510 $pdf->SetXY($col2x, $tab2_top);
1511 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1517 $pdf->SetFillColor(255, 255, 255);
1518 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1519 $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);
1521 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1522 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1523 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1527 $pdf->SetFillColor(255, 255, 255);
1528 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1529 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalVAT"), 0,
'L', 1);
1531 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1532 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->total_tva), 0,
'R', 1);
1536 $pdf->SetFillColor(248, 248, 248);
1538 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1540 $this->atleastoneratenotnull = 0;
1542 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1543 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1547 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1548 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1552 foreach ($localtax_rate as $tvakey => $tvaval) {
1557 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1560 if (preg_match(
'/\*/', (
string) $tvakey)) {
1561 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1562 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1565 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1569 $totalvat .= $tvacompl;
1571 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1574 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1576 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1578 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1579 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1585 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1586 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1590 foreach ($localtax_rate as $tvakey => $tvaval) {
1595 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1598 if (preg_match(
'/\*/', (
string) $tvakey)) {
1599 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1600 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1602 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1606 $totalvat .= $tvacompl;
1608 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1611 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1613 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1615 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1616 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1623 foreach ($this->tva_array as $tvakey => $tvaval) {
1625 $this->atleastoneratenotnull++;
1628 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1631 if (preg_match(
'/\*/', $tvakey)) {
1632 $tvakey = str_replace(
'*',
'', $tvakey);
1633 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1635 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1638 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).$tvacompl;
1640 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1642 $totalvat .= $tvacompl;
1644 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1646 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1647 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1648 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1654 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1655 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1659 foreach ($localtax_rate as $tvakey => $tvaval) {
1664 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1667 if (preg_match(
'/\*/', (
string) $tvakey)) {
1668 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1669 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1671 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1674 $totalvat .= $tvacompl;
1676 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1679 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1681 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1683 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1684 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1690 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1691 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1695 foreach ($localtax_rate as $tvakey => $tvaval) {
1699 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1702 if (preg_match(
'/\*/', (
string) $tvakey)) {
1703 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1704 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1706 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1709 $totalvat .= $tvacompl;
1711 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1714 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1716 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1718 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1719 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1726 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1727 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp"), $useborder,
'L', 1);
1729 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1730 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1735 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1736 $pdf->SetTextColor(0, 0, 60);
1737 $pdf->SetFillColor(224, 224, 224);
1738 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1740 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1741 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1744 if (
$object->displayRetainedWarranty()) {
1745 $pdf->SetTextColor(40, 40, 40);
1746 $pdf->SetFillColor(255, 255, 255);
1748 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1749 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1753 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1754 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1756 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1757 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1761 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1763 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").
' ('.
$object->retained_warranty.
'%)';
1764 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1766 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1767 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1768 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1773 $pdf->SetTextColor(0, 0, 0);
1774 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1775 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1777 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1782 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1785 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1786 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L', 0);
1787 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1788 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1791 if ($creditnoteamount) {
1792 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1794 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1795 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1796 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1797 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1801 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1803 $pdf->SetFillColor(255, 255, 255);
1805 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1806 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L', 1);
1807 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1808 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R', 1);
1814 $pdf->SetTextColor(0, 0, 60);
1815 $pdf->SetFillColor(224, 224, 224);
1816 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1817 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1818 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1819 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1821 $pdf->SetFont(
'',
'', $default_font_size - 1);
1822 $pdf->SetTextColor(0, 0, 0);
1830 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1831 $pdf->MultiCell($col2x - $col1x, $tab2_hl,
$conf->global->BILL_TEXT_TOTAL_FOOTER, 0,
'L', 0);
1834 return ($tab2_top + ($tab2_hl * $index));
1851 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1861 $currency = !empty($currency) ? $currency :
$conf->currency;
1865 $pdf->SetTextColor(0, 0, 0);
1866 $pdf->SetFont(
'',
'', $default_font_size - 2);
1868 if (empty($hidetop)) {
1870 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
1871 $categoryOfOperations = $outputlangs->transnoentities(
"MentionCategoryOfOperations") .
' : ' . $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1872 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
1873 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
1876 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1877 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1878 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1882 $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')));
1886 $pdf->SetDrawColor(128, 128, 128);
1887 $pdf->SetFont(
'',
'', $default_font_size - 1);
1890 $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');
1892 if (empty($hidetop)) {
1893 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1895 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1896 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1900 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1901 if (empty($hidetop)) {
1908 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1909 if (empty($hidetop)) {
1910 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1911 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1915 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1916 if (empty($hidetop)) {
1917 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1918 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1921 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1922 if (empty($hidetop)) {
1923 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1924 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1928 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1929 if (empty($hidetop)) {
1930 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1931 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1935 if ($this->atleastonediscount) {
1936 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1937 if (empty($hidetop)) {
1938 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1939 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1943 if ($this->situationinvoice) {
1944 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1945 if (empty($hidetop)) {
1946 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1947 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities(
"ProgressShort"),
'',
'C');
1951 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1952 if (empty($hidetop)) {
1953 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1954 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1969 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1972 global
$conf, $langs;
1974 $ltrdirection =
'L';
1975 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1976 $ltrdirection =
'R';
1980 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
1986 $pdf->SetTextColor(0, 0, 60);
1987 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1991 $posy = $this->marge_haute;
1992 $posx = $this->page_largeur - $this->marge_droite - $w;
1994 $pdf->SetXY($this->marge_gauche, $posy);
1998 if ($this->emetteur->logo) {
1999 $logodir =
$conf->mycompany->dir_output;
2000 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
2001 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
2004 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2006 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2008 if (is_readable($logo)) {
2010 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2012 $pdf->SetTextColor(200, 0, 0);
2013 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2014 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2015 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2018 $text = $this->emetteur->name;
2019 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2023 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2024 $pdf->SetXY($posx, $posy);
2025 $pdf->SetTextColor(0, 0, 60);
2026 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2028 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2031 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2034 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2037 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2039 if ($this->situationinvoice) {
2040 $langs->loadLangs(array(
"other"));
2041 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
2043 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2046 if ($this->situationinvoice) {
2047 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2049 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2050 } elseif (
$object->type == 1) {
2051 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2052 } elseif (
$object->type == 2) {
2053 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2054 } elseif (
$object->type == 3) {
2055 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2056 } elseif (
$object->type == 4) {
2057 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2060 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2061 if (
$object->status == $object::STATUS_DRAFT) {
2062 $pdf->SetTextColor(128, 0, 0);
2063 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2066 $pdf->MultiCell($w, 3, $title,
'',
'R');
2068 $pdf->SetFont(
'',
'B', $default_font_size);
2082 $pdf->SetFont(
'',
'', $default_font_size - 2);
2086 $pdf->SetXY($posx, $posy);
2087 $pdf->SetTextColor(0, 0, 60);
2088 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_customer),
'',
'R');
2093 if (!empty(
$object->project->ref)) {
2095 $pdf->SetXY($posx, $posy);
2096 $pdf->SetTextColor(0, 0, 60);
2097 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2103 if (!empty(
$object->project->ref)) {
2104 $outputlangs->load(
"projects");
2106 $pdf->SetXY($posx, $posy);
2107 $pdf->SetTextColor(0, 0, 60);
2108 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2112 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2113 if (
$object->type == 0 && $objectidnext) {
2114 $objectreplacing =
new Facture($this->db);
2115 $objectreplacing->fetch($objectidnext);
2118 $pdf->SetXY($posx, $posy);
2119 $pdf->SetTextColor(0, 0, 60);
2120 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2123 $objectreplaced =
new Facture($this->db);
2124 $objectreplaced->fetch(
$object->fk_facture_source);
2127 $pdf->SetXY($posx, $posy);
2128 $pdf->SetTextColor(0, 0, 60);
2129 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2132 $objectreplaced =
new Facture($this->db);
2133 $objectreplaced->fetch(
$object->fk_facture_source);
2136 $pdf->SetXY($posx, $posy);
2137 $pdf->SetTextColor(0, 0, 60);
2138 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2142 $pdf->SetXY($posx, $posy);
2143 $pdf->SetTextColor(0, 0, 60);
2144 $title = $outputlangs->transnoentities(
"DateInvoice");
2145 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2146 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2148 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2152 $pdf->SetXY($posx, $posy);
2153 $pdf->SetTextColor(0, 0, 60);
2154 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2159 $pdf->SetXY($posx, $posy);
2160 $pdf->SetTextColor(0, 0, 60);
2161 $title = $outputlangs->transnoentities(
"DateDue");
2162 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2163 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2165 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2170 $pdf->SetXY($posx, $posy);
2171 $pdf->SetTextColor(0, 0, 60);
2172 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2177 $pdf->SetXY($posx, $posy);
2178 $pdf->SetTextColor(0, 0, 60);
2179 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
2184 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2185 if (count($arrayidcontact) > 0) {
2186 $usertmp =
new User($this->db);
2187 $usertmp->fetch($arrayidcontact[0]);
2189 $pdf->SetXY($posx, $posy);
2190 $pdf->SetTextColor(0, 0, 60);
2191 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2199 $current_y = $pdf->getY();
2201 if ($current_y < $pdf->getY()) {
2202 $top_shift = $pdf->getY() - $current_y;
2207 $carac_emetteur =
'';
2209 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2210 if (count($arrayidcontact) > 0) {
2211 $object->fetch_user($arrayidcontact[0]);
2212 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2213 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2214 $carac_emetteur .=
"\n";
2221 $posy += $top_shift;
2222 $posx = $this->marge_gauche;
2224 $posx = $this->page_largeur - $this->marge_droite - 80;
2233 $pdf->SetTextColor(0, 0, 0);
2234 $pdf->SetFont(
'',
'', $default_font_size - 2);
2235 $pdf->SetXY($posx, $posy - 5);
2236 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2237 $pdf->SetXY($posx, $posy);
2238 $pdf->SetFillColor(230, 230, 230);
2239 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2240 $pdf->SetTextColor(0, 0, 60);
2245 $pdf->SetXY($posx + 2, $posy + 3);
2246 $pdf->SetFont(
'',
'B', $default_font_size);
2247 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2248 $posy = $pdf->getY();
2252 $pdf->SetXY($posx + 2, $posy);
2253 $pdf->SetFont(
'',
'', $default_font_size - 1);
2254 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2258 $usecontact =
false;
2259 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2260 if (count($arrayidcontact) > 0) {
2262 $result =
$object->fetch_contact($arrayidcontact[0]);
2266 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2267 $thirdparty =
$object->contact;
2269 $thirdparty =
$object->thirdparty;
2279 if ($this->page_largeur < 210) {
2283 $posy += $top_shift;
2284 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2286 $posx = $this->marge_gauche;
2291 $pdf->SetTextColor(0, 0, 0);
2292 $pdf->SetFont(
'',
'', $default_font_size - 2);
2293 $pdf->SetXY($posx + 2, $posy - 5);
2294 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2295 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2299 $pdf->SetXY($posx + 2, $posy + 3);
2300 $pdf->SetFont(
'',
'B', $default_font_size);
2302 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2304 $posy = $pdf->getY();
2307 $pdf->SetFont(
'',
'', $default_font_size - 1);
2308 $pdf->SetXY($posx + 2, $posy);
2310 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2314 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2316 if (!empty($idaddressshipping)) {
2317 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2318 $companystatic =
new Societe($this->db);
2319 $companystatic->fetch(
$object->contact->fk_soc);
2321 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
2326 if (!empty($carac_client_shipping)) {
2327 $posy += $hautcadre;
2332 $pdf->SetXY($posx + 2, $posy - 5);
2333 $pdf->SetFont(
'',
'', $default_font_size - 2);
2334 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2335 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2338 $pdf->SetXY($posx + 2, $posy + 3);
2339 $pdf->SetFont(
'',
'B', $default_font_size);
2340 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2342 $posy = $pdf->getY();
2345 $pdf->SetXY($posx + 2, $posy);
2346 $pdf->SetFont(
'',
'', $default_font_size - 1);
2347 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2349 $top_shift += $hautcadre + 10;
2354 $pdf->SetTextColor(0, 0, 0);