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;
143 global $conf, $langs, $mysoc;
146 $langs->loadLangs(array(
"main",
"bills"));
149 $this->
name =
"sponge";
150 $this->
description = $langs->trans(
'PDFSpongeDescription');
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);
159 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
160 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
161 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
162 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
164 $this->option_logo = 1;
165 $this->option_tva = 1;
166 $this->option_modereg = 1;
167 $this->option_condreg = 1;
168 $this->option_codeproduitservice = 1;
169 $this->option_multilang = 1;
170 $this->option_escompte = 1;
171 $this->option_credit_note = 1;
172 $this->option_freetext = 1;
173 $this->option_draft_watermark = 1;
176 $this->emetteur = $mysoc;
177 if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2);
180 $this->posxdesc = $this->marge_gauche + 1;
183 $this->tabTitleHeight = 5;
187 $this->tva = array();
188 $this->localtax1 = array();
189 $this->localtax2 = array();
190 $this->atleastoneratenotnull = 0;
191 $this->atleastonediscount = 0;
192 $this->situationinvoice =
false;
208 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
211 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
213 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
215 if (!is_object($outputlangs)) $outputlangs = $langs;
217 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
220 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
222 global $outputlangsbis;
223 $outputlangsbis = null;
224 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
225 $outputlangsbis =
new Translate(
'', $conf);
226 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
227 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
230 $nblines = count($object->lines);
233 if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
234 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
238 $realpatharray = array();
239 $this->atleastonephoto =
false;
240 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
244 for ($i = 0; $i < $nblines; $i++)
246 if (empty($object->lines[$i]->fk_product))
continue;
248 $objphoto->fetch($object->lines[$i]->fk_product);
250 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
252 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
253 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
255 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
256 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
260 foreach ($pdir as $midir)
264 if ($conf->product->entity != $objphoto->entity) {
265 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
267 $dir = $conf->product->dir_output.
'/'.$midir;
270 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
272 if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))
274 if ($obj[
'photo_vignette'])
276 $filename = $obj[
'photo_vignette'];
278 $filename = $obj[
'photo'];
281 $filename = $obj[
'photo'];
284 $realpath = $dir.$filename;
286 $this->atleastonephoto =
true;
291 if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
297 if ($conf->facture->multidir_output[$conf->entity])
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)
308 $dir = $conf->facture->multidir_output[$conf->entity];
309 $file = $dir.
"/SPECIMEN.pdf";
312 $dir = $conf->facture->multidir_output[$object->entity].
"/".$objectref;
313 $file = $dir.
"/".$objectref.
".pdf";
315 if (!file_exists($dir))
319 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
324 if (file_exists($dir))
327 if (!is_object($hookmanager))
329 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
332 $hookmanager->initHooks(array(
'pdfgeneration'));
333 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
335 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
338 $nblines = count($object->lines);
339 $nbpayments = count($object->getListOfPayments());
344 $pdf->SetAutoPageBreak(1, 0);
346 $heightforinfotot = 50 + (4 * $nbpayments);
347 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
348 $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22);
350 if (class_exists(
'TCPDF'))
352 $pdf->setPrintHeader(
false);
353 $pdf->setPrintFooter(
false);
358 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
360 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
361 $tplidx = $pdf->importPage(1);
366 $pdf->SetDrawColor(128, 128, 128);
368 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
369 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
370 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
371 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
372 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
373 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(
false);
376 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
379 $cert = empty($conf->global->CERTIFICATE_CRT) ?
'' : $conf->global->CERTIFICATE_CRT;
384 'Name' => $this->emetteur->name,
385 'Location' =>
getCountry($this->emetteur->country_code, 0),
386 'Reason' =>
'INVOICE',
387 'ContactInfo' => $this->emetteur->email
389 $pdf->setSignature($cert, $cert, $this->emetteur->name,
'', 2, $info);
392 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
395 for ($i = 0; $i < $nblines; $i++)
397 if ($object->lines[$i]->remise_percent)
399 $this->atleastonediscount++;
405 if ($object->situation_cycle_ref)
407 $this->situationinvoice =
true;
412 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
415 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
416 $pdf->SetFont(
'',
'', $default_font_size - 1);
417 $pdf->MultiCell(0, 3,
'');
418 $pdf->SetTextColor(0, 0, 0);
420 $tab_top = 90 + $top_shift;
421 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
422 $tab_height = 130 - $top_shift;
423 $tab_height_newpage = 150;
424 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
426 $nexY = $tab_top - 1;
429 $height_incoterms = 0;
430 if (!empty($conf->incoterm->enabled))
432 $desc_incoterms = $object->getIncotermsForPDF();
437 $pdf->SetFont(
'',
'', $default_font_size - 1);
438 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
439 $nexY = max($pdf->GetY(), $nexY);
440 $height_incoterms = $nexY - $tab_top;
443 $pdf->SetDrawColor(192, 192, 192);
444 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
446 $tab_top = $nexY + 6;
447 $height_incoterms += 4;
452 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
453 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
456 if (is_object($object->thirdparty))
458 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
459 $salerepobj =
new User($this->
db);
460 $salerepobj->fetch($salereparray[0][
'id']);
461 if (!empty($salerepobj->signature)) $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
466 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
467 if (!empty($extranote)) {
471 $pagenb = $pdf->getPage();
476 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
477 $pageposbeforenote = $pagenb;
484 $pdf->startTransaction();
486 $pdf->SetFont(
'',
'', $default_font_size - 1);
487 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
489 $pageposafternote = $pdf->getPage();
490 $posyafter = $pdf->GetY();
492 if ($pageposafternote > $pageposbeforenote)
494 $pdf->rollbackTransaction(
true);
497 while ($pagenb < $pageposafternote) {
500 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
501 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
503 $pdf->setTopMargin($tab_top_newpage);
505 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
509 $pdf->setPage($pageposbeforenote);
510 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
511 $pdf->SetFont(
'',
'', $default_font_size - 1);
512 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
513 $pageposafternote = $pdf->getPage();
515 $posyafter = $pdf->GetY();
517 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
519 $pdf->AddPage(
'',
'',
true);
522 $pdf->setPage($pageposafternote);
523 $pdf->setTopMargin($tab_top_newpage);
525 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
531 $i = $pageposbeforenote;
532 while ($i < $pageposafternote) {
536 $pdf->SetDrawColor(128, 128, 128);
538 if ($i > $pageposbeforenote) {
539 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
540 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
542 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
543 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
547 $pdf->setPageOrientation(
'', 1, 0);
548 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
554 $pdf->setPage($pageposafternote);
555 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
556 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
557 $height_note = $posyafter - $tab_top_newpage;
558 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
561 $pdf->commitTransaction();
562 $posyafter = $pdf->GetY();
563 $height_note = $posyafter - $tab_top;
564 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
567 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
570 $pdf->AddPage(
'',
'',
true);
573 $pdf->setPage($pageposafternote);
574 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
575 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
577 $posyafter = $tab_top_newpage;
581 $tab_height = $tab_height - $height_note;
582 $tab_top = $posyafter + 6;
591 $pdf->startTransaction();
592 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
593 $pdf->rollbackTransaction(
true);
595 $nexY = $tab_top + $this->tabTitleHeight;
598 $pageposbeforeprintlines = $pdf->getPage();
599 $pagenb = $pageposbeforeprintlines;
600 for ($i = 0; $i < $nblines; $i++)
603 $pdf->SetFont(
'',
'', $default_font_size - 1);
604 $pdf->SetTextColor(0, 0, 0);
607 $imglinesize = array();
610 $pdf->setTopMargin($tab_top_newpage);
611 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
612 $pageposbefore = $pdf->getPage();
614 $showpricebeforepagebreak = 1;
616 $posYAfterDescription = 0;
621 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))
623 $pdf->AddPage(
'',
'',
true);
624 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
625 $pdf->setPage($pageposbefore + 1);
627 $curY = $tab_top_newpage;
630 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
631 $showpricebeforepagebreak = 1;
632 else $showpricebeforepagebreak = 0;
635 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height']))
637 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
639 $posYAfterImage = $curY + $imglinesize[
'height'];
646 $pdf->startTransaction();
648 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
649 $pageposafter = $pdf->getPage();
651 if ($pageposafter > $pageposbefore)
653 $pdf->rollbackTransaction(
true);
654 $pageposafter = $pageposbefore;
655 $pdf->setPageOrientation(
'', 1, $heightforfooter);
657 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
659 $pageposafter = $pdf->getPage();
660 $posyafter = $pdf->GetY();
662 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))
664 if ($i == ($nblines - 1))
666 $pdf->AddPage(
'',
'',
true);
667 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
668 $pdf->setPage($pageposafter + 1);
673 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
674 $showpricebeforepagebreak = 1;
675 else $showpricebeforepagebreak = 0;
679 $pdf->commitTransaction();
681 $posYAfterDescription = $pdf->GetY();
684 $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
686 $pageposafter = $pdf->getPage();
687 $pdf->setPage($pageposbefore);
688 $pdf->setTopMargin($this->marge_haute);
689 $pdf->setPageOrientation(
'', 1, 0);
692 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
693 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
696 $pdf->SetFont(
'',
'', $default_font_size - 1);
703 $nexY = max($pdf->GetY(), $nexY);
711 $nexY = max($pdf->GetY(), $nexY);
720 $nexY = max($pdf->GetY(), $nexY);
728 $nexY = max($pdf->GetY(), $nexY);
734 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
736 $nexY = max($pdf->GetY(), $nexY);
740 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent)
744 $nexY = max($pdf->GetY(), $nexY);
752 $nexY = max($pdf->GetY(), $nexY);
760 $nexY = max($pdf->GetY(), $nexY);
764 if (!empty($object->lines[$i]->array_options)) {
765 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
770 $nexY = max($pdf->GetY(), $nexY);
782 'outputlangs' => $outputlangs,
783 'hidedetails' => $hidedetails
785 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
789 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
791 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
792 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent))
794 if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
795 else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
797 if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
798 else $tvaligne = $sign * $object->lines[$i]->total_tva;
801 $localtax1ligne = $object->lines[$i]->total_localtax1;
802 $localtax2ligne = $object->lines[$i]->total_localtax2;
803 $localtax1_rate = $object->lines[$i]->localtax1_tx;
804 $localtax2_rate = $object->lines[$i]->localtax2_tx;
805 $localtax1_type = $object->lines[$i]->localtax1_type;
806 $localtax2_type = $object->lines[$i]->localtax2_type;
808 if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
809 if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
810 if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
812 $vatrate = (string) $object->lines[$i]->tva_tx;
815 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
816 && (!empty($localtax1_rate) || !empty($localtax2_rate)))
819 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
820 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
824 if ($localtax1_type && $localtax1ligne != 0) {
825 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
827 if ($localtax2_type && $localtax2ligne != 0) {
828 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
831 if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .=
'*';
832 if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
833 $this->tva[$vatrate] += $tvaligne;
835 $nexY = max($nexY, $posYAfterImage);
838 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
839 $pdf->setPage($pageposafter);
840 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
842 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
843 $pdf->SetLineStyle(array(
'dash'=>0));
847 while ($pagenb < $pageposafter) {
848 $pdf->setPage($pagenb);
849 if ($pagenb == $pageposbeforeprintlines) {
850 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
852 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
854 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
856 $pdf->setPage($pagenb);
857 $pdf->setPageOrientation(
'', 1, 0);
858 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
861 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
862 if ($pagenb == $pageposafter) {
863 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
865 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
867 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
870 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
872 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
877 if ($pagenb == $pageposbeforeprintlines)
879 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
880 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
882 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
883 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
887 $posy = $this->
drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
890 $posy = $this->
drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
893 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
899 $this->
_pagefoot($pdf, $object, $outputlangs);
900 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
904 $pdf->Output($file,
'F');
907 $hookmanager->initHooks(array(
'pdfgeneration'));
908 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
910 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
913 $this->error = $hookmanager->error;
914 $this->errors = $hookmanager->errors;
917 if (!empty($conf->global->MAIN_UMASK))
918 @chmod($file, octdec($conf->global->MAIN_UMASK));
920 $this->result = array(
'fullpath'=>$file);
924 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
928 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
948 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
951 $tab3_top = $posy + 8;
954 if ($this->page_largeur < 210)
961 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
962 if ($object->type == 2) $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
964 $pdf->SetFont(
'',
'', $default_font_size - 3);
965 $pdf->SetXY($tab3_posx, $tab3_top - 4);
966 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
968 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
970 $pdf->SetFont(
'',
'', $default_font_size - 4);
971 $pdf->SetXY($tab3_posx, $tab3_top);
972 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
973 $pdf->SetXY($tab3_posx + 21, $tab3_top);
974 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
975 $pdf->SetXY($tab3_posx + 40, $tab3_top);
976 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
977 $pdf->SetXY($tab3_posx + 58, $tab3_top);
978 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
980 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
984 $pdf->SetFont(
'',
'', $default_font_size - 4);
988 $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,";
989 $sql .=
" re.description, re.fk_facture_source,";
990 $sql .=
" f.type, f.datef";
991 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
992 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
1002 $obj = $this->
db->fetch_object(
$resql);
1004 if ($obj->type == 2) $text = $outputlangs->transnoentities(
"CreditNote");
1005 elseif ($obj->type == 3) $text = $outputlangs->transnoentities(
"Deposit");
1006 elseif ($obj->type == 0) $text = $outputlangs->transnoentities(
"ExcessReceived");
1007 else $text = $outputlangs->transnoentities(
"UnknownType");
1009 $invoice->fetch($obj->fk_facture_source);
1011 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1012 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1013 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1014 $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);
1015 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1016 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
1017 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1018 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
1020 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1025 $this->error = $this->
db->lasterror();
1031 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1033 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1034 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1035 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
1037 $sql .=
" ORDER BY p.datep";
1042 $num = $this->
db->num_rows(
$resql);
1046 $row = $this->
db->fetch_object(
$resql);
1048 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1049 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
1050 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1051 $pdf->MultiCell(20, 3,
price($sign * ((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
1052 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1053 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1055 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
1056 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1057 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
1059 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1064 return $tab3_top + $y + 3;
1066 $this->error = $this->
db->lasterror();
1083 global $conf, $mysoc;
1087 $pdf->SetFont(
'',
'', $default_font_size - 1);
1090 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj))
1092 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1093 $pdf->SetXY($this->marge_gauche, $posy);
1094 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
1096 $posy = $pdf->GetY() + 4;
1102 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
1104 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1105 $pdf->SetXY($this->marge_gauche, $posy);
1106 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1107 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1109 $pdf->SetFont(
'',
'', $default_font_size - 2);
1110 $pdf->SetXY($posxval, $posy);
1111 $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);
1112 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1113 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1115 $posy = $pdf->GetY() + 3;
1118 if ($object->type != 2)
1121 if (empty($object->mode_reglement_code)
1122 && empty($conf->global->FACTURE_CHQ_NUMBER)
1123 && empty($conf->global->FACTURE_RIB_NUMBER))
1125 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1128 elseif (($object->mode_reglement_code ==
'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
1129 || ($object->mode_reglement_code ==
'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)))
1131 $outputlangs->load(
"errors");
1133 $pdf->SetXY($this->marge_gauche, $posy);
1134 $pdf->SetTextColor(200, 0, 0);
1135 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1136 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1137 $pdf->MultiCell(80, 3, $this->error, 0,
'L', 0);
1138 $pdf->SetTextColor(0, 0, 0);
1140 $posy = $pdf->GetY() + 1;
1144 if ($object->mode_reglement_code
1145 && $object->mode_reglement_code !=
'CHQ'
1146 && $object->mode_reglement_code !=
'VIR')
1148 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1149 $pdf->SetXY($this->marge_gauche, $posy);
1150 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1151 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1153 $pdf->SetFont(
'',
'', $default_font_size - 2);
1154 $pdf->SetXY($posxval, $posy);
1155 $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);
1156 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1159 $useonlinepayment = ((!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)) && !empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT));
1160 if (($object->mode_reglement_code ==
'CB' || $object->mode_reglement_code ==
'VAD') && $object->statut !=
Facture::STATUS_DRAFT && $useonlinepayment) {
1161 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1164 $langs->loadLangs(array(
'payment',
'paybox'));
1165 $servicename = $langs->transnoentities(
'Online');
1166 $paiement_url = getOnlinePaymentUrl(
'',
'invoice', $object->ref,
'',
'',
'');
1167 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1172 $posy = $pdf->GetY() + 2;
1176 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ')
1179 if (!empty($conf->global->FACTURE_CHQ_NUMBER))
1181 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1183 if ($conf->global->FACTURE_CHQ_NUMBER > 0)
1186 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1188 $pdf->SetXY($this->marge_gauche, $posy);
1189 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1190 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1191 $posy = $pdf->GetY() + 1;
1193 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1195 $pdf->SetXY($this->marge_gauche, $posy);
1196 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1197 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1198 $posy = $pdf->GetY() + 2;
1201 if ($conf->global->FACTURE_CHQ_NUMBER == -1)
1203 $pdf->SetXY($this->marge_gauche, $posy);
1204 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1205 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1206 $posy = $pdf->GetY() + 1;
1208 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1210 $pdf->SetXY($this->marge_gauche, $posy);
1211 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1212 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1213 $posy = $pdf->GetY() + 2;
1220 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR')
1222 if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
1223 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1224 if ($object->fk_bank > 0) $bankid = $object->fk_bank;
1226 $account->fetch($bankid);
1228 $curx = $this->marge_gauche;
1231 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1254 global $conf, $mysoc, $hookmanager;
1257 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
1261 $outputlangsbis = null;
1262 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1263 $outputlangsbis =
new Translate(
'', $conf);
1264 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1265 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1266 $default_font_size--;
1271 $pdf->SetFont(
'',
'', $default_font_size - 1);
1274 $col1x = 120; $col2x = 170;
1275 if ($this->page_largeur < 210)
1279 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1285 $parameters = array(
1286 'object' => &$object,
1287 'outputlangs' => $outputlangs,
1289 $hookmanager->executeHooks(
'beforePercentCalculation', $parameters, $this);
1294 foreach ($object->lines as $line)
1296 $percent += $line->situation_percent;
1301 $avancementGlobal = $percent / $i;
1303 $avancementGlobal = 0;
1306 $object->fetchPreviousNextSituationInvoice();
1307 $TPreviousIncoice = $object->tab_previous_situation_invoice;
1310 $total_a_payer_ttc = 0;
1311 foreach ($TPreviousIncoice as &$fac) {
1312 $total_a_payer += $fac->total_ht;
1313 $total_a_payer_ttc += $fac->total_ttc;
1315 $total_a_payer += $object->total_ht;
1316 $total_a_payer_ttc += $object->total_ttc;
1318 if (!empty($avancementGlobal)) {
1319 $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
1320 $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
1323 $total_a_payer_ttc = 0;
1327 if (!empty($TPreviousIncoice)) {
1328 $pdf->setY($tab2_top);
1329 $posy = $pdf->GetY();
1331 foreach ($TPreviousIncoice as &$fac) {
1332 if ($posy > $this->page_hauteur - 4) {
1333 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
1335 $pdf->setY($this->marge_haute);
1336 $posy = $pdf->GetY();
1341 $pdf->SetFillColor(255, 255, 255);
1342 $pdf->SetXY($col1x, $posy);
1343 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $fac->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1345 $pdf->SetXY($col2x, $posy);
1349 $facSign = $fac->total_ht >= 0 ?
'+' :
'';
1352 $displayAmount =
' '.$facSign.
' '.
price($fac->total_ht, 0, $outputlangs);
1354 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1363 $pdf->SetFillColor(255, 255, 255);
1364 $pdf->SetXY($col1x, $posy);
1365 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"PDFSituationTitle", $object->situation_counter).
' '.$outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1367 $pdf->SetXY($col2x, $posy);
1370 $facSign = $object->total_ht >= 0 ?
'+' :
'';
1373 if ($fac->type === facture::TYPE_CREDIT_NOTE) {
1378 $displayAmount =
' '.$facSign.
' '.
price($object->total_ht, 0, $outputlangs);
1379 $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0,
'R', 1);
1384 $pdf->SetFont(
'',
'', $default_font_size - 1);
1385 $pdf->SetFillColor(255, 255, 255);
1386 $pdf->SetXY($col1x, $posy);
1387 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"SituationTotalProgress", $avancementGlobal), 0,
'L', 1);
1389 $pdf->SetXY($col2x, $posy);
1390 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0,
'R', 1);
1391 $pdf->SetFont(
'',
'', $default_font_size - 2);
1395 if ($posy > $this->page_hauteur - 4) {
1397 $pdf->setY($this->marge_haute);
1398 $posy = $pdf->GetY();
1408 $total_ht = (!empty($conf->multicurrency->enabled) && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1411 $total_line_remise = 0;
1412 foreach ($object->lines as $i => $line) {
1415 if ($line->total_ht < 0) $total_line_remise += -$line->total_ht;
1417 if ($total_line_remise > 0) {
1418 if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
1419 $pdf->SetFillColor(255, 255, 255);
1420 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1421 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1422 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1423 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1428 if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
1429 $pdf->SetFillColor(255, 255, 255);
1430 $pdf->SetXY($col1x, $tab2_top + 0);
1431 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1432 $pdf->SetXY($col2x, $tab2_top + 0);
1433 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1440 $pdf->SetFillColor(255, 255, 255);
1441 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1442 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1444 $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1445 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1446 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1449 $pdf->SetFillColor(248, 248, 248);
1451 $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1453 $this->atleastoneratenotnull = 0;
1454 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1456 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1457 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1466 foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1468 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5')))
continue;
1470 foreach ($localtax_rate as $tvakey => $tvaval)
1477 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1480 if (preg_match(
'/\*/', $tvakey))
1482 $tvakey = str_replace(
'*',
'', $tvakey);
1483 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1486 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1488 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1489 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1491 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1492 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1500 foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1502 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5')))
continue;
1504 foreach ($localtax_rate as $tvakey => $tvaval)
1511 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1514 if (preg_match(
'/\*/', $tvakey))
1516 $tvakey = str_replace(
'*',
'', $tvakey);
1517 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1519 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1521 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1522 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1524 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1525 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1533 if ($object->situation_cycle_ref && $object->situation_counter > 1) {
1535 foreach ($this->tva as $tvakey => $tvaval) {
1536 $sum_pdf_tva += $tvaval;
1539 if ($sum_pdf_tva != $object->total_tva) {
1540 if (!empty($sum_pdf_tva))
1542 $coef_fix_tva = $object->total_tva / $sum_pdf_tva;
1548 foreach ($this->tva as $tvakey => $tvaval) {
1549 $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1554 foreach ($this->tva as $tvakey => $tvaval)
1558 $this->atleastoneratenotnull++;
1561 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1564 if (preg_match(
'/\*/', $tvakey))
1566 $tvakey = str_replace(
'*',
'', $tvakey);
1567 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1569 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1571 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1572 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1574 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1575 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1582 foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1584 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6')))
continue;
1586 foreach ($localtax_rate as $tvakey => $tvaval)
1593 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1596 if (preg_match(
'/\*/', $tvakey))
1598 $tvakey = str_replace(
'*',
'', $tvakey);
1599 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1601 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1603 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1605 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1606 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1607 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1615 foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1617 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6')))
continue;
1619 foreach ($localtax_rate as $tvakey => $tvaval)
1627 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1630 if (preg_match(
'/\*/', $tvakey))
1632 $tvakey = str_replace(
'*',
'', $tvakey);
1633 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1635 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1638 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1639 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1641 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1642 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1649 if (
price2num($object->revenuestamp) != 0)
1652 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1653 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RevenueStamp", $mysoc->country_code) :
''), $useborder,
'L', 1);
1655 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1656 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $object->revenuestamp), $useborder,
'R', 1);
1661 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1662 $pdf->SetTextColor(0, 0, 60);
1663 $pdf->SetFillColor(224, 224, 224);
1664 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalTTC") :
''), $useborder,
'L', 1);
1666 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1667 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1671 if ($object->displayRetainedWarranty())
1673 $pdf->SetTextColor(40, 40, 40);
1674 $pdf->SetFillColor(255, 255, 255);
1676 $retainedWarranty = $object->getRetainedWarrantyAmount();
1677 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1681 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1682 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date($object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1684 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1685 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1689 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1691 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RetainedWarranty") :
'').
' ('.$object->retained_warranty.
'%)';
1692 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date($object->retained_warranty_date_limit,
'day')) :
'';
1694 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1695 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1696 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1701 $pdf->SetTextColor(0, 0, 0);
1703 $creditnoteamount = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
1704 $depositsamount = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
1706 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1707 if (!empty($object->paye)) $resteapayer = 0;
1709 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
1713 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1714 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"Paid") :
''), 0,
'L', 0);
1715 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1716 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1719 if ($creditnoteamount)
1721 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1722 $labeltouse .= (is_object($outputlangsbis) ?
' / '.($outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities(
"CreditNotes") :
'');
1724 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1725 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1726 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1727 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1746 $pdf->SetTextColor(0, 0, 60);
1747 $pdf->SetFillColor(224, 224, 224);
1748 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1749 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1750 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1751 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1753 $pdf->SetFont(
'',
'', $default_font_size - 1);
1754 $pdf->SetTextColor(0, 0, 0);
1758 return ($tab2_top + ($tab2_hl * $index));
1772 return parent::liste_modeles($db, $maxfilenamelength);
1790 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis = null)
1796 if ($hidetop) $hidetop = -1;
1798 $currency = !empty($currency) ? $currency : $conf->currency;
1802 $pdf->SetTextColor(0, 0, 0);
1803 $pdf->SetFont(
'',
'', $default_font_size - 2);
1805 if (empty($hidetop))
1807 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1808 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1809 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
1812 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1813 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1816 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1817 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight,
'F', null, explode(
',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1821 $pdf->SetDrawColor(128, 128, 128);
1822 $pdf->SetFont(
'',
'', $default_font_size - 1);
1825 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1828 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1830 if (empty($hidetop)) {
1831 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight);
1846 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
1848 global $conf, $langs;
1851 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
1858 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
1860 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
1863 $pdf->SetTextColor(0, 0, 60);
1864 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1868 $posy = $this->marge_haute;
1869 $posx = $this->page_largeur - $this->marge_droite - $w;
1871 $pdf->SetXY($this->marge_gauche, $posy);
1874 if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1876 if ($this->emetteur->logo)
1878 $logodir = $conf->mycompany->dir_output;
1879 if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
1880 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
1882 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1884 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1886 if (is_readable($logo)) {
1888 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1890 $pdf->SetTextColor(200, 0, 0);
1891 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1892 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1893 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1896 $text = $this->emetteur->name;
1897 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1901 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1902 $pdf->SetXY($posx, $posy);
1903 $pdf->SetTextColor(0, 0, 60);
1904 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
1905 if ($object->type == 1) $title = $outputlangs->transnoentities(
"InvoiceReplacement");
1906 if ($object->type == 2) $title = $outputlangs->transnoentities(
"InvoiceAvoir");
1907 if ($object->type == 3) $title = $outputlangs->transnoentities(
"InvoiceDeposit");
1908 if ($object->type == 4) $title = $outputlangs->transnoentities(
"InvoiceProForma");
1909 if ($this->situationinvoice) $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
1910 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1912 if ($object->type == 0) {
1913 if ($this->situationinvoice) $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
1914 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
1915 } elseif ($object->type == 1) $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
1916 elseif ($object->type == 2) $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
1917 elseif ($object->type == 3) $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
1918 elseif ($object->type == 4) $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
1920 $pdf->MultiCell($w, 3, $title,
'',
'R');
1922 $pdf->SetFont(
'',
'B', $default_font_size);
1925 $pdf->SetXY($posx, $posy);
1926 $pdf->SetTextColor(0, 0, 60);
1927 $textref = $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref);
1928 if ($object->statut == $object::STATUS_DRAFT)
1930 $pdf->SetTextColor(128, 0, 0);
1931 $textref .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1933 $pdf->MultiCell($w, 4, $textref,
'',
'R');
1936 $pdf->SetFont(
'',
'', $default_font_size - 2);
1938 if ($object->ref_client)
1941 $pdf->SetXY($posx, $posy);
1942 $pdf->SetTextColor(0, 0, 60);
1943 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1946 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
1948 $object->fetch_projet();
1949 if (!empty($object->project->ref))
1952 $pdf->SetXY($posx, $posy);
1953 $pdf->SetTextColor(0, 0, 60);
1954 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
1958 if (!empty($conf->global->PDF_SHOW_PROJECT))
1960 $object->fetch_projet();
1961 if (!empty($object->project->ref))
1964 $pdf->SetXY($posx, $posy);
1965 $pdf->SetTextColor(0, 0, 60);
1966 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->projet->ref),
'',
'R');
1970 $objectidnext = $object->getIdReplacingInvoice(
'validated');
1971 if ($object->type == 0 && $objectidnext)
1973 $objectreplacing =
new Facture($this->
db);
1974 $objectreplacing->fetch($objectidnext);
1977 $pdf->SetXY($posx, $posy);
1978 $pdf->SetTextColor(0, 0, 60);
1979 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
1981 if ($object->type == 1)
1983 $objectreplaced =
new Facture($this->
db);
1984 $objectreplaced->fetch($object->fk_facture_source);
1987 $pdf->SetXY($posx, $posy);
1988 $pdf->SetTextColor(0, 0, 60);
1989 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
1991 if ($object->type == 2 && !empty($object->fk_facture_source))
1993 $objectreplaced =
new Facture($this->
db);
1994 $objectreplaced->fetch($object->fk_facture_source);
1997 $pdf->SetXY($posx, $posy);
1998 $pdf->SetTextColor(0, 0, 60);
1999 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2003 $pdf->SetXY($posx, $posy);
2004 $pdf->SetTextColor(0, 0, 60);
2006 $title = $outputlangs->transnoentities(
"DateInvoice");
2007 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
2008 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2010 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2012 if (!empty($conf->global->INVOICE_POINTOFTAX_DATE))
2015 $pdf->SetXY($posx, $posy);
2016 $pdf->SetTextColor(0, 0, 60);
2017 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date($object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2020 if ($object->type != 2)
2023 $pdf->SetXY($posx, $posy);
2024 $pdf->SetTextColor(0, 0, 60);
2025 $title = $outputlangs->transnoentities(
"DateDue");
2026 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
2027 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2029 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2032 if ($object->thirdparty->code_client)
2035 $pdf->SetXY($posx, $posy);
2036 $pdf->SetTextColor(0, 0, 60);
2037 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
2041 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
2043 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
2044 if (count($arrayidcontact) > 0)
2046 $usertmp =
new User($this->
db);
2047 $usertmp->fetch($arrayidcontact[0]);
2049 $pdf->SetXY($posx, $posy);
2050 $pdf->SetTextColor(0, 0, 60);
2051 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2059 $current_y = $pdf->getY();
2060 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
2061 if ($current_y < $pdf->getY())
2063 $top_shift = $pdf->getY() - $current_y;
2069 $carac_emetteur =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
2072 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
2073 $posy += $top_shift;
2074 $posx = $this->marge_gauche;
2075 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
2077 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
2078 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
2082 $pdf->SetTextColor(0, 0, 0);
2083 $pdf->SetFont(
'',
'', $default_font_size - 2);
2084 $pdf->SetXY($posx, $posy - 5);
2085 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0,
'L');
2086 $pdf->SetXY($posx, $posy);
2087 $pdf->SetFillColor(230, 230, 230);
2088 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
2089 $pdf->SetTextColor(0, 0, 60);
2092 $pdf->SetXY($posx + 2, $posy + 3);
2093 $pdf->SetFont(
'',
'B', $default_font_size);
2094 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
2095 $posy = $pdf->getY();
2098 $pdf->SetXY($posx + 2, $posy);
2099 $pdf->SetFont(
'',
'', $default_font_size - 1);
2100 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
2103 $usecontact =
false;
2104 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
2105 if (count($arrayidcontact) > 0)
2108 $result = $object->fetch_contact($arrayidcontact[0]);
2112 if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
2113 $thirdparty = $object->contact;
2115 $thirdparty = $object->thirdparty;
2120 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
2123 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
2124 if ($this->page_largeur < 210) $widthrecbox = 84;
2125 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
2126 $posy += $top_shift;
2127 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2128 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
2131 $pdf->SetTextColor(0, 0, 0);
2132 $pdf->SetFont(
'',
'', $default_font_size - 2);
2133 $pdf->SetXY($posx + 2, $posy - 5);
2134 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo").
":", 0,
'L');
2135 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
2138 $pdf->SetXY($posx + 2, $posy + 3);
2139 $pdf->SetFont(
'',
'B', $default_font_size);
2140 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
2142 $posy = $pdf->getY();
2145 $pdf->SetFont(
'',
'', $default_font_size - 1);
2146 $pdf->SetXY($posx + 2, $posy);
2147 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
2150 $pdf->SetTextColor(0, 0, 0);
2164 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
2167 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
2168 return pdf_pagefoot($pdf, $outputlangs,
'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
2181 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2183 global $conf, $hookmanager;
2186 $this->defaultContentsFieldsStyle = array(
2188 'padding' => array(1, 0.5, 1, 0.5),
2192 $this->defaultTitlesFieldsStyle = array(
2194 'padding' => array(0.5, 0, 0.5, 0),
2216 $this->cols[
'desc'] = array(
2221 'textkey' =>
'Designation',
2225 'padding' => array(0.5, 0.5, 0.5, 0.5),
2229 'padding' => array(1, 0.5, 1, 1.5),
2235 $this->cols[
'photo'] = array(
2237 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
2240 'textkey' =>
'Photo',
2244 'padding' => array(0, 0, 0, 0),
2246 'border-left' =>
false,
2249 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
2251 $this->cols[
'photo'][
'status'] =
true;
2256 $this->cols[
'vat'] = array(
2263 'border-left' =>
true,
2266 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
2268 $this->cols[
'vat'][
'status'] =
true;
2272 $this->cols[
'subprice'] = array(
2277 'textkey' =>
'PriceUHT'
2279 'border-left' =>
true,
2284 $nblines = count($object->lines);
2285 for ($i = 0; $i < $nblines; $i++) {
2287 $tmpwidth = max($tmpwidth, $tmpwidth2);
2289 if ($tmpwidth > 10) {
2290 $this->cols[
'subprice'][
'width'] += (2 * ($tmpwidth - 10));
2294 $this->cols[
'qty'] = array(
2301 'border-left' =>
true,
2305 $this->cols[
'progress'] = array(
2310 'textkey' =>
'Progress'
2312 'border-left' =>
true,
2315 if ($this->situationinvoice)
2317 $this->cols[
'progress'][
'status'] =
true;
2321 $this->cols[
'unit'] = array(
2328 'border-left' =>
true,
2330 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2331 $this->cols[
'unit'][
'status'] =
true;
2335 $this->cols[
'discount'] = array(
2340 'textkey' =>
'ReductionShort'
2342 'border-left' =>
true,
2344 if ($this->atleastonediscount) {
2345 $this->cols[
'discount'][
'status'] =
true;
2348 $rank = $rank + 1000;
2349 $this->cols[
'totalexcltax'] = array(
2352 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ?
true :
false,
2354 'textkey' =>
'TotalHT'
2356 'border-left' =>
true,
2359 $rank = $rank + 1010;
2360 $this->cols[
'totalincltax'] = array(
2363 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ?
false :
true,
2365 'textkey' =>
'TotalTTC'
2367 'border-left' =>
true,
2371 if (!empty($object->lines)) {
2372 $line = reset($object->lines);
2376 $parameters = array(
2377 'object' => $object,
2378 'outputlangs' => $outputlangs,
2379 'hidedetails' => $hidedetails,
2380 'hidedesc' => $hidedesc,
2381 'hideref' => $hideref
2384 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
2388 } elseif (empty($reshook))
2390 $this->cols = array_replace($this->cols, $hookmanager->resArray);
2392 $this->cols = $hookmanager->resArray;
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
getExtrafieldContent($object, $extrafieldKey)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Class to manage products or services.
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
Class to manage Dolibarr users.
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
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...
printStdColumnContent($pdf, &$curY, $colKey, $columnText= '')
print standard column content
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
$conf db name
Only used if Module[ID]Name translation string is not found.
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...
$conf db
API class for accounts.
Class to manage bank accounts.
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...
drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
Show payments table.
getColumnStatus($colKey)
get column status from column key
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
Print standard column content.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
Parent class of invoice document generators.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
const STATUS_DRAFT
Draft status.
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails=0)
Return line total amount discount.
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
pdf_getlineprogress($object, $i, $outputlangs, $hidedetails=0, $hookmanager=null)
Return line percent.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
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)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
drawInfoTable(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
pdf_build_address($outputlangs, $sourcecompany, $targetcompany= '', $targetcontact= '', $usecontact=0, $mode= 'source', $object=null)
Return a string with full address formated for output on documents.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
Class to manage invoices.
Class to manage PDF invoice template sponge.
__construct($db)
Constructor.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null)
Show top header of page.
drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
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...
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency= '', $outputlangsbis=null)
Show table for lines.
pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.