32 require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
33 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
63 public $update_main_doc_field;
74 public $version =
'dolibarr';
125 global $conf, $langs, $mysoc;
128 $langs->loadLangs(array(
"main",
"bills"));
131 $this->
name =
"cornas";
132 $this->
description = $langs->trans(
'SuppliersCommandModel');
133 $this->update_main_doc_field = 1;
138 $this->page_largeur = $formatarray[
'width'];
139 $this->page_hauteur = $formatarray[
'height'];
140 $this->format = array($this->page_largeur, $this->page_hauteur);
146 $this->option_logo = 1;
147 $this->option_tva = 1;
148 $this->option_modereg = 1;
149 $this->option_condreg = 1;
150 $this->option_multilang = 1;
151 $this->option_escompte = 0;
152 $this->option_credit_note = 0;
153 $this->option_freetext = 1;
154 $this->option_draft_watermark = 1;
157 $this->emetteur = $mysoc;
158 if (empty($this->emetteur->country_code)) {
159 $this->emetteur->country_code = substr($langs->defaultlang, -2);
163 $this->posxdesc = $this->marge_gauche + 1;
165 $this->tva = array();
166 $this->tva_array = array();
167 $this->localtax1 = array();
168 $this->localtax2 = array();
169 $this->atleastoneratenotnull = 0;
170 $this->atleastonediscount = 0;
186 public function write_file($object, $outputlangs =
'', $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
189 global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
191 if (!is_object($outputlangs)) {
192 $outputlangs = $langs;
195 if (!empty($conf->global->MAIN_USE_FPDF)) {
196 $outputlangs->charset_output =
'ISO-8859-1';
200 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
202 global $outputlangsbis;
203 $outputlangsbis =
null;
204 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
205 $outputlangsbis =
new Translate(
'', $conf);
206 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
207 $outputlangsbis->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
210 $nblines = count($object->lines);
213 if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
214 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
218 $realpatharray = array();
219 if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) {
220 for ($i = 0; $i < $nblines; $i++) {
221 if (empty($object->lines[$i]->fk_product)) {
225 $objphoto =
new Product($this->db);
226 $objphoto->fetch($object->lines[$i]->fk_product);
229 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
230 $dir = $conf->product->dir_output.
'/'.$pdir;
232 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
233 $dir = $conf->product->dir_output.
'/'.$pdir;
237 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
239 if ($obj[
'photo_vignette']) {
240 $filename = $obj[
'photo_vignette'];
242 $filename = $obj[
'photo'];
245 $filename = $obj[
'photo'];
247 $realpath = $dir.$filename;
252 $realpatharray[$i] = $realpath;
256 if (count($realpatharray) == 0) {
257 $this->posxpicture = $this->posxtva;
260 if ($conf->fournisseur->commande->dir_output) {
261 $object->fetch_thirdparty();
264 $amount_credit_notes_included = 0;
265 $amount_deposits_included = 0;
270 if ($object->specimen) {
271 $dir = $conf->fournisseur->commande->dir_output;
272 $file = $dir.
"/SPECIMEN.pdf";
276 $dir = $conf->fournisseur->commande->dir_output.
'/'.$objectref;
277 $file = $dir.
"/".$objectref.
".pdf";
278 if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) {
279 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
283 if (!file_exists($dir)) {
285 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
290 if (file_exists($dir)) {
292 if (!is_object($hookmanager)) {
293 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
296 $hookmanager->initHooks(array(
'pdfgeneration'));
297 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
299 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
301 $nblines = count($object->lines);
305 $heightforinfotot = 50;
306 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
307 $heightforfooter = $this->marge_basse + 8;
308 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
309 $heightforfooter += 6;
311 $pdf->SetAutoPageBreak(1, 0);
313 if (class_exists(
'TCPDF')) {
314 $pdf->setPrintHeader(
false);
315 $pdf->setPrintFooter(
false);
319 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
320 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
321 $tplidx = $pdf->importPage(1);
326 $pdf->SetDrawColor(128, 128, 128);
328 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
329 $pdf->SetSubject($outputlangs->transnoentities(
"Order"));
330 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
331 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
332 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Order").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
334 $pdf->SetCompression(
false);
337 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
340 foreach ($object->lines as $line) {
341 if ($line->remise_percent) {
342 $this->atleastonediscount =
true;
349 if (!empty($tplidx)) {
350 $pdf->useTemplate($tplidx);
353 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
354 $pdf->SetFont(
'',
'', $default_font_size - 1);
355 $pdf->MultiCell(0, 3,
'');
356 $pdf->SetTextColor(0, 0, 0);
358 $tab_top = 90 + $top_shift;
359 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
361 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
365 $desc_incoterms = $object->getIncotermsForPDF();
366 if ($desc_incoterms) {
369 $pdf->SetFont(
'',
'', $default_font_size - 1);
370 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
371 $nexY = $pdf->GetY();
372 $height_incoterms = $nexY - $tab_top;
375 $pdf->SetDrawColor(192, 192, 192);
376 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
378 $tab_top = $nexY + 6;
383 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
386 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
387 if (!empty($extranote)) {
391 $pagenb = $pdf->getPage();
393 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
394 $pageposbeforenote = $pagenb;
403 $pdf->startTransaction();
405 $pdf->SetFont(
'',
'', $default_font_size - 1);
406 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
408 $pageposafternote = $pdf->getPage();
409 $posyafter = $pdf->GetY();
411 if ($pageposafternote > $pageposbeforenote) {
412 $pdf->rollbackTransaction(
true);
415 while ($pagenb < $pageposafternote) {
418 if (!empty($tplidx)) {
419 $pdf->useTemplate($tplidx);
422 $this->
_pagehead($pdf, $object, 0, $outputlangs);
425 $pdf->setTopMargin($tab_top_newpage);
427 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
431 $pdf->setPage($pageposbeforenote);
432 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
433 $pdf->SetFont(
'',
'', $default_font_size - 1);
434 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
435 $pageposafternote = $pdf->getPage();
437 $posyafter = $pdf->GetY();
439 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
440 $pdf->AddPage(
'',
'',
true);
443 $pdf->setPage($pageposafternote);
444 $pdf->setTopMargin($tab_top_newpage);
446 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
452 $i = $pageposbeforenote;
453 while ($i < $pageposafternote) {
457 $pdf->SetDrawColor(128, 128, 128);
459 if ($i > $pageposbeforenote) {
460 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
461 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
463 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
464 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
468 $pdf->setPageOrientation(
'', 1, 0);
469 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
475 $pdf->setPage($pageposafternote);
476 if (!empty($tplidx)) {
477 $pdf->useTemplate($tplidx);
480 $this->
_pagehead($pdf, $object, 0, $outputlangs);
482 $height_note = $posyafter - $tab_top_newpage;
483 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
486 $pdf->commitTransaction();
487 $posyafter = $pdf->GetY();
488 $height_note = $posyafter - $tab_top;
489 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
492 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
494 $pdf->AddPage(
'',
'',
true);
497 $pdf->setPage($pageposafternote);
498 if (!empty($tplidx)) {
499 $pdf->useTemplate($tplidx);
502 $this->
_pagehead($pdf, $object, 0, $outputlangs);
505 $posyafter = $tab_top_newpage;
509 $tab_height = $tab_height - $height_note;
510 $tab_top = $posyafter + 6;
515 $nexY = $tab_top + 5;
521 $pageposbeforeprintlines = $pdf->getPage();
522 $pagenb = $pageposbeforeprintlines;
523 for ($i = 0; $i < $nblines; $i++) {
525 $pdf->SetFont(
'',
'', $default_font_size - 1);
526 $pdf->SetTextColor(0, 0, 0);
529 $imglinesize = array();
530 if (!empty($realpatharray[$i])) {
534 $pdf->setTopMargin($tab_top_newpage);
535 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
536 $pageposbefore = $pdf->getPage();
538 $showpricebeforepagebreak = 1;
540 $posYAfterDescription = 0;
545 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
546 $pdf->AddPage(
'',
'',
true);
547 if (!empty($tplidx)) {
548 $pdf->useTemplate($tplidx);
550 $pdf->setPage($pageposbefore + 1);
552 $curY = $tab_top_newpage;
555 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
556 $showpricebeforepagebreak = 1;
558 $showpricebeforepagebreak = 0;
562 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
563 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
565 $posYAfterImage = $curY + $imglinesize[
'height'];
569 $curX = $this->posxdesc - 1;
570 $showpricebeforepagebreak = 1;
573 $pdf->startTransaction();
574 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
576 $pageposafter = $pdf->getPage();
577 if ($pageposafter > $pageposbefore) {
578 $pdf->rollbackTransaction(
true);
580 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
582 $pageposafter = $pdf->getPage();
583 $posyafter = $pdf->GetY();
584 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
585 if ($i == ($nblines - 1)) {
586 $pdf->AddPage(
'',
'',
true);
587 if (!empty($tplidx)) {
588 $pdf->useTemplate($tplidx);
591 $pdf->setPage($pageposafter + 1);
596 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
597 $showpricebeforepagebreak = 1;
599 $showpricebeforepagebreak = 0;
604 $pdf->commitTransaction();
606 $posYAfterDescription = $pdf->GetY();
609 $nexY = $pdf->GetY();
610 $pageposafter = $pdf->getPage();
611 $pdf->setPage($pageposbefore);
612 $pdf->setTopMargin($this->marge_haute);
613 $pdf->setPageOrientation(
'', 1, 0);
616 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
617 $pdf->setPage($pageposafter);
618 $curY = $tab_top_newpage;
621 $pdf->SetFont(
'',
'', $default_font_size - 1);
627 $nexY = max($pdf->GetY(), $nexY);
634 $nexY = max($pdf->GetY(), $nexY);
642 $nexY = max($pdf->GetY(), $nexY);
648 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
650 $nexY = max($pdf->GetY(), $nexY);
654 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
657 $nexY = max($pdf->GetY(), $nexY);
664 $nexY = max($pdf->GetY(), $nexY);
668 if (!empty($object->lines[$i]->array_options)) {
669 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
671 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
673 $nexY = max($pdf->GetY(), $nexY);
684 'outputlangs' => $outputlangs,
685 'hidedetails' => $hidedetails
687 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
691 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
692 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
694 $tvaligne = $object->lines[$i]->total_tva;
697 $localtax1ligne = $object->lines[$i]->total_localtax1;
698 $localtax2ligne = $object->lines[$i]->total_localtax2;
699 $localtax1_rate = $object->lines[$i]->localtax1_tx;
700 $localtax2_rate = $object->lines[$i]->localtax2_tx;
701 $localtax1_type = $object->lines[$i]->localtax1_type;
702 $localtax2_type = $object->lines[$i]->localtax2_type;
715 $vatrate = (string) $object->lines[$i]->tva_tx;
718 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
719 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
721 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
722 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
726 if ($localtax1_type && $localtax1ligne != 0) {
727 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
728 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
730 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
733 if ($localtax2_type && $localtax2ligne != 0) {
734 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
735 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
737 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
741 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
746 if (!isset($this->tva[$vatrate])) {
747 $this->tva[$vatrate] = 0;
749 $this->tva[$vatrate] += $tvaligne;
750 $vatcode = $object->lines[$i]->vat_src_code;
751 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
752 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
754 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
756 if ($posYAfterImage > $posYAfterDescription) {
757 $nexY = $posYAfterImage;
761 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
762 $pdf->setPage($pageposafter);
763 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
765 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
766 $pdf->SetLineStyle(array(
'dash'=>0));
770 while ($pagenb < $pageposafter) {
771 $pdf->setPage($pagenb);
772 if ($pagenb == $pageposbeforeprintlines) {
773 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
775 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
777 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
779 $pdf->setPage($pagenb);
780 $pdf->setPageOrientation(
'', 1, 0);
782 $this->
_pagehead($pdf, $object, 0, $outputlangs);
784 if (!empty($tplidx)) {
785 $pdf->useTemplate($tplidx);
788 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
789 if ($pagenb == $pageposafter) {
790 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
792 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
794 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
797 if (!empty($tplidx)) {
798 $pdf->useTemplate($tplidx);
802 $this->
_pagehead($pdf, $object, 0, $outputlangs);
808 if ($pagenb == $pageposbeforeprintlines) {
809 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
810 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
812 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
813 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
817 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
820 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
823 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
828 $this->
_pagefoot($pdf, $object, $outputlangs);
829 if (method_exists($pdf,
'AliasNbPages')) {
830 $pdf->AliasNbPages();
835 $pdf->Output($file,
'F');
838 $hookmanager->initHooks(array(
'pdfgeneration'));
839 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
841 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
843 $this->error = $hookmanager->error;
844 $this->errors = $hookmanager->errors;
849 $this->result = array(
'fullpath'=>$file);
853 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
857 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
893 global $conf, $mysoc;
896 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
899 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
900 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
901 $pdf->SetXY($this->marge_gauche, $posy);
902 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
904 $posy = $pdf->GetY() + 4;
910 if (!empty($object->cond_reglement_code) || $object->cond_reglement) {
911 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
912 $pdf->SetXY($this->marge_gauche, $posy);
913 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
914 $pdf->MultiCell(80, 4, $titre, 0,
'L');
916 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
917 $pdf->SetXY($posxval, $posy);
918 $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);
919 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
920 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
922 $posy = $pdf->GetY() + 3;
926 if (!empty($object->mode_reglement_code)) {
927 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
928 $pdf->SetXY($this->marge_gauche, $posy);
929 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
930 $pdf->MultiCell(80, 5, $titre, 0,
'L');
932 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
933 $pdf->SetXY($posxval, $posy);
934 $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);
935 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
937 $posy = $pdf->GetY() + 2;
956 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
959 global $conf, $mysoc;
965 $pdf->SetFont(
'',
'', $default_font_size - 1);
970 if ($this->page_largeur < 210) {
973 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
979 $pdf->SetFillColor(255, 255, 255);
980 $pdf->SetXY($col1x, $tab2_top);
981 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
983 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
984 $pdf->SetXY($col2x, $tab2_top);
985 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0,
'R', 1);
988 $pdf->SetFillColor(248, 248, 248);
990 $this->atleastoneratenotnull = 0;
991 foreach ($this->tva as $tvakey => $tvaval) {
993 $this->atleastoneratenotnull++;
996 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1000 if (preg_match(
'/\*/', $tvakey)) {
1001 $tvakey = str_replace(
'*',
'', $tvakey);
1002 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1005 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
1006 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1007 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1009 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1010 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1013 if (!$this->atleastoneratenotnull) {
1015 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1016 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
1018 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1019 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_tva), 0,
'R', 1);
1022 if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION ==
'localtax1on' && $object->total_localtax1 > 0) {
1024 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1025 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
1026 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1027 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax1), $useborder,
'R', 1);
1031 if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION ==
'localtax2on' && $object->total_localtax2 > 0) {
1033 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1034 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
1035 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1036 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax2), $useborder,
'R', 1);
1042 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1043 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1047 foreach ($localtax_rate as $tvakey => $tvaval) {
1052 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1055 if (preg_match(
'/\*/', $tvakey)) {
1056 $tvakey = str_replace(
'*',
'', $tvakey);
1057 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1059 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1060 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1061 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1063 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1064 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1072 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1073 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1077 foreach ($localtax_rate as $tvakey => $tvaval) {
1082 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1085 if (preg_match(
'/\*/', $tvakey)) {
1086 $tvakey = str_replace(
'*',
'', $tvakey);
1087 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1089 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1090 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1091 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1093 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1094 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1102 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1103 $pdf->SetTextColor(0, 0, 60);
1104 $pdf->SetFillColor(224, 224, 224);
1105 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1107 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1108 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1109 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
1110 $pdf->SetFont(
'',
'', $default_font_size - 1);
1111 $pdf->SetTextColor(0, 0, 0);
1113 $creditnoteamount = 0;
1114 $depositsamount = 0;
1118 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1119 if (!empty($object->paye)) {
1123 if ($deja_regle > 0) {
1127 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1128 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1129 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1130 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
1133 $pdf->SetTextColor(0, 0, 60);
1134 $pdf->SetFillColor(224, 224, 224);
1135 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1136 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1138 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1139 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
1141 $pdf->SetFont(
'',
'', $default_font_size - 1);
1142 $pdf->SetTextColor(0, 0, 0);
1146 return ($tab2_top + ($tab2_hl * $index));
1163 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1173 $currency = !empty($currency) ? $currency : $conf->currency;
1177 $pdf->SetTextColor(0, 0, 0);
1178 $pdf->SetFont(
'',
'', $default_font_size - 2);
1180 if (empty($hidetop)) {
1181 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1182 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1183 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1186 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1187 $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));
1191 $pdf->SetDrawColor(128, 128, 128);
1192 $pdf->SetFont(
'',
'', $default_font_size - 1);
1195 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1197 foreach ($this->cols as $colKey => $colDef) {
1203 $colDef[
'title'][
'label'] = !empty($colDef[
'title'][
'label']) ? $colDef[
'title'][
'label'] : $outputlangs->transnoentities($colDef[
'title'][
'textkey']);
1206 if (!empty($colDef[
'border-left'])) {
1207 $pdf->line($colDef[
'xStartPos'], $tab_top, $colDef[
'xStartPos'], $tab_top + $tab_height);
1210 if (empty($hidetop)) {
1211 $pdf->SetXY($colDef[
'xStartPos'] + $colDef[
'title'][
'padding'][3], $tab_top + $colDef[
'title'][
'padding'][0]);
1213 $textWidth = $colDef[
'width'] - $colDef[
'title'][
'padding'][3] - $colDef[
'title'][
'padding'][1];
1214 $pdf->MultiCell($textWidth, 2, $colDef[
'title'][
'label'],
'', $colDef[
'title'][
'align']);
1218 if (empty($hidetop)) {
1219 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1233 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1235 global $langs, $conf, $mysoc;
1237 $ltrdirection =
'L';
1238 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
1241 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1255 $pdf->SetTextColor(0, 0, 60);
1256 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1260 $posx = $this->page_largeur - $this->marge_droite - $w;
1261 $posy = $this->marge_haute;
1263 $pdf->SetXY($this->marge_gauche, $posy);
1267 if ($this->emetteur->logo) {
1268 $logodir = $conf->mycompany->dir_output;
1269 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1270 $logodir = $conf->mycompany->multidir_output[$object->entity];
1273 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1275 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1277 if (is_readable($logo)) {
1279 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1281 $pdf->SetTextColor(200, 0, 0);
1282 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1283 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1284 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1287 $text = $this->emetteur->name;
1288 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1292 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1293 $pdf->SetXY($posx, $posy);
1294 $pdf->SetTextColor(0, 0, 60);
1295 $title = $outputlangs->transnoentities(
"SupplierOrder").
" ".$outputlangs->convToOutputCharset($object->ref);
1296 $pdf->MultiCell($w, 3, $title,
'',
'R');
1299 if ($object->ref_supplier) {
1301 $pdf->SetFont(
'',
'B', $default_font_size);
1302 $pdf->SetXY($posx, $posy);
1303 $pdf->SetTextColor(0, 0, 60);
1304 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset($object->ref_supplier),
'',
'R');
1308 $pdf->SetFont(
'',
'', $default_font_size - 1);
1310 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1311 $object->fetch_projet();
1312 if (!empty($object->project->ref)) {
1314 $pdf->SetXY($posx, $posy);
1315 $pdf->SetTextColor(0, 0, 60);
1316 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1320 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1321 $object->fetch_projet();
1322 if (!empty($object->project->ref)) {
1323 $outputlangs->load(
"projects");
1325 $pdf->SetXY($posx, $posy);
1326 $langs->load(
"projects");
1327 $pdf->SetTextColor(0, 0, 60);
1328 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1332 if (!empty($object->date_commande)) {
1334 $pdf->SetXY($posx, $posy);
1335 $pdf->SetTextColor(0, 0, 60);
1336 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($object->date_commande,
"day",
false, $outputlangs,
true),
'',
'R');
1339 $pdf->SetXY($posx, $posy);
1340 $pdf->SetTextColor(255, 0, 0);
1341 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderToProcess"),
'',
'R');
1344 $pdf->SetTextColor(0, 0, 60);
1345 $usehourmin =
'day';
1346 if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) {
1347 $usehourmin =
'dayhour';
1349 if (!empty($object->delivery_date)) {
1351 $pdf->SetXY($posx - 90, $posy);
1352 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1355 if ($object->thirdparty->code_fournisseur) {
1357 $pdf->SetXY($posx, $posy);
1358 $pdf->SetTextColor(0, 0, 60);
1359 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
1363 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1364 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1365 if (count($arrayidcontact) > 0) {
1366 $usertmp =
new User($this->db);
1367 $usertmp->fetch($arrayidcontact[0]);
1369 $pdf->SetXY($posx, $posy);
1370 $pdf->SetTextColor(0, 0, 60);
1371 $pdf->MultiCell($w, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1376 $pdf->SetTextColor(0, 0, 60);
1380 $current_y = $pdf->getY();
1381 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1382 if ($current_y < $pdf->getY()) {
1383 $top_shift = $pdf->getY() - $current_y;
1388 $carac_emetteur =
'';
1390 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1391 if (count($arrayidcontact) > 0) {
1392 $object->fetch_user($arrayidcontact[0]);
1393 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1394 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1396 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1398 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1400 $carac_emetteur .=
"\n";
1403 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1406 $posy = 42 + $top_shift;
1407 $posx = $this->marge_gauche;
1408 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1409 $posx = $this->page_largeur - $this->marge_droite - 80;
1414 $pdf->SetTextColor(0, 0, 0);
1415 $pdf->SetFont(
'',
'', $default_font_size - 2);
1416 $pdf->SetXY($posx, $posy - 5);
1417 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1418 $pdf->SetXY($posx, $posy);
1419 $pdf->SetFillColor(230, 230, 230);
1420 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1421 $pdf->SetTextColor(0, 0, 60);
1424 $pdf->SetXY($posx + 2, $posy + 3);
1425 $pdf->SetFont(
'',
'B', $default_font_size);
1426 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1427 $posy = $pdf->getY();
1430 $pdf->SetXY($posx + 2, $posy);
1431 $pdf->SetFont(
'',
'', $default_font_size - 1);
1432 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1437 $usecontact =
false;
1438 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1439 if (count($arrayidcontact) > 0) {
1441 $result = $object->fetch_contact($arrayidcontact[0]);
1445 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1446 $thirdparty = $object->contact;
1448 $thirdparty = $object->thirdparty;
1453 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1457 if ($this->page_largeur < 210) {
1460 $posy = 42 + $top_shift;
1461 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1462 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1463 $posx = $this->marge_gauche;
1467 $pdf->SetTextColor(0, 0, 0);
1468 $pdf->SetFont(
'',
'', $default_font_size - 2);
1469 $pdf->SetXY($posx + 2, $posy - 5);
1470 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1471 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1474 $pdf->SetXY($posx + 2, $posy + 3);
1475 $pdf->SetFont(
'',
'B', $default_font_size);
1476 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1478 $posy = $pdf->getY();
1481 $pdf->SetFont(
'',
'', $default_font_size - 1);
1482 $pdf->SetXY($posx + 2, $posy);
1483 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1499 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1501 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1502 return pdf_pagefoot($pdf, $outputlangs,
'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1517 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1519 global $conf, $hookmanager;
1522 $this->defaultContentsFieldsStyle = array(
1524 'padding' => array(1, 0.5, 1, 0.5),
1528 $this->defaultTitlesFieldsStyle = array(
1530 'padding' => array(0.5, 0, 0.5, 0),
1552 $this->cols[
'desc'] = array(
1557 'textkey' =>
'Designation',
1561 'padding' => array(0.5, 1, 0.5, 1.5),
1565 'padding' => array(1, 0.5, 1, 1.5),
1570 $this->cols[
'photo'] = array(
1572 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
1575 'textkey' =>
'Photo',
1579 'padding' => array(0, 0, 0, 0),
1581 'border-left' =>
false,
1584 if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) {
1585 $this->cols[
'photo'][
'status'] =
true;
1590 $this->cols[
'vat'] = array(
1597 'border-left' =>
true,
1600 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1601 $this->cols[
'vat'][
'status'] =
true;
1605 $this->cols[
'subprice'] = array(
1610 'textkey' =>
'PriceUHT'
1612 'border-left' =>
true,
1615 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE)) {
1616 $this->cols[
'subprice'][
'status'] =
true;
1620 $this->cols[
'qty'] = array(
1627 'border-left' =>
true,
1631 $this->cols[
'unit'] = array(
1638 'border-left' =>
true,
1641 $this->cols[
'unit'][
'status'] =
true;
1645 $this->cols[
'discount'] = array(
1650 'textkey' =>
'ReductionShort'
1652 'border-left' =>
true,
1654 if ($this->atleastonediscount) {
1655 $this->cols[
'discount'][
'status'] =
true;
1658 $rank = $rank + 1000;
1659 $this->cols[
'totalexcltax'] = array(
1664 'textkey' =>
'TotalHT'
1666 'border-left' =>
true,
1669 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN)) {
1670 $this->cols[
'totalexcltax'][
'status'] =
true;
1674 if (!empty($object->lines)) {
1675 $line = reset($object->lines);
1679 $parameters = array(
1680 'object' => $object,
1681 'outputlangs' => $outputlangs,
1682 'hidedetails' => $hidedetails,
1683 'hidedesc' => $hidedesc,
1684 'hideref' => $hideref
1687 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
1690 } elseif (empty($reshook)) {
1691 $this->cols = array_replace($this->cols, $hookmanager->resArray);
1693 $this->cols = $hookmanager->resArray;
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
getColumnStatus($colKey)
get column status from column key
printStdColumnContent($pdf, &$curY, $colKey, $columnText='')
print standard column content
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
getExtrafieldContent($object, $extrafieldKey, $outputlangs=null)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
Parent class for supplier orders models.
Class to manage products or services.
Class to manage translations.
Class to manage Dolibarr users.
Class to generate the supplier orders with the cornas model.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
_tableau_versements(&$pdf, $object, $posy, $outputlangs)
Show payments table.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
__construct($db)
Constructor.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!function_exists('dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formated for output on documents.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.