161 public function write_file(
$object, $outputlangs =
null, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
164 global $user, $langs,
$conf, $mysoc, $hookmanager, $nblines;
167 if (!is_object(
$object->thirdparty)) {
170 if (!is_object(
$object->thirdparty)) {
174 $this->emetteur =
$object->thirdparty;
175 if (!$this->emetteur->country_code) {
176 $this->emetteur->country_code = substr($langs->defaultlang, -2);
179 if (!is_object($outputlangs)) {
180 $outputlangs = $langs;
184 $outputlangs->charset_output =
'ISO-8859-1';
188 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products"));
190 $nblines = count(
$object->lines);
192 if (
$conf->fournisseur->facture->dir_output) {
193 $deja_regle =
$object->getSommePaiement((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
194 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
195 $amount_deposits_included =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
199 $dir =
$conf->fournisseur->facture->dir_output;
200 $file = $dir.
"/SPECIMEN.pdf";
205 $file = $dir.
"/".$objectref.
".pdf";
207 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
211 if (!file_exists($dir)) {
213 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
218 if (file_exists($dir)) {
220 if (!is_object($hookmanager)) {
221 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
224 $hookmanager->initHooks(array(
'pdfgeneration'));
225 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
227 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
230 $nblines = count(
$object->lines);
231 $nbpayments = count(
$object->getListOfPayments());
236 $pdf->SetAutoPageBreak(1, 0);
238 $heightforinfotot = 50 + (4 * $nbpayments);
239 if ($heightforinfotot > 220) {
240 $heightforinfotot = 220;
243 $heightforfooter = $this->marge_basse + 8;
245 $heightforfooter += 6;
248 if (class_exists(
'TCPDF')) {
249 $pdf->setPrintHeader(
false);
250 $pdf->setPrintFooter(
false);
255 $logodir =
$conf->mycompany->dir_output;
256 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
257 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
259 $pagecount = $pdf->setSourceFile($logodir .
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
260 $tplidx = $pdf->importPage(1);
265 $pdf->SetDrawColor(128, 128, 128);
267 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
268 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
269 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
270 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
271 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
273 $pdf->SetCompression(
false);
277 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
280 for ($i = 0; $i < $nblines; $i++) {
281 if (
$object->lines[$i]->remise_percent) {
282 $this->atleastonediscount++;
285 if (empty($this->atleastonediscount)) {
286 $delta = ($this->postotalht - $this->posxdiscount);
287 $this->posxpicture += $delta;
288 $this->posxtva += $delta;
289 $this->posxup += $delta;
290 $this->posxqty += $delta;
291 $this->posxunit += $delta;
292 $this->posxdiscount += $delta;
298 if (!empty($tplidx)) {
299 $pdf->useTemplate($tplidx);
303 $pdf->SetFont(
'',
'', $default_font_size - 1);
304 $pdf->MultiCell(0, 3,
'');
305 $pdf->SetTextColor(0, 0, 0);
307 $tab_top = 90 + $top_shift;
308 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
311 if (isModEnabled(
'incoterm')) {
312 $desc_incoterms =
$object->getIncotermsForPDF();
313 if ($desc_incoterms) {
316 $pdf->SetFont(
'',
'', $default_font_size - 1);
317 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
318 $nexY = $pdf->GetY();
319 $height_incoterms = $nexY - $tab_top;
322 $pdf->SetDrawColor(192, 192, 192);
323 $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');
325 $tab_top = $nexY + 6;
330 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
334 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
335 if (!empty($extranote)) {
348 $pdf->SetFont(
'',
'', $default_font_size - 1);
349 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
350 $nexY = $pdf->GetY();
351 $height_note = $nexY - $tab_top;
354 $pdf->SetDrawColor(192, 192, 192);
355 $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');
357 $tab_top = $nexY + 6;
360 $iniY = $tab_top + 7;
361 $curY = $tab_top + 7;
362 $nexY = $tab_top + 7;
365 for ($i = 0; $i < $nblines; $i++) {
367 $pdf->SetFont(
'',
'', $default_font_size - 1);
368 $pdf->SetTextColor(0, 0, 0);
376 $pdf->setTopMargin($tab_top_newpage);
377 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
378 $pageposbefore = $pdf->getPage();
380 $showpricebeforepagebreak = 1;
384 $curX = $this->posxdesc - 1;
386 $pdf->startTransaction();
387 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc, 1);
388 $pageposafter = $pdf->getPage();
389 if ($pageposafter > $pageposbefore) {
390 $pdf->rollbackTransaction(
true);
391 $pageposafter = $pageposbefore;
393 $pdf->setPageOrientation(
'', 1, $heightforfooter);
394 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc, 1);
395 $posyafter = $pdf->GetY();
396 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
397 if ($i == ($nblines - 1)) {
398 $pdf->AddPage(
'',
'',
true);
399 if (!empty($tplidx)) {
400 $pdf->useTemplate($tplidx);
405 $pdf->setPage($pageposafter + 1);
411 $showpricebeforepagebreak = 1;
413 $showpricebeforepagebreak = 0;
417 $pdf->commitTransaction();
419 $posYAfterDescription = $pdf->GetY();
421 $nexY = $pdf->GetY();
422 $pageposafter = $pdf->getPage();
423 $pdf->setPage($pageposbefore);
424 $pdf->setTopMargin($this->marge_haute);
425 $pdf->setPageOrientation(
'', 1, 0);
428 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
429 $pdf->setPage($pageposafter);
430 $curY = $tab_top_newpage;
433 $pdf->SetFont(
'',
'', $default_font_size - 1);
438 $pdf->SetXY($this->posxtva, $curY);
439 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0,
'R');
444 $pdf->SetXY($this->posxup, $curY);
445 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
449 $pdf->SetXY($this->posxqty, $curY);
450 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
455 $pdf->SetXY($this->posxunit, $curY);
456 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
460 if (
$object->lines[$i]->remise_percent) {
461 $pdf->SetXY($this->posxdiscount - 2, $curY);
463 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0,
'R');
468 $pdf->SetXY($this->postotalht, $curY);
469 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
472 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
473 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
475 $tvaligne =
$object->lines[$i]->total_tva;
478 $localtax1ligne =
$object->lines[$i]->total_localtax1;
479 $localtax2ligne =
$object->lines[$i]->total_localtax2;
486 $vatrate = (string)
$object->lines[$i]->tva_tx;
487 $localtax1rate = (string)
$object->lines[$i]->localtax1_tx;
488 $localtax2rate = (string)
$object->lines[$i]->localtax2_tx;
490 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
493 if (empty($this->tva[$vatrate])) {
494 $this->tva[$vatrate] = 0;
496 if (empty($this->localtax1[$localtax1rate])) {
497 $this->localtax1[$localtax1rate] = 0;
499 if (empty($this->localtax2[$localtax2rate])) {
500 $this->localtax2[$localtax2rate] = 0;
502 $this->tva[$vatrate] += $tvaligne;
503 $this->localtax1[$localtax1rate] += $localtax1ligne;
504 $this->localtax2[$localtax2rate] += $localtax2ligne;
506 if ($posYAfterImage > $posYAfterDescription) {
507 $nexY = $posYAfterImage;
512 $pdf->setPage($pageposafter);
513 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
515 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
516 $pdf->SetLineStyle(array(
'dash' => 0));
522 while ($pagenb < $pageposafter) {
523 $pdf->setPage($pagenb);
525 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
527 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
531 $pdf->setPage($pagenb);
532 $pdf->setPageOrientation(
'', 1, 0);
537 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
539 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
541 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
546 if (!empty($tplidx)) {
547 $pdf->useTemplate($tplidx);
558 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
559 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
561 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
562 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
568 $amount_credit_notes_included = 0;
569 $amount_deposits_included = 0;
572 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'SUPPLIER_INVOICE_NO_PAYMENT_DETAILS')) {
578 if (method_exists($pdf,
'AliasNbPages')) {
579 $pdf->AliasNbPages();
584 $pdf->Output($file,
'F');
587 $hookmanager->initHooks(array(
'pdfgeneration'));
588 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
590 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
592 $this->error = $hookmanager->error;
593 $this->errors = $hookmanager->errors;
598 $this->result = array(
'fullpath' => $file);
602 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
606 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
626 global
$conf, $mysoc, $hookmanager;
637 $pdf->SetFont(
'',
'', $default_font_size - 1);
642 if ($this->page_largeur < 210) {
645 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
651 $pdf->SetFillColor(255, 255, 255);
652 $pdf->SetXY($col1x, $tab2_top);
653 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
655 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
656 $pdf->SetXY($col2x, $tab2_top);
657 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
660 $pdf->SetFillColor(248, 248, 248);
662 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
664 $this->atleastoneratenotnull = 0;
665 foreach ($this->tva as $tvakey => $tvaval) {
667 $this->atleastoneratenotnull++;
670 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
674 if (preg_match(
'/\*/', $tvakey)) {
675 $tvakey = str_replace(
'*',
'', $tvakey);
676 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
679 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
680 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
681 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
683 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
684 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
687 if (!$this->atleastoneratenotnull) {
689 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
690 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
691 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
692 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva, 0, $outputlangs), 0,
'R', 1);
697 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
698 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
699 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
700 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1, 0, $outputlangs), 0,
'R', 1);
706 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
707 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
708 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
709 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2, 0, $outputlangs), 0,
'R', 1);
715 foreach ($this->localtax1 as $tvakey => $tvaval) {
720 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
723 if (preg_match(
'/\*/', (
string) $tvakey)) {
724 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
725 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
727 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
728 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
729 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
731 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
732 $pdf->MultiCell($largcol2, $tab2_hl,
price((
string) $tvaval, 0, $outputlangs), 0,
'R', 1);
740 foreach ($this->localtax2 as $tvakey => $tvaval) {
745 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
748 if (preg_match(
'/\*/', (
string) $tvakey)) {
749 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
750 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
752 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
753 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
754 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
756 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
757 $pdf->MultiCell($largcol2, $tab2_hl,
price((
string) $tvaval, 0, $outputlangs), 0,
'R', 1);
765 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
766 $pdf->SetTextColor(0, 0, 60);
767 $pdf->SetFillColor(224, 224, 224);
768 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
770 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
771 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
773 $pdf->SetTextColor(0, 0, 0);
774 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
775 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
777 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
782 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
785 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
786 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L', 0);
787 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
788 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
791 if ($creditnoteamount) {
792 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
794 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
795 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
796 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
797 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
801 if (
$object->close_code == FactureFournisseur::CLOSECODE_DISCOUNTVAT) {
803 $pdf->SetFillColor(255, 255, 255);
805 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
806 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L', 1);
807 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
808 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R', 1);
814 $pdf->SetTextColor(0, 0, 60);
815 $pdf->SetFillColor(224, 224, 224);
816 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
817 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
819 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
820 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
821 $pdf->SetFont(
'',
'', $default_font_size - 1);
822 $pdf->SetTextColor(0, 0, 0);
825 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
827 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
829 $this->error = $hookmanager->error;
830 $this->errors = $hookmanager->errors;
834 return ($tab2_top + ($tab2_hl * $index));
851 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
861 $currency = !empty($currency) ? $currency :
$conf->currency;
865 $pdf->SetTextColor(0, 0, 0);
866 $pdf->SetFont(
'',
'', $default_font_size - 2);
868 if (empty($hidetop)) {
869 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
870 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
871 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
875 $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')));
879 $pdf->SetDrawColor(128, 128, 128);
880 $pdf->SetFont(
'',
'', $default_font_size - 1);
883 $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');
885 if (empty($hidetop)) {
886 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
888 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
889 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
893 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
894 if (empty($hidetop)) {
895 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
896 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
900 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
901 if (empty($hidetop)) {
902 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
903 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
906 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
907 if (empty($hidetop)) {
908 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
909 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
913 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
914 if (empty($hidetop)) {
915 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
917 $this->posxdiscount - $this->posxunit - 1,
919 $outputlangs->transnoentities(
"Unit"),
926 if ($this->atleastonediscount) {
927 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
928 if (empty($hidetop)) {
929 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
930 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
934 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
935 if (empty($hidetop)) {
936 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
937 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
964 $tab3_top = $posy + 8;
967 if ($this->page_largeur < 210) {
973 $pdf->SetFont(
'',
'', $default_font_size - 3);
974 $pdf->SetXY($tab3_posx, $tab3_top - 4);
975 $pdf->MultiCell(60, 3, $outputlangs->transnoentities(
"PaymentsAlreadyDone"), 0,
'L', 0);
977 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
979 $pdf->SetFont(
'',
'', $default_font_size - 4);
980 $pdf->SetXY($tab3_posx, $tab3_top);
981 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
982 $pdf->SetXY($tab3_posx + 21, $tab3_top);
983 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
984 $pdf->SetXY($tab3_posx + 40, $tab3_top);
985 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
986 $pdf->SetXY($tab3_posx + 58, $tab3_top);
987 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
989 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
993 $pdf->SetFont(
'',
'', $default_font_size - 4);
999 $sql =
"SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num_payment, pf.amount as amount, pf.multicurrency_amount,";
1001 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX.
"paiementfourn as p";
1002 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1003 $sql .=
" WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".((int)
$object->id);
1004 $sql .=
" ORDER BY p.datep";
1005 $resql = $this->db->query($sql);
1007 $num = $this->db->num_rows($resql);
1011 $row = $this->db->fetch_object($resql);
1013 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1014 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1015 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1016 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0,
'L', 0);
1017 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1018 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1020 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1021 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1022 $pdf->MultiCell(30, 3, $row->num_payment, 0,
'L', 0);
1024 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1029 $this->error = $this->db->lasterror();
1047 global $langs,
$conf, $mysoc;
1050 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills"));
1057 $pdf->SetTextColor(0, 0, 60);
1058 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1062 $posy = $this->marge_haute;
1063 $posx = $this->page_largeur - $this->marge_droite - 100;
1065 $pdf->SetXY($this->marge_gauche, $posy);
1087 $text = $this->emetteur->name;
1088 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1091 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1092 $pdf->SetXY($posx, $posy);
1093 $pdf->SetTextColor(0, 0, 60);
1094 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
1096 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
1099 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
1102 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
1104 $pdf->MultiCell($w, 3, $title.
" ".$outputlangs->convToOutputCharset(
$object->ref),
'',
'R');
1109 $pdf->SetFont(
'',
'B', $default_font_size);
1110 $pdf->SetXY($posx, $posy);
1111 $pdf->SetTextColor(0, 0, 60);
1112 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSupplier").
" : ".
$object->ref_supplier,
'',
'R');
1116 $pdf->SetFont(
'',
'', $default_font_size - 1);
1120 if (!empty(
$object->project->ref)) {
1122 $pdf->SetXY($posx, $posy);
1123 $pdf->SetTextColor(0, 0, 60);
1124 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1130 if (!empty(
$object->project->ref)) {
1131 $outputlangs->load(
"projects");
1133 $pdf->SetXY($posx, $posy);
1134 $langs->load(
"projects");
1135 $pdf->SetTextColor(0, 0, 60);
1136 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1142 $pdf->SetXY($posx, $posy);
1143 $pdf->SetTextColor(0, 0, 60);
1144 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1147 $pdf->SetXY($posx, $posy);
1148 $pdf->SetTextColor(255, 0, 0);
1149 $pdf->MultiCell($w, 4, strtolower($outputlangs->transnoentities(
"OrderToProcess")),
'',
'R');
1152 if (
$object->thirdparty->code_fournisseur) {
1154 $pdf->SetXY($posx, $posy);
1155 $pdf->SetTextColor(0, 0, 60);
1156 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1160 $pdf->SetTextColor(0, 0, 60);
1164 $current_y = $pdf->getY();
1166 if ($current_y < $pdf->getY()) {
1167 $top_shift = $pdf->getY() - $current_y;
1172 $carac_emetteur =
'';
1174 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1175 if (count($arrayidcontact) > 0) {
1176 $object->fetch_user($arrayidcontact[0]);
1177 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1178 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1180 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1184 $carac_emetteur .=
"\n";
1190 $posy = 42 + $top_shift;
1191 $posx = $this->marge_gauche;
1193 $posx = $this->page_largeur - $this->marge_droite - 80;
1198 $pdf->SetTextColor(0, 0, 0);
1199 $pdf->SetFont(
'',
'', $default_font_size - 2);
1200 $pdf->SetXY($posx, $posy - 5);
1201 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0,
'L');
1202 $pdf->SetXY($posx, $posy);
1203 $pdf->SetFillColor(230, 230, 230);
1204 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1205 $pdf->SetTextColor(0, 0, 60);
1208 $pdf->SetXY($posx + 2, $posy + 3);
1209 $pdf->SetFont(
'',
'B', $default_font_size);
1210 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1211 $posy = $pdf->getY();
1214 $pdf->SetXY($posx + 2, $posy);
1215 $pdf->SetFont(
'',
'', $default_font_size - 1);
1216 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1221 $usecontact =
false;
1222 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
1223 if (count($arrayidcontact) > 0) {
1225 $result =
$object->fetch_contact($arrayidcontact[0]);
1229 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1230 $thirdparty =
$object->contact;
1232 $thirdparty = $mysoc;
1241 if ($this->page_largeur < 210) {
1244 $posy = 42 + $top_shift;
1245 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1247 $posx = $this->marge_gauche;
1251 $pdf->SetTextColor(0, 0, 0);
1252 $pdf->SetFont(
'',
'', $default_font_size - 2);
1253 $pdf->SetXY($posx + 2, $posy - 5);
1254 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0,
'L');
1255 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1258 $pdf->SetXY($posx + 2, $posy + 3);
1259 $pdf->SetFont(
'',
'B', $default_font_size);
1260 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0,
'L');
1262 $posy = $pdf->getY();
1265 $pdf->SetFont(
'',
'', $default_font_size - 1);
1266 $pdf->SetXY($posx + 2, $posy);
1267 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');