34 require_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
35 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
64 public $update_main_doc_field;
75 public $phpmin = array(5, 6);
81 public $version =
'dolibarr';
101 public $marge_gauche;
106 public $marge_droite;
127 public $situationinvoice;
132 public $posxprogress;
142 global $conf, $langs, $mysoc;
145 $langs->loadLangs(array(
"main",
"bills"));
148 $this->
name =
"crabe";
149 $this->
description = $langs->trans(
'PDFCrabeDescription');
150 $this->update_main_doc_field = 1;
155 $this->page_largeur = $formatarray[
'width'];
156 $this->page_hauteur = $formatarray[
'height'];
157 $this->format = array($this->page_largeur, $this->page_hauteur);
158 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
159 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
160 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
161 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
163 $this->option_logo = 1;
164 $this->option_tva = 1;
165 $this->option_modereg = 1;
166 $this->option_condreg = 1;
167 $this->option_multilang = 1;
168 $this->option_escompte = 1;
169 $this->option_credit_note = 1;
170 $this->option_freetext = 1;
171 $this->option_draft_watermark = 1;
172 $this->watermark =
'';
175 $this->emetteur = $mysoc;
176 if (empty($this->emetteur->country_code)) {
177 $this->emetteur->country_code = substr($langs->defaultlang, -2);
181 $this->posxdesc = $this->marge_gauche + 1;
182 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
183 $this->posxtva = 101;
185 $this->posxqty = 135;
186 $this->posxunit = 151;
188 $this->posxtva = 110;
190 $this->posxqty = 145;
191 $this->posxunit = 162;
193 $this->posxprogress = 151;
194 $this->posxdiscount = 162;
195 $this->posxprogress = 174;
196 $this->postotalht = 174;
197 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
198 $this->posxtva = $this->posxup;
200 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
201 if ($this->page_largeur < 210) {
202 $this->posxpicture -= 20;
203 $this->posxtva -= 20;
205 $this->posxqty -= 20;
206 $this->posxunit -= 20;
207 $this->posxdiscount -= 20;
208 $this->posxprogress -= 20;
209 $this->postotalht -= 20;
212 $this->tva = array();
213 $this->tva_array = array();
214 $this->localtax1 = array();
215 $this->localtax2 = array();
216 $this->atleastoneratenotnull = 0;
217 $this->atleastonediscount = 0;
218 $this->situationinvoice =
false;
234 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
237 global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
239 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
241 if (!is_object($outputlangs)) {
242 $outputlangs = $langs;
245 if (!empty($conf->global->MAIN_USE_FPDF)) {
246 $outputlangs->charset_output =
'ISO-8859-1';
250 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
253 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) {
254 $this->watermark = $conf->global->FACTURE_DRAFT_WATERMARK;
257 global $outputlangsbis;
258 $outputlangsbis =
null;
259 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
260 $outputlangsbis =
new Translate(
'', $conf);
261 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
262 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
265 $nblines = count($object->lines);
268 $realpatharray = array();
269 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) {
270 for ($i = 0; $i < $nblines; $i++) {
271 if (empty($object->lines[$i]->fk_product)) {
276 $objphoto->fetch($object->lines[$i]->fk_product);
278 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
279 $dir = $conf->product->dir_output.
'/'.$pdir;
282 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
283 $filename = $obj[
'photo'];
285 $realpath = $dir.$filename;
290 $realpatharray[$i] = $realpath;
294 if (count($realpatharray) == 0) {
295 $this->posxpicture = $this->posxtva;
298 if ($conf->facture->dir_output) {
299 $object->fetch_thirdparty();
301 $deja_regle = $object->getSommePaiement((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
302 $amount_credit_notes_included = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
303 $amount_deposits_included = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
306 if ($object->specimen) {
307 $dir = empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$conf->entity];
308 $file = $dir.
"/SPECIMEN.pdf";
311 $dir = (empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$conf->entity]).
"/".$objectref;
312 $file = $dir.
"/".$objectref.
".pdf";
314 if (!file_exists($dir)) {
316 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
321 if (file_exists($dir)) {
323 if (!is_object($hookmanager)) {
324 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
327 $hookmanager->initHooks(array(
'pdfgeneration'));
328 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
330 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
333 $nblines = count($object->lines);
334 $nbpayments = count($object->getListOfPayments());
339 $pdf->SetAutoPageBreak(1, 0);
341 $heightforinfotot = 50 + (4 * $nbpayments);
342 if ($heightforinfotot > 220) {
343 $heightforinfotot = 220;
345 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
346 $heightforfooter = $this->marge_basse + 8;
347 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
348 $heightforfooter += 6;
351 if (class_exists(
'TCPDF')) {
352 $pdf->setPrintHeader(
false);
353 $pdf->setPrintFooter(
false);
358 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
359 $logodir = $conf->mycompany->dir_output;
360 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
361 $logodir = $conf->mycompany->multidir_output[$object->entity];
363 $pagecount = $pdf->setSourceFile($logodir.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
364 $tplidx = $pdf->importPage(1);
369 $pdf->SetDrawColor(128, 128, 128);
371 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
372 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
373 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
374 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
375 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
376 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
377 $pdf->SetCompression(
false);
381 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
382 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
385 $cert = empty($conf->global->CERTIFICATE_CRT) ?
'' : $conf->global->CERTIFICATE_CRT;
388 $certprivate = empty($conf->global->CERTIFICATE_CRT_PRIVATE) ?
'' : $conf->global->CERTIFICATE_CRT_PRIVATE;
393 'Name' => $this->emetteur->name,
394 'Location' =>
getCountry($this->emetteur->country_code, 0),
395 'Reason' =>
'INVOICE',
396 'ContactInfo' => $this->emetteur->email
398 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
401 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
404 for ($i = 0; $i < $nblines; $i++) {
405 if ($object->lines[$i]->remise_percent) {
406 $this->atleastonediscount++;
409 if (empty($this->atleastonediscount)) {
410 $delta = ($this->posxprogress - $this->posxdiscount);
411 $this->posxpicture += $delta;
412 $this->posxtva += $delta;
413 $this->posxup += $delta;
414 $this->posxqty += $delta;
415 $this->posxunit += $delta;
416 $this->posxdiscount += $delta;
422 if ($object->situation_cycle_ref && empty($conf->global->MAIN_PDF_HIDE_SITUATION)) {
423 $this->situationinvoice =
true;
424 $progress_width = 10;
425 $this->posxpicture -= $progress_width;
426 $this->posxtva -= $progress_width;
427 $this->posxup -= $progress_width;
428 $this->posxqty -= $progress_width;
429 $this->posxunit -= $progress_width;
430 $this->posxdiscount -= $progress_width;
431 $this->posxprogress -= $progress_width;
436 if (!empty($tplidx)) {
437 $pdf->useTemplate($tplidx);
442 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
443 $pdf->SetFont(
'',
'', $default_font_size - 1);
444 $pdf->MultiCell(0, 3,
'');
445 $pdf->SetTextColor(0, 0, 0);
450 $tab_top = 90 + $top_shift;
451 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
454 $extra_under_address_shift = 0;
456 if (! empty($conf->global->INVOICE_ADD_ZATCA_QR_CODE)) {
457 $qrcodestring = $object->buildZATCAQRString();
458 } elseif (! empty($conf->global->INVOICE_ADD_SWISS_QR_CODE)) {
459 $qrcodestring = $object->buildSwitzerlandQRString();
462 $qrcodecolor = array(
'25',
'25',
'25');
467 'fgcolor' => $qrcodecolor,
472 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr,
'N');
473 $extra_under_address_shift += 25;
481 'outputlangs' => $outputlangs,
482 'hidedetails' => $hidedetails
484 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
485 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
486 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_header_shift'];
489 $tab_top += $extra_under_address_shift;
490 $tab_top_newpage += 0;
493 $height_incoterms = 0;
494 if (!empty($conf->incoterm->enabled)) {
495 $desc_incoterms = $object->getIncotermsForPDF();
496 if ($desc_incoterms) {
499 $pdf->SetFont(
'',
'', $default_font_size - 1);
500 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
501 $nexY = $pdf->GetY();
502 $height_incoterms = $nexY - $tab_top;
505 $pdf->SetDrawColor(192, 192, 192);
506 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
508 $tab_top = $nexY + 6;
513 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
514 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
516 if (is_object($object->thirdparty)) {
517 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
518 $salerepobj =
new User($this->
db);
519 $salerepobj->fetch($salereparray[0][
'id']);
520 if (!empty($salerepobj->signature)) {
521 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
526 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
527 if (!empty($extranote)) {
539 $pdf->SetFont(
'',
'', $default_font_size - 1);
540 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
541 $nexY = $pdf->GetY();
542 $height_note = $nexY - $tab_top;
545 $pdf->SetDrawColor(192, 192, 192);
546 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
548 $tab_top = $nexY + 6;
551 $iniY = $tab_top + 7;
552 $curY = $tab_top + 7;
553 $nexY = $tab_top + 7;
556 for ($i = 0; $i < $nblines; $i++) {
558 $pdf->SetFont(
'',
'', $default_font_size - 1);
559 $pdf->SetTextColor(0, 0, 0);
562 $imglinesize = array();
563 if (!empty($realpatharray[$i])) {
567 $pdf->setTopMargin($tab_top_newpage);
568 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
569 $pageposbefore = $pdf->getPage();
571 $showpricebeforepagebreak = 1;
573 $posYAfterDescription = 0;
576 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
577 $pdf->AddPage(
'',
'',
true);
578 if (!empty($tplidx)) {
579 $pdf->useTemplate($tplidx);
581 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
582 $this->
_pagehead($pdf, $object, 0, $outputlangs);
584 $pdf->setPage($pageposbefore + 1);
586 $curY = $tab_top_newpage;
589 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
590 $showpricebeforepagebreak = 1;
592 $showpricebeforepagebreak = 0;
596 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
597 $curX = $this->posxpicture - 1;
598 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
600 $posYAfterImage = $curY + $imglinesize[
'height'];
604 $curX = $this->posxdesc - 1;
606 $pdf->startTransaction();
607 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
608 $pageposafter = $pdf->getPage();
609 if ($pageposafter > $pageposbefore) {
610 $pdf->rollbackTransaction(
true);
611 $pageposafter = $pageposbefore;
613 $pdf->setPageOrientation(
'', 1, $heightforfooter);
614 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
615 $pageposafter = $pdf->getPage();
616 $posyafter = $pdf->GetY();
618 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
619 if ($i == ($nblines - 1)) {
620 $pdf->AddPage(
'',
'',
true);
621 if (!empty($tplidx)) {
622 $pdf->useTemplate($tplidx);
624 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
625 $this->
_pagehead($pdf, $object, 0, $outputlangs);
627 $pdf->setPage($pageposafter + 1);
633 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
634 $showpricebeforepagebreak = 1;
636 $showpricebeforepagebreak = 0;
641 $pdf->commitTransaction();
643 $posYAfterDescription = $pdf->GetY();
645 $nexY = $pdf->GetY();
646 $pageposafter = $pdf->getPage();
647 $pdf->setPage($pageposbefore);
648 $pdf->setTopMargin($this->marge_haute);
649 $pdf->setPageOrientation(
'', 1, 0);
652 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
653 $pdf->setPage($pageposafter);
654 $curY = $tab_top_newpage;
657 $pdf->SetFont(
'',
'', $default_font_size - 1);
660 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
662 $pdf->SetXY($this->posxtva - 5, $curY);
663 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
668 $pdf->SetXY($this->posxup, $curY);
669 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
673 $pdf->SetXY($this->posxqty, $curY);
674 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
677 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
678 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
679 $pdf->SetXY($this->posxunit, $curY);
680 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
684 if ($object->lines[$i]->remise_percent) {
685 $pdf->SetXY($this->posxdiscount - 2, $curY);
687 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
691 if ($this->situationinvoice) {
693 $pdf->SetXY($this->posxprogress, $curY);
694 $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0,
'R');
699 $pdf->SetXY($this->postotalht, $curY);
700 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
704 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
708 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
709 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
710 if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) {
711 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
713 $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
716 if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) {
717 $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
719 $tvaligne = $sign * $object->lines[$i]->total_tva;
723 $localtax1ligne = $object->lines[$i]->total_localtax1;
724 $localtax2ligne = $object->lines[$i]->total_localtax2;
725 $localtax1_rate = $object->lines[$i]->localtax1_tx;
726 $localtax2_rate = $object->lines[$i]->localtax2_tx;
727 $localtax1_type = $object->lines[$i]->localtax1_type;
728 $localtax2_type = $object->lines[$i]->localtax2_type;
730 if ($object->remise_percent) {
731 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
733 if ($object->remise_percent) {
734 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
736 if ($object->remise_percent) {
737 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
740 $vatrate = (string) $object->lines[$i]->tva_tx;
743 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
744 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
746 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
747 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
751 if ($localtax1_type && $localtax1ligne != 0) {
752 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
754 if ($localtax2_type && $localtax2ligne != 0) {
755 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
758 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
763 if (!isset($this->tva[$vatrate])) {
764 $this->tva[$vatrate] = 0;
766 $this->tva[$vatrate] += $tvaligne;
767 $vatcode = $object->lines[$i]->vat_src_code;
768 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
769 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
771 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
773 if ($posYAfterImage > $posYAfterDescription) {
774 $nexY = $posYAfterImage;
778 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
779 $pdf->setPage($pageposafter);
780 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
782 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
783 $pdf->SetLineStyle(array(
'dash'=>0));
789 while ($pagenb < $pageposafter) {
790 $pdf->setPage($pagenb);
792 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
794 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
796 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
798 $pdf->setPage($pagenb);
799 $pdf->setPageOrientation(
'', 1, 0);
800 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
801 $this->
_pagehead($pdf, $object, 0, $outputlangs);
803 if (!empty($tplidx)) {
804 $pdf->useTemplate($tplidx);
807 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
809 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
811 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
813 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
816 if (!empty($tplidx)) {
817 $pdf->useTemplate($tplidx);
820 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
821 $this->
_pagehead($pdf, $object, 0, $outputlangs);
828 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
829 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
831 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
832 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
834 dol_syslog(
"bottomlasttab=".$bottomlasttab.
" this->page_hauteur=".$this->page_hauteur.
" heightforinfotot=".$heightforinfotot.
" heightforfreetext=".$heightforfreetext.
" heightforfooter=".$heightforfooter);
837 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
840 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
843 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) {
848 $this->
_pagefoot($pdf, $object, $outputlangs);
849 if (method_exists($pdf,
'AliasNbPages')) {
850 $pdf->AliasNbPages();
855 $pdf->Output($file,
'F');
858 $hookmanager->initHooks(array(
'pdfgeneration'));
859 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
861 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
863 $this->error = $hookmanager->error;
864 $this->errors = $hookmanager->errors;
867 if (!empty($conf->global->MAIN_UMASK)) {
868 @chmod($file, octdec($conf->global->MAIN_UMASK));
871 $this->result = array(
'fullpath'=>$file);
875 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
879 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
903 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
907 $current_page = $pdf->getPage();
909 $tab3_top = $posy + 8;
912 if ($this->page_largeur < 210) {
918 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height);
922 $pdf->SetFont(
'',
'', $default_font_size - 4);
926 $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,";
927 $sql .=
" re.description, re.fk_facture_source,";
928 $sql .=
" f.type, f.datef";
929 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
930 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int) $object->id);
938 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
941 $pdf->AddPage(
'',
'',
true);
942 if (!empty($tplidx)) {
943 $pdf->useTemplate($tplidx);
945 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
946 $this->
_pagehead($pdf, $object, 0, $outputlangs);
948 $pdf->setPage($current_page);
949 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
952 $obj = $this->
db->fetch_object(
$resql);
954 if ($obj->type == 2) {
955 $text = $outputlangs->transnoentities(
"CreditNote");
956 } elseif ($obj->type == 3) {
957 $text = $outputlangs->transnoentities(
"Deposit");
958 } elseif ($obj->type == 0) {
959 $text = $outputlangs->transnoentities(
"ExcessReceived");
961 $text = $outputlangs->transnoentities(
"UnknownType");
964 $invoice->fetch($obj->fk_facture_source);
966 $pdf->SetXY($tab3_posx, $tab3_top + $y);
967 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
968 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
969 $pdf->MultiCell(20, 3,
price((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L', 0);
970 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
971 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
972 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
973 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
975 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
980 $this->error = $this->
db->lasterror();
986 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
988 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
989 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
990 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
992 $sql .=
" ORDER BY p.datep";
1000 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1003 $pdf->AddPage(
'',
'',
true);
1004 if (!empty($tplidx)) {
1005 $pdf->useTemplate($tplidx);
1007 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
1008 $this->
_pagehead($pdf, $object, 0, $outputlangs);
1010 $pdf->setPage($current_page);
1011 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
1014 $row = $this->
db->fetch_object(
$resql);
1016 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1017 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1018 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1019 $pdf->MultiCell(20, 3,
price($sign * ((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1020 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1021 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1023 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1024 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1025 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1027 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1032 return $tab3_top + $y + 3;
1034 $this->error = $this->
db->lasterror();
1057 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
1058 if ($object->type == 2) {
1059 $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
1062 $pdf->SetFont(
'',
'', $default_font_size - 3);
1063 $pdf->SetXY($tab3_posx, $tab3_top - 4);
1064 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
1066 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
1068 $pdf->SetFont(
'',
'', $default_font_size - 4);
1069 $pdf->SetXY($tab3_posx, $tab3_top);
1070 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
1071 $pdf->SetXY($tab3_posx + 21, $tab3_top);
1072 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
1073 $pdf->SetXY($tab3_posx + 40, $tab3_top);
1074 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
1075 $pdf->SetXY($tab3_posx + 58, $tab3_top);
1076 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
1078 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
1093 protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
1096 global $conf, $mysoc;
1100 $pdf->SetFont(
'',
'', $default_font_size - 1);
1103 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
1104 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1105 $pdf->SetXY($this->marge_gauche, $posy);
1106 if ($mysoc->forme_juridique_code == 92) {
1107 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L', 0);
1109 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1112 $posy = $pdf->GetY() + 4;
1118 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
1119 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1120 $pdf->SetXY($this->marge_gauche, $posy);
1121 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1122 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1124 $pdf->SetFont(
'',
'', $default_font_size - 2);
1125 $pdf->SetXY($posxval, $posy);
1126 $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);
1127 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1128 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1130 $posy = $pdf->GetY() + 3;
1133 if ($object->type != 2) {
1135 if (empty($object->mode_reglement_code)
1136 && empty($conf->global->FACTURE_CHQ_NUMBER)
1137 && empty($conf->global->FACTURE_RIB_NUMBER)) {
1138 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1139 } elseif (($object->mode_reglement_code ==
'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
1140 || ($object->mode_reglement_code ==
'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) {
1142 $outputlangs->load(
"errors");
1144 $pdf->SetXY($this->marge_gauche, $posy);
1145 $pdf->SetTextColor(200, 0, 0);
1146 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1147 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1148 $pdf->MultiCell(80, 3, $this->error, 0,
'L', 0);
1149 $pdf->SetTextColor(0, 0, 0);
1151 $posy = $pdf->GetY() + 1;
1155 if (!empty($object->mode_reglement_code)
1156 && $object->mode_reglement_code !=
'CHQ'
1157 && $object->mode_reglement_code !=
'VIR') {
1158 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1159 $pdf->SetXY($this->marge_gauche, $posy);
1160 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1161 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1163 $pdf->SetFont(
'',
'', $default_font_size - 2);
1164 $pdf->SetXY($posxval, $posy);
1165 $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);
1166 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1168 $posy = $pdf->GetY();
1172 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CB' || $object->mode_reglement_code ==
'VAD') {
1173 $useonlinepayment = 0;
1174 if (!empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)) {
1175 if (!empty($conf->paypal->enabled)) {
1176 $useonlinepayment++;
1178 if (!empty($conf->stripe->enabled)) {
1179 $useonlinepayment++;
1181 if (!empty($conf->paybox->enabled)) {
1182 $useonlinepayment++;
1187 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1190 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1191 $servicename = $langs->transnoentities(
'Online');
1192 $paiement_url = getOnlinePaymentUrl(
'',
'invoice', $object->ref,
'',
'',
'');
1193 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1195 $pdf->SetXY($this->marge_gauche, $posy);
1198 $posy = $pdf->GetY() + 1;
1203 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1205 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
1206 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1208 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
1210 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1212 $pdf->SetXY($this->marge_gauche, $posy);
1213 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1214 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1215 $posy = $pdf->GetY() + 1;
1217 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1218 $pdf->SetXY($this->marge_gauche, $posy);
1219 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1220 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1221 $posy = $pdf->GetY() + 2;
1224 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1225 $pdf->SetXY($this->marge_gauche, $posy);
1226 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1227 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1228 $posy = $pdf->GetY() + 1;
1230 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1231 $pdf->SetXY($this->marge_gauche, $posy);
1232 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1233 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1234 $posy = $pdf->GetY() + 2;
1241 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1242 if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
1243 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1244 if ($object->fk_bank > 0) {
1245 $bankid = $object->fk_bank;
1248 $account->fetch($bankid);
1250 $curx = $this->marge_gauche;
1253 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1277 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
1280 global $conf, $mysoc, $hookmanager;
1283 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1289 $outputlangsbis =
null;
1290 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1291 $outputlangsbis =
new Translate(
'', $conf);
1292 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1293 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1294 $default_font_size--;
1299 $pdf->SetFont(
'',
'', $default_font_size - 1);
1304 if ($this->page_largeur < 210) {
1308 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1314 $pdf->SetFillColor(255, 255, 255);
1315 $pdf->SetXY($col1x, $tab2_top + 0);
1316 $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);
1318 $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1319 $pdf->SetXY($col2x, $tab2_top + 0);
1320 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1323 $pdf->SetFillColor(248, 248, 248);
1325 $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1327 $this->atleastoneratenotnull = 0;
1328 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
1329 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1330 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
1338 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1339 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1343 foreach ($localtax_rate as $tvakey => $tvaval) {
1348 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1351 if (preg_match(
'/\*/', $tvakey)) {
1352 $tvakey = str_replace(
'*',
'', $tvakey);
1353 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1356 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1358 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1359 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1361 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1362 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1370 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1371 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1375 foreach ($localtax_rate as $tvakey => $tvaval) {
1380 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1383 if (preg_match(
'/\*/', $tvakey)) {
1384 $tvakey = str_replace(
'*',
'', $tvakey);
1385 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1387 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1389 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1390 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1392 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1393 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1401 foreach ($this->tva_array as $tvakey => $tvaval) {
1403 $this->atleastoneratenotnull++;
1406 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1409 if (preg_match(
'/\*/', $tvakey)) {
1410 $tvakey = str_replace(
'*',
'', $tvakey);
1411 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1413 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1416 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1418 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1420 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1422 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1424 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1425 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1432 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1433 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1437 foreach ($localtax_rate as $tvakey => $tvaval) {
1442 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1445 if (preg_match(
'/\*/', $tvakey)) {
1446 $tvakey = str_replace(
'*',
'', $tvakey);
1447 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1449 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1450 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1452 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1453 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1454 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1462 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1463 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1467 foreach ($localtax_rate as $tvakey => $tvaval) {
1471 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1474 if (preg_match(
'/\*/', $tvakey)) {
1475 $tvakey = str_replace(
'*',
'', $tvakey);
1476 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1478 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1480 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1481 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1483 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1484 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1490 if (
price2num($object->revenuestamp) != 0) {
1492 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1493 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp"), $useborder,
'L', 1);
1495 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1496 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $object->revenuestamp), $useborder,
'R', 1);
1501 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1502 $pdf->SetTextColor(0, 0, 60);
1503 $pdf->SetFillColor(224, 224, 224);
1504 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1506 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1507 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1510 if ($object->displayRetainedWarranty()) {
1511 $pdf->SetTextColor(40, 40, 40);
1512 $pdf->SetFillColor(255, 255, 255);
1514 $retainedWarranty = $object->getRetainedWarrantyAmount();
1515 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1519 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1520 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date($object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1522 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1523 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1527 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1529 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").
' ('.$object->retained_warranty.
'%)';
1530 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date($object->retained_warranty_date_limit,
'day')) :
'';
1532 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1533 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1534 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1539 $pdf->SetTextColor(0, 0, 0);
1540 $creditnoteamount = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
1541 $depositsamount = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
1543 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1544 if (!empty($object->paye)) {
1548 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) {
1551 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1552 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L', 0);
1553 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1554 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1557 if ($creditnoteamount) {
1558 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1560 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1561 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1562 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1563 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1567 if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1569 $pdf->SetFillColor(255, 255, 255);
1571 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1572 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L', 1);
1573 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1574 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R', 1);
1580 $pdf->SetTextColor(0, 0, 60);
1581 $pdf->SetFillColor(224, 224, 224);
1582 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1583 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1584 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1585 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1587 $pdf->SetFont(
'',
'', $default_font_size - 1);
1588 $pdf->SetTextColor(0, 0, 0);
1592 return ($tab2_top + ($tab2_hl * $index));
1609 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1619 $currency = !empty($currency) ? $currency : $conf->currency;
1623 $pdf->SetTextColor(0, 0, 0);
1624 $pdf->SetFont(
'',
'', $default_font_size - 2);
1626 if (empty($hidetop)) {
1627 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1628 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1629 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1632 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1633 $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));
1637 $pdf->SetDrawColor(128, 128, 128);
1638 $pdf->SetFont(
'',
'', $default_font_size - 1);
1641 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1643 if (empty($hidetop)) {
1644 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1646 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1647 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1650 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) {
1651 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1652 if (empty($hidetop)) {
1658 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1659 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1660 if (empty($hidetop)) {
1661 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1662 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1666 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1667 if (empty($hidetop)) {
1668 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1669 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1672 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1673 if (empty($hidetop)) {
1674 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1675 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1678 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1679 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1680 if (empty($hidetop)) {
1681 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1682 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1686 if ($this->atleastonediscount) {
1687 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1688 if (empty($hidetop)) {
1689 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1690 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1694 if ($this->situationinvoice) {
1695 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1696 if (empty($hidetop)) {
1697 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1698 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities(
"ProgressShort"),
'',
'C');
1702 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1703 if (empty($hidetop)) {
1704 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1705 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
1720 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
1722 global $conf, $langs;
1724 $ltrdirection =
'L';
1725 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
1728 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
1734 $pdf->SetTextColor(0, 0, 60);
1735 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1739 $posy = $this->marge_haute;
1740 $posx = $this->page_largeur - $this->marge_droite - $w;
1742 $pdf->SetXY($this->marge_gauche, $posy);
1745 if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
1746 if ($this->emetteur->logo) {
1747 $logodir = $conf->mycompany->dir_output;
1748 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1749 $logodir = $conf->mycompany->multidir_output[$object->entity];
1751 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
1752 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1754 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1756 if (is_readable($logo)) {
1758 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1760 $pdf->SetTextColor(200, 0, 0);
1761 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1762 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1763 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1766 $text = $this->emetteur->name;
1767 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1771 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1772 $pdf->SetXY($posx, $posy);
1773 $pdf->SetTextColor(0, 0, 60);
1774 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
1775 if ($object->type == 1) {
1776 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
1778 if ($object->type == 2) {
1779 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
1781 if ($object->type == 3) {
1782 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
1784 if ($object->type == 4) {
1785 $title = $outputlangs->transnoentities(
"InvoiceProForma");
1787 if ($this->situationinvoice) {
1788 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
1790 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1792 if ($object->type == 0) {
1793 if ($this->situationinvoice) {
1794 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
1796 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
1797 } elseif ($object->type == 1) {
1798 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
1799 } elseif ($object->type == 2) {
1800 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
1801 } elseif ($object->type == 3) {
1802 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
1803 } elseif ($object->type == 4) {
1804 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
1807 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1808 if ($object->statut == $object::STATUS_DRAFT) {
1809 $pdf->SetTextColor(128, 0, 0);
1810 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1813 $pdf->MultiCell($w, 3, $title,
'',
'R');
1815 $pdf->SetFont(
'',
'B', $default_font_size);
1829 $pdf->SetFont(
'',
'', $default_font_size - 2);
1831 if ($object->ref_client) {
1833 $pdf->SetXY($posx, $posy);
1834 $pdf->SetTextColor(0, 0, 60);
1835 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1838 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1839 $object->fetch_projet();
1840 if (!empty($object->project->ref)) {
1842 $pdf->SetXY($posx, $posy);
1843 $pdf->SetTextColor(0, 0, 60);
1844 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1848 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1849 $object->fetch_projet();
1850 if (!empty($object->project->ref)) {
1851 $outputlangs->load(
"projects");
1853 $pdf->SetXY($posx, $posy);
1854 $pdf->SetTextColor(0, 0, 60);
1855 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1859 $objectidnext = $object->getIdReplacingInvoice(
'validated');
1860 if ($object->type == 0 && $objectidnext) {
1861 $objectreplacing =
new Facture($this->
db);
1862 $objectreplacing->fetch($objectidnext);
1865 $pdf->SetXY($posx, $posy);
1866 $pdf->SetTextColor(0, 0, 60);
1867 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
1869 if ($object->type == 1) {
1870 $objectreplaced =
new Facture($this->
db);
1871 $objectreplaced->fetch($object->fk_facture_source);
1874 $pdf->SetXY($posx, $posy);
1875 $pdf->SetTextColor(0, 0, 60);
1876 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
1878 if ($object->type == 2 && !empty($object->fk_facture_source)) {
1879 $objectreplaced =
new Facture($this->
db);
1880 $objectreplaced->fetch($object->fk_facture_source);
1883 $pdf->SetXY($posx, $posy);
1884 $pdf->SetTextColor(0, 0, 60);
1885 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
1889 $pdf->SetXY($posx, $posy);
1890 $pdf->SetTextColor(0, 0, 60);
1891 $title = $outputlangs->transnoentities(
"DateInvoice");
1892 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1893 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1895 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1897 if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) {
1899 $pdf->SetXY($posx, $posy);
1900 $pdf->SetTextColor(0, 0, 60);
1901 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date($object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
1904 if ($object->type != 2) {
1906 $pdf->SetXY($posx, $posy);
1907 $pdf->SetTextColor(0, 0, 60);
1908 $title = $outputlangs->transnoentities(
"DateDue");
1909 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1910 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
1912 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
1915 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && $object->thirdparty->code_client) {
1917 $pdf->SetXY($posx, $posy);
1918 $pdf->SetTextColor(0, 0, 60);
1919 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1923 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1924 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1925 if (count($arrayidcontact) > 0) {
1926 $usertmp =
new User($this->
db);
1927 $usertmp->fetch($arrayidcontact[0]);
1929 $pdf->SetXY($posx, $posy);
1930 $pdf->SetTextColor(0, 0, 60);
1931 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1939 $current_y = $pdf->getY();
1940 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1941 if ($current_y < $pdf->getY()) {
1942 $top_shift = $pdf->getY() - $current_y;
1947 $carac_emetteur =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1950 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1951 $posy += $top_shift;
1952 $posx = $this->marge_gauche;
1953 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1954 $posx = $this->page_largeur - $this->marge_droite - 80;
1957 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1958 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1962 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1963 $pdf->SetTextColor(0, 0, 0);
1964 $pdf->SetFont(
'',
'', $default_font_size - 2);
1965 $pdf->SetXY($posx, $posy - 5);
1966 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1967 $pdf->SetXY($posx, $posy);
1968 $pdf->SetFillColor(230, 230, 230);
1969 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1970 $pdf->SetTextColor(0, 0, 60);
1974 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1975 $pdf->SetXY($posx + 2, $posy + 3);
1976 $pdf->SetFont(
'',
'B', $default_font_size);
1977 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1978 $posy = $pdf->getY();
1982 $pdf->SetXY($posx + 2, $posy);
1983 $pdf->SetFont(
'',
'', $default_font_size - 1);
1984 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1988 $usecontact =
false;
1989 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
1990 if (count($arrayidcontact) > 0) {
1992 $result = $object->fetch_contact($arrayidcontact[0]);
1996 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)))) {
1997 $thirdparty = $object->contact;
1999 $thirdparty = $object->thirdparty;
2005 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
2008 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
2009 if ($this->page_largeur < 210) {
2012 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
2013 $posy += $top_shift;
2014 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2015 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
2016 $posx = $this->marge_gauche;
2020 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
2021 $pdf->SetTextColor(0, 0, 0);
2022 $pdf->SetFont(
'',
'', $default_font_size - 2);
2023 $pdf->SetXY($posx + 2, $posy - 5);
2024 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2025 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2029 $pdf->SetXY($posx + 2, $posy + 3);
2030 $pdf->SetFont(
'',
'B', $default_font_size);
2031 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2033 $posy = $pdf->getY();
2036 $pdf->SetFont(
'',
'', $default_font_size - 1);
2037 $pdf->SetXY($posx + 2, $posy);
2038 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2041 $pdf->SetTextColor(0, 0, 0);
2055 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
2058 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
2059 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);