163 public function write_file(
$object, $outputlangs =
null, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
166 global $user, $langs,
$conf,
$mysoc, $hookmanager, $nblines;
169 if (!is_object(
$object->thirdparty)) {
172 if (!is_object(
$object->thirdparty)) {
176 $this->emetteur =
$object->thirdparty;
177 if (!$this->emetteur->country_code) {
178 $this->emetteur->country_code = substr($langs->defaultlang, -2);
181 if (!is_object($outputlangs)) {
182 $outputlangs = $langs;
186 $outputlangs->charset_output =
'ISO-8859-1';
190 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products"));
192 $nblines = count(
$object->lines);
194 if (
$conf->fournisseur->facture->dir_output) {
196 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
197 $amount_deposits_included =
$object->getSumDepositsUsed((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
201 $dir =
$conf->fournisseur->facture->dir_output;
202 $file = $dir.
"/SPECIMEN.pdf";
207 $file = $dir.
"/".$objectref.
".pdf";
209 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
213 if (!file_exists($dir)) {
215 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
220 if (file_exists($dir)) {
222 if (!is_object($hookmanager)) {
223 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
226 $hookmanager->initHooks(array(
'pdfgeneration'));
227 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
229 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
232 $nblines = count(
$object->lines);
233 $nbpayments = count(
$object->getListOfPayments());
238 $pdf->setAutoPageBreak(
true, 0);
240 $heightforinfotot = 50 + (4 * $nbpayments);
241 if ($heightforinfotot > 220) {
242 $heightforinfotot = 220;
245 $heightforfooter = $this->marge_basse + 8;
247 $heightforfooter += 6;
250 if (class_exists(
'TCPDF')) {
251 $pdf->setPrintHeader(
false);
252 $pdf->setPrintFooter(
false);
257 $logodir =
$conf->mycompany->dir_output;
258 if (!empty(
$conf->mycompany->multidir_output[
$object->entity ??
$conf->entity])) {
261 $pagecount = $pdf->setSourceFile($logodir .
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
262 $tplidx = $pdf->importPage(1);
267 $pdf->SetDrawColor(128, 128, 128);
269 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
270 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
271 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
272 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)));
273 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
275 $pdf->SetCompression(
false);
279 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
282 for ($i = 0; $i < $nblines; $i++) {
283 if (
$object->lines[$i]->remise_percent) {
284 $this->atleastonediscount++;
287 if (empty($this->atleastonediscount)) {
288 $delta = ($this->postotalht - $this->posxdiscount);
289 $this->posxpicture += $delta;
290 $this->posxtva += $delta;
291 $this->posxup += $delta;
292 $this->posxqty += $delta;
293 $this->posxunit += $delta;
294 $this->posxdiscount += $delta;
300 if (!empty($tplidx)) {
301 $pdf->useTemplate($tplidx);
305 $pdf->SetFont(
'',
'', $default_font_size - 1);
306 $pdf->MultiCell(0, 3,
'');
307 $pdf->SetTextColor(0, 0, 0);
309 $tab_top = 90 + $top_shift;
310 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
314 $desc_incoterms =
$object->getIncotermsForPDF();
315 if ($desc_incoterms) {
318 $pdf->SetFont(
'',
'', $default_font_size - 1);
319 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
320 $nexY = $pdf->GetY();
321 $height_incoterms = $nexY - $tab_top;
324 $pdf->SetDrawColor(192, 192, 192);
325 $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');
327 $tab_top = $nexY + 6;
332 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
336 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
337 if (!empty($extranote)) {
350 $pdf->SetFont(
'',
'', $default_font_size - 1);
351 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
352 $nexY = $pdf->GetY();
353 $height_note = $nexY - $tab_top;
356 $pdf->SetDrawColor(192, 192, 192);
357 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius,
'1234',
'D');
359 $tab_top = $nexY + 6;
362 $iniY = $tab_top + 7;
363 $curY = $tab_top + 7;
364 $nexY = $tab_top + 7;
366 'titleshowuponpdf' => 1,
367 'titleshowtotalexludingvatonpdf' => 1,
371 for ($i = 0; $i < $nblines; $i++) {
372 $sub_options =
$object->lines[$i]->extraparams[
"subtotal"] ?? array();
374 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
375 $level =
$object->lines[$i]->qty;
377 if (isset($sub_options[
'titleshowuponpdf'])) {
378 $pdf_sub_options[
'titleshowuponpdf'] = isset($pdf_sub_options[
'titleshowuponpdf']) && $pdf_sub_options[
'titleshowuponpdf'] < $level ? $pdf_sub_options[
'titleshowuponpdf'] : $level;
379 } elseif (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
380 unset($pdf_sub_options[
'titleshowuponpdf']);
382 if (isset($sub_options[
'titleshowtotalexludingvatonpdf'])) {
383 $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] = isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] < $level ? $pdf_sub_options[
'titleshowtotalexludingvatonpdf'] : $level;
384 } elseif (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
385 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
388 if (isset($pdf_sub_options[
'titleshowuponpdf']) && abs($level) <= $pdf_sub_options[
'titleshowuponpdf']) {
389 unset($pdf_sub_options[
'titleshowuponpdf']);
391 if (isset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']) && abs($level) <= $pdf_sub_options[
'titleshowtotalexludingvatonpdf']) {
392 unset($pdf_sub_options[
'titleshowtotalexludingvatonpdf']);
397 $pdf->SetFont(
'',
'', $default_font_size - 1);
398 $pdf->SetTextColor(0, 0, 0);
406 $pdf->setTopMargin($tab_top_newpage);
407 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
408 $pageposbefore = $pdf->getPage();
410 $showpricebeforepagebreak = 1;
414 $curX = $this->posxdesc - 1;
416 $pdf->startTransaction();
417 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc, 1);
418 $pageposafter = $pdf->getPage();
419 if ($pageposafter > $pageposbefore) {
420 $pdf->rollbackTransaction(
true);
421 $pageposafter = $pageposbefore;
423 $pdf->setPageOrientation(
'',
true, $heightforfooter);
424 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc, 1);
425 $posyafter = $pdf->GetY();
426 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
427 if ($i == ($nblines - 1)) {
428 $pdf->AddPage(
'',
'',
true);
429 if (!empty($tplidx)) {
430 $pdf->useTemplate($tplidx);
435 $pdf->setPage($pageposafter + 1);
441 $showpricebeforepagebreak = 1;
443 $showpricebeforepagebreak = 0;
447 $pdf->commitTransaction();
449 $posYAfterDescription = $pdf->GetY();
451 $nexY = $pdf->GetY();
452 $pageposafter = $pdf->getPage();
453 $pdf->setPage($pageposbefore);
454 $pdf->setTopMargin($this->marge_haute);
455 $pdf->setPageOrientation(
'',
true, 0);
458 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
459 $pdf->setPage($pageposafter);
460 $curY = $tab_top_newpage;
463 $pdf->SetFont(
'',
'', $default_font_size - 1);
468 $pdf->SetXY($this->posxtva, $curY);
469 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0,
'R');
474 $pdf->SetXY($this->posxup, $curY);
475 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R',
false);
479 $pdf->SetXY($this->posxqty, $curY);
480 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
485 $pdf->SetXY($this->posxunit, $curY);
486 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
490 if (
$object->lines[$i]->remise_percent) {
491 $pdf->SetXY($this->posxdiscount - 2, $curY);
493 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0,
'R');
498 $pdf->SetXY($this->postotalht, $curY);
499 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R',
false);
503 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
505 $tvaligne =
$object->lines[$i]->total_tva;
508 $localtax1ligne =
$object->lines[$i]->total_localtax1;
509 $localtax2ligne =
$object->lines[$i]->total_localtax2;
520 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
523 if (empty($this->tva[$vatrate])) {
524 $this->tva[$vatrate] = 0;
526 if (empty($this->localtax1[$localtax1rate])) {
527 $this->localtax1[$localtax1rate] = 0;
529 if (empty($this->localtax2[$localtax2rate])) {
530 $this->localtax2[$localtax2rate] = 0;
532 $this->tva[$vatrate] += $tvaligne;
533 $this->localtax1[$localtax1rate] += $localtax1ligne;
534 $this->localtax2[$localtax2rate] += $localtax2ligne;
536 if ($posYAfterImage > $posYAfterDescription) {
537 $nexY = $posYAfterImage;
542 $pdf->setPage($pageposafter);
543 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
545 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
546 $pdf->SetLineStyle(array(
'dash' => 0));
552 while ($pagenb < $pageposafter) {
553 $pdf->setPage($pagenb);
555 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
557 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
561 $pdf->setPage($pagenb);
562 $pdf->setPageOrientation(
'',
true, 0);
567 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
569 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
571 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
576 if (!empty($tplidx)) {
577 $pdf->useTemplate($tplidx);
588 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
589 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
591 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
592 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
598 $amount_credit_notes_included = 0;
599 $amount_deposits_included = 0;
602 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'SUPPLIER_INVOICE_NO_PAYMENT_DETAILS')) {
608 if (method_exists($pdf,
'AliasNbPages')) {
609 $pdf->AliasNbPages();
614 $pdf->Output($file,
'F');
617 $hookmanager->initHooks(array(
'pdfgeneration'));
618 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
620 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
621 $this->warnings = $hookmanager->warnings;
623 $this->error = $hookmanager->error;
624 $this->errors = $hookmanager->errors;
631 $this->result = array(
'fullpath' => $file);
635 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
639 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
670 $pdf->SetFont(
'',
'', $default_font_size - 1);
675 if ($this->page_largeur < 210) {
678 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
684 $pdf->SetFillColor(255, 255, 255);
685 $pdf->SetXY($col1x, $tab2_top);
686 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L',
true);
689 $pdf->SetXY($col2x, $tab2_top);
690 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R',
true);
693 $pdf->SetFillColor(248, 248, 248);
697 $this->atleastoneratenotnull = 0;
698 foreach ($this->tva as $tvakey => $tvaval) {
700 $this->atleastoneratenotnull++;
703 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
707 if (preg_match(
'/\*/', $tvakey)) {
708 $tvakey = str_replace(
'*',
'', $tvakey);
709 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
712 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).
' ';
713 $totalvat .=
vatrate($tvakey,
true).$tvacompl;
714 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
716 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
717 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R',
true);
720 if (!$this->atleastoneratenotnull) {
722 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
723 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code), 0,
'L',
true);
724 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
725 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva, 0, $outputlangs), 0,
'R',
true);
730 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
731 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code), 0,
'L',
true);
732 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
733 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1, 0, $outputlangs), 0,
'R',
true);
739 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
740 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code), 0,
'L',
true);
741 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
742 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2, 0, $outputlangs), 0,
'R',
true);
748 foreach ($this->localtax1 as $tvakey => $tvaval) {
753 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
756 if (preg_match(
'/\*/', (
string) $tvakey)) {
757 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
758 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
760 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
761 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
762 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
764 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
765 $pdf->MultiCell($largcol2, $tab2_hl,
price((
string) $tvaval, 0, $outputlangs), 0,
'R',
true);
773 foreach ($this->localtax2 as $tvakey => $tvaval) {
778 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
781 if (preg_match(
'/\*/', (
string) $tvakey)) {
782 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
783 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
785 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
786 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
787 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
789 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
790 $pdf->MultiCell($largcol2, $tab2_hl,
price((
string) $tvaval, 0, $outputlangs), 0,
'R',
true);
798 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
799 $pdf->SetTextColor(0, 0, 60);
800 $pdf->SetFillColor(224, 224, 224);
801 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
803 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
804 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R',
true);
806 $pdf->SetTextColor(0, 0, 0);
807 $creditnoteamount =
$object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
810 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
815 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
818 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
819 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L',
false);
820 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
821 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R',
false);
824 if ($creditnoteamount) {
825 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
827 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
828 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L',
false);
829 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
830 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R',
false);
834 if (
$object->close_code == FactureFournisseur::CLOSECODE_DISCOUNTVAT) {
836 $pdf->SetFillColor(255, 255, 255);
838 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
839 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L',
true);
840 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
841 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R',
true);
847 $pdf->SetTextColor(0, 0, 60);
848 $pdf->SetFillColor(224, 224, 224);
849 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
850 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
852 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
853 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
854 $pdf->SetFont(
'',
'', $default_font_size - 1);
855 $pdf->SetTextColor(0, 0, 0);
858 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
860 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
862 $this->error = $hookmanager->error;
863 $this->errors = $hookmanager->errors;
867 return ($tab2_top + ($tab2_hl * $index));
884 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
894 $currency = !empty($currency) ? $currency :
$conf->currency;
898 $pdf->SetTextColor(0, 0, 0);
899 $pdf->SetFont(
'',
'', $default_font_size - 2);
901 if (empty($hidetop)) {
902 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
903 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
904 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
908 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F', array(), explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
912 $pdf->SetDrawColor(128, 128, 128);
913 $pdf->SetFont(
'',
'', $default_font_size - 1);
916 $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');
918 if (empty($hidetop)) {
919 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
921 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
922 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
926 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
927 if (empty($hidetop)) {
928 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
929 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
933 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
934 if (empty($hidetop)) {
935 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
936 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
939 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
940 if (empty($hidetop)) {
941 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
942 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
946 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
947 if (empty($hidetop)) {
948 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
950 $this->posxdiscount - $this->posxunit - 1,
952 $outputlangs->transnoentities(
"Unit"),
959 if ($this->atleastonediscount) {
960 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
961 if (empty($hidetop)) {
962 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
963 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
967 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
968 if (empty($hidetop)) {
969 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
970 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
997 $tab3_top = $posy + 8;
1000 if ($this->page_largeur < 210) {
1006 $pdf->SetFont(
'',
'', $default_font_size - 3);
1007 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1008 $pdf->MultiCell(60, 3, $outputlangs->transnoentities(
"PaymentsAlreadyDone"), 0,
'L',
false);
1010 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1012 $pdf->SetFont(
'',
'', $default_font_size - 4);
1013 $pdf->SetXY($tab3_posx, $tab3_top);
1014 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L',
false);
1015 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1016 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L',
false);
1017 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1018 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L',
false);
1019 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1020 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L',
false);
1022 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1026 $pdf->SetFont(
'',
'', $default_font_size - 4);
1032 $sql =
"SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num_payment, pf.amount as amount, pf.multicurrency_amount,";
1034 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX.
"paiementfourn as p";
1035 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1036 $sql .=
" WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".((int)
$object->id);
1037 $sql .=
" ORDER BY p.datep";
1038 $resql = $this->db->query($sql);
1040 $num = $this->db->num_rows($resql);
1044 $row = $this->db->fetch_object($resql);
1046 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1047 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L',
false);
1048 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1049 $pdf->MultiCell(20, 3,
price($sign * ((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0,
'L',
false);
1050 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1051 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1053 $pdf->MultiCell(20, 3, $oper, 0,
'L',
false);
1054 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1055 $pdf->MultiCell(30, 3, $row->num_payment, 0,
'L',
false);
1057 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1062 $this->error = $this->db->lasterror();
1083 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills"));
1090 $pdf->SetTextColor(0, 0, 60);
1091 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1095 $posy = $this->marge_haute;
1096 $posx = $this->page_largeur - $this->marge_droite - 100;
1098 $pdf->SetXY($this->marge_gauche, $posy);
1120 $text = $this->emetteur->name;
1121 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1124 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1125 $pdf->SetXY($posx, $posy);
1126 $pdf->SetTextColor(0, 0, 60);
1127 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
1129 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
1132 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
1135 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
1137 $pdf->MultiCell($w, 3, $title.
" ".$outputlangs->convToOutputCharset(
$object->ref),
'',
'R');
1142 $pdf->SetFont(
'',
'B', $default_font_size);
1143 $pdf->SetXY($posx, $posy);
1144 $pdf->SetTextColor(0, 0, 60);
1145 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSupplier").
" : ".
$object->ref_supplier,
'',
'R');
1149 $pdf->SetFont(
'',
'', $default_font_size - 1);
1153 if (!empty(
$object->project->ref)) {
1155 $pdf->SetXY($posx, $posy);
1156 $pdf->SetTextColor(0, 0, 60);
1157 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1163 if (!empty(
$object->project->ref)) {
1164 $outputlangs->load(
"projects");
1166 $pdf->SetXY($posx, $posy);
1167 $langs->load(
"projects");
1168 $pdf->SetTextColor(0, 0, 60);
1169 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1175 $pdf->SetXY($posx, $posy);
1176 $pdf->SetTextColor(0, 0, 60);
1177 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1180 $pdf->SetXY($posx, $posy);
1181 $pdf->SetTextColor(255, 0, 0);
1182 $pdf->MultiCell($w, 4, strtolower($outputlangs->transnoentities(
"OrderToProcess")),
'',
'R');
1185 if (
$object->thirdparty->code_fournisseur) {
1187 $pdf->SetXY($posx, $posy);
1188 $pdf->SetTextColor(0, 0, 60);
1189 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities((
string)
$object->thirdparty->code_fournisseur),
'',
'R');
1193 $pdf->SetTextColor(0, 0, 60);
1197 $current_y = $pdf->getY();
1199 if ($current_y < $pdf->getY()) {
1200 $top_shift = $pdf->getY() - $current_y;
1205 $carac_emetteur =
'';
1207 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1208 if (count($arrayidcontact) > 0) {
1209 $object->fetch_user($arrayidcontact[0]);
1210 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1211 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1213 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1217 $carac_emetteur .=
"\n";
1223 $posy = 42 + $top_shift;
1224 $posx = $this->marge_gauche;
1226 $posx = $this->page_largeur - $this->marge_droite - 80;
1231 $pdf->SetTextColor(0, 0, 0);
1232 $pdf->SetFont(
'',
'', $default_font_size - 2);
1233 $pdf->SetXY($posx, $posy - 5);
1234 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0,
'L');
1235 $pdf->SetXY($posx, $posy);
1236 $pdf->SetFillColor(230, 230, 230);
1237 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1238 $pdf->SetTextColor(0, 0, 60);
1241 $pdf->SetXY($posx + 2, $posy + 3);
1242 $pdf->SetFont(
'',
'B', $default_font_size);
1243 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1244 $posy = $pdf->getY();
1247 $pdf->SetXY($posx + 2, $posy);
1248 $pdf->SetFont(
'',
'', $default_font_size - 1);
1249 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1254 $usecontact =
false;
1255 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
1256 if (count($arrayidcontact) > 0) {
1258 $result =
$object->fetch_contact($arrayidcontact[0]);
1262 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1263 $thirdparty =
$object->contact;
1274 if ($this->page_largeur < 210) {
1277 $posy = 42 + $top_shift;
1278 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1280 $posx = $this->marge_gauche;
1284 $pdf->SetTextColor(0, 0, 0);
1285 $pdf->SetFont(
'',
'', $default_font_size - 2);
1286 $pdf->SetXY($posx + 2, $posy - 5);
1287 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0,
'L');
1288 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1291 $pdf->SetXY($posx + 2, $posy + 3);
1292 $pdf->SetFont(
'',
'B', $default_font_size);
1293 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0,
'L');
1295 $posy = $pdf->getY();
1298 $pdf->SetFont(
'',
'', $default_font_size - 1);
1299 $pdf->SetXY($posx + 2, $posy);
1300 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');