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 $phpmin = array(7, 0);
79 public $version =
'dolibarr';
104 public $marge_droite;
130 global $conf, $langs, $mysoc;
133 $langs->loadLangs(array(
"main",
"bills"));
136 $this->
name =
"cornas";
137 $this->
description = $langs->trans(
'SuppliersCommandModel');
138 $this->update_main_doc_field = 1;
143 $this->page_largeur = $formatarray[
'width'];
144 $this->page_hauteur = $formatarray[
'height'];
145 $this->format = array($this->page_largeur, $this->page_hauteur);
151 $this->option_logo = 1;
152 $this->option_tva = 1;
153 $this->option_modereg = 1;
154 $this->option_condreg = 1;
155 $this->option_multilang = 1;
156 $this->option_escompte = 0;
157 $this->option_credit_note = 0;
158 $this->option_freetext = 1;
159 $this->option_draft_watermark = 1;
162 $this->emetteur = $mysoc;
163 if (empty($this->emetteur->country_code)) {
164 $this->emetteur->country_code = substr($langs->defaultlang, -2);
168 $this->posxdesc = $this->marge_gauche + 1;
170 $this->tva = array();
171 $this->tva_array = array();
172 $this->localtax1 = array();
173 $this->localtax2 = array();
174 $this->atleastoneratenotnull = 0;
175 $this->atleastonediscount = 0;
191 public function write_file($object, $outputlangs =
'', $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
194 global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
196 if (!is_object($outputlangs)) {
197 $outputlangs = $langs;
200 if (!empty($conf->global->MAIN_USE_FPDF)) {
201 $outputlangs->charset_output =
'ISO-8859-1';
205 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
207 global $outputlangsbis;
208 $outputlangsbis =
null;
209 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
210 $outputlangsbis =
new Translate(
'', $conf);
211 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
212 $outputlangsbis->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
215 $nblines = count($object->lines);
218 if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
219 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
223 $realpatharray = array();
224 if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) {
225 for ($i = 0; $i < $nblines; $i++) {
226 if (empty($object->lines[$i]->fk_product)) {
231 $objphoto->fetch($object->lines[$i]->fk_product);
234 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
235 $dir = $conf->product->dir_output.
'/'.$pdir;
237 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
238 $dir = $conf->product->dir_output.
'/'.$pdir;
242 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
244 if ($obj[
'photo_vignette']) {
245 $filename = $obj[
'photo_vignette'];
247 $filename = $obj[
'photo'];
250 $filename = $obj[
'photo'];
252 $realpath = $dir.$filename;
257 $realpatharray[$i] = $realpath;
261 if (count($realpatharray) == 0) {
262 $this->posxpicture = $this->posxtva;
265 if ($conf->fournisseur->commande->dir_output) {
266 $object->fetch_thirdparty();
269 $amount_credit_notes_included = 0;
270 $amount_deposits_included = 0;
275 if ($object->specimen) {
276 $dir = $conf->fournisseur->commande->dir_output;
277 $file = $dir.
"/SPECIMEN.pdf";
281 $dir = $conf->fournisseur->commande->dir_output.
'/'.$objectref;
282 $file = $dir.
"/".$objectref.
".pdf";
283 if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) {
284 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
288 if (!file_exists($dir)) {
290 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
295 if (file_exists($dir)) {
297 if (!is_object($hookmanager)) {
298 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
301 $hookmanager->initHooks(array(
'pdfgeneration'));
302 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
304 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
306 $nblines = count($object->lines);
310 $heightforinfotot = 50;
311 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
312 $heightforfooter = $this->marge_basse + 8;
313 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
314 $heightforfooter += 6;
316 $pdf->SetAutoPageBreak(1, 0);
318 if (class_exists(
'TCPDF')) {
319 $pdf->setPrintHeader(
false);
320 $pdf->setPrintFooter(
false);
324 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
325 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
326 $tplidx = $pdf->importPage(1);
331 $pdf->SetDrawColor(128, 128, 128);
333 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
334 $pdf->SetSubject($outputlangs->transnoentities(
"Order"));
335 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
336 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
337 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Order").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
339 $pdf->SetCompression(
false);
342 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
345 foreach ($object->lines as $line) {
346 if ($line->remise_percent) {
347 $this->atleastonediscount =
true;
354 if (!empty($tplidx)) {
355 $pdf->useTemplate($tplidx);
358 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
359 $pdf->SetFont(
'',
'', $default_font_size - 1);
360 $pdf->MultiCell(0, 3,
'');
361 $pdf->SetTextColor(0, 0, 0);
363 $tab_top = 90 + $top_shift;
364 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
366 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
370 $desc_incoterms = $object->getIncotermsForPDF();
371 if ($desc_incoterms) {
374 $pdf->SetFont(
'',
'', $default_font_size - 1);
375 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
376 $nexY = $pdf->GetY();
377 $height_incoterms = $nexY - $tab_top;
380 $pdf->SetDrawColor(192, 192, 192);
381 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
383 $tab_top = $nexY + 6;
388 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
391 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
392 if (!empty($extranote)) {
396 $pagenb = $pdf->getPage();
398 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
399 $pageposbeforenote = $pagenb;
408 $pdf->startTransaction();
410 $pdf->SetFont(
'',
'', $default_font_size - 1);
411 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
413 $pageposafternote = $pdf->getPage();
414 $posyafter = $pdf->GetY();
416 if ($pageposafternote > $pageposbeforenote) {
417 $pdf->rollbackTransaction(
true);
420 while ($pagenb < $pageposafternote) {
423 if (!empty($tplidx)) {
424 $pdf->useTemplate($tplidx);
427 $this->
_pagehead($pdf, $object, 0, $outputlangs);
430 $pdf->setTopMargin($tab_top_newpage);
432 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
436 $pdf->setPage($pageposbeforenote);
437 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
438 $pdf->SetFont(
'',
'', $default_font_size - 1);
439 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
440 $pageposafternote = $pdf->getPage();
442 $posyafter = $pdf->GetY();
444 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
445 $pdf->AddPage(
'',
'',
true);
448 $pdf->setPage($pageposafternote);
449 $pdf->setTopMargin($tab_top_newpage);
451 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
457 $i = $pageposbeforenote;
458 while ($i < $pageposafternote) {
462 $pdf->SetDrawColor(128, 128, 128);
464 if ($i > $pageposbeforenote) {
465 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
466 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
468 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
469 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
473 $pdf->setPageOrientation(
'', 1, 0);
474 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
480 $pdf->setPage($pageposafternote);
481 if (!empty($tplidx)) {
482 $pdf->useTemplate($tplidx);
485 $this->
_pagehead($pdf, $object, 0, $outputlangs);
487 $height_note = $posyafter - $tab_top_newpage;
488 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
491 $pdf->commitTransaction();
492 $posyafter = $pdf->GetY();
493 $height_note = $posyafter - $tab_top;
494 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
497 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
499 $pdf->AddPage(
'',
'',
true);
502 $pdf->setPage($pageposafternote);
503 if (!empty($tplidx)) {
504 $pdf->useTemplate($tplidx);
507 $this->
_pagehead($pdf, $object, 0, $outputlangs);
510 $posyafter = $tab_top_newpage;
514 $tab_height = $tab_height - $height_note;
515 $tab_top = $posyafter + 6;
520 $nexY = $tab_top + 5;
526 $pageposbeforeprintlines = $pdf->getPage();
527 $pagenb = $pageposbeforeprintlines;
528 for ($i = 0; $i < $nblines; $i++) {
530 $pdf->SetFont(
'',
'', $default_font_size - 1);
531 $pdf->SetTextColor(0, 0, 0);
534 $imglinesize = array();
535 if (!empty($realpatharray[$i])) {
539 $pdf->setTopMargin($tab_top_newpage);
540 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
541 $pageposbefore = $pdf->getPage();
543 $showpricebeforepagebreak = 1;
545 $posYAfterDescription = 0;
550 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
551 $pdf->AddPage(
'',
'',
true);
552 if (!empty($tplidx)) {
553 $pdf->useTemplate($tplidx);
555 $pdf->setPage($pageposbefore + 1);
557 $curY = $tab_top_newpage;
560 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
561 $showpricebeforepagebreak = 1;
563 $showpricebeforepagebreak = 0;
567 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
568 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
570 $posYAfterImage = $curY + $imglinesize[
'height'];
574 $curX = $this->posxdesc - 1;
575 $showpricebeforepagebreak = 1;
578 $pdf->startTransaction();
579 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
581 $pageposafter = $pdf->getPage();
582 if ($pageposafter > $pageposbefore) {
583 $pdf->rollbackTransaction(
true);
585 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
587 $pageposafter = $pdf->getPage();
588 $posyafter = $pdf->GetY();
589 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
590 if ($i == ($nblines - 1)) {
591 $pdf->AddPage(
'',
'',
true);
592 if (!empty($tplidx)) {
593 $pdf->useTemplate($tplidx);
596 $pdf->setPage($pageposafter + 1);
601 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
602 $showpricebeforepagebreak = 1;
604 $showpricebeforepagebreak = 0;
609 $pdf->commitTransaction();
611 $posYAfterDescription = $pdf->GetY();
614 $nexY = $pdf->GetY();
615 $pageposafter = $pdf->getPage();
616 $pdf->setPage($pageposbefore);
617 $pdf->setTopMargin($this->marge_haute);
618 $pdf->setPageOrientation(
'', 1, 0);
621 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
622 $pdf->setPage($pageposafter);
623 $curY = $tab_top_newpage;
626 $pdf->SetFont(
'',
'', $default_font_size - 1);
632 $nexY = max($pdf->GetY(), $nexY);
639 $nexY = max($pdf->GetY(), $nexY);
647 $nexY = max($pdf->GetY(), $nexY);
653 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
655 $nexY = max($pdf->GetY(), $nexY);
659 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
662 $nexY = max($pdf->GetY(), $nexY);
669 $nexY = max($pdf->GetY(), $nexY);
673 if (!empty($object->lines[$i]->array_options)) {
674 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
676 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
678 $nexY = max($pdf->GetY(), $nexY);
689 'outputlangs' => $outputlangs,
690 'hidedetails' => $hidedetails
692 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
696 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
697 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
699 $tvaligne = $object->lines[$i]->total_tva;
702 $localtax1ligne = $object->lines[$i]->total_localtax1;
703 $localtax2ligne = $object->lines[$i]->total_localtax2;
704 $localtax1_rate = $object->lines[$i]->localtax1_tx;
705 $localtax2_rate = $object->lines[$i]->localtax2_tx;
706 $localtax1_type = $object->lines[$i]->localtax1_type;
707 $localtax2_type = $object->lines[$i]->localtax2_type;
709 if (!empty($object->remise_percent)) {
710 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
712 if (!empty($object->remise_percent)) {
713 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
715 if (!empty($object->remise_percent)) {
716 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
719 $vatrate = (string) $object->lines[$i]->tva_tx;
722 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
723 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
725 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
726 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
730 if ($localtax1_type && $localtax1ligne != 0) {
731 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
733 if ($localtax2_type && $localtax2ligne != 0) {
734 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
737 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
742 if (!isset($this->tva[$vatrate])) {
743 $this->tva[$vatrate] = 0;
745 $this->tva[$vatrate] += $tvaligne;
746 $vatcode = $object->lines[$i]->vat_src_code;
747 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
748 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
750 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
752 if ($posYAfterImage > $posYAfterDescription) {
753 $nexY = $posYAfterImage;
757 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
758 $pdf->setPage($pageposafter);
759 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
761 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
762 $pdf->SetLineStyle(array(
'dash'=>0));
766 while ($pagenb < $pageposafter) {
767 $pdf->setPage($pagenb);
768 if ($pagenb == $pageposbeforeprintlines) {
769 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
771 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
773 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
775 $pdf->setPage($pagenb);
776 $pdf->setPageOrientation(
'', 1, 0);
778 $this->
_pagehead($pdf, $object, 0, $outputlangs);
780 if (!empty($tplidx)) {
781 $pdf->useTemplate($tplidx);
784 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
785 if ($pagenb == $pageposafter) {
786 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
788 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
790 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
793 if (!empty($tplidx)) {
794 $pdf->useTemplate($tplidx);
798 $this->
_pagehead($pdf, $object, 0, $outputlangs);
804 if ($pagenb == $pageposbeforeprintlines) {
805 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
806 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
808 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
809 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
813 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
816 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
819 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
824 $this->
_pagefoot($pdf, $object, $outputlangs);
825 if (method_exists($pdf,
'AliasNbPages')) {
826 $pdf->AliasNbPages();
831 $pdf->Output($file,
'F');
834 $hookmanager->initHooks(array(
'pdfgeneration'));
835 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
837 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
839 $this->error = $hookmanager->error;
840 $this->errors = $hookmanager->errors;
843 if (!empty($conf->global->MAIN_UMASK)) {
844 @chmod($file, octdec($conf->global->MAIN_UMASK));
847 $this->result = array(
'fullpath'=>$file);
851 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
855 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
890 global $conf, $mysoc;
893 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
896 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
897 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
898 $pdf->SetXY($this->marge_gauche, $posy);
899 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
901 $posy = $pdf->GetY() + 4;
907 if (!empty($object->cond_reglement_code) || $object->cond_reglement) {
908 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
909 $pdf->SetXY($this->marge_gauche, $posy);
910 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
911 $pdf->MultiCell(80, 4, $titre, 0,
'L');
913 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
914 $pdf->SetXY($posxval, $posy);
915 $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);
916 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
917 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
919 $posy = $pdf->GetY() + 3;
923 if (!empty($object->mode_reglement_code)) {
924 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
925 $pdf->SetXY($this->marge_gauche, $posy);
926 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
927 $pdf->MultiCell(80, 5, $titre, 0,
'L');
929 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
930 $pdf->SetXY($posxval, $posy);
931 $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);
932 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
934 $posy = $pdf->GetY() + 2;
953 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
956 global $conf, $mysoc;
962 $pdf->SetFont(
'',
'', $default_font_size - 1);
967 if ($this->page_largeur < 210) {
970 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
976 $pdf->SetFillColor(255, 255, 255);
977 $pdf->SetXY($col1x, $tab2_top + 0);
978 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
980 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
981 $pdf->SetXY($col2x, $tab2_top + 0);
982 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0,
'R', 1);
985 $pdf->SetFillColor(248, 248, 248);
987 $this->atleastoneratenotnull = 0;
988 foreach ($this->tva as $tvakey => $tvaval) {
990 $this->atleastoneratenotnull++;
993 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
997 if (preg_match(
'/\*/', $tvakey)) {
998 $tvakey = str_replace(
'*',
'', $tvakey);
999 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1002 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
1003 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1004 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1006 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1007 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1010 if (!$this->atleastoneratenotnull) {
1012 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1013 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
1015 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1016 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_tva), 0,
'R', 1);
1019 if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION ==
'localtax1on' && $object->total_localtax1 > 0) {
1021 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1022 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
1023 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1024 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax1), $useborder,
'R', 1);
1028 if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION ==
'localtax2on' && $object->total_localtax2 > 0) {
1030 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1031 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
1032 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1033 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax2), $useborder,
'R', 1);
1039 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1040 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1044 foreach ($localtax_rate as $tvakey => $tvaval) {
1049 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1052 if (preg_match(
'/\*/', $tvakey)) {
1053 $tvakey = str_replace(
'*',
'', $tvakey);
1054 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1056 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1057 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1058 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1060 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1061 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1069 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1070 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1074 foreach ($localtax_rate as $tvakey => $tvaval) {
1079 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1082 if (preg_match(
'/\*/', $tvakey)) {
1083 $tvakey = str_replace(
'*',
'', $tvakey);
1084 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1086 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1087 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1088 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1090 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1091 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1099 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1100 $pdf->SetTextColor(0, 0, 60);
1101 $pdf->SetFillColor(224, 224, 224);
1102 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1104 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1105 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1106 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
1107 $pdf->SetFont(
'',
'', $default_font_size - 1);
1108 $pdf->SetTextColor(0, 0, 0);
1110 $creditnoteamount = 0;
1111 $depositsamount = 0;
1115 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1116 if (!empty($object->paye)) {
1120 if ($deja_regle > 0) {
1124 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1125 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1126 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1127 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
1130 $pdf->SetTextColor(0, 0, 60);
1131 $pdf->SetFillColor(224, 224, 224);
1132 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1133 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1135 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1136 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
1138 $pdf->SetFont(
'',
'', $default_font_size - 1);
1139 $pdf->SetTextColor(0, 0, 0);
1143 return ($tab2_top + ($tab2_hl * $index));
1160 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1170 $currency = !empty($currency) ? $currency : $conf->currency;
1174 $pdf->SetTextColor(0, 0, 0);
1175 $pdf->SetFont(
'',
'', $default_font_size - 2);
1177 if (empty($hidetop)) {
1178 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1179 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1180 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1183 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1184 $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));
1188 $pdf->SetDrawColor(128, 128, 128);
1189 $pdf->SetFont(
'',
'', $default_font_size - 1);
1192 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1194 foreach ($this->cols as $colKey => $colDef) {
1200 $colDef[
'title'][
'label'] = !empty($colDef[
'title'][
'label']) ? $colDef[
'title'][
'label'] : $outputlangs->transnoentities($colDef[
'title'][
'textkey']);
1203 if (!empty($colDef[
'border-left'])) {
1204 $pdf->line($colDef[
'xStartPos'], $tab_top, $colDef[
'xStartPos'], $tab_top + $tab_height);
1207 if (empty($hidetop)) {
1208 $pdf->SetXY($colDef[
'xStartPos'] + $colDef[
'title'][
'padding'][3], $tab_top + $colDef[
'title'][
'padding'][0]);
1210 $textWidth = $colDef[
'width'] - $colDef[
'title'][
'padding'][3] - $colDef[
'title'][
'padding'][1];
1211 $pdf->MultiCell($textWidth, 2, $colDef[
'title'][
'label'],
'', $colDef[
'title'][
'align']);
1215 if (empty($hidetop)) {
1216 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1230 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1232 global $langs, $conf, $mysoc;
1234 $ltrdirection =
'L';
1235 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
1238 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1252 $pdf->SetTextColor(0, 0, 60);
1253 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1255 $posx = $this->page_largeur - $this->marge_droite - 100;
1256 $posy = $this->marge_haute;
1258 $pdf->SetXY($this->marge_gauche, $posy);
1261 if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
1262 if ($this->emetteur->logo) {
1263 $logodir = $conf->mycompany->dir_output;
1264 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1265 $logodir = $conf->mycompany->multidir_output[$object->entity];
1267 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
1268 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1270 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1272 if (is_readable($logo)) {
1274 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1276 $pdf->SetTextColor(200, 0, 0);
1277 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1278 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1279 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1282 $text = $this->emetteur->name;
1283 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1287 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1288 $pdf->SetXY($posx, $posy);
1289 $pdf->SetTextColor(0, 0, 60);
1290 $title = $outputlangs->transnoentities(
"SupplierOrder").
" ".$outputlangs->convToOutputCharset($object->ref);
1291 $pdf->MultiCell(100, 3, $title,
'',
'R');
1294 if ($object->ref_supplier) {
1296 $pdf->SetFont(
'',
'B', $default_font_size);
1297 $pdf->SetXY($posx, $posy);
1298 $pdf->SetTextColor(0, 0, 60);
1299 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset($object->ref_supplier),
'',
'R');
1303 $pdf->SetFont(
'',
'', $default_font_size - 1);
1305 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1306 $object->fetch_projet();
1307 if (!empty($object->project->ref)) {
1309 $pdf->SetXY($posx, $posy);
1310 $pdf->SetTextColor(0, 0, 60);
1311 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1315 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1316 $object->fetch_projet();
1317 if (!empty($object->project->ref)) {
1318 $outputlangs->load(
"projects");
1320 $pdf->SetXY($posx, $posy);
1321 $langs->load(
"projects");
1322 $pdf->SetTextColor(0, 0, 60);
1323 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1327 if (!empty($object->date_commande)) {
1329 $pdf->SetXY($posx, $posy);
1330 $pdf->SetTextColor(0, 0, 60);
1331 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($object->date_commande,
"day",
false, $outputlangs,
true),
'',
'R');
1334 $pdf->SetXY($posx, $posy);
1335 $pdf->SetTextColor(255, 0, 0);
1336 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"OrderToProcess"),
'',
'R');
1339 $pdf->SetTextColor(0, 0, 60);
1340 $usehourmin =
'day';
1341 if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) {
1342 $usehourmin =
'dayhour';
1344 if (!empty($object->delivery_date)) {
1346 $pdf->SetXY($posx - 90, $posy);
1347 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1350 if ($object->thirdparty->code_fournisseur) {
1352 $pdf->SetXY($posx, $posy);
1353 $pdf->SetTextColor(0, 0, 60);
1354 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
1358 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1359 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1360 if (count($arrayidcontact) > 0) {
1361 $usertmp =
new User($this->
db);
1362 $usertmp->fetch($arrayidcontact[0]);
1364 $pdf->SetXY($posx, $posy);
1365 $pdf->SetTextColor(0, 0, 60);
1366 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1371 $pdf->SetTextColor(0, 0, 60);
1375 $current_y = $pdf->getY();
1376 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1377 if ($current_y < $pdf->getY()) {
1378 $top_shift = $pdf->getY() - $current_y;
1383 $carac_emetteur =
'';
1385 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1386 if (count($arrayidcontact) > 0) {
1387 $object->fetch_user($arrayidcontact[0]);
1388 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1391 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1394 $posy = 42 + $top_shift;
1395 $posx = $this->marge_gauche;
1396 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1397 $posx = $this->page_largeur - $this->marge_droite - 80;
1402 $pdf->SetTextColor(0, 0, 0);
1403 $pdf->SetFont(
'',
'', $default_font_size - 2);
1404 $pdf->SetXY($posx, $posy - 5);
1405 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1406 $pdf->SetXY($posx, $posy);
1407 $pdf->SetFillColor(230, 230, 230);
1408 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1409 $pdf->SetTextColor(0, 0, 60);
1412 $pdf->SetXY($posx + 2, $posy + 3);
1413 $pdf->SetFont(
'',
'B', $default_font_size);
1414 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1415 $posy = $pdf->getY();
1418 $pdf->SetXY($posx + 2, $posy);
1419 $pdf->SetFont(
'',
'', $default_font_size - 1);
1420 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1425 $usecontact =
false;
1426 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1427 if (count($arrayidcontact) > 0) {
1429 $result = $object->fetch_contact($arrayidcontact[0]);
1433 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)))) {
1434 $thirdparty = $object->contact;
1436 $thirdparty = $object->thirdparty;
1441 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1445 if ($this->page_largeur < 210) {
1448 $posy = 42 + $top_shift;
1449 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1450 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1451 $posx = $this->marge_gauche;
1455 $pdf->SetTextColor(0, 0, 0);
1456 $pdf->SetFont(
'',
'', $default_font_size - 2);
1457 $pdf->SetXY($posx + 2, $posy - 5);
1458 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1459 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1462 $pdf->SetXY($posx + 2, $posy + 3);
1463 $pdf->SetFont(
'',
'B', $default_font_size);
1464 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1466 $posy = $pdf->getY();
1469 $pdf->SetFont(
'',
'', $default_font_size - 1);
1470 $pdf->SetXY($posx + 2, $posy);
1471 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1487 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1489 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1490 return pdf_pagefoot($pdf, $outputlangs,
'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1505 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1507 global $conf, $hookmanager;
1510 $this->defaultContentsFieldsStyle = array(
1512 'padding' => array(1, 0.5, 1, 0.5),
1516 $this->defaultTitlesFieldsStyle = array(
1518 'padding' => array(0.5, 0, 0.5, 0),
1540 $this->cols[
'desc'] = array(
1545 'textkey' =>
'Designation',
1549 'padding' => array(0.5, 1, 0.5, 1.5),
1553 'padding' => array(1, 0.5, 1, 1.5),
1558 $this->cols[
'photo'] = array(
1560 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
1563 'textkey' =>
'Photo',
1567 'padding' => array(0, 0, 0, 0),
1569 'border-left' =>
false,
1572 if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) {
1573 $this->cols[
'photo'][
'status'] =
true;
1578 $this->cols[
'vat'] = array(
1585 'border-left' =>
true,
1588 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1589 $this->cols[
'vat'][
'status'] =
true;
1593 $this->cols[
'subprice'] = array(
1598 'textkey' =>
'PriceUHT'
1600 'border-left' =>
true,
1603 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE)) {
1604 $this->cols[
'subprice'][
'status'] =
true;
1608 $this->cols[
'qty'] = array(
1615 'border-left' =>
true,
1619 $this->cols[
'unit'] = array(
1626 'border-left' =>
true,
1628 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1629 $this->cols[
'unit'][
'status'] =
true;
1633 $this->cols[
'discount'] = array(
1638 'textkey' =>
'ReductionShort'
1640 'border-left' =>
true,
1642 if ($this->atleastonediscount) {
1643 $this->cols[
'discount'][
'status'] =
true;
1646 $rank = $rank + 1000;
1647 $this->cols[
'totalexcltax'] = array(
1652 'textkey' =>
'TotalHT'
1654 'border-left' =>
true,
1657 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN)) {
1658 $this->cols[
'totalexcltax'][
'status'] =
true;
1662 if (!empty($object->lines)) {
1663 $line = reset($object->lines);
1667 $parameters = array(
1668 'object' => $object,
1669 'outputlangs' => $outputlangs,
1670 'hidedetails' => $hidedetails,
1671 'hidedesc' => $hidedesc,
1672 'hideref' => $hideref
1675 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
1678 } elseif (empty($reshook)) {
1679 $this->cols = array_replace($this->cols, $hookmanager->resArray);
1681 $this->cols = $hookmanager->resArray;