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_codeproduitservice = 1;
168 $this->option_multilang = 1;
169 $this->option_escompte = 1;
170 $this->option_credit_note = 1;
171 $this->option_freetext = 1;
172 $this->option_draft_watermark = 1;
175 $this->emetteur = $mysoc;
176 if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2);
179 $this->posxdesc = $this->marge_gauche + 1;
180 if (!empty($conf->global->PRODUCT_USE_UNITS))
182 $this->posxtva = 101;
184 $this->posxqty = 135;
185 $this->posxunit = 151;
187 $this->posxtva = 110;
189 $this->posxqty = 145;
190 $this->posxunit = 162;
192 $this->posxprogress = 151;
193 $this->posxdiscount = 162;
194 $this->posxprogress = 174;
195 $this->postotalht = 174;
196 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
197 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
198 if ($this->page_largeur < 210)
200 $this->posxpicture -= 20;
201 $this->posxtva -= 20;
203 $this->posxqty -= 20;
204 $this->posxunit -= 20;
205 $this->posxdiscount -= 20;
206 $this->posxprogress -= 20;
207 $this->postotalht -= 20;
210 $this->tva = array();
211 $this->localtax1 = array();
212 $this->localtax2 = array();
213 $this->atleastoneratenotnull = 0;
214 $this->atleastonediscount = 0;
215 $this->situationinvoice =
false;
231 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
234 global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
236 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
238 if (!is_object($outputlangs)) $outputlangs = $langs;
240 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
243 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
245 $nblines = count($object->lines);
248 $realpatharray = array();
249 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
251 for ($i = 0; $i < $nblines; $i++)
253 if (empty($object->lines[$i]->fk_product))
continue;
256 $objphoto->fetch($object->lines[$i]->fk_product);
258 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
259 $dir = $conf->product->dir_output.
'/'.$pdir;
262 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
264 $filename = $obj[
'photo'];
266 $realpath = $dir.$filename;
270 if ($realpath) $realpatharray[$i] = $realpath;
273 if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
275 if ($conf->facture->dir_output)
277 $object->fetch_thirdparty();
279 $deja_regle = $object->getSommePaiement((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
280 $amount_credit_notes_included = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
281 $amount_deposits_included = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
284 if ($object->specimen)
286 $dir = $conf->facture->dir_output;
287 $file = $dir.
"/SPECIMEN.pdf";
290 $dir = $conf->facture->dir_output.
"/".$objectref;
291 $file = $dir.
"/".$objectref.
".pdf";
293 if (!file_exists($dir))
297 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
302 if (file_exists($dir))
305 if (!is_object($hookmanager))
307 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
310 $hookmanager->initHooks(array(
'pdfgeneration'));
311 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
313 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
316 $nblines = count($object->lines);
317 $nbpayments = count($object->getListOfPayments());
322 $pdf->SetAutoPageBreak(1, 0);
324 $heightforinfotot = 50 + (4 * $nbpayments);
325 if ($heightforinfotot > 220) $heightforinfotot = 220;
326 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
327 $heightforfooter = $this->marge_basse + 8;
328 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;
330 if (class_exists(
'TCPDF'))
332 $pdf->setPrintHeader(
false);
333 $pdf->setPrintFooter(
false);
338 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
340 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
341 $tplidx = $pdf->importPage(1);
346 $pdf->SetDrawColor(128, 128, 128);
348 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
349 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
350 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
351 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
352 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
353 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(
false);
356 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
359 $cert = empty($conf->global->CERTIFICATE_CRT) ?
'' : $conf->global->CERTIFICATE_CRT;
364 'Name' => $this->emetteur->name,
365 'Location' =>
getCountry($this->emetteur->country_code, 0),
366 'Reason' =>
'INVOICE',
367 'ContactInfo' => $this->emetteur->email
369 $pdf->setSignature($cert, $cert, $this->emetteur->name,
'', 2, $info);
372 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
375 for ($i = 0; $i < $nblines; $i++)
377 if ($object->lines[$i]->remise_percent)
379 $this->atleastonediscount++;
382 if (empty($this->atleastonediscount))
384 $delta = ($this->posxprogress - $this->posxdiscount);
385 $this->posxpicture += $delta;
386 $this->posxtva += $delta;
387 $this->posxup += $delta;
388 $this->posxqty += $delta;
389 $this->posxunit += $delta;
390 $this->posxdiscount += $delta;
396 if ($object->situation_cycle_ref && empty($conf->global->MAIN_PDF_HIDE_SITUATION))
398 $this->situationinvoice =
true;
399 $progress_width = 10;
400 $this->posxpicture -= $progress_width;
401 $this->posxtva -= $progress_width;
402 $this->posxup -= $progress_width;
403 $this->posxqty -= $progress_width;
404 $this->posxunit -= $progress_width;
405 $this->posxdiscount -= $progress_width;
406 $this->posxprogress -= $progress_width;
411 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
414 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
415 $pdf->SetFont(
'',
'', $default_font_size - 1);
416 $pdf->MultiCell(0, 3,
'');
417 $pdf->SetTextColor(0, 0, 0);
419 $tab_top = 90 + $top_shift;
420 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
423 if (!empty($conf->incoterm->enabled))
425 $desc_incoterms = $object->getIncotermsForPDF();
430 $pdf->SetFont(
'',
'', $default_font_size - 1);
431 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
432 $nexY = $pdf->GetY();
433 $height_incoterms = $nexY - $tab_top;
436 $pdf->SetDrawColor(192, 192, 192);
437 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
439 $tab_top = $nexY + 6;
444 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
445 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
448 if (is_object($object->thirdparty))
450 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
451 $salerepobj =
new User($this->
db);
452 $salerepobj->fetch($salereparray[0][
'id']);
453 if (!empty($salerepobj->signature)) $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
457 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
458 if (!empty($extranote)) {
471 $pdf->SetFont(
'',
'', $default_font_size - 1);
472 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
473 $nexY = $pdf->GetY();
474 $height_note = $nexY - $tab_top;
477 $pdf->SetDrawColor(192, 192, 192);
478 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
480 $tab_top = $nexY + 6;
483 $iniY = $tab_top + 7;
484 $curY = $tab_top + 7;
485 $nexY = $tab_top + 7;
488 for ($i = 0; $i < $nblines; $i++)
491 $pdf->SetFont(
'',
'', $default_font_size - 1);
492 $pdf->SetTextColor(0, 0, 0);
495 $imglinesize = array();
498 $pdf->setTopMargin($tab_top_newpage);
499 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
500 $pageposbefore = $pdf->getPage();
502 $showpricebeforepagebreak = 1;
504 $posYAfterDescription = 0;
507 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))
509 $pdf->AddPage(
'',
'',
true);
510 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
511 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
512 $pdf->setPage($pageposbefore + 1);
514 $curY = $tab_top_newpage;
517 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
518 $showpricebeforepagebreak = 1;
519 else $showpricebeforepagebreak = 0;
522 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']))
524 $curX = $this->posxpicture - 1;
525 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
527 $posYAfterImage = $curY + $imglinesize[
'height'];
531 $curX = $this->posxdesc - 1;
533 $pdf->startTransaction();
534 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
535 $pageposafter = $pdf->getPage();
536 if ($pageposafter > $pageposbefore)
538 $pdf->rollbackTransaction(
true);
539 $pageposafter = $pageposbefore;
541 $pdf->setPageOrientation(
'', 1, $heightforfooter);
542 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
543 $pageposafter = $pdf->getPage();
544 $posyafter = $pdf->GetY();
546 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))
548 if ($i == ($nblines - 1))
550 $pdf->AddPage(
'',
'',
true);
551 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
552 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
553 $pdf->setPage($pageposafter + 1);
559 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
560 $showpricebeforepagebreak = 1;
561 else $showpricebeforepagebreak = 0;
565 $pdf->commitTransaction();
567 $posYAfterDescription = $pdf->GetY();
569 $nexY = $pdf->GetY();
570 $pageposafter = $pdf->getPage();
571 $pdf->setPage($pageposbefore);
572 $pdf->setTopMargin($this->marge_haute);
573 $pdf->setPageOrientation(
'', 1, 0);
576 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
577 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
580 $pdf->SetFont(
'',
'', $default_font_size - 1);
583 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
586 $pdf->SetXY($this->posxtva - 5, $curY);
587 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
592 $pdf->SetXY($this->posxup, $curY);
593 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
597 $pdf->SetXY($this->posxqty, $curY);
598 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
601 if (!empty($conf->global->PRODUCT_USE_UNITS))
603 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
604 $pdf->SetXY($this->posxunit, $curY);
605 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
609 if ($object->lines[$i]->remise_percent)
611 $pdf->SetXY($this->posxdiscount - 2, $curY);
613 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
617 if ($this->situationinvoice)
620 $pdf->SetXY($this->posxprogress, $curY);
621 $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0,
'R');
626 $pdf->SetXY($this->postotalht, $curY);
627 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
631 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
633 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
634 if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent))
636 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;
637 else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
639 if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
640 else $tvaligne = $sign * $object->lines[$i]->total_tva;
643 $localtax1ligne = $object->lines[$i]->total_localtax1;
644 $localtax2ligne = $object->lines[$i]->total_localtax2;
645 $localtax1_rate = $object->lines[$i]->localtax1_tx;
646 $localtax2_rate = $object->lines[$i]->localtax2_tx;
647 $localtax1_type = $object->lines[$i]->localtax1_type;
648 $localtax2_type = $object->lines[$i]->localtax2_type;
650 if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
651 if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
652 if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
654 $vatrate = (string) $object->lines[$i]->tva_tx;
657 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
658 && (!empty($localtax1_rate) || !empty($localtax2_rate)))
661 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
662 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
666 if ($localtax1_type && $localtax1ligne != 0)
667 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
668 if ($localtax2_type && $localtax2ligne != 0)
669 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
671 if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .=
'*';
672 if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
673 $this->tva[$vatrate] += $tvaligne;
675 if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
678 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
680 $pdf->setPage($pageposafter);
681 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
683 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
684 $pdf->SetLineStyle(array(
'dash'=>0));
690 while ($pagenb < $pageposafter)
692 $pdf->setPage($pagenb);
695 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
697 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
699 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
701 $pdf->setPage($pagenb);
702 $pdf->setPageOrientation(
'', 1, 0);
703 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
705 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
709 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
711 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
713 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
716 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
718 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
725 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
726 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
728 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
729 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
733 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
736 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
739 if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
745 $this->
_pagefoot($pdf, $object, $outputlangs);
746 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
750 $pdf->Output($file,
'F');
753 $hookmanager->initHooks(array(
'pdfgeneration'));
754 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
756 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
759 $this->error = $hookmanager->error;
760 $this->errors = $hookmanager->errors;
763 if (!empty($conf->global->MAIN_UMASK))
764 @chmod($file, octdec($conf->global->MAIN_UMASK));
766 $this->result = array(
'fullpath'=>$file);
770 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
774 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
798 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
800 $current_page = $pdf->getPage();
802 $tab3_top = $posy + 8;
805 if ($this->page_largeur < 210)
812 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height);
816 $pdf->SetFont(
'',
'', $default_font_size - 4);
820 $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,";
821 $sql .=
" re.description, re.fk_facture_source,";
822 $sql .=
" f.type, f.datef";
823 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
824 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
834 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter))
838 $pdf->AddPage(
'',
'',
true);
839 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
840 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
841 $pdf->setPage($current_page);
842 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
845 $obj = $this->
db->fetch_object(
$resql);
847 if ($obj->type == 2) $text = $outputlangs->transnoentities(
"CreditNote");
848 elseif ($obj->type == 3) $text = $outputlangs->transnoentities(
"Deposit");
849 elseif ($obj->type == 0) $text = $outputlangs->transnoentities(
"ExcessReceived");
850 else $text = $outputlangs->transnoentities(
"UnknownType");
852 $invoice->fetch($obj->fk_facture_source);
854 $pdf->SetXY($tab3_posx, $tab3_top + $y);
855 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L', 0);
856 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
857 $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);
858 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
859 $pdf->MultiCell(20, 3, $text, 0,
'L', 0);
860 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
861 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L', 0);
863 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
868 $this->error = $this->
db->lasterror();
874 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
876 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
877 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
878 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
880 $sql .=
" ORDER BY p.datep";
889 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter))
893 $pdf->AddPage(
'',
'',
true);
894 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
895 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
896 $pdf->setPage($current_page);
897 $this->
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height);
900 $row = $this->
db->fetch_object(
$resql);
902 $pdf->SetXY($tab3_posx, $tab3_top + $y);
903 $pdf->MultiCell(20, 3,
dol_print_date($this->
db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L', 0);
904 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
905 $pdf->MultiCell(20, 3,
price($sign * ((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L', 0);
906 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
907 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
909 $pdf->MultiCell(20, 3, $oper, 0,
'L', 0);
910 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
911 $pdf->MultiCell(30, 3, $row->num, 0,
'L', 0);
913 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
918 return $tab3_top + $y + 3;
920 $this->error = $this->
db->lasterror();
940 protected function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height)
943 $title = $outputlangs->transnoentities(
"PaymentsAlreadyDone");
944 if ($object->type == 2) $title = $outputlangs->transnoentities(
"PaymentsBackAlreadyDone");
946 $pdf->SetFont(
'',
'', $default_font_size - 3);
947 $pdf->SetXY($tab3_posx, $tab3_top - 4);
948 $pdf->MultiCell(60, 3, $title, 0,
'L', 0);
950 $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
952 $pdf->SetFont(
'',
'', $default_font_size - 4);
953 $pdf->SetXY($tab3_posx, $tab3_top);
954 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Payment"), 0,
'L', 0);
955 $pdf->SetXY($tab3_posx + 21, $tab3_top);
956 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Amount"), 0,
'L', 0);
957 $pdf->SetXY($tab3_posx + 40, $tab3_top);
958 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Type"), 0,
'L', 0);
959 $pdf->SetXY($tab3_posx + 58, $tab3_top);
960 $pdf->MultiCell(20, 3, $outputlangs->transnoentities(
"Num"), 0,
'L', 0);
962 $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
979 global $conf, $mysoc;
983 $pdf->SetFont(
'',
'', $default_font_size - 1);
986 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj))
988 $pdf->SetFont(
'',
'B', $default_font_size - 2);
989 $pdf->SetXY($this->marge_gauche, $posy);
990 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
992 $posy = $pdf->GetY() + 4;
998 if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
1000 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1001 $pdf->SetXY($this->marge_gauche, $posy);
1002 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1003 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1005 $pdf->SetFont(
'',
'', $default_font_size - 2);
1006 $pdf->SetXY($posxval, $posy);
1007 $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);
1008 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1009 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1011 $posy = $pdf->GetY() + 3;
1014 if ($object->type != 2)
1017 if (empty($object->mode_reglement_code)
1018 && empty($conf->global->FACTURE_CHQ_NUMBER)
1019 && empty($conf->global->FACTURE_RIB_NUMBER))
1021 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1024 elseif (($object->mode_reglement_code ==
'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
1025 || ($object->mode_reglement_code ==
'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)))
1027 $outputlangs->load(
"errors");
1029 $pdf->SetXY($this->marge_gauche, $posy);
1030 $pdf->SetTextColor(200, 0, 0);
1031 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1032 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1033 $pdf->MultiCell(80, 3, $this->error, 0,
'L', 0);
1034 $pdf->SetTextColor(0, 0, 0);
1036 $posy = $pdf->GetY() + 1;
1040 if ($object->mode_reglement_code
1041 && $object->mode_reglement_code !=
'CHQ'
1042 && $object->mode_reglement_code !=
'VIR')
1044 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1045 $pdf->SetXY($this->marge_gauche, $posy);
1046 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1047 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1049 $pdf->SetFont(
'',
'', $default_font_size - 2);
1050 $pdf->SetXY($posxval, $posy);
1051 $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);
1052 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1055 $useonlinepayment = ((!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)) && !empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT));
1056 if (($object->mode_reglement_code ==
'CB' || $object->mode_reglement_code ==
'VAD') && $object->statut !=
Facture::STATUS_DRAFT && $useonlinepayment) {
1057 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1060 $langs->loadLangs(array(
'payment',
'paybox'));
1061 $servicename = $langs->transnoentities(
'Online');
1062 $paiement_url = getOnlinePaymentUrl(
'',
'invoice', $object->ref,
'',
'',
'');
1063 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1069 $posy = $pdf->GetY() + 2;
1073 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ')
1076 if (!empty($conf->global->FACTURE_CHQ_NUMBER))
1078 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1080 if ($conf->global->FACTURE_CHQ_NUMBER > 0)
1083 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1085 $pdf->SetXY($this->marge_gauche, $posy);
1086 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1087 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1088 $posy = $pdf->GetY() + 1;
1090 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1092 $pdf->SetXY($this->marge_gauche, $posy);
1093 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1094 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1095 $posy = $pdf->GetY() + 2;
1098 if ($conf->global->FACTURE_CHQ_NUMBER == -1)
1100 $pdf->SetXY($this->marge_gauche, $posy);
1101 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1102 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1103 $posy = $pdf->GetY() + 1;
1105 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1107 $pdf->SetXY($this->marge_gauche, $posy);
1108 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1109 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1110 $posy = $pdf->GetY() + 2;
1117 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR')
1119 if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
1120 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1121 if ($object->fk_bank > 0) $bankid = $object->fk_bank;
1123 $account->fetch($bankid);
1125 $curx = $this->marge_gauche;
1128 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1151 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1154 global $conf, $mysoc;
1157 if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
1163 $pdf->SetFont(
'',
'', $default_font_size - 1);
1166 $col1x = 120; $col2x = 170;
1167 if ($this->page_largeur < 210)
1171 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1177 $pdf->SetFillColor(255, 255, 255);
1178 $pdf->SetXY($col1x, $tab2_top + 0);
1179 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1181 $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1182 $pdf->SetXY($col2x, $tab2_top + 0);
1183 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0,
'R', 1);
1186 $pdf->SetFillColor(248, 248, 248);
1188 $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1190 $this->atleastoneratenotnull = 0;
1191 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1193 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1194 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1203 foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1205 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5')))
continue;
1207 foreach ($localtax_rate as $tvakey => $tvaval)
1214 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1217 if (preg_match(
'/\*/', $tvakey))
1219 $tvakey = str_replace(
'*',
'', $tvakey);
1220 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1223 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1224 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1225 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1227 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1228 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1236 foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1238 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5')))
continue;
1240 foreach ($localtax_rate as $tvakey => $tvaval)
1249 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1252 if (preg_match(
'/\*/', $tvakey))
1254 $tvakey = str_replace(
'*',
'', $tvakey);
1255 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1257 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1258 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1259 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1261 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1262 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1270 foreach ($this->tva as $tvakey => $tvaval)
1274 $this->atleastoneratenotnull++;
1277 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1280 if (preg_match(
'/\*/', $tvakey))
1282 $tvakey = str_replace(
'*',
'', $tvakey);
1283 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1285 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
1286 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1287 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1289 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1290 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval,
'MT'), 0, $outputlangs), 0,
'R', 1);
1297 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1298 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6')))
continue;
1300 foreach ($localtax_rate as $tvakey => $tvaval)
1307 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1310 if (preg_match(
'/\*/', $tvakey))
1312 $tvakey = str_replace(
'*',
'', $tvakey);
1313 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1315 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1316 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1318 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1319 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1320 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1328 foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1330 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6')))
continue;
1332 foreach ($localtax_rate as $tvakey => $tvaval)
1337 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1340 if (preg_match(
'/\*/', $tvakey))
1342 $tvakey = str_replace(
'*',
'', $tvakey);
1343 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1345 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1347 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1348 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1350 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1351 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1357 if (
price2num($object->revenuestamp) != 0)
1360 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1361 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp"), $useborder,
'L', 1);
1363 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1364 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $object->revenuestamp), $useborder,
'R', 1);
1369 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1370 $pdf->SetTextColor(0, 0, 60);
1371 $pdf->SetFillColor(224, 224, 224);
1372 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1374 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1375 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1378 if ($object->displayRetainedWarranty())
1380 $pdf->SetTextColor(40, 40, 40);
1381 $pdf->SetFillColor(255, 255, 255);
1383 $retainedWarranty = $object->getRetainedWarrantyAmount();
1384 $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
1388 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1389 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date($object->date_lim_reglement,
'day')), $useborder,
'L', 1);
1391 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1392 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R', 1);
1396 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1398 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").
' ('.$object->retained_warranty.
'%)';
1399 $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date($object->retained_warranty_date_limit,
'day')) :
'';
1401 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L', 1);
1402 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1403 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R', 1);
1408 $pdf->SetTextColor(0, 0, 0);
1409 $creditnoteamount = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
1410 $depositsamount = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
1412 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1413 if (!empty($object->paye)) $resteapayer = 0;
1415 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
1419 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1420 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L', 0);
1421 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1422 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R', 0);
1425 if ($creditnoteamount)
1427 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1429 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1430 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L', 0);
1431 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1432 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R', 0);
1436 if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT)
1439 $pdf->SetFillColor(255, 255, 255);
1441 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1442 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L', 1);
1443 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1444 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R', 1);
1450 $pdf->SetTextColor(0, 0, 60);
1451 $pdf->SetFillColor(224, 224, 224);
1452 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1453 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1454 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1455 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1457 $pdf->SetFont(
'',
'', $default_font_size - 1);
1458 $pdf->SetTextColor(0, 0, 0);
1462 return ($tab2_top + ($tab2_hl * $index));
1479 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1485 if ($hidetop) $hidetop = -1;
1487 $currency = !empty($currency) ? $currency : $conf->currency;
1491 $pdf->SetTextColor(0, 0, 0);
1492 $pdf->SetFont(
'',
'', $default_font_size - 2);
1494 if (empty($hidetop))
1496 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1497 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1498 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1501 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $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));
1504 $pdf->SetDrawColor(128, 128, 128);
1505 $pdf->SetFont(
'',
'', $default_font_size - 1);
1508 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1510 if (empty($hidetop))
1512 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1514 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1515 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1518 if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
1520 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1521 if (empty($hidetop))
1528 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1530 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1531 if (empty($hidetop))
1533 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1534 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1538 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1539 if (empty($hidetop))
1541 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1542 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1545 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1546 if (empty($hidetop))
1548 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1549 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1552 if (!empty($conf->global->PRODUCT_USE_UNITS))
1554 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1555 if (empty($hidetop)) {
1556 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1557 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1561 if ($this->atleastonediscount)
1563 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1564 if (empty($hidetop))
1566 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1567 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1571 if ($this->situationinvoice) {
1572 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1573 if (empty($hidetop)) {
1574 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1575 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities(
"ProgressShort"),
'',
'C');
1579 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1580 if (empty($hidetop))
1582 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1583 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
1597 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1599 global $conf, $langs;
1602 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
1611 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
1614 $pdf->SetTextColor(0, 0, 60);
1615 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1619 $posy = $this->marge_haute;
1620 $posx = $this->page_largeur - $this->marge_droite - $w;
1622 $pdf->SetXY($this->marge_gauche, $posy);
1625 if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1627 if ($this->emetteur->logo)
1629 $logodir = $conf->mycompany->dir_output;
1630 if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
1631 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
1633 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1635 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1637 if (is_readable($logo))
1640 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1642 $pdf->SetTextColor(200, 0, 0);
1643 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1644 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1645 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1648 $text = $this->emetteur->name;
1649 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1653 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1654 $pdf->SetXY($posx, $posy);
1655 $pdf->SetTextColor(0, 0, 60);
1656 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
1657 if ($object->type == 1) $title = $outputlangs->transnoentities(
"InvoiceReplacement");
1658 if ($object->type == 2) $title = $outputlangs->transnoentities(
"InvoiceAvoir");
1659 if ($object->type == 3) $title = $outputlangs->transnoentities(
"InvoiceDeposit");
1660 if ($object->type == 4) $title = $outputlangs->transnoentities(
"InvoiceProForma");
1661 if ($this->situationinvoice) $title = $outputlangs->transnoentities(
"PDFInvoiceSituation");
1662 $pdf->MultiCell($w, 3, $title,
'',
'R');
1664 $pdf->SetFont(
'',
'B', $default_font_size);
1667 $pdf->SetXY($posx, $posy);
1668 $pdf->SetTextColor(0, 0, 60);
1669 $textref = $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref);
1672 $pdf->SetTextColor(128, 0, 0);
1673 $textref .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1675 $pdf->MultiCell($w, 4, $textref,
'',
'R');
1678 $pdf->SetFont(
'',
'', $default_font_size - 2);
1680 if ($object->ref_client)
1683 $pdf->SetXY($posx, $posy);
1684 $pdf->SetTextColor(0, 0, 60);
1685 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1688 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
1690 $object->fetch_projet();
1691 if (!empty($object->project->ref))
1694 $pdf->SetXY($posx, $posy);
1695 $pdf->SetTextColor(0, 0, 60);
1696 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
1700 if (!empty($conf->global->PDF_SHOW_PROJECT))
1702 $object->fetch_projet();
1703 if (!empty($object->project->ref))
1706 $pdf->SetXY($posx, $posy);
1707 $pdf->SetTextColor(0, 0, 60);
1708 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->projet->ref),
'',
'R');
1712 $objectidnext = $object->getIdReplacingInvoice(
'validated');
1713 if ($object->type == 0 && $objectidnext)
1715 $objectreplacing =
new Facture($this->
db);
1716 $objectreplacing->fetch($objectidnext);
1719 $pdf->SetXY($posx, $posy);
1720 $pdf->SetTextColor(0, 0, 60);
1721 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
1723 if ($object->type == 1)
1725 $objectreplaced =
new Facture($this->
db);
1726 $objectreplaced->fetch($object->fk_facture_source);
1729 $pdf->SetXY($posx, $posy);
1730 $pdf->SetTextColor(0, 0, 60);
1731 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
1733 if ($object->type == 2 && !empty($object->fk_facture_source))
1735 $objectreplaced =
new Facture($this->
db);
1736 $objectreplaced->fetch($object->fk_facture_source);
1739 $pdf->SetXY($posx, $posy);
1740 $pdf->SetTextColor(0, 0, 60);
1741 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
1745 $pdf->SetXY($posx, $posy);
1746 $pdf->SetTextColor(0, 0, 60);
1747 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DateInvoice").
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs),
'',
'R');
1749 if (!empty($conf->global->INVOICE_POINTOFTAX_DATE))
1752 $pdf->SetXY($posx, $posy);
1753 $pdf->SetTextColor(0, 0, 60);
1754 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date($object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
1757 if ($object->type != 2)
1760 $pdf->SetXY($posx, $posy);
1761 $pdf->SetTextColor(0, 0, 60);
1762 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DateDue").
" : ".
dol_print_date($object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
1765 if ($object->thirdparty->code_client)
1768 $pdf->SetXY($posx, $posy);
1769 $pdf->SetTextColor(0, 0, 60);
1770 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1774 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1776 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1777 if (count($arrayidcontact) > 0)
1779 $usertmp =
new User($this->
db);
1780 $usertmp->fetch($arrayidcontact[0]);
1782 $pdf->SetXY($posx, $posy);
1783 $pdf->SetTextColor(0, 0, 60);
1784 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1792 $current_y = $pdf->getY();
1793 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1794 if ($current_y < $pdf->getY())
1796 $top_shift = $pdf->getY() - $current_y;
1802 $carac_emetteur =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1805 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1806 $posy += $top_shift;
1807 $posx = $this->marge_gauche;
1808 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1810 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1811 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1815 $pdf->SetTextColor(0, 0, 0);
1816 $pdf->SetFont(
'',
'', $default_font_size - 2);
1817 $pdf->SetXY($posx, $posy - 5);
1818 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0,
'L');
1819 $pdf->SetXY($posx, $posy);
1820 $pdf->SetFillColor(230, 230, 230);
1821 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1822 $pdf->SetTextColor(0, 0, 60);
1825 $pdf->SetXY($posx + 2, $posy + 3);
1826 $pdf->SetFont(
'',
'B', $default_font_size);
1827 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1828 $posy = $pdf->getY();
1831 $pdf->SetXY($posx + 2, $posy);
1832 $pdf->SetFont(
'',
'', $default_font_size - 1);
1833 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1838 $usecontact =
false;
1839 $arrayidcontact = $object->getIdContact(
'external',
'BILLING');
1840 if (count($arrayidcontact) > 0)
1843 $result = $object->fetch_contact($arrayidcontact[0]);
1847 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)))) {
1848 $thirdparty = $object->contact;
1850 $thirdparty = $object->thirdparty;
1855 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1858 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1859 if ($this->page_largeur < 210) $widthrecbox = 84;
1860 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1861 $posy += $top_shift;
1862 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1863 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1866 $pdf->SetTextColor(0, 0, 0);
1867 $pdf->SetFont(
'',
'', $default_font_size - 2);
1868 $pdf->SetXY($posx + 2, $posy - 5);
1869 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo").
":", 0,
'L');
1870 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1873 $pdf->SetXY($posx + 2, $posy + 3);
1874 $pdf->SetFont(
'',
'B', $default_font_size);
1875 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1877 $posy = $pdf->getY();
1880 $pdf->SetFont(
'',
'', $default_font_size - 1);
1881 $pdf->SetXY($posx + 2, $posy);
1882 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1885 $pdf->SetTextColor(0, 0, 0);
1899 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1902 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1903 return pdf_pagefoot($pdf, $outputlangs,
'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
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.
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.
Class to generate the customer invoice PDF with template Crabe.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height)
Function _tableau_versements_header.
</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.
Class to manage Dolibarr users.
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...
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
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...
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency= '')
Show table for lines.
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
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.
_tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter=0)
Show payments table.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
const STATUS_DRAFT
Draft status.
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...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
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.
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
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.
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).
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
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.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
Class to manage invoices.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
__construct($db)
Constructor.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
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...