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 $mysoc, $hookmanager;
1169 $pdf->SetFont(
'',
'', $default_font_size - 1);
1171 krsort($this->tva_array);
1178 $pdf->SetFillColor(224, 224, 224);
1180 $pdf->SetFont(
'',
'', $default_font_size - 2);
1181 $pdf->SetXY($this->marge_gauche, $posy);
1182 $titre = $outputlangs->transnoentities(
"VAT");
1183 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1185 $pdf->SetFont(
'',
'', $default_font_size - 2);
1186 $pdf->SetXY($this->marge_gauche + 25, $posy);
1187 $titre = $outputlangs->transnoentities(
"NetTotal");
1188 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1190 $pdf->SetFont(
'',
'', $default_font_size - 2);
1191 $pdf->SetXY($this->marge_gauche + 50, $posy);
1192 $titre = $outputlangs->transnoentities(
"VATAmount");
1193 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1195 $pdf->SetFont(
'',
'', $default_font_size - 2);
1196 $pdf->SetXY($this->marge_gauche + 75, $posy);
1197 $titre = $outputlangs->transnoentities(
"AmountTotal");
1198 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1200 $posy = $pdf->GetY();
1205 foreach ($this->tva_array as $tvakey => $tvaval) {
1206 $pdf->SetFont(
'',
'', $default_font_size - 2);
1207 $pdf->SetXY($this->marge_gauche, $posy);
1208 $titre = round((
float) $tvakey, 2) .
"%";
1209 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1211 $pdf->SetFont(
'',
'', $default_font_size - 2);
1212 $pdf->SetXY($this->marge_gauche + 25, $posy);
1213 $titre =
price($tvaval[
'tot_ht']);
1214 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1215 $tot_ht += $tvaval[
'tot_ht'];
1217 $pdf->SetFont(
'',
'', $default_font_size - 2);
1218 $pdf->SetXY($this->marge_gauche + 50, $posy);
1219 $titre =
price($tvaval[
'amount']);
1220 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1221 $tot_tva += $tvaval[
'amount'];
1223 $pdf->SetFont(
'',
'', $default_font_size - 2);
1224 $pdf->SetXY($this->marge_gauche + 75, $posy);
1225 $titre =
price($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1226 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1227 $tot_ttc += ($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1229 $posy = $pdf->GetY();
1234 if (in_array($this->emetteur->country_code, array(
'FR')) && empty(
$object->total_tva)) {
1235 $pdf->SetFont(
'',
'', $default_font_size - 2);
1236 $pdf->SetXY($this->marge_gauche, $posy);
1237 if (empty($mysoc->tva_assuj)) {
1238 if ($mysoc->forme_juridique_code == 92) {
1239 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1241 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1243 } elseif (
getDolGlobalString(
"INVOICE_VAT_SHOW_REVERSE_CHARGE_MENTION") && $this->emetteur->country_code !=
$object->thirdparty->country_code && $this->emetteur->isInEEC() &&
$object->thirdparty->isInEEC()) {
1244 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedReverseChargeProcedure"), 0,
'L', 0);
1246 $posy = $pdf->GetY() + 4;
1251 if ($this->page_largeur < 210) {
1257 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1258 $pdf->SetXY($this->marge_gauche, $posy);
1259 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1260 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1262 $pdf->SetFont(
'',
'', $default_font_size - 2);
1263 $pdf->SetXY($posxval, $posy);
1264 $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);
1265 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1266 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1268 $posy = $pdf->GetY() + 3;
1272 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1273 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1274 $pdf->SetXY($this->marge_gauche, $posy);
1275 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1276 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1278 $pdf->SetFont(
'',
'', $default_font_size - 2);
1279 $pdf->SetXY($posxval, $posy);
1280 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1281 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1283 $posy = $pdf->GetY() + 3;
1288 if (empty(
$object->mode_reglement_code)
1291 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1295 $outputlangs->load(
"errors");
1297 $pdf->SetXY($this->marge_gauche, $posy);
1298 $pdf->SetTextColor(200, 0, 0);
1299 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1300 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1301 $pdf->MultiCell(80, 3, $this->error, 0,
'L', 0);
1302 $pdf->SetTextColor(0, 0, 0);
1304 $posy = $pdf->GetY() + 1;
1308 if (!empty(
$object->mode_reglement_code)
1309 &&
$object->mode_reglement_code !=
'CHQ'
1310 &&
$object->mode_reglement_code !=
'VIR') {
1311 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1312 $pdf->SetXY($this->marge_gauche, $posy);
1313 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1314 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1316 $pdf->SetFont(
'',
'', $default_font_size - 2);
1317 $pdf->SetXY($posxval, $posy);
1318 $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);
1320 if (
$object->mode_reglement_code ==
"PRE") {
1321 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1324 $bac->fetch(0,
'',
$object->thirdparty->id);
1325 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1326 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1328 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1330 $posy = $pdf->GetY();
1336 if ($this->emetteur->country_code ==
'FR') {
1338 $pdf->SetXY($this->marge_gauche, $posy);
1339 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1341 $posy = $pdf->GetY() + 1;
1346 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1347 $useonlinepayment = 0;
1351 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1352 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1353 $useonlinepayment = count($validpaymentmethod);
1357 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1360 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1361 $servicename = $langs->transnoentities(
'Online');
1362 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1363 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1365 $pdf->SetXY($this->marge_gauche, $posy);
1368 $posy = $pdf->GetY() + 1;
1373 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1379 $account =
new Account($this->db);
1382 $pdf->SetXY($this->marge_gauche, $posy);
1383 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1384 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1385 $posy = $pdf->GetY() + 1;
1388 $pdf->SetXY($this->marge_gauche, $posy);
1389 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1390 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1391 $posy = $pdf->GetY() + 2;
1395 $pdf->SetXY($this->marge_gauche, $posy);
1396 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1397 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1398 $posy = $pdf->GetY() + 1;
1401 $pdf->SetXY($this->marge_gauche, $posy);
1402 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1403 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1404 $posy = $pdf->GetY() + 2;
1411 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1417 $account =
new Account($this->db);
1418 $account->fetch($bankid);
1420 $curx = $this->marge_gauche;
1423 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1428 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1431 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L', 0);
1457 global
$conf, $mysoc, $hookmanager;
1466 $outputlangsbis =
null;
1470 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1471 $default_font_size--;
1476 $pdf->SetFont(
'',
'', $default_font_size - 1);
1481 if ($this->page_largeur < 210) {
1485 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1491 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1494 $total_line_remise = 0;
1495 foreach (
$object->lines as $i => $line) {
1497 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1499 if ($line->total_ht < 0) {
1500 $total_line_remise += -$line->total_ht;
1503 if ($total_line_remise > 0) {
1504 $pdf->SetFillColor(255, 255, 255);
1505 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1506 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1507 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1508 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1513 $pdf->SetFillColor(255, 255, 255);
1514 $pdf->SetXY($col1x, $tab2_top);
1515 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1516 $pdf->SetXY($col2x, $tab2_top);
1517 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1523 $pdf->SetFillColor(255, 255, 255);
1524 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1525 $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);
1527 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1528 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1529 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1533 $pdf->SetFillColor(255, 255, 255);
1534 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1535 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalVAT"), 0,
'L', 1);
1537 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1538 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->total_tva), 0,
'R', 1);
1542 $pdf->SetFillColor(248, 248, 248);
1544 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1546 $this->atleastoneratenotnull = 0;
1548 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1549 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1553 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1554 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1558 foreach ($localtax_rate as $tvakey => $tvaval) {
1563 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1566 if (preg_match(
'/\*/', (
string) $tvakey)) {
1567 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1568 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1571 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1575 $totalvat .= $tvacompl;
1577 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1580 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1582 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1584 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1585 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1591 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1592 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1596 foreach ($localtax_rate as $tvakey => $tvaval) {
1601 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1604 if (preg_match(
'/\*/', (
string) $tvakey)) {
1605 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1606 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1608 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1612 $totalvat .= $tvacompl;
1614 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1617 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1619 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1621 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1622 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1629 foreach ($this->tva_array as $tvakey => $tvaval) {
1631 $this->atleastoneratenotnull++;
1634 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1637 if (preg_match(
'/\*/', $tvakey)) {
1638 $tvakey = str_replace(
'*',
'', $tvakey);
1639 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1641 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1644 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).$tvacompl;
1646 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1648 $totalvat .= $tvacompl;
1650 $totalvat .=
vatrate($tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1652 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1653 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1654 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1660 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1661 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1665 foreach ($localtax_rate as $tvakey => $tvaval) {
1670 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1673 if (preg_match(
'/\*/', (
string) $tvakey)) {
1674 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1675 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1677 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1680 $totalvat .= $tvacompl;
1682 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1685 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1687 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1689 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1690 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1696 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1697 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1701 foreach ($localtax_rate as $tvakey => $tvaval) {
1705 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1708 if (preg_match(
'/\*/', (
string) $tvakey)) {
1709 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1710 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1712 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1715 $totalvat .= $tvacompl;
1717 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1720 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1722 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1724 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1725 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1732 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1733 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp"), $useborder,
'L', 1);
1735 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1736 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R', 1);
1741 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1742 $pdf->SetTextColor(0, 0, 60);
1743 $pdf->SetFillColor(224, 224, 224);
1744 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1746 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1747 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1750 if (
$object->displayRetainedWarranty()) {
1751 $pdf->SetTextColor(40, 40, 40);
1752 $pdf->SetFillColor(255, 255, 255);
1754 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1755 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1759 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1760 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1762 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1763 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1767 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1769 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").
' ('.
$object->retained_warranty.
'%)';
1770 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1772 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1773 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1774 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1779 $pdf->SetTextColor(0, 0, 0);
1780 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1781 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1783 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1788 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1791 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1792 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L', 0);
1793 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1794 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1797 if ($creditnoteamount) {
1798 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1800 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1801 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1802 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1803 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1807 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1809 $pdf->SetFillColor(255, 255, 255);
1811 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1812 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L', 1);
1813 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1814 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R', 1);
1820 $pdf->SetTextColor(0, 0, 60);
1821 $pdf->SetFillColor(224, 224, 224);
1822 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1823 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1824 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1825 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1827 $pdf->SetFont(
'',
'', $default_font_size - 1);
1828 $pdf->SetTextColor(0, 0, 0);
1836 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1837 $pdf->MultiCell($col2x - $col1x, $tab2_hl,
getDolGlobalString(
'BILL_TEXT_TOTAL_FOOTER'), 0,
'L', 0);
1840 return ($tab2_top + ($tab2_hl * $index));
1857 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1867 $currency = !empty($currency) ? $currency :
$conf->currency;
1871 $pdf->SetTextColor(0, 0, 0);
1872 $pdf->SetFont(
'',
'', $default_font_size - 2);
1874 if (empty($hidetop)) {
1876 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
1877 $categoryOfOperations = $outputlangs->transnoentities(
"MentionCategoryOfOperations") .
' : ' . $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1878 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
1879 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
1882 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1883 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1884 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1887 $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')));
1891 $pdf->SetDrawColor(128, 128, 128);
1892 $pdf->SetFont(
'',
'', $default_font_size - 1);
1895 $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');
1897 if (empty($hidetop)) {
1898 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1900 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1901 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1905 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1906 if (empty($hidetop)) {
1913 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1914 if (empty($hidetop)) {
1915 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1916 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1920 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1921 if (empty($hidetop)) {
1922 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1923 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1926 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1927 if (empty($hidetop)) {
1928 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1929 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1933 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1934 if (empty($hidetop)) {
1935 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1936 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1940 if ($this->atleastonediscount) {
1941 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1942 if (empty($hidetop)) {
1943 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1944 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1948 if ($this->situationinvoice) {
1949 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1950 if (empty($hidetop)) {
1951 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1952 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities(
"ProgressShort"),
'',
'C');
1956 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1957 if (empty($hidetop)) {
1958 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1959 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1974 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1977 global
$conf, $langs;
1979 $ltrdirection =
'L';
1980 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1981 $ltrdirection =
'R';
1985 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
1991 $pdf->SetTextColor(0, 0, 60);
1992 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1996 $posy = $this->marge_haute;
1997 $posx = $this->page_largeur - $this->marge_droite - $w;
1999 $pdf->SetXY($this->marge_gauche, $posy);
2003 if ($this->emetteur->logo) {
2004 $logodir =
$conf->mycompany->dir_output;
2005 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
2006 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
2009 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2011 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2013 if (is_readable($logo)) {
2015 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2017 $pdf->SetTextColor(200, 0, 0);
2018 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2019 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2020 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2023 $text = $this->emetteur->name;
2024 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2028 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2029 $pdf->SetXY($posx, $posy);
2030 $pdf->SetTextColor(0, 0, 60);
2031 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2033 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2036 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2039 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2042 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2044 if ($this->situationinvoice) {
2045 $langs->loadLangs(array(
"other"));
2046 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
2048 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2051 if ($this->situationinvoice) {
2052 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2054 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2055 } elseif (
$object->type == 1) {
2056 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2057 } elseif (
$object->type == 2) {
2058 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2059 } elseif (
$object->type == 3) {
2060 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2061 } elseif (
$object->type == 4) {
2062 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2065 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2066 if (
$object->status == $object::STATUS_DRAFT) {
2067 $pdf->SetTextColor(128, 0, 0);
2068 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2071 $pdf->MultiCell($w, 3, $title,
'',
'R');
2073 $pdf->SetFont(
'',
'B', $default_font_size);
2087 $pdf->SetFont(
'',
'', $default_font_size - 2);
2091 $pdf->SetXY($posx, $posy);
2092 $pdf->SetTextColor(0, 0, 60);
2093 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_customer),
'',
'R');
2098 if (!empty(
$object->project->ref)) {
2100 $pdf->SetXY($posx, $posy);
2101 $pdf->SetTextColor(0, 0, 60);
2102 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2108 if (!empty(
$object->project->ref)) {
2109 $outputlangs->load(
"projects");
2111 $pdf->SetXY($posx, $posy);
2112 $pdf->SetTextColor(0, 0, 60);
2113 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2117 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2118 if (
$object->type == 0 && $objectidnext) {
2119 $objectreplacing =
new Facture($this->db);
2120 $objectreplacing->fetch($objectidnext);
2123 $pdf->SetXY($posx, $posy);
2124 $pdf->SetTextColor(0, 0, 60);
2125 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2128 $objectreplaced =
new Facture($this->db);
2129 $objectreplaced->fetch(
$object->fk_facture_source);
2132 $pdf->SetXY($posx, $posy);
2133 $pdf->SetTextColor(0, 0, 60);
2134 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2137 $objectreplaced =
new Facture($this->db);
2138 $objectreplaced->fetch(
$object->fk_facture_source);
2141 $pdf->SetXY($posx, $posy);
2142 $pdf->SetTextColor(0, 0, 60);
2143 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2147 $pdf->SetXY($posx, $posy);
2148 $pdf->SetTextColor(0, 0, 60);
2149 $title = $outputlangs->transnoentities(
"DateInvoice");
2150 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2151 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2153 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2157 $pdf->SetXY($posx, $posy);
2158 $pdf->SetTextColor(0, 0, 60);
2159 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2164 $pdf->SetXY($posx, $posy);
2165 $pdf->SetTextColor(0, 0, 60);
2166 $title = $outputlangs->transnoentities(
"DateDue");
2167 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2168 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2170 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2175 $pdf->SetXY($posx, $posy);
2176 $pdf->SetTextColor(0, 0, 60);
2177 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2182 $pdf->SetXY($posx, $posy);
2183 $pdf->SetTextColor(0, 0, 60);
2184 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
2189 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2190 if (count($arrayidcontact) > 0) {
2191 $usertmp =
new User($this->db);
2192 $usertmp->fetch($arrayidcontact[0]);
2194 $pdf->SetXY($posx, $posy);
2195 $pdf->SetTextColor(0, 0, 60);
2196 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2204 $current_y = $pdf->getY();
2206 if ($current_y < $pdf->getY()) {
2207 $top_shift = $pdf->getY() - $current_y;
2212 $carac_emetteur =
'';
2214 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2215 if (count($arrayidcontact) > 0) {
2216 $object->fetch_user($arrayidcontact[0]);
2217 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2218 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2219 $carac_emetteur .=
"\n";
2226 $posy += $top_shift;
2227 $posx = $this->marge_gauche;
2229 $posx = $this->page_largeur - $this->marge_droite - 80;
2238 $pdf->SetTextColor(0, 0, 0);
2239 $pdf->SetFont(
'',
'', $default_font_size - 2);
2240 $pdf->SetXY($posx, $posy - 5);
2241 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2242 $pdf->SetXY($posx, $posy);
2243 $pdf->SetFillColor(230, 230, 230);
2244 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2245 $pdf->SetTextColor(0, 0, 60);
2250 $pdf->SetXY($posx + 2, $posy + 3);
2251 $pdf->SetFont(
'',
'B', $default_font_size);
2252 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2253 $posy = $pdf->getY();
2257 $pdf->SetXY($posx + 2, $posy);
2258 $pdf->SetFont(
'',
'', $default_font_size - 1);
2259 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2263 $usecontact =
false;
2264 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2265 if (count($arrayidcontact) > 0) {
2267 $result =
$object->fetch_contact($arrayidcontact[0]);
2271 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2272 $thirdparty =
$object->contact;
2274 $thirdparty =
$object->thirdparty;
2284 if ($this->page_largeur < 210) {
2288 $posy += $top_shift;
2289 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2291 $posx = $this->marge_gauche;
2296 $pdf->SetTextColor(0, 0, 0);
2297 $pdf->SetFont(
'',
'', $default_font_size - 2);
2298 $pdf->SetXY($posx + 2, $posy - 5);
2299 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2300 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2304 $pdf->SetXY($posx + 2, $posy + 3);
2305 $pdf->SetFont(
'',
'B', $default_font_size);
2307 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2309 $posy = $pdf->getY();
2312 $pdf->SetFont(
'',
'', $default_font_size - 1);
2313 $pdf->SetXY($posx + 2, $posy);
2315 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2319 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2321 if (!empty($idaddressshipping)) {
2322 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2323 $companystatic =
new Societe($this->db);
2324 $companystatic->fetch(
$object->contact->fk_soc);
2326 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
2331 if (!empty($carac_client_shipping)) {
2332 $posy += $hautcadre;
2337 $pdf->SetXY($posx + 2, $posy - 5);
2338 $pdf->SetFont(
'',
'', $default_font_size - 2);
2339 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
2340 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2343 $pdf->SetXY($posx + 2, $posy + 3);
2344 $pdf->SetFont(
'',
'B', $default_font_size);
2345 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2347 $posy = $pdf->getY();
2350 $pdf->SetXY($posx + 2, $posy);
2351 $pdf->SetFont(
'',
'', $default_font_size - 1);
2352 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2354 $top_shift += $hautcadre + 10;
2359 $pdf->SetTextColor(0, 0, 0);