35 require_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
36 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
65 public $update_main_doc_field;
76 public $phpmin = array(7, 0);
82 public $version =
'dolibarr';
102 public $marge_gauche;
107 public $marge_droite;
128 public $situationinvoice;
133 public $posxprogress;
143 global $conf, $langs, $mysoc;
146 $langs->loadLangs(array(
"main",
"bills"));
149 $this->
name =
"crabe";
150 $this->
description = $langs->trans(
'PDFCrabeDescription');
151 $this->update_main_doc_field = 1;
156 $this->page_largeur = $formatarray[
'width'];
157 $this->page_hauteur = $formatarray[
'height'];
158 $this->format = array($this->page_largeur, $this->page_hauteur);
164 $this->option_logo = 1;
165 $this->option_tva = 1;
166 $this->option_modereg = 1;
167 $this->option_condreg = 1;
168 $this->option_multilang = 1;
169 $this->option_escompte = 1;
170 $this->option_credit_note = 1;
171 $this->option_freetext = 1;
172 $this->option_draft_watermark = 1;
173 $this->watermark =
'';
176 $this->emetteur = $mysoc;
177 if (empty($this->emetteur->country_code)) {
178 $this->emetteur->country_code = substr($langs->defaultlang, -2);
182 $this->posxdesc = $this->marge_gauche + 1;
184 $this->posxtva = 101;
186 $this->posxqty = 135;
187 $this->posxunit = 151;
189 $this->posxtva = 110;
191 $this->posxqty = 145;
192 $this->posxunit = 162;
194 $this->posxprogress = 151;
195 $this->posxdiscount = 162;
196 $this->posxprogress = 174;
197 $this->postotalht = 174;
198 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
199 $this->posxtva = $this->posxup;
201 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
202 if ($this->page_largeur < 210) {
203 $this->posxpicture -= 20;
204 $this->posxtva -= 20;
206 $this->posxqty -= 20;
207 $this->posxunit -= 20;
208 $this->posxdiscount -= 20;
209 $this->posxprogress -= 20;
210 $this->postotalht -= 20;
213 $this->tva = array();
214 $this->tva_array = array();
215 $this->localtax1 = array();
216 $this->localtax2 = array();
217 $this->atleastoneratenotnull = 0;
218 $this->atleastonediscount = 0;
219 $this->situationinvoice =
false;
235 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
238 global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
240 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
242 if (!is_object($outputlangs)) {
243 $outputlangs = $langs;
246 if (!empty($conf->global->MAIN_USE_FPDF)) {
247 $outputlangs->charset_output =
'ISO-8859-1';
251 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
254 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) {
255 $this->watermark = $conf->global->FACTURE_DRAFT_WATERMARK;
258 global $outputlangsbis;
259 $outputlangsbis =
null;
260 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
261 $outputlangsbis =
new Translate(
'', $conf);
262 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
263 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
266 $nblines = count($object->lines);
269 $realpatharray = array();
270 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) {
271 for ($i = 0; $i < $nblines; $i++) {
272 if (empty($object->lines[$i]->fk_product)) {
277 $objphoto->fetch($object->lines[$i]->fk_product);
279 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
280 $dir = $conf->product->dir_output.
'/'.$pdir;
283 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
284 $filename = $obj[
'photo'];
286 $realpath = $dir.$filename;
291 $realpatharray[$i] = $realpath;
295 if (count($realpatharray) == 0) {
296 $this->posxpicture = $this->posxtva;
299 if ($conf->facture->dir_output) {
300 $object->fetch_thirdparty();
302 $deja_regle = $object->getSommePaiement((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
303 $amount_credit_notes_included = $object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
304 $amount_deposits_included = $object->getSumDepositsUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
307 if ($object->specimen) {
308 $dir = empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$conf->entity];
309 $file = $dir.
"/SPECIMEN.pdf";
312 $dir = (empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$conf->entity]).
"/".$objectref;
313 $file = $dir.
"/".$objectref.
".pdf";
315 if (!file_exists($dir)) {
317 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
322 if (file_exists($dir)) {
324 if (!is_object($hookmanager)) {
325 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
328 $hookmanager->initHooks(array(
'pdfgeneration'));
329 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
331 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
334 $nblines = count($object->lines);
335 $nbpayments = count($object->getListOfPayments());
340 $pdf->SetAutoPageBreak(1, 0);
342 $heightforinfotot = 50 + (4 * $nbpayments);
343 if ($heightforinfotot > 220) {
344 $heightforinfotot = 220;
346 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
347 $heightforfooter = $this->marge_basse + 8;
348 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
349 $heightforfooter += 6;
352 if (class_exists(
'TCPDF')) {
353 $pdf->setPrintHeader(
false);
354 $pdf->setPrintFooter(
false);
359 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
360 $logodir = $conf->mycompany->dir_output;
361 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
362 $logodir = $conf->mycompany->multidir_output[$object->entity];
364 $pagecount = $pdf->setSourceFile($logodir.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
365 $tplidx = $pdf->importPage(1);
370 $pdf->SetDrawColor(128, 128, 128);
372 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
373 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
374 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
375 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
376 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
378 $pdf->SetCompression(
false);
382 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
383 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
386 $cert = empty($conf->global->CERTIFICATE_CRT) ?
'' : $conf->global->CERTIFICATE_CRT;
389 $certprivate = empty($conf->global->CERTIFICATE_CRT_PRIVATE) ?
'' : $conf->global->CERTIFICATE_CRT_PRIVATE;
394 'Name' => $this->emetteur->name,
395 'Location' =>
getCountry($this->emetteur->country_code, 0),
396 'Reason' =>
'INVOICE',
397 'ContactInfo' => $this->emetteur->email
399 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
402 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
405 for ($i = 0; $i < $nblines; $i++) {
406 if ($object->lines[$i]->remise_percent) {
407 $this->atleastonediscount++;
410 if (empty($this->atleastonediscount)) {
411 $delta = ($this->posxprogress - $this->posxdiscount);
412 $this->posxpicture += $delta;
413 $this->posxtva += $delta;
414 $this->posxup += $delta;
415 $this->posxqty += $delta;
416 $this->posxunit += $delta;
417 $this->posxdiscount += $delta;
423 if ($object->situation_cycle_ref && empty($conf->global->MAIN_PDF_HIDE_SITUATION)) {
424 $this->situationinvoice =
true;
425 $progress_width = 10;
426 $this->posxpicture -= $progress_width;
427 $this->posxtva -= $progress_width;
428 $this->posxup -= $progress_width;
429 $this->posxqty -= $progress_width;
430 $this->posxunit -= $progress_width;
431 $this->posxdiscount -= $progress_width;
432 $this->posxprogress -= $progress_width;
437 if (!empty($tplidx)) {
438 $pdf->useTemplate($tplidx);
443 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
444 $pdf->SetFont(
'',
'', $default_font_size - 1);
445 $pdf->MultiCell(0, 3,
'');
446 $pdf->SetTextColor(0, 0, 0);
451 $tab_top = 90 + $top_shift;
452 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
455 $extra_under_address_shift = 0;
457 if (!empty($conf->global->INVOICE_ADD_ZATCA_QR_CODE)) {
458 $qrcodestring = $object->buildZATCAQRString();
459 } elseif (!empty($conf->global->INVOICE_ADD_SWISS_QR_CODE)) {
460 $qrcodestring = $object->buildSwitzerlandQRString();
463 $qrcodecolor = array(
'25',
'25',
'25');
468 'fgcolor' => $qrcodecolor,
473 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr,
'N');
474 $extra_under_address_shift += 25;
482 'outputlangs' => $outputlangs,
483 'hidedetails' => $hidedetails
485 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
486 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
487 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_header_shift'];
490 $tab_top += $extra_under_address_shift;
491 $tab_top_newpage += 0;
494 $height_incoterms = 0;
496 $desc_incoterms = $object->getIncotermsForPDF();
497 if ($desc_incoterms) {
500 $pdf->SetFont(
'',
'', $default_font_size - 1);
501 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
502 $nexY = $pdf->GetY();
503 $height_incoterms = $nexY - $tab_top;
506 $pdf->SetDrawColor(192, 192, 192);
507 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
509 $tab_top = $nexY + 6;
514 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
515 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
517 if (is_object($object->thirdparty)) {
518 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
519 $salerepobj =
new User($this->
db);
520 $salerepobj->fetch($salereparray[0][
'id']);
521 if (!empty($salerepobj->signature)) {
522 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
527 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
528 if (!empty($extranote)) {
540 $pdf->SetFont(
'',
'', $default_font_size - 1);
541 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
542 $nexY = $pdf->GetY();
543 $height_note = $nexY - $tab_top;
546 $pdf->SetDrawColor(192, 192, 192);
547 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
549 $tab_top = $nexY + 6;
552 $iniY = $tab_top + 7;
553 $curY = $tab_top + 7;
554 $nexY = $tab_top + 7;
557 for ($i = 0; $i < $nblines; $i++) {
559 $pdf->SetFont(
'',
'', $default_font_size - 1);
560 $pdf->SetTextColor(0, 0, 0);
563 $imglinesize = array();
564 if (!empty($realpatharray[$i])) {
568 $pdf->setTopMargin($tab_top_newpage);
569 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
570 $pageposbefore = $pdf->getPage();
572 $showpricebeforepagebreak = 1;
574 $posYAfterDescription = 0;
577 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
578 $pdf->AddPage(
'',
'',
true);
579 if (!empty($tplidx)) {
580 $pdf->useTemplate($tplidx);
583 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
584 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
586 $pdf->setPage($pageposbefore + 1);
588 $curY = $tab_top_newpage;
591 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
592 $showpricebeforepagebreak = 1;
594 $showpricebeforepagebreak = 0;
598 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
599 $curX = $this->posxpicture - 1;
600 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
602 $posYAfterImage = $curY + $imglinesize[
'height'];
606 $curX = $this->posxdesc - 1;
608 $pdf->startTransaction();
609 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
610 $pageposafter = $pdf->getPage();
611 if ($pageposafter > $pageposbefore) {
612 $pdf->rollbackTransaction(
true);
613 $pageposafter = $pageposbefore;
615 $pdf->setPageOrientation(
'', 1, $heightforfooter);
616 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
617 $pageposafter = $pdf->getPage();
618 $posyafter = $pdf->GetY();
620 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
621 if ($i == ($nblines - 1)) {
622 $pdf->AddPage(
'',
'',
true);
623 if (!empty($tplidx)) {
624 $pdf->useTemplate($tplidx);
627 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
628 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
630 $pdf->setPage($pageposafter + 1);
636 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
637 $showpricebeforepagebreak = 1;
639 $showpricebeforepagebreak = 0;
644 $pdf->commitTransaction();
646 $posYAfterDescription = $pdf->GetY();
648 $nexY = $pdf->GetY();
649 $pageposafter = $pdf->getPage();
650 $pdf->setPage($pageposbefore);
651 $pdf->setTopMargin($this->marge_haute);
652 $pdf->setPageOrientation(
'', 1, 0);
655 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
656 $pdf->setPage($pageposafter);
657 $curY = $tab_top_newpage;
660 $pdf->SetFont(
'',
'', $default_font_size - 1);
663 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
665 $pdf->SetXY($this->posxtva - 5, $curY);
666 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
671 $pdf->SetXY($this->posxup, $curY);
672 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
676 $pdf->SetXY($this->posxqty, $curY);
677 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
681 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
682 $pdf->SetXY($this->posxunit, $curY);
683 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
687 if ($object->lines[$i]->remise_percent) {
688 $pdf->SetXY($this->posxdiscount - 2, $curY);
690 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
694 if ($this->situationinvoice) {
696 $pdf->SetXY($this->posxprogress, $curY);
697 $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0,
'R');
702 $pdf->SetXY($this->postotalht, $curY);
703 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
707 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
711 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
712 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
713 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
714 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
716 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
719 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
720 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
722 $tvaligne = $sign * $object->lines[$i]->total_tva;
726 $localtax1ligne = $object->lines[$i]->total_localtax1;
727 $localtax2ligne = $object->lines[$i]->total_localtax2;
728 $localtax1_rate = $object->lines[$i]->localtax1_tx;
729 $localtax2_rate = $object->lines[$i]->localtax2_tx;
730 $localtax1_type = $object->lines[$i]->localtax1_type;
731 $localtax2_type = $object->lines[$i]->localtax2_type;
733 if ($object->remise_percent) {
734 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
736 if ($object->remise_percent) {
737 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
739 if ($object->remise_percent) {
740 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
743 $vatrate = (string) $object->lines[$i]->tva_tx;
746 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
747 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
749 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
750 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
754 if ($localtax1_type && $localtax1ligne != 0) {
755 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
756 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
758 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
761 if ($localtax2_type && $localtax2ligne != 0) {
762 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
763 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
765 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
769 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
774 if (!isset($this->tva[$vatrate])) {
775 $this->tva[$vatrate] = 0;
777 $this->tva[$vatrate] += $tvaligne;
778 $vatcode = $object->lines[$i]->vat_src_code;
779 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
780 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
782 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
784 if ($posYAfterImage > $posYAfterDescription) {
785 $nexY = $posYAfterImage;
789 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
790 $pdf->setPage($pageposafter);
791 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
793 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
794 $pdf->SetLineStyle(array(
'dash'=>0));
800 while ($pagenb < $pageposafter) {
801 $pdf->setPage($pagenb);
803 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
805 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
807 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
809 $pdf->setPage($pagenb);
810 $pdf->setPageOrientation(
'', 1, 0);
812 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
813 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
815 if (!empty($tplidx)) {
816 $pdf->useTemplate($tplidx);
819 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
821 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
823 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
825 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
828 if (!empty($tplidx)) {
829 $pdf->useTemplate($tplidx);
833 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
834 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
841 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
842 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
844 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
845 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
847 dol_syslog(
"bottomlasttab=".$bottomlasttab.
" this->page_hauteur=".$this->page_hauteur.
" heightforinfotot=".$heightforinfotot.
" heightforfreetext=".$heightforfreetext.
" heightforfooter=".$heightforfooter);
850 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
853 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
856 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) {
861 $this->
_pagefoot($pdf, $object, $outputlangs);
862 if (method_exists($pdf,
'AliasNbPages')) {
863 $pdf->AliasNbPages();
868 $pdf->Output($file,
'F');
871 $hookmanager->initHooks(array(
'pdfgeneration'));
872 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
874 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
876 $this->error = $hookmanager->error;
877 $this->errors = $hookmanager->errors;
880 if (!empty($conf->global->MAIN_UMASK)) {
881 @chmod($file, octdec($conf->global->MAIN_UMASK));
884 $this->result = array(
'fullpath'=>$file);
888 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
892 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
916 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
920 $current_page = $pdf->getPage();
922 $tab3_top = $posy + 8;
925 if ($this->page_largeur < 210) {
931 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height);
935 $pdf->SetFont(
'',
'', $default_font_size - 4);
939 $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,";
940 $sql .=
" re.description, re.fk_facture_source,";
941 $sql .=
" f.type, f.datef";
942 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
943 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int) $object->id);
951 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
954 $pdf->AddPage(
'',
'',
true);
955 if (!empty($tplidx)) {
956 $pdf->useTemplate($tplidx);
959 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
960 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
962 $pdf->setPage($current_page);
963 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
966 $obj = $this->
db->fetch_object(
$resql);
968 if ($obj->type == 2) {
969 $text = $outputlangs->transnoentities(
"CreditNote");
970 } elseif ($obj->type == 3) {
971 $text = $outputlangs->transnoentities(
"Deposit");
972 } elseif ($obj->type == 0) {
973 $text = $outputlangs->transnoentities(
"ExcessReceived");
975 $text = $outputlangs->transnoentities(
"UnknownType");
978 $invoice->fetch($obj->fk_facture_source);
980 $pdf->SetXY($tab3_posx, $tab3_top + $y);
981 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
982 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
983 $pdf->MultiCell(20, 3,
price((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
984 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
985 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
986 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
987 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
989 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
994 $this->error = $this->
db->lasterror();
1000 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1002 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1003 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1004 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
1006 $sql .=
" ORDER BY p.datep";
1010 $num = $this->
db->num_rows(
$resql);
1014 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1017 $pdf->AddPage(
'',
'',
true);
1018 if (!empty($tplidx)) {
1019 $pdf->useTemplate($tplidx);
1022 $top_shift = $this->
_pagehead($pdf, $object, 0, $outputlangs);
1023 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1025 $pdf->setPage($current_page);
1026 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
1029 $row = $this->
db->fetch_object(
$resql);
1031 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1032 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1033 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1034 $pdf->MultiCell(20, 3,
price($sign * ((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1035 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1036 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1038 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1039 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1040 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1042 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1047 return $tab3_top + $y + 3;
1049 $this->error = $this->
db->lasterror();
1072 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1073 if ($object->type == 2) {
1074 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1077 $pdf->SetFont(
'',
'', $default_font_size - 3);
1078 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1079 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1081 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1083 $pdf->SetFont(
'',
'', $default_font_size - 4);
1084 $pdf->SetXY($tab3_posx, $tab3_top);
1085 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1086 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1087 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1088 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1089 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1090 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1091 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1093 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1108 protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
1111 global $conf, $mysoc;
1115 $pdf->SetFont(
'',
'', $default_font_size - 1);
1118 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1119 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1120 $pdf->SetXY($this->marge_gauche, $posy);
1121 if ($mysoc->forme_juridique_code == 92) {
1122 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1124 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1127 $posy = $pdf->GetY() + 4;
1133 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
1134 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1135 $pdf->SetXY($this->marge_gauche, $posy);
1136 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1137 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1139 $pdf->SetFont(
'',
'', $default_font_size - 2);
1140 $pdf->SetXY($posxval, $posy);
1141 $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);
1142 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1143 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1145 $posy = $pdf->GetY() + 3;
1148 if ($object->type != 2) {
1150 if (empty($object->mode_reglement_code)
1151 && empty($conf->global->FACTURE_CHQ_NUMBER)
1153 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1154 } elseif (($object->mode_reglement_code ==
'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
1155 || ($object->mode_reglement_code ==
'VIR' && !
getDolGlobalInt(
'FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
1157 $outputlangs->load(
"errors");
1159 $pdf->SetXY($this->marge_gauche, $posy);
1160 $pdf->SetTextColor(200, 0, 0);
1161 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1162 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1163 $pdf->MultiCell(80, 3, $this->error, 0,
'L', 0);
1164 $pdf->SetTextColor(0, 0, 0);
1166 $posy = $pdf->GetY() + 1;
1170 if (!empty($object->mode_reglement_code)
1171 && $object->mode_reglement_code !=
'CHQ'
1172 && $object->mode_reglement_code !=
'VIR') {
1173 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1174 $pdf->SetXY($this->marge_gauche, $posy);
1175 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1176 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1178 $pdf->SetFont(
'',
'', $default_font_size - 2);
1179 $pdf->SetXY($posxval, $posy);
1180 $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);
1182 if ($object->mode_reglement_code ==
"PRE") {
1183 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1185 $bac->fetch(0, $object->thirdparty->id);
1186 $iban= $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1187 $lib_mode_reg .= $outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1189 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1191 $posy = $pdf->GetY();
1197 if ($this->emetteur->country_code ==
'FR') {
1198 if (isset($conf->global->TAX_MODE) && $conf->global->TAX_MODE == 1) {
1199 $pdf->SetXY($this->marge_gauche, $posy);
1200 $pdf->writeHTMLCell(80, 5,
'',
'', $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1202 $posy = $pdf->GetY() + 1;
1207 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CB' || $object->mode_reglement_code ==
'VAD') {
1208 $useonlinepayment = 0;
1209 if (!empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)) {
1211 $useonlinepayment++;
1214 $useonlinepayment++;
1217 $useonlinepayment++;
1222 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1225 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1226 $servicename = $langs->transnoentities(
'Online');
1227 $paiement_url = getOnlinePaymentUrl(
'',
'invoice', $object->ref,
'',
'',
'');
1228 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1230 $pdf->SetXY($this->marge_gauche, $posy);
1233 $posy = $pdf->GetY() + 1;
1238 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1240 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
1241 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1243 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
1245 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1247 $pdf->SetXY($this->marge_gauche, $posy);
1248 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1249 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1250 $posy = $pdf->GetY() + 1;
1252 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1253 $pdf->SetXY($this->marge_gauche, $posy);
1254 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1255 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1256 $posy = $pdf->GetY() + 2;
1259 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1260 $pdf->SetXY($this->marge_gauche, $posy);
1261 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1262 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1263 $posy = $pdf->GetY() + 1;
1265 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1266 $pdf->SetXY($this->marge_gauche, $posy);
1267 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1268 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1269 $posy = $pdf->GetY() + 2;
1276 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1277 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1278 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1279 if ($object->fk_bank > 0) {
1280 $bankid = $object->fk_bank;
1283 $account->fetch($bankid);
1285 $curx = $this->marge_gauche;
1288 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1312 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
1315 global $conf, $mysoc, $hookmanager;
1318 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1324 $outputlangsbis =
null;
1325 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1326 $outputlangsbis =
new Translate(
'', $conf);
1327 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1328 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1329 $default_font_size--;
1334 $pdf->SetFont(
'',
'', $default_font_size - 1);
1339 if ($this->page_largeur < 210) {
1343 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1349 $pdf->SetFillColor(255, 255, 255);
1350 $pdf->SetXY($col1x, $tab2_top);
1351 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ?
"TotalHT" :
"Total").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ?
"TotalHT" :
"Total") :
''), 0,
'L', 1);
1353 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1354 $pdf->SetXY($col2x, $tab2_top);
1355 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1358 $pdf->SetFillColor(248, 248, 248);
1360 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1362 $this->atleastoneratenotnull = 0;
1363 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
1364 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1365 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
1373 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1374 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1378 foreach ($localtax_rate as $tvakey => $tvaval) {
1383 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1386 if (preg_match(
'/\*/', $tvakey)) {
1387 $tvakey = str_replace(
'*',
'', $tvakey);
1388 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1391 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1393 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1394 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1396 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1397 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1405 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1406 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1410 foreach ($localtax_rate as $tvakey => $tvaval) {
1415 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1418 if (preg_match(
'/\*/', $tvakey)) {
1419 $tvakey = str_replace(
'*',
'', $tvakey);
1420 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1422 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1424 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1425 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1427 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1428 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1436 foreach ($this->tva_array as $tvakey => $tvaval) {
1438 $this->atleastoneratenotnull++;
1441 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1444 if (preg_match(
'/\*/', $tvakey)) {
1445 $tvakey = str_replace(
'*',
'', $tvakey);
1446 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1448 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1451 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1453 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1455 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1457 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1459 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1460 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1467 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1468 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1472 foreach ($localtax_rate as $tvakey => $tvaval) {
1477 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1480 if (preg_match(
'/\*/', $tvakey)) {
1481 $tvakey = str_replace(
'*',
'', $tvakey);
1482 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1484 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1485 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1487 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1488 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1489 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1497 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1498 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1502 foreach ($localtax_rate as $tvakey => $tvaval) {
1506 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1509 if (preg_match(
'/\*/', $tvakey)) {
1510 $tvakey = str_replace(
'*',
'', $tvakey);
1511 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1513 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1515 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1516 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1518 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1519 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1525 if (
price2num($object->revenuestamp) != 0) {
1527 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1528 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp"), $useborder,
'L', 1);
1530 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1531 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $object->revenuestamp), $useborder,
'R', 1);
1536 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1537 $pdf->SetTextColor(0, 0, 60);
1538 $pdf->SetFillColor(224, 224, 224);
1539 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1541 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1542 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1545 if ($object->displayRetainedWarranty()) {
1546 $pdf->SetTextColor(40, 40, 40);
1547 $pdf->SetFillColor(255, 255, 255);
1549 $retainedWarranty = $object->getRetainedWarrantyAmount();
1550 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1554 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1555 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date($object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1557 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1558 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1562 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1564 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").
' ('.$object->retained_warranty.
'%)';
1565 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date($object->retained_warranty_date_limit,
'day')) :
'';
1567 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1568 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1569 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1574 $pdf->SetTextColor(0, 0, 0);
1575 $creditnoteamount = $object->getSumCreditNotesUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1576 $depositsamount = $object->getSumDepositsUsed((
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
1578 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1579 if (!empty($object->paye)) {
1583 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) {
1586 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1587 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L', 0);
1588 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1589 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1592 if ($creditnoteamount) {
1593 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1595 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1596 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1597 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1598 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1602 if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1604 $pdf->SetFillColor(255, 255, 255);
1606 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1607 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L', 1);
1608 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1609 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R', 1);
1615 $pdf->SetTextColor(0, 0, 60);
1616 $pdf->SetFillColor(224, 224, 224);
1617 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1618 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1619 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1620 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1622 $pdf->SetFont(
'',
'', $default_font_size - 1);
1623 $pdf->SetTextColor(0, 0, 0);
1627 return ($tab2_top + ($tab2_hl * $index));
1644 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1654 $currency = !empty($currency) ? $currency : $conf->currency;
1658 $pdf->SetTextColor(0, 0, 0);
1659 $pdf->SetFont(
'',
'', $default_font_size - 2);
1661 if (empty($hidetop)) {
1662 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1663 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1664 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1667 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1668 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1672 $pdf->SetDrawColor(128, 128, 128);
1673 $pdf->SetFont(
'',
'', $default_font_size - 1);
1676 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1678 if (empty($hidetop)) {
1679 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1681 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1682 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1685 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) {
1686 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1687 if (empty($hidetop)) {
1693 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1694 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1695 if (empty($hidetop)) {
1696 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1697 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1701 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1702 if (empty($hidetop)) {
1703 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1704 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1707 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1708 if (empty($hidetop)) {
1709 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1710 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1714 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1715 if (empty($hidetop)) {
1716 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1717 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1721 if ($this->atleastonediscount) {
1722 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1723 if (empty($hidetop)) {
1724 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1725 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1729 if ($this->situationinvoice) {
1730 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1731 if (empty($hidetop)) {
1732 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1733 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities(
"ProgressShort"),
'',
'C');
1737 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1738 if (empty($hidetop)) {
1739 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1740 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
1755 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
1757 global $conf, $langs;
1759 $ltrdirection =
'L';
1760 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
1763 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
1769 $pdf->SetTextColor(0, 0, 60);
1770 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1774 $posy = $this->marge_haute;
1775 $posx = $this->page_largeur - $this->marge_droite - $w;
1777 $pdf->SetXY($this->marge_gauche, $posy);
1781 if ($this->emetteur->logo) {
1782 $logodir = $conf->mycompany->dir_output;
1783 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1784 $logodir = $conf->mycompany->multidir_output[$object->entity];
1787 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1789 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1791 if (is_readable($logo)) {
1793 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1795 $pdf->SetTextColor(200, 0, 0);
1796 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1797 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1798 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1801 $text = $this->emetteur->name;
1802 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1806 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1807 $pdf->SetXY($posx, $posy);
1808 $pdf->SetTextColor(0, 0, 60);
1809 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
1810 if ($object->type == 1) {
1811 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
1813 if ($object->type == 2) {
1814 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
1816 if ($object->type == 3) {
1817 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
1819 if ($object->type == 4) {
1820 $title = $outputlangs->transnoentities(
"InvoiceProForma");
1822 if ($this->situationinvoice) {
1823 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
1825 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1827 if ($object->type == 0) {
1828 if ($this->situationinvoice) {
1829 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
1831 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
1832 } elseif ($object->type == 1) {
1833 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
1834 } elseif ($object->type == 2) {
1835 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
1836 } elseif ($object->type == 3) {
1837 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
1838 } elseif ($object->type == 4) {
1839 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
1842 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1843 if ($object->statut == $object::STATUS_DRAFT) {
1844 $pdf->SetTextColor(128, 0, 0);
1845 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1848 $pdf->MultiCell($w, 3, $title,
'',
'R');
1850 $pdf->SetFont(
'',
'B', $default_font_size);
1864 $pdf->SetFont(
'',
'', $default_font_size - 2);
1866 if ($object->ref_client) {
1868 $pdf->SetXY($posx, $posy);
1869 $pdf->SetTextColor(0, 0, 60);
1870 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1873 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1874 $object->fetch_projet();
1875 if (!empty($object->project->ref)) {
1877 $pdf->SetXY($posx, $posy);
1878 $pdf->SetTextColor(0, 0, 60);
1879 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1883 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1884 $object->fetch_projet();
1885 if (!empty($object->project->ref)) {
1886 $outputlangs->load(
"projects");
1888 $pdf->SetXY($posx, $posy);
1889 $pdf->SetTextColor(0, 0, 60);
1890 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1894 $objectidnext = $object->getIdReplacingInvoice(
'validated');
1895 if ($object->type == 0 && $objectidnext) {
1896 $objectreplacing =
new Facture($this->
db);
1897 $objectreplacing->fetch($objectidnext);
1900 $pdf->SetXY($posx, $posy);
1901 $pdf->SetTextColor(0, 0, 60);
1902 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
1904 if ($object->type == 1) {
1905 $objectreplaced =
new Facture($this->
db);
1906 $objectreplaced->fetch($object->fk_facture_source);
1909 $pdf->SetXY($posx, $posy);
1910 $pdf->SetTextColor(0, 0, 60);
1911 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
1913 if ($object->type == 2 && !empty($object->fk_facture_source)) {
1914 $objectreplaced =
new Facture($this->
db);
1915 $objectreplaced->fetch($object->fk_facture_source);
1918 $pdf->SetXY($posx, $posy);
1919 $pdf->SetTextColor(0, 0, 60);
1920 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
1924 $pdf->SetXY($posx, $posy);
1925 $pdf->SetTextColor(0, 0, 60);
1926 $title = $outputlangs->transnoentities(
"DateInvoice");
1927 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1928 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1930 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1932 if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) {
1934 $pdf->SetXY($posx, $posy);
1935 $pdf->SetTextColor(0, 0, 60);
1936 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date($object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
1939 if ($object->type != 2) {
1941 $pdf->SetXY($posx, $posy);
1942 $pdf->SetTextColor(0, 0, 60);
1943 $title = $outputlangs->transnoentities(
"DateDue");
1944 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1945 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
1947 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
1950 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && $object->thirdparty->code_client) {
1952 $pdf->SetXY($posx, $posy);
1953 $pdf->SetTextColor(0, 0, 60);
1954 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1958 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1959 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1960 if (count($arrayidcontact) > 0) {
1961 $usertmp =
new User($this->
db);
1962 $usertmp->fetch($arrayidcontact[0]);
1964 $pdf->SetXY($posx, $posy);
1965 $pdf->SetTextColor(0, 0, 60);
1966 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1974 $current_y = $pdf->getY();
1975 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1976 if ($current_y < $pdf->getY()) {
1977 $top_shift = $pdf->getY() - $current_y;
1982 $carac_emetteur =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1985 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1986 $posy += $top_shift;
1987 $posx = $this->marge_gauche;
1988 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1989 $posx = $this->page_largeur - $this->marge_droite - 80;
1992 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1993 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1997 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1998 $pdf->SetTextColor(0, 0, 0);
1999 $pdf->SetFont(
'',
'', $default_font_size - 2);
2000 $pdf->SetXY($posx, $posy - 5);
2001 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2002 $pdf->SetXY($posx, $posy);
2003 $pdf->SetFillColor(230, 230, 230);
2004 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2005 $pdf->SetTextColor(0, 0, 60);
2009 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
2010 $pdf->SetXY($posx + 2, $posy + 3);
2011 $pdf->SetFont(
'',
'B', $default_font_size);
2012 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2013 $posy = $pdf->getY();
2017 $pdf->SetXY($posx + 2, $posy);
2018 $pdf->SetFont(
'',
'', $default_font_size - 1);
2019 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2023 $usecontact =
false;
2024 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
2025 if (count($arrayidcontact) > 0) {
2027 $result = $object->fetch_contact($arrayidcontact[0]);
2031 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
2032 $thirdparty = $object->contact;
2034 $thirdparty = $object->thirdparty;
2040 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
2043 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
2044 if ($this->page_largeur < 210) {
2047 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
2048 $posy += $top_shift;
2049 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2050 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
2051 $posx = $this->marge_gauche;
2055 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
2056 $pdf->SetTextColor(0, 0, 0);
2057 $pdf->SetFont(
'',
'', $default_font_size - 2);
2058 $pdf->SetXY($posx + 2, $posy - 5);
2059 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2060 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2064 $pdf->SetXY($posx + 2, $posy + 3);
2065 $pdf->SetFont(
'',
'B', $default_font_size);
2066 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2068 $posy = $pdf->getY();
2071 $pdf->SetFont(
'',
'', $default_font_size - 1);
2072 $pdf->SetXY($posx + 2, $posy);
2073 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2077 $idaddressshipping = $object->getIdContact(
'external',
'SHIPPING');
2079 if (!empty($idaddressshipping)) {
2080 $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
2081 $object->fetch_thirdparty($object->contact->fk_soc);
2083 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact,
'target', $object);
2086 $carac_client_shipping=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'target', $object);
2088 if (!empty($carac_client_shipping) && (isset($object->contact->socid) && $object->contact->socid != $object->socid)) {
2089 $posy += $hautcadre;
2092 $pdf->SetXY($posx + 2, $posy - 5);
2093 $pdf->SetFont(
'',
'', $default_font_size - 2);
2094 $pdf->MultiCell($widthrecbox,
'', $langs->trans(
'ShippingTo'), 0,
'L', 0);
2095 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2098 $pdf->SetXY($posx + 2, $posy + 3);
2099 $pdf->SetFont(
'',
'B', $default_font_size);
2100 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2102 $posy = $pdf->getY();
2105 $pdf->SetXY($posx+2, $posy);
2106 $pdf->SetFont(
'',
'', $default_font_size - 1);
2107 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2108 $top_shift += $hautcadre;
2113 $pdf->SetTextColor(0, 0, 0);
2127 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
2129 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
2130 return pdf_pagefoot($pdf, $outputlangs,
'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
Class to manage bank accounts.
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Class to manage bank accounts description of third parties.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
Parent class of invoice document generators.
Class to manage products or services.
Class to manage translations.
Class to manage Dolibarr users.
Class to generate the customer invoice PDF with template Crabe.
__construct($db)
Constructor.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null)
Show top header of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
_tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter=0)
Show payments table.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
Show miscellaneous information (payment mode, payment term, ...)
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height)
Function _tableau_versements_header.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
Show total to pay.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!function_exists('dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
pdf_getlineprogress($object, $i, $outputlangs, $hidedetails=0, $hookmanager=null)
Return line percent.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formated for output on documents.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.