31 require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
32 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
62 public $update_main_doc_field;
73 public $version =
'dolibarr';
124 global $conf, $langs, $mysoc;
127 $langs->loadLangs(array(
"main",
"bills"));
130 $this->
name =
"cornas";
131 $this->
description = $langs->trans(
'SuppliersCommandModel');
132 $this->update_main_doc_field = 1;
137 $this->page_largeur = $formatarray[
'width'];
138 $this->page_hauteur = $formatarray[
'height'];
139 $this->format = array($this->page_largeur, $this->page_hauteur);
145 $this->option_logo = 1;
146 $this->option_tva = 1;
147 $this->option_modereg = 1;
148 $this->option_condreg = 1;
149 $this->option_multilang = 1;
150 $this->option_escompte = 0;
151 $this->option_credit_note = 0;
152 $this->option_freetext = 1;
153 $this->option_draft_watermark = 1;
156 $this->emetteur = $mysoc;
157 if (empty($this->emetteur->country_code)) {
158 $this->emetteur->country_code = substr($langs->defaultlang, -2);
162 $this->posxdesc = $this->marge_gauche + 1;
164 $this->tabTitleHeight = 5;
166 $this->tva = array();
167 $this->tva_array = array();
168 $this->localtax1 = array();
169 $this->localtax2 = array();
170 $this->atleastoneratenotnull = 0;
171 $this->atleastonediscount = 0;
187 public function write_file($object, $outputlangs =
'', $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
190 global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
192 if (!is_object($outputlangs)) {
193 $outputlangs = $langs;
196 if (!empty($conf->global->MAIN_USE_FPDF)) {
197 $outputlangs->charset_output =
'ISO-8859-1';
201 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
203 global $outputlangsbis;
204 $outputlangsbis =
null;
205 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
206 $outputlangsbis =
new Translate(
'', $conf);
207 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
208 $outputlangsbis->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
211 $nblines = count($object->lines);
214 if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
215 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
219 $realpatharray = array();
220 if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) {
221 for ($i = 0; $i < $nblines; $i++) {
222 if (empty($object->lines[$i]->fk_product)) {
226 $objphoto =
new Product($this->db);
227 $objphoto->fetch($object->lines[$i]->fk_product);
230 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
231 $dir = $conf->product->dir_output.
'/'.$pdir;
233 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
234 $dir = $conf->product->dir_output.
'/'.$pdir;
238 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
240 if ($obj[
'photo_vignette']) {
241 $filename = $obj[
'photo_vignette'];
243 $filename = $obj[
'photo'];
246 $filename = $obj[
'photo'];
248 $realpath = $dir.$filename;
253 $realpatharray[$i] = $realpath;
257 if (count($realpatharray) == 0) {
258 $this->posxpicture = $this->posxtva;
261 if ($conf->fournisseur->commande->dir_output) {
262 $object->fetch_thirdparty();
265 $amount_credit_notes_included = 0;
266 $amount_deposits_included = 0;
271 if ($object->specimen) {
272 $dir = $conf->fournisseur->commande->dir_output;
273 $file = $dir.
"/SPECIMEN.pdf";
277 $dir = $conf->fournisseur->commande->dir_output.
'/'.$objectref;
278 $file = $dir.
"/".$objectref.
".pdf";
279 if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) {
280 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
284 if (!file_exists($dir)) {
286 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
291 if (file_exists($dir)) {
293 if (!is_object($hookmanager)) {
294 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
297 $hookmanager->initHooks(array(
'pdfgeneration'));
298 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
300 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
302 $nblines = count($object->lines);
306 $heightforinfotot = 50;
307 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
308 $heightforfooter = $this->marge_basse + 8;
309 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
310 $heightforfooter += 6;
312 $pdf->SetAutoPageBreak(1, 0);
314 if (class_exists(
'TCPDF')) {
315 $pdf->setPrintHeader(
false);
316 $pdf->setPrintFooter(
false);
320 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
321 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
322 $tplidx = $pdf->importPage(1);
327 $pdf->SetDrawColor(128, 128, 128);
329 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
330 $pdf->SetSubject($outputlangs->transnoentities(
"Order"));
331 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
332 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
333 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Order").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
335 $pdf->SetCompression(
false);
338 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
341 foreach ($object->lines as $line) {
342 if ($line->remise_percent) {
343 $this->atleastonediscount =
true;
350 if (!empty($tplidx)) {
351 $pdf->useTemplate($tplidx);
354 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
355 $pdf->SetFont(
'',
'', $default_font_size - 1);
356 $pdf->MultiCell(0, 3,
'');
357 $pdf->SetTextColor(0, 0, 0);
359 $tab_top = 90 + $top_shift;
360 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
362 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
366 $desc_incoterms = $object->getIncotermsForPDF();
367 if ($desc_incoterms) {
370 $pdf->SetFont(
'',
'', $default_font_size - 1);
371 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
372 $nexY = $pdf->GetY();
373 $height_incoterms = $nexY - $tab_top;
376 $pdf->SetDrawColor(192, 192, 192);
377 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
379 $tab_top = $nexY + 6;
384 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
387 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
388 if (!empty($extranote)) {
392 $pagenb = $pdf->getPage();
394 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
395 $pageposbeforenote = $pagenb;
404 $pdf->startTransaction();
406 $pdf->SetFont(
'',
'', $default_font_size - 1);
407 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
409 $pageposafternote = $pdf->getPage();
410 $posyafter = $pdf->GetY();
412 if ($pageposafternote > $pageposbeforenote) {
413 $pdf->rollbackTransaction(
true);
416 while ($pagenb < $pageposafternote) {
419 if (!empty($tplidx)) {
420 $pdf->useTemplate($tplidx);
423 $this->
_pagehead($pdf, $object, 0, $outputlangs);
426 $pdf->setTopMargin($tab_top_newpage);
428 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
432 $pdf->setPage($pageposbeforenote);
433 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
434 $pdf->SetFont(
'',
'', $default_font_size - 1);
435 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
436 $pageposafternote = $pdf->getPage();
438 $posyafter = $pdf->GetY();
440 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
441 $pdf->AddPage(
'',
'',
true);
444 $pdf->setPage($pageposafternote);
445 $pdf->setTopMargin($tab_top_newpage);
447 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
453 $i = $pageposbeforenote;
454 while ($i < $pageposafternote) {
458 $pdf->SetDrawColor(128, 128, 128);
460 if ($i > $pageposbeforenote) {
461 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
462 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
464 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
465 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
469 $pdf->setPageOrientation(
'', 1, 0);
470 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
476 $pdf->setPage($pageposafternote);
477 if (!empty($tplidx)) {
478 $pdf->useTemplate($tplidx);
481 $this->
_pagehead($pdf, $object, 0, $outputlangs);
483 $height_note = $posyafter - $tab_top_newpage;
484 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
487 $pdf->commitTransaction();
488 $posyafter = $pdf->GetY();
489 $height_note = $posyafter - $tab_top;
490 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
493 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
495 $pdf->AddPage(
'',
'',
true);
498 $pdf->setPage($pageposafternote);
499 if (!empty($tplidx)) {
500 $pdf->useTemplate($tplidx);
503 $this->
_pagehead($pdf, $object, 0, $outputlangs);
506 $posyafter = $tab_top_newpage;
510 $tab_height = $tab_height - $height_note;
511 $tab_top = $posyafter + 6;
519 $nexY = $tab_top + $this->tabTitleHeight;
522 $pageposbeforeprintlines = $pdf->getPage();
523 $pagenb = $pageposbeforeprintlines;
524 for ($i = 0; $i < $nblines; $i++) {
526 $pdf->SetFont(
'',
'', $default_font_size - 1);
527 $pdf->SetTextColor(0, 0, 0);
530 $imglinesize = array();
531 if (!empty($realpatharray[$i])) {
535 $pdf->setTopMargin($tab_top_newpage);
536 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
537 $pageposbefore = $pdf->getPage();
539 $showpricebeforepagebreak = 1;
541 $posYAfterDescription = 0;
546 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
547 $pdf->AddPage(
'',
'',
true);
548 if (!empty($tplidx)) {
549 $pdf->useTemplate($tplidx);
551 $pdf->setPage($pageposbefore + 1);
553 $curY = $tab_top_newpage;
556 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
557 $showpricebeforepagebreak = 1;
559 $showpricebeforepagebreak = 0;
563 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
564 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
566 $posYAfterImage = $curY + $imglinesize[
'height'];
570 $curX = $this->posxdesc - 1;
571 $showpricebeforepagebreak = 1;
574 $pdf->startTransaction();
575 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
577 $pageposafter = $pdf->getPage();
578 if ($pageposafter > $pageposbefore) {
579 $pdf->rollbackTransaction(
true);
581 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
583 $pageposafter = $pdf->getPage();
584 $posyafter = $pdf->GetY();
585 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
586 if ($i == ($nblines - 1)) {
587 $pdf->AddPage(
'',
'',
true);
588 if (!empty($tplidx)) {
589 $pdf->useTemplate($tplidx);
592 $pdf->setPage($pageposafter + 1);
597 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
598 $showpricebeforepagebreak = 1;
600 $showpricebeforepagebreak = 0;
605 $pdf->commitTransaction();
607 $posYAfterDescription = $pdf->GetY();
610 $nexY = $pdf->GetY();
611 $pageposafter = $pdf->getPage();
612 $pdf->setPage($pageposbefore);
613 $pdf->setTopMargin($this->marge_haute);
614 $pdf->setPageOrientation(
'', 1, 0);
617 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
618 $pdf->setPage($pageposafter);
619 $curY = $tab_top_newpage;
622 $pdf->SetFont(
'',
'', $default_font_size - 1);
628 $nexY = max($pdf->GetY(), $nexY);
635 $nexY = max($pdf->GetY(), $nexY);
643 $nexY = max($pdf->GetY(), $nexY);
649 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
651 $nexY = max($pdf->GetY(), $nexY);
655 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
658 $nexY = max($pdf->GetY(), $nexY);
665 $nexY = max($pdf->GetY(), $nexY);
669 if (!empty($object->lines[$i]->array_options)) {
670 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
672 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
674 $nexY = max($pdf->GetY(), $nexY);
685 'outputlangs' => $outputlangs,
686 'hidedetails' => $hidedetails
688 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
692 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
693 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
695 $tvaligne = $object->lines[$i]->total_tva;
698 $localtax1ligne = $object->lines[$i]->total_localtax1;
699 $localtax2ligne = $object->lines[$i]->total_localtax2;
700 $localtax1_rate = $object->lines[$i]->localtax1_tx;
701 $localtax2_rate = $object->lines[$i]->localtax2_tx;
702 $localtax1_type = $object->lines[$i]->localtax1_type;
703 $localtax2_type = $object->lines[$i]->localtax2_type;
716 $vatrate = (string) $object->lines[$i]->tva_tx;
719 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
720 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
722 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
723 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
727 if ($localtax1_type && $localtax1ligne != 0) {
728 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
729 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
731 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
734 if ($localtax2_type && $localtax2ligne != 0) {
735 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
736 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
738 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
742 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
747 if (!isset($this->tva[$vatrate])) {
748 $this->tva[$vatrate] = 0;
750 $this->tva[$vatrate] += $tvaligne;
751 $vatcode = $object->lines[$i]->vat_src_code;
752 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
753 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
755 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
757 if ($posYAfterImage > $posYAfterDescription) {
758 $nexY = $posYAfterImage;
762 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
763 $pdf->setPage($pageposafter);
764 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
766 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
767 $pdf->SetLineStyle(array(
'dash'=>0));
771 while ($pagenb < $pageposafter) {
772 $pdf->setPage($pagenb);
773 if ($pagenb == $pageposbeforeprintlines) {
774 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
776 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
778 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
780 $pdf->setPage($pagenb);
781 $pdf->setPageOrientation(
'', 1, 0);
783 $this->
_pagehead($pdf, $object, 0, $outputlangs);
785 if (!empty($tplidx)) {
786 $pdf->useTemplate($tplidx);
789 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
790 if ($pagenb == $pageposafter) {
791 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
793 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
795 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
798 if (!empty($tplidx)) {
799 $pdf->useTemplate($tplidx);
803 $this->
_pagehead($pdf, $object, 0, $outputlangs);
809 if ($pagenb == $pageposbeforeprintlines) {
810 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
811 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
813 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
814 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
818 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
821 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
824 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
829 $this->
_pagefoot($pdf, $object, $outputlangs);
830 if (method_exists($pdf,
'AliasNbPages')) {
831 $pdf->AliasNbPages();
836 $pdf->Output($file,
'F');
839 $hookmanager->initHooks(array(
'pdfgeneration'));
840 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
842 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
844 $this->error = $hookmanager->error;
845 $this->errors = $hookmanager->errors;
850 $this->result = array(
'fullpath'=>$file);
854 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
858 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
894 global $conf, $mysoc;
897 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
900 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
901 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
902 $pdf->SetXY($this->marge_gauche, $posy);
903 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
905 $posy = $pdf->GetY() + 4;
911 if (!empty($object->cond_reglement_code) || $object->cond_reglement) {
912 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
913 $pdf->SetXY($this->marge_gauche, $posy);
914 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
915 $pdf->MultiCell(80, 4, $titre, 0,
'L');
917 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
918 $pdf->SetXY($posxval, $posy);
919 $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);
920 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
921 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
923 $posy = $pdf->GetY() + 3;
927 if (!empty($object->mode_reglement_code)) {
928 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
929 $pdf->SetXY($this->marge_gauche, $posy);
930 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
931 $pdf->MultiCell(80, 5, $titre, 0,
'L');
933 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
934 $pdf->SetXY($posxval, $posy);
935 $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);
936 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
938 $posy = $pdf->GetY() + 2;
957 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
960 global $conf, $mysoc;
966 $pdf->SetFont(
'',
'', $default_font_size - 1);
971 if ($this->page_largeur < 210) {
974 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
980 $pdf->SetFillColor(255, 255, 255);
981 $pdf->SetXY($col1x, $tab2_top);
982 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
984 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
985 $pdf->SetXY($col2x, $tab2_top);
986 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0,
'R', 1);
989 $pdf->SetFillColor(248, 248, 248);
991 $this->atleastoneratenotnull = 0;
992 foreach ($this->tva as $tvakey => $tvaval) {
994 $this->atleastoneratenotnull++;
997 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1001 if (preg_match(
'/\*/', $tvakey)) {
1002 $tvakey = str_replace(
'*',
'', $tvakey);
1003 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1006 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
1007 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1008 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1010 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1011 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1014 if (!$this->atleastoneratenotnull) {
1016 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1017 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
1019 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1020 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_tva), 0,
'R', 1);
1023 if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION ==
'localtax1on' && $object->total_localtax1 > 0) {
1025 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1026 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
1027 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1028 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax1), $useborder,
'R', 1);
1032 if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION ==
'localtax2on' && $object->total_localtax2 > 0) {
1034 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1035 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
1036 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1037 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax2), $useborder,
'R', 1);
1043 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1044 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1048 foreach ($localtax_rate as $tvakey => $tvaval) {
1053 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1056 if (preg_match(
'/\*/', $tvakey)) {
1057 $tvakey = str_replace(
'*',
'', $tvakey);
1058 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1060 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1061 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1062 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1064 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1065 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1073 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1074 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1078 foreach ($localtax_rate as $tvakey => $tvaval) {
1083 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1086 if (preg_match(
'/\*/', $tvakey)) {
1087 $tvakey = str_replace(
'*',
'', $tvakey);
1088 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1090 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1091 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1092 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1094 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1095 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1103 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1104 $pdf->SetTextColor(0, 0, 60);
1105 $pdf->SetFillColor(224, 224, 224);
1106 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1108 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1109 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1110 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
1111 $pdf->SetFont(
'',
'', $default_font_size - 1);
1112 $pdf->SetTextColor(0, 0, 0);
1114 $creditnoteamount = 0;
1115 $depositsamount = 0;
1119 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1120 if (!empty($object->paye)) {
1124 if ($deja_regle > 0) {
1128 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1129 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1130 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1131 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
1134 $pdf->SetTextColor(0, 0, 60);
1135 $pdf->SetFillColor(224, 224, 224);
1136 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1137 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1139 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1140 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
1142 $pdf->SetFont(
'',
'', $default_font_size - 1);
1143 $pdf->SetTextColor(0, 0, 0);
1147 return ($tab2_top + ($tab2_hl * $index));
1164 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1174 $currency = !empty($currency) ? $currency : $conf->currency;
1178 $pdf->SetTextColor(0, 0, 0);
1179 $pdf->SetFont(
'',
'', $default_font_size - 2);
1181 if (empty($hidetop)) {
1182 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1183 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1184 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1187 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1188 $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));
1192 $pdf->SetDrawColor(128, 128, 128);
1193 $pdf->SetFont(
'',
'', $default_font_size - 1);
1196 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1198 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1200 if (empty($hidetop)) {
1201 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight);
1215 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1217 global $langs, $conf, $mysoc;
1219 $ltrdirection =
'L';
1220 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
1223 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1237 $pdf->SetTextColor(0, 0, 60);
1238 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1240 $posx = $this->page_largeur - $this->marge_droite - 100;
1241 $posy = $this->marge_haute;
1243 $pdf->SetXY($this->marge_gauche, $posy);
1247 if ($this->emetteur->logo) {
1248 $logodir = $conf->mycompany->dir_output;
1249 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1250 $logodir = $conf->mycompany->multidir_output[$object->entity];
1253 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1255 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1257 if (is_readable($logo)) {
1259 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1261 $pdf->SetTextColor(200, 0, 0);
1262 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1263 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1264 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1267 $text = $this->emetteur->name;
1268 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1272 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1273 $pdf->SetXY($posx, $posy);
1274 $pdf->SetTextColor(0, 0, 60);
1275 $title = $outputlangs->transnoentities(
"SupplierOrder").
" ".$outputlangs->convToOutputCharset($object->ref);
1276 $pdf->MultiCell(100, 3, $title,
'',
'R');
1279 if ($object->ref_supplier) {
1281 $pdf->SetFont(
'',
'B', $default_font_size);
1282 $pdf->SetXY($posx, $posy);
1283 $pdf->SetTextColor(0, 0, 60);
1284 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset($object->ref_supplier),
'',
'R');
1288 $pdf->SetFont(
'',
'', $default_font_size - 1);
1290 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1291 $object->fetch_projet();
1292 if (!empty($object->project->ref)) {
1294 $pdf->SetXY($posx, $posy);
1295 $pdf->SetTextColor(0, 0, 60);
1296 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1300 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1301 $object->fetch_projet();
1302 if (!empty($object->project->ref)) {
1303 $outputlangs->load(
"projects");
1305 $pdf->SetXY($posx, $posy);
1306 $langs->load(
"projects");
1307 $pdf->SetTextColor(0, 0, 60);
1308 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1312 if (!empty($object->date_commande)) {
1314 $pdf->SetXY($posx, $posy);
1315 $pdf->SetTextColor(0, 0, 60);
1316 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($object->date_commande,
"day",
false, $outputlangs,
true),
'',
'R');
1319 $pdf->SetXY($posx, $posy);
1320 $pdf->SetTextColor(255, 0, 0);
1321 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"OrderToProcess"),
'',
'R');
1324 $pdf->SetTextColor(0, 0, 60);
1325 $usehourmin =
'day';
1326 if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) {
1327 $usehourmin =
'dayhour';
1329 if (!empty($object->delivery_date)) {
1331 $pdf->SetXY($posx - 90, $posy);
1332 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1335 if ($object->thirdparty->code_fournisseur) {
1337 $pdf->SetXY($posx, $posy);
1338 $pdf->SetTextColor(0, 0, 60);
1339 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
1343 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1344 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1345 if (count($arrayidcontact) > 0) {
1346 $usertmp =
new User($this->db);
1347 $usertmp->fetch($arrayidcontact[0]);
1349 $pdf->SetXY($posx, $posy);
1350 $pdf->SetTextColor(0, 0, 60);
1351 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1356 $pdf->SetTextColor(0, 0, 60);
1360 $current_y = $pdf->getY();
1361 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1362 if ($current_y < $pdf->getY()) {
1363 $top_shift = $pdf->getY() - $current_y;
1368 $carac_emetteur =
'';
1370 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1371 if (count($arrayidcontact) > 0) {
1372 $object->fetch_user($arrayidcontact[0]);
1373 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1374 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1376 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1378 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1380 $carac_emetteur .=
"\n";
1383 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1386 $posy = 42 + $top_shift;
1387 $posx = $this->marge_gauche;
1388 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1389 $posx = $this->page_largeur - $this->marge_droite - 80;
1394 $pdf->SetTextColor(0, 0, 0);
1395 $pdf->SetFont(
'',
'', $default_font_size - 2);
1396 $pdf->SetXY($posx, $posy - 5);
1397 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1398 $pdf->SetXY($posx, $posy);
1399 $pdf->SetFillColor(230, 230, 230);
1400 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1401 $pdf->SetTextColor(0, 0, 60);
1404 $pdf->SetXY($posx + 2, $posy + 3);
1405 $pdf->SetFont(
'',
'B', $default_font_size);
1406 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1407 $posy = $pdf->getY();
1410 $pdf->SetXY($posx + 2, $posy);
1411 $pdf->SetFont(
'',
'', $default_font_size - 1);
1412 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1417 $usecontact =
false;
1418 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1419 if (count($arrayidcontact) > 0) {
1421 $result = $object->fetch_contact($arrayidcontact[0]);
1425 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)))) {
1426 $thirdparty = $object->contact;
1428 $thirdparty = $object->thirdparty;
1433 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1437 if ($this->page_largeur < 210) {
1440 $posy = 42 + $top_shift;
1441 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1442 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1443 $posx = $this->marge_gauche;
1447 $pdf->SetTextColor(0, 0, 0);
1448 $pdf->SetFont(
'',
'', $default_font_size - 2);
1449 $pdf->SetXY($posx + 2, $posy - 5);
1450 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1451 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1454 $pdf->SetXY($posx + 2, $posy + 3);
1455 $pdf->SetFont(
'',
'B', $default_font_size);
1456 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1458 $posy = $pdf->getY();
1461 $pdf->SetFont(
'',
'', $default_font_size - 1);
1462 $pdf->SetXY($posx + 2, $posy);
1463 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1479 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1481 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1482 return pdf_pagefoot($pdf, $outputlangs,
'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1497 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1499 global $conf, $hookmanager;
1502 $this->defaultContentsFieldsStyle = array(
1504 'padding' => array(1, 0.5, 1, 0.5),
1508 $this->defaultTitlesFieldsStyle = array(
1510 'padding' => array(0.5, 0, 0.5, 0),
1532 $this->cols[
'desc'] = array(
1537 'textkey' =>
'Designation',
1541 'padding' => array(0.5, 0.5, 0.5, 0.5),
1545 'padding' => array(1, 0.5, 1, 1.5),
1550 $this->cols[
'photo'] = array(
1552 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
1555 'textkey' =>
'Photo',
1559 'padding' => array(0, 0, 0, 0),
1561 'border-left' =>
false,
1564 if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) {
1565 $this->cols[
'photo'][
'status'] =
true;
1570 $this->cols[
'vat'] = array(
1577 'border-left' =>
true,
1580 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1581 $this->cols[
'vat'][
'status'] =
true;
1585 $this->cols[
'subprice'] = array(
1590 'textkey' =>
'PriceUHT'
1592 'border-left' =>
true,
1595 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE)) {
1596 $this->cols[
'subprice'][
'status'] =
true;
1600 $this->cols[
'qty'] = array(
1607 'border-left' =>
true,
1611 $this->cols[
'unit'] = array(
1618 'border-left' =>
true,
1621 $this->cols[
'unit'][
'status'] =
true;
1625 $this->cols[
'discount'] = array(
1630 'textkey' =>
'ReductionShort'
1632 'border-left' =>
true,
1634 if ($this->atleastonediscount) {
1635 $this->cols[
'discount'][
'status'] =
true;
1638 $rank = $rank + 1000;
1639 $this->cols[
'totalexcltax'] = array(
1644 'textkey' =>
'TotalHT'
1646 'border-left' =>
true,
1649 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN)) {
1650 $this->cols[
'totalexcltax'][
'status'] =
true;
1654 if (!empty($object->lines)) {
1655 $line = reset($object->lines);
1659 $parameters = array(
1660 'object' => $object,
1661 'outputlangs' => $outputlangs,
1662 'hidedetails' => $hidedetails,
1663 'hidedesc' => $hidedesc,
1664 'hideref' => $hideref
1667 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
1670 } elseif (empty($reshook)) {
1671 $this->cols = array_replace($this->cols, $hookmanager->resArray);
1673 $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
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
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.