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->tva = array();
165 $this->tva_array = array();
166 $this->localtax1 = array();
167 $this->localtax2 = array();
168 $this->atleastoneratenotnull = 0;
169 $this->atleastonediscount = 0;
185 public function write_file($object, $outputlangs =
'', $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
188 global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
190 if (!is_object($outputlangs)) {
191 $outputlangs = $langs;
194 if (!empty($conf->global->MAIN_USE_FPDF)) {
195 $outputlangs->charset_output =
'ISO-8859-1';
199 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
201 global $outputlangsbis;
202 $outputlangsbis =
null;
203 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
204 $outputlangsbis =
new Translate(
'', $conf);
205 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
206 $outputlangsbis->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"dict",
"products"));
209 $nblines = count($object->lines);
212 if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
213 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
217 $realpatharray = array();
218 if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) {
219 for ($i = 0; $i < $nblines; $i++) {
220 if (empty($object->lines[$i]->fk_product)) {
224 $objphoto =
new Product($this->db);
225 $objphoto->fetch($object->lines[$i]->fk_product);
228 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
229 $dir = $conf->product->dir_output.
'/'.$pdir;
231 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
232 $dir = $conf->product->dir_output.
'/'.$pdir;
236 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
238 if ($obj[
'photo_vignette']) {
239 $filename = $obj[
'photo_vignette'];
241 $filename = $obj[
'photo'];
244 $filename = $obj[
'photo'];
246 $realpath = $dir.$filename;
251 $realpatharray[$i] = $realpath;
255 if (count($realpatharray) == 0) {
256 $this->posxpicture = $this->posxtva;
259 if ($conf->fournisseur->commande->dir_output) {
260 $object->fetch_thirdparty();
263 $amount_credit_notes_included = 0;
264 $amount_deposits_included = 0;
269 if ($object->specimen) {
270 $dir = $conf->fournisseur->commande->dir_output;
271 $file = $dir.
"/SPECIMEN.pdf";
275 $dir = $conf->fournisseur->commande->dir_output.
'/'.$objectref;
276 $file = $dir.
"/".$objectref.
".pdf";
277 if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) {
278 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
282 if (!file_exists($dir)) {
284 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
289 if (file_exists($dir)) {
291 if (!is_object($hookmanager)) {
292 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
295 $hookmanager->initHooks(array(
'pdfgeneration'));
296 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
298 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
300 $nblines = count($object->lines);
304 $heightforinfotot = 50;
305 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
306 $heightforfooter = $this->marge_basse + 8;
307 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
308 $heightforfooter += 6;
310 $pdf->SetAutoPageBreak(1, 0);
312 if (class_exists(
'TCPDF')) {
313 $pdf->setPrintHeader(
false);
314 $pdf->setPrintFooter(
false);
318 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
319 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
320 $tplidx = $pdf->importPage(1);
325 $pdf->SetDrawColor(128, 128, 128);
327 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
328 $pdf->SetSubject($outputlangs->transnoentities(
"Order"));
329 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
330 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
331 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Order").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
333 $pdf->SetCompression(
false);
336 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
339 foreach ($object->lines as $line) {
340 if ($line->remise_percent) {
341 $this->atleastonediscount =
true;
348 if (!empty($tplidx)) {
349 $pdf->useTemplate($tplidx);
352 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
353 $pdf->SetFont(
'',
'', $default_font_size - 1);
354 $pdf->MultiCell(0, 3,
'');
355 $pdf->SetTextColor(0, 0, 0);
357 $tab_top = 90 + $top_shift;
358 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
360 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
364 $desc_incoterms = $object->getIncotermsForPDF();
365 if ($desc_incoterms) {
368 $pdf->SetFont(
'',
'', $default_font_size - 1);
369 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
370 $nexY = $pdf->GetY();
371 $height_incoterms = $nexY - $tab_top;
374 $pdf->SetDrawColor(192, 192, 192);
375 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
377 $tab_top = $nexY + 6;
382 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
385 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
386 if (!empty($extranote)) {
390 $pagenb = $pdf->getPage();
392 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
393 $pageposbeforenote = $pagenb;
402 $pdf->startTransaction();
404 $pdf->SetFont(
'',
'', $default_font_size - 1);
405 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
407 $pageposafternote = $pdf->getPage();
408 $posyafter = $pdf->GetY();
410 if ($pageposafternote > $pageposbeforenote) {
411 $pdf->rollbackTransaction(
true);
414 while ($pagenb < $pageposafternote) {
417 if (!empty($tplidx)) {
418 $pdf->useTemplate($tplidx);
421 $this->
_pagehead($pdf, $object, 0, $outputlangs);
424 $pdf->setTopMargin($tab_top_newpage);
426 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
430 $pdf->setPage($pageposbeforenote);
431 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
432 $pdf->SetFont(
'',
'', $default_font_size - 1);
433 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
434 $pageposafternote = $pdf->getPage();
436 $posyafter = $pdf->GetY();
438 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
439 $pdf->AddPage(
'',
'',
true);
442 $pdf->setPage($pageposafternote);
443 $pdf->setTopMargin($tab_top_newpage);
445 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
451 $i = $pageposbeforenote;
452 while ($i < $pageposafternote) {
456 $pdf->SetDrawColor(128, 128, 128);
458 if ($i > $pageposbeforenote) {
459 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
460 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
462 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
463 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
467 $pdf->setPageOrientation(
'', 1, 0);
468 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
474 $pdf->setPage($pageposafternote);
475 if (!empty($tplidx)) {
476 $pdf->useTemplate($tplidx);
479 $this->
_pagehead($pdf, $object, 0, $outputlangs);
481 $height_note = $posyafter - $tab_top_newpage;
482 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
485 $pdf->commitTransaction();
486 $posyafter = $pdf->GetY();
487 $height_note = $posyafter - $tab_top;
488 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
491 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
493 $pdf->AddPage(
'',
'',
true);
496 $pdf->setPage($pageposafternote);
497 if (!empty($tplidx)) {
498 $pdf->useTemplate($tplidx);
501 $this->
_pagehead($pdf, $object, 0, $outputlangs);
504 $posyafter = $tab_top_newpage;
508 $tab_height = $tab_height - $height_note;
509 $tab_top = $posyafter + 6;
514 $nexY = $tab_top + 5;
520 $pageposbeforeprintlines = $pdf->getPage();
521 $pagenb = $pageposbeforeprintlines;
522 for ($i = 0; $i < $nblines; $i++) {
524 $pdf->SetFont(
'',
'', $default_font_size - 1);
525 $pdf->SetTextColor(0, 0, 0);
528 $imglinesize = array();
529 if (!empty($realpatharray[$i])) {
533 $pdf->setTopMargin($tab_top_newpage);
534 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
535 $pageposbefore = $pdf->getPage();
537 $showpricebeforepagebreak = 1;
539 $posYAfterDescription = 0;
544 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
545 $pdf->AddPage(
'',
'',
true);
546 if (!empty($tplidx)) {
547 $pdf->useTemplate($tplidx);
549 $pdf->setPage($pageposbefore + 1);
551 $curY = $tab_top_newpage;
554 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
555 $showpricebeforepagebreak = 1;
557 $showpricebeforepagebreak = 0;
561 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
562 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
564 $posYAfterImage = $curY + $imglinesize[
'height'];
568 $curX = $this->posxdesc - 1;
569 $showpricebeforepagebreak = 1;
572 $pdf->startTransaction();
573 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
575 $pageposafter = $pdf->getPage();
576 if ($pageposafter > $pageposbefore) {
577 $pdf->rollbackTransaction(
true);
579 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
581 $pageposafter = $pdf->getPage();
582 $posyafter = $pdf->GetY();
583 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
584 if ($i == ($nblines - 1)) {
585 $pdf->AddPage(
'',
'',
true);
586 if (!empty($tplidx)) {
587 $pdf->useTemplate($tplidx);
590 $pdf->setPage($pageposafter + 1);
595 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
596 $showpricebeforepagebreak = 1;
598 $showpricebeforepagebreak = 0;
603 $pdf->commitTransaction();
605 $posYAfterDescription = $pdf->GetY();
608 $nexY = $pdf->GetY();
609 $pageposafter = $pdf->getPage();
610 $pdf->setPage($pageposbefore);
611 $pdf->setTopMargin($this->marge_haute);
612 $pdf->setPageOrientation(
'', 1, 0);
615 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
616 $pdf->setPage($pageposafter);
617 $curY = $tab_top_newpage;
620 $pdf->SetFont(
'',
'', $default_font_size - 1);
626 $nexY = max($pdf->GetY(), $nexY);
633 $nexY = max($pdf->GetY(), $nexY);
641 $nexY = max($pdf->GetY(), $nexY);
647 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
649 $nexY = max($pdf->GetY(), $nexY);
653 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
656 $nexY = max($pdf->GetY(), $nexY);
663 $nexY = max($pdf->GetY(), $nexY);
667 if (!empty($object->lines[$i]->array_options)) {
668 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
670 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
672 $nexY = max($pdf->GetY(), $nexY);
683 'outputlangs' => $outputlangs,
684 'hidedetails' => $hidedetails
686 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
690 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
691 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
693 $tvaligne = $object->lines[$i]->total_tva;
696 $localtax1ligne = $object->lines[$i]->total_localtax1;
697 $localtax2ligne = $object->lines[$i]->total_localtax2;
698 $localtax1_rate = $object->lines[$i]->localtax1_tx;
699 $localtax2_rate = $object->lines[$i]->localtax2_tx;
700 $localtax1_type = $object->lines[$i]->localtax1_type;
701 $localtax2_type = $object->lines[$i]->localtax2_type;
714 $vatrate = (string) $object->lines[$i]->tva_tx;
717 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
718 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
720 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
721 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
725 if ($localtax1_type && $localtax1ligne != 0) {
726 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
727 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
729 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
732 if ($localtax2_type && $localtax2ligne != 0) {
733 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
734 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
736 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
740 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
745 if (!isset($this->tva[$vatrate])) {
746 $this->tva[$vatrate] = 0;
748 $this->tva[$vatrate] += $tvaligne;
749 $vatcode = $object->lines[$i]->vat_src_code;
750 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
751 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
753 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
755 if ($posYAfterImage > $posYAfterDescription) {
756 $nexY = $posYAfterImage;
760 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
761 $pdf->setPage($pageposafter);
762 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
764 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
765 $pdf->SetLineStyle(array(
'dash'=>0));
769 while ($pagenb < $pageposafter) {
770 $pdf->setPage($pagenb);
771 if ($pagenb == $pageposbeforeprintlines) {
772 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
774 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
776 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
778 $pdf->setPage($pagenb);
779 $pdf->setPageOrientation(
'', 1, 0);
781 $this->
_pagehead($pdf, $object, 0, $outputlangs);
783 if (!empty($tplidx)) {
784 $pdf->useTemplate($tplidx);
787 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
788 if ($pagenb == $pageposafter) {
789 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
791 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
793 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
796 if (!empty($tplidx)) {
797 $pdf->useTemplate($tplidx);
801 $this->
_pagehead($pdf, $object, 0, $outputlangs);
807 if ($pagenb == $pageposbeforeprintlines) {
808 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
809 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
811 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
812 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
816 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
819 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
822 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
827 $this->
_pagefoot($pdf, $object, $outputlangs);
828 if (method_exists($pdf,
'AliasNbPages')) {
829 $pdf->AliasNbPages();
834 $pdf->Output($file,
'F');
837 $hookmanager->initHooks(array(
'pdfgeneration'));
838 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
840 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
842 $this->error = $hookmanager->error;
843 $this->errors = $hookmanager->errors;
848 $this->result = array(
'fullpath'=>$file);
852 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
856 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
892 global $conf, $mysoc;
895 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
898 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
899 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
900 $pdf->SetXY($this->marge_gauche, $posy);
901 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
903 $posy = $pdf->GetY() + 4;
909 if (!empty($object->cond_reglement_code) || $object->cond_reglement) {
910 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
911 $pdf->SetXY($this->marge_gauche, $posy);
912 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
913 $pdf->MultiCell(80, 4, $titre, 0,
'L');
915 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
916 $pdf->SetXY($posxval, $posy);
917 $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);
918 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
919 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
921 $posy = $pdf->GetY() + 3;
925 if (!empty($object->mode_reglement_code)) {
926 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
927 $pdf->SetXY($this->marge_gauche, $posy);
928 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
929 $pdf->MultiCell(80, 5, $titre, 0,
'L');
931 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
932 $pdf->SetXY($posxval, $posy);
933 $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);
934 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
936 $posy = $pdf->GetY() + 2;
955 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
958 global $conf, $mysoc;
964 $pdf->SetFont(
'',
'', $default_font_size - 1);
969 if ($this->page_largeur < 210) {
972 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
978 $pdf->SetFillColor(255, 255, 255);
979 $pdf->SetXY($col1x, $tab2_top);
980 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
982 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
983 $pdf->SetXY($col2x, $tab2_top);
984 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0,
'R', 1);
987 $pdf->SetFillColor(248, 248, 248);
989 $this->atleastoneratenotnull = 0;
990 foreach ($this->tva as $tvakey => $tvaval) {
992 $this->atleastoneratenotnull++;
995 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
999 if (preg_match(
'/\*/', $tvakey)) {
1000 $tvakey = str_replace(
'*',
'', $tvakey);
1001 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1004 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
1005 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1006 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1008 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1009 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1012 if (!$this->atleastoneratenotnull) {
1014 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1015 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
1017 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1018 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_tva), 0,
'R', 1);
1021 if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION ==
'localtax1on' && $object->total_localtax1 > 0) {
1023 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1024 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
1025 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1026 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax1), $useborder,
'R', 1);
1030 if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION ==
'localtax2on' && $object->total_localtax2 > 0) {
1032 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1033 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
1034 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1035 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax2), $useborder,
'R', 1);
1041 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1042 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1046 foreach ($localtax_rate as $tvakey => $tvaval) {
1051 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1054 if (preg_match(
'/\*/', $tvakey)) {
1055 $tvakey = str_replace(
'*',
'', $tvakey);
1056 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1058 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1059 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1060 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1062 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1063 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1071 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1072 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1076 foreach ($localtax_rate as $tvakey => $tvaval) {
1081 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1084 if (preg_match(
'/\*/', $tvakey)) {
1085 $tvakey = str_replace(
'*',
'', $tvakey);
1086 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1088 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1089 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1090 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1092 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1093 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1101 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1102 $pdf->SetTextColor(0, 0, 60);
1103 $pdf->SetFillColor(224, 224, 224);
1104 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1106 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1107 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1108 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
1109 $pdf->SetFont(
'',
'', $default_font_size - 1);
1110 $pdf->SetTextColor(0, 0, 0);
1112 $creditnoteamount = 0;
1113 $depositsamount = 0;
1117 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1118 if (!empty($object->paye)) {
1122 if ($deja_regle > 0) {
1126 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1127 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1128 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1129 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
1132 $pdf->SetTextColor(0, 0, 60);
1133 $pdf->SetFillColor(224, 224, 224);
1134 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1135 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1137 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1138 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
1140 $pdf->SetFont(
'',
'', $default_font_size - 1);
1141 $pdf->SetTextColor(0, 0, 0);
1145 return ($tab2_top + ($tab2_hl * $index));
1162 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1172 $currency = !empty($currency) ? $currency : $conf->currency;
1176 $pdf->SetTextColor(0, 0, 0);
1177 $pdf->SetFont(
'',
'', $default_font_size - 2);
1179 if (empty($hidetop)) {
1180 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1181 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1182 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1185 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1186 $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));
1190 $pdf->SetDrawColor(128, 128, 128);
1191 $pdf->SetFont(
'',
'', $default_font_size - 1);
1194 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1196 foreach ($this->cols as $colKey => $colDef) {
1202 $colDef[
'title'][
'label'] = !empty($colDef[
'title'][
'label']) ? $colDef[
'title'][
'label'] : $outputlangs->transnoentities($colDef[
'title'][
'textkey']);
1205 if (!empty($colDef[
'border-left'])) {
1206 $pdf->line($colDef[
'xStartPos'], $tab_top, $colDef[
'xStartPos'], $tab_top + $tab_height);
1209 if (empty($hidetop)) {
1210 $pdf->SetXY($colDef[
'xStartPos'] + $colDef[
'title'][
'padding'][3], $tab_top + $colDef[
'title'][
'padding'][0]);
1212 $textWidth = $colDef[
'width'] - $colDef[
'title'][
'padding'][3] - $colDef[
'title'][
'padding'][1];
1213 $pdf->MultiCell($textWidth, 2, $colDef[
'title'][
'label'],
'', $colDef[
'title'][
'align']);
1217 if (empty($hidetop)) {
1218 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1232 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1234 global $langs, $conf, $mysoc;
1236 $ltrdirection =
'L';
1237 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
1240 $outputlangs->loadLangs(array(
"main",
"orders",
"companies",
"bills",
"sendings"));
1254 $pdf->SetTextColor(0, 0, 60);
1255 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1257 $posx = $this->page_largeur - $this->marge_droite - 100;
1258 $posy = $this->marge_haute;
1260 $pdf->SetXY($this->marge_gauche, $posy);
1264 if ($this->emetteur->logo) {
1265 $logodir = $conf->mycompany->dir_output;
1266 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1267 $logodir = $conf->mycompany->multidir_output[$object->entity];
1270 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1272 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1274 if (is_readable($logo)) {
1276 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1278 $pdf->SetTextColor(200, 0, 0);
1279 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1280 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1281 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1284 $text = $this->emetteur->name;
1285 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1289 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1290 $pdf->SetXY($posx, $posy);
1291 $pdf->SetTextColor(0, 0, 60);
1292 $title = $outputlangs->transnoentities(
"SupplierOrder").
" ".$outputlangs->convToOutputCharset($object->ref);
1293 $pdf->MultiCell(100, 3, $title,
'',
'R');
1296 if ($object->ref_supplier) {
1298 $pdf->SetFont(
'',
'B', $default_font_size);
1299 $pdf->SetXY($posx, $posy);
1300 $pdf->SetTextColor(0, 0, 60);
1301 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset($object->ref_supplier),
'',
'R');
1305 $pdf->SetFont(
'',
'', $default_font_size - 1);
1307 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1308 $object->fetch_projet();
1309 if (!empty($object->project->ref)) {
1311 $pdf->SetXY($posx, $posy);
1312 $pdf->SetTextColor(0, 0, 60);
1313 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1317 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1318 $object->fetch_projet();
1319 if (!empty($object->project->ref)) {
1320 $outputlangs->load(
"projects");
1322 $pdf->SetXY($posx, $posy);
1323 $langs->load(
"projects");
1324 $pdf->SetTextColor(0, 0, 60);
1325 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1329 if (!empty($object->date_commande)) {
1331 $pdf->SetXY($posx, $posy);
1332 $pdf->SetTextColor(0, 0, 60);
1333 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($object->date_commande,
"day",
false, $outputlangs,
true),
'',
'R');
1336 $pdf->SetXY($posx, $posy);
1337 $pdf->SetTextColor(255, 0, 0);
1338 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"OrderToProcess"),
'',
'R');
1341 $pdf->SetTextColor(0, 0, 60);
1342 $usehourmin =
'day';
1343 if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) {
1344 $usehourmin =
'dayhour';
1346 if (!empty($object->delivery_date)) {
1348 $pdf->SetXY($posx - 90, $posy);
1349 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1352 if ($object->thirdparty->code_fournisseur) {
1354 $pdf->SetXY($posx, $posy);
1355 $pdf->SetTextColor(0, 0, 60);
1356 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
1360 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1361 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1362 if (count($arrayidcontact) > 0) {
1363 $usertmp =
new User($this->db);
1364 $usertmp->fetch($arrayidcontact[0]);
1366 $pdf->SetXY($posx, $posy);
1367 $pdf->SetTextColor(0, 0, 60);
1368 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1373 $pdf->SetTextColor(0, 0, 60);
1377 $current_y = $pdf->getY();
1378 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1379 if ($current_y < $pdf->getY()) {
1380 $top_shift = $pdf->getY() - $current_y;
1385 $carac_emetteur =
'';
1387 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1388 if (count($arrayidcontact) > 0) {
1389 $object->fetch_user($arrayidcontact[0]);
1390 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1391 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1393 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1395 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1397 $carac_emetteur .=
"\n";
1400 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1403 $posy = 42 + $top_shift;
1404 $posx = $this->marge_gauche;
1405 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1406 $posx = $this->page_largeur - $this->marge_droite - 80;
1411 $pdf->SetTextColor(0, 0, 0);
1412 $pdf->SetFont(
'',
'', $default_font_size - 2);
1413 $pdf->SetXY($posx, $posy - 5);
1414 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1415 $pdf->SetXY($posx, $posy);
1416 $pdf->SetFillColor(230, 230, 230);
1417 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1418 $pdf->SetTextColor(0, 0, 60);
1421 $pdf->SetXY($posx + 2, $posy + 3);
1422 $pdf->SetFont(
'',
'B', $default_font_size);
1423 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1424 $posy = $pdf->getY();
1427 $pdf->SetXY($posx + 2, $posy);
1428 $pdf->SetFont(
'',
'', $default_font_size - 1);
1429 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1434 $usecontact =
false;
1435 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1436 if (count($arrayidcontact) > 0) {
1438 $result = $object->fetch_contact($arrayidcontact[0]);
1442 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)))) {
1443 $thirdparty = $object->contact;
1445 $thirdparty = $object->thirdparty;
1450 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1454 if ($this->page_largeur < 210) {
1457 $posy = 42 + $top_shift;
1458 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1459 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1460 $posx = $this->marge_gauche;
1464 $pdf->SetTextColor(0, 0, 0);
1465 $pdf->SetFont(
'',
'', $default_font_size - 2);
1466 $pdf->SetXY($posx + 2, $posy - 5);
1467 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1468 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1471 $pdf->SetXY($posx + 2, $posy + 3);
1472 $pdf->SetFont(
'',
'B', $default_font_size);
1473 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1475 $posy = $pdf->getY();
1478 $pdf->SetFont(
'',
'', $default_font_size - 1);
1479 $pdf->SetXY($posx + 2, $posy);
1480 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1496 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1498 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1499 return pdf_pagefoot($pdf, $outputlangs,
'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1514 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1516 global $conf, $hookmanager;
1519 $this->defaultContentsFieldsStyle = array(
1521 'padding' => array(1, 0.5, 1, 0.5),
1525 $this->defaultTitlesFieldsStyle = array(
1527 'padding' => array(0.5, 0, 0.5, 0),
1549 $this->cols[
'desc'] = array(
1554 'textkey' =>
'Designation',
1558 'padding' => array(0.5, 1, 0.5, 1.5),
1562 'padding' => array(1, 0.5, 1, 1.5),
1567 $this->cols[
'photo'] = array(
1569 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
1572 'textkey' =>
'Photo',
1576 'padding' => array(0, 0, 0, 0),
1578 'border-left' =>
false,
1581 if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) {
1582 $this->cols[
'photo'][
'status'] =
true;
1587 $this->cols[
'vat'] = array(
1594 'border-left' =>
true,
1597 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1598 $this->cols[
'vat'][
'status'] =
true;
1602 $this->cols[
'subprice'] = array(
1607 'textkey' =>
'PriceUHT'
1609 'border-left' =>
true,
1612 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE)) {
1613 $this->cols[
'subprice'][
'status'] =
true;
1617 $this->cols[
'qty'] = array(
1624 'border-left' =>
true,
1628 $this->cols[
'unit'] = array(
1635 'border-left' =>
true,
1638 $this->cols[
'unit'][
'status'] =
true;
1642 $this->cols[
'discount'] = array(
1647 'textkey' =>
'ReductionShort'
1649 'border-left' =>
true,
1651 if ($this->atleastonediscount) {
1652 $this->cols[
'discount'][
'status'] =
true;
1655 $rank = $rank + 1000;
1656 $this->cols[
'totalexcltax'] = array(
1661 'textkey' =>
'TotalHT'
1663 'border-left' =>
true,
1666 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN)) {
1667 $this->cols[
'totalexcltax'][
'status'] =
true;
1671 if (!empty($object->lines)) {
1672 $line = reset($object->lines);
1676 $parameters = array(
1677 'object' => $object,
1678 'outputlangs' => $outputlangs,
1679 'hidedetails' => $hidedetails,
1680 'hidedesc' => $hidedesc,
1681 'hideref' => $hideref
1684 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
1687 } elseif (empty($reshook)) {
1688 $this->cols = array_replace($this->cols, $hookmanager->resArray);
1690 $this->cols = $hookmanager->resArray;