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";
206 $dir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir(
$object->id, 2, 0, 0,
$object,
'invoice_supplier').$objectref;
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])) {
259 $logodir = $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->getFullName($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;
367 for ($i = 0; $i < $nblines; $i++) {
369 $pdf->SetFont(
'',
'', $default_font_size - 1);
370 $pdf->SetTextColor(0, 0, 0);
378 $pdf->setTopMargin($tab_top_newpage);
379 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
380 $pageposbefore = $pdf->getPage();
382 $showpricebeforepagebreak = 1;
386 $curX = $this->posxdesc - 1;
388 $pdf->startTransaction();
389 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc, 1);
390 $pageposafter = $pdf->getPage();
391 if ($pageposafter > $pageposbefore) {
392 $pdf->rollbackTransaction(
true);
393 $pageposafter = $pageposbefore;
395 $pdf->setPageOrientation(
'',
true, $heightforfooter);
396 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc, 1);
397 $posyafter = $pdf->GetY();
398 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
399 if ($i == ($nblines - 1)) {
400 $pdf->AddPage(
'',
'',
true);
401 if (!empty($tplidx)) {
402 $pdf->useTemplate($tplidx);
407 $pdf->setPage($pageposafter + 1);
413 $showpricebeforepagebreak = 1;
415 $showpricebeforepagebreak = 0;
419 $pdf->commitTransaction();
421 $posYAfterDescription = $pdf->GetY();
423 $nexY = $pdf->GetY();
424 $pageposafter = $pdf->getPage();
425 $pdf->setPage($pageposbefore);
426 $pdf->setTopMargin($this->marge_haute);
427 $pdf->setPageOrientation(
'',
true, 0);
430 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
431 $pdf->setPage($pageposafter);
432 $curY = $tab_top_newpage;
435 $pdf->SetFont(
'',
'', $default_font_size - 1);
440 $pdf->SetXY($this->posxtva, $curY);
441 $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0,
'R');
446 $pdf->SetXY($this->posxup, $curY);
447 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R',
false);
451 $pdf->SetXY($this->posxqty, $curY);
452 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
457 $pdf->SetXY($this->posxunit, $curY);
458 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
462 if (
$object->lines[$i]->remise_percent) {
463 $pdf->SetXY($this->posxdiscount - 2, $curY);
465 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0,
'R');
470 $pdf->SetXY($this->postotalht, $curY);
471 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R',
false);
475 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
477 $tvaligne =
$object->lines[$i]->total_tva;
480 $localtax1ligne =
$object->lines[$i]->total_localtax1;
481 $localtax2ligne =
$object->lines[$i]->total_localtax2;
488 $vatrate = (string)
$object->lines[$i]->tva_tx;
489 $localtax1rate = (string)
$object->lines[$i]->localtax1_tx;
490 $localtax2rate = (string)
$object->lines[$i]->localtax2_tx;
492 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
495 if (empty($this->tva[$vatrate])) {
496 $this->tva[$vatrate] = 0;
498 if (empty($this->localtax1[$localtax1rate])) {
499 $this->localtax1[$localtax1rate] = 0;
501 if (empty($this->localtax2[$localtax2rate])) {
502 $this->localtax2[$localtax2rate] = 0;
504 $this->tva[$vatrate] += $tvaligne;
505 $this->localtax1[$localtax1rate] += $localtax1ligne;
506 $this->localtax2[$localtax2rate] += $localtax2ligne;
508 if ($posYAfterImage > $posYAfterDescription) {
509 $nexY = $posYAfterImage;
514 $pdf->setPage($pageposafter);
515 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
517 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
518 $pdf->SetLineStyle(array(
'dash' => 0));
524 while ($pagenb < $pageposafter) {
525 $pdf->setPage($pagenb);
527 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
529 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
533 $pdf->setPage($pagenb);
534 $pdf->setPageOrientation(
'',
true, 0);
539 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
541 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
543 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
548 if (!empty($tplidx)) {
549 $pdf->useTemplate($tplidx);
560 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
561 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
563 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
564 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
570 $amount_credit_notes_included = 0;
571 $amount_deposits_included = 0;
574 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'SUPPLIER_INVOICE_NO_PAYMENT_DETAILS')) {
580 if (method_exists($pdf,
'AliasNbPages')) {
581 $pdf->AliasNbPages();
586 $pdf->Output($file,
'F');
589 $hookmanager->initHooks(array(
'pdfgeneration'));
590 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
592 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
593 $this->warnings = $hookmanager->warnings;
595 $this->error = $hookmanager->error;
596 $this->errors = $hookmanager->errors;
603 $this->result = array(
'fullpath' => $file);
607 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
611 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
631 global $conf,
$mysoc, $hookmanager;
642 $pdf->SetFont(
'',
'', $default_font_size - 1);
647 if ($this->page_largeur < 210) {
650 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
656 $pdf->SetFillColor(255, 255, 255);
657 $pdf->SetXY($col1x, $tab2_top);
658 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L',
true);
661 $pdf->SetXY($col2x, $tab2_top);
662 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0, $outputlangs), 0,
'R',
true);
665 $pdf->SetFillColor(248, 248, 248);
669 $this->atleastoneratenotnull = 0;
670 foreach ($this->tva as $tvakey => $tvaval) {
672 $this->atleastoneratenotnull++;
675 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
679 if (preg_match(
'/\*/', $tvakey)) {
680 $tvakey = str_replace(
'*',
'', $tvakey);
681 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
684 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).
' ';
685 $totalvat .=
vatrate($tvakey,
true).$tvacompl;
686 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
688 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
689 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R',
true);
692 if (!$this->atleastoneratenotnull) {
694 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
695 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code), 0,
'L',
true);
696 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
697 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva, 0, $outputlangs), 0,
'R',
true);
702 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
703 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code), 0,
'L',
true);
704 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
705 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1, 0, $outputlangs), 0,
'R',
true);
711 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
712 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code), 0,
'L',
true);
713 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
714 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2, 0, $outputlangs), 0,
'R',
true);
720 foreach ($this->localtax1 as $tvakey => $tvaval) {
725 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
728 if (preg_match(
'/\*/', (
string) $tvakey)) {
729 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
730 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
732 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).
' ';
733 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
734 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
736 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
737 $pdf->MultiCell($largcol2, $tab2_hl,
price((
string) $tvaval, 0, $outputlangs), 0,
'R',
true);
745 foreach ($this->localtax2 as $tvakey => $tvaval) {
750 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
753 if (preg_match(
'/\*/', (
string) $tvakey)) {
754 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
755 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
757 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).
' ';
758 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
759 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
761 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
762 $pdf->MultiCell($largcol2, $tab2_hl,
price((
string) $tvaval, 0, $outputlangs), 0,
'R',
true);
770 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
771 $pdf->SetTextColor(0, 0, 60);
772 $pdf->SetFillColor(224, 224, 224);
773 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
775 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
776 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R',
true);
778 $pdf->SetTextColor(0, 0, 0);
779 $creditnoteamount =
$object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
782 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
787 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
790 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
791 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L',
false);
792 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
793 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R',
false);
796 if ($creditnoteamount) {
797 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
799 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
800 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L',
false);
801 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
802 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R',
false);
806 if (
$object->close_code == FactureFournisseur::CLOSECODE_DISCOUNTVAT) {
808 $pdf->SetFillColor(255, 255, 255);
810 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
811 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L',
true);
812 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
813 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R',
true);
819 $pdf->SetTextColor(0, 0, 60);
820 $pdf->SetFillColor(224, 224, 224);
821 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
822 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
824 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
825 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
826 $pdf->SetFont(
'',
'', $default_font_size - 1);
827 $pdf->SetTextColor(0, 0, 0);
830 $parameters = array(
'pdf' => &$pdf,
'object' => &
$object,
'outputlangs' => $outputlangs,
'index' => &$index,
'posy' => $posy);
832 $reshook = $hookmanager->executeHooks(
'afterPDFTotalTable', $parameters, $this);
834 $this->error = $hookmanager->error;
835 $this->errors = $hookmanager->errors;
839 return ($tab2_top + ($tab2_hl * $index));
856 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
866 $currency = !empty($currency) ? $currency : $conf->currency;
870 $pdf->SetTextColor(0, 0, 0);
871 $pdf->SetFont(
'',
'', $default_font_size - 2);
873 if (empty($hidetop)) {
874 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
875 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
876 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
880 $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')));
884 $pdf->SetDrawColor(128, 128, 128);
885 $pdf->SetFont(
'',
'', $default_font_size - 1);
888 $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');
890 if (empty($hidetop)) {
891 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
893 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
894 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
898 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
899 if (empty($hidetop)) {
900 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
901 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
905 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
906 if (empty($hidetop)) {
907 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
908 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
911 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
912 if (empty($hidetop)) {
913 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
914 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
918 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
919 if (empty($hidetop)) {
920 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
922 $this->posxdiscount - $this->posxunit - 1,
924 $outputlangs->transnoentities(
"Unit"),
931 if ($this->atleastonediscount) {
932 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
933 if (empty($hidetop)) {
934 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
935 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
939 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
940 if (empty($hidetop)) {
941 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
942 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
969 $tab3_top = $posy + 8;
972 if ($this->page_largeur < 210) {
978 $pdf->SetFont(
'',
'', $default_font_size - 3);
979 $pdf->SetXY($tab3_posx, $tab3_top - 4);
980 $pdf->MultiCell(60, 3, $outputlangs->transnoentities(
"PaymentsAlreadyDone"), 0,
'L',
false);
982 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
984 $pdf->SetFont(
'',
'', $default_font_size - 4);
985 $pdf->SetXY($tab3_posx, $tab3_top);
986 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L',
false);
987 $pdf->SetXY($tab3_posx + 21, $tab3_top);
988 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L',
false);
989 $pdf->SetXY($tab3_posx + 40, $tab3_top);
990 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L',
false);
991 $pdf->SetXY($tab3_posx + 58, $tab3_top);
992 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L',
false);
994 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
998 $pdf->SetFont(
'',
'', $default_font_size - 4);
1004 $sql =
"SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num_payment, pf.amount as amount, pf.multicurrency_amount,";
1006 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX.
"paiementfourn as p";
1007 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1008 $sql .=
" WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".((int)
$object->id);
1009 $sql .=
" ORDER BY p.datep";
1010 $resql = $this->db->query($sql);
1012 $num = $this->db->num_rows($resql);
1016 $row = $this->db->fetch_object($resql);
1018 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1019 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L',
false);
1020 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1021 $pdf->MultiCell(20, 3,
price($sign * ((
isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0,
'L',
false);
1022 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1023 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1025 $pdf->MultiCell(20, 3, $oper, 0,
'L',
false);
1026 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1027 $pdf->MultiCell(30, 3, $row->num_payment, 0,
'L',
false);
1029 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1034 $this->error = $this->db->lasterror();
1052 global $langs, $conf,
$mysoc;
1055 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills"));
1062 $pdf->SetTextColor(0, 0, 60);
1063 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1067 $posy = $this->marge_haute;
1068 $posx = $this->page_largeur - $this->marge_droite - 100;
1070 $pdf->SetXY($this->marge_gauche, $posy);
1092 $text = $this->emetteur->name;
1093 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1096 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1097 $pdf->SetXY($posx, $posy);
1098 $pdf->SetTextColor(0, 0, 60);
1099 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
1101 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
1104 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
1107 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
1109 $pdf->MultiCell($w, 3, $title.
" ".$outputlangs->convToOutputCharset(
$object->ref),
'',
'R');
1114 $pdf->SetFont(
'',
'B', $default_font_size);
1115 $pdf->SetXY($posx, $posy);
1116 $pdf->SetTextColor(0, 0, 60);
1117 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSupplier").
" : ".
$object->ref_supplier,
'',
'R');
1121 $pdf->SetFont(
'',
'', $default_font_size - 1);
1125 if (!empty(
$object->project->ref)) {
1127 $pdf->SetXY($posx, $posy);
1128 $pdf->SetTextColor(0, 0, 60);
1129 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1135 if (!empty(
$object->project->ref)) {
1136 $outputlangs->load(
"projects");
1138 $pdf->SetXY($posx, $posy);
1139 $langs->load(
"projects");
1140 $pdf->SetTextColor(0, 0, 60);
1141 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1147 $pdf->SetXY($posx, $posy);
1148 $pdf->SetTextColor(0, 0, 60);
1149 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1152 $pdf->SetXY($posx, $posy);
1153 $pdf->SetTextColor(255, 0, 0);
1154 $pdf->MultiCell($w, 4, strtolower($outputlangs->transnoentities(
"OrderToProcess")),
'',
'R');
1157 if (
$object->thirdparty->code_fournisseur) {
1159 $pdf->SetXY($posx, $posy);
1160 $pdf->SetTextColor(0, 0, 60);
1161 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1165 $pdf->SetTextColor(0, 0, 60);
1169 $current_y = $pdf->getY();
1171 if ($current_y < $pdf->getY()) {
1172 $top_shift = $pdf->getY() - $current_y;
1177 $carac_emetteur =
'';
1179 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1180 if (count($arrayidcontact) > 0) {
1181 $object->fetch_user($arrayidcontact[0]);
1182 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1183 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1185 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1189 $carac_emetteur .=
"\n";
1195 $posy = 42 + $top_shift;
1196 $posx = $this->marge_gauche;
1198 $posx = $this->page_largeur - $this->marge_droite - 80;
1203 $pdf->SetTextColor(0, 0, 0);
1204 $pdf->SetFont(
'',
'', $default_font_size - 2);
1205 $pdf->SetXY($posx, $posy - 5);
1206 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0,
'L');
1207 $pdf->SetXY($posx, $posy);
1208 $pdf->SetFillColor(230, 230, 230);
1209 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1210 $pdf->SetTextColor(0, 0, 60);
1213 $pdf->SetXY($posx + 2, $posy + 3);
1214 $pdf->SetFont(
'',
'B', $default_font_size);
1215 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1216 $posy = $pdf->getY();
1219 $pdf->SetXY($posx + 2, $posy);
1220 $pdf->SetFont(
'',
'', $default_font_size - 1);
1221 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1226 $usecontact =
false;
1227 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
1228 if (count($arrayidcontact) > 0) {
1230 $result =
$object->fetch_contact($arrayidcontact[0]);
1234 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1235 $thirdparty =
$object->contact;
1246 if ($this->page_largeur < 210) {
1249 $posy = 42 + $top_shift;
1250 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1252 $posx = $this->marge_gauche;
1256 $pdf->SetTextColor(0, 0, 0);
1257 $pdf->SetFont(
'',
'', $default_font_size - 2);
1258 $pdf->SetXY($posx + 2, $posy - 5);
1259 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0,
'L');
1260 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1263 $pdf->SetXY($posx + 2, $posy + 3);
1264 $pdf->SetFont(
'',
'B', $default_font_size);
1265 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0,
'L');
1267 $posy = $pdf->getY();
1270 $pdf->SetFont(
'',
'', $default_font_size - 1);
1271 $pdf->SetXY($posx + 2, $posy);
1272 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');