From 4008e26328974a878f5f62e1a466d01f18a6b045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Hahn?= Date: Mon, 6 May 2019 13:12:41 +0200 Subject: [PATCH 1/2] Add support for units Fetch units from db when they've been enabled in configuration --- htdocs/core/class/html.form.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3c4ac0b9804..987331d1e0c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2084,6 +2084,11 @@ class Form $sql.=' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx'; $selectFields.= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx"; } + // Units + if($conf->global->PRODUCT_USE_UNITS) { + $sql .= ', u.label as unit_long, u.short_label as unit_short'; + $selectFields .= ', unit_long, unit_short'; + } // Multilang : we add translation if (! empty($conf->global->MAIN_MULTILANGS)) @@ -2121,6 +2126,10 @@ class Form if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid"; } + // Units + if($conf->global->PRODUCT_USE_UNITS) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_units u ON u.rowid = p.fk_unit"; + } // Multilang : we add translation if (! empty($conf->global->MAIN_MULTILANGS)) { @@ -2382,6 +2391,10 @@ class Form $opt.= $objp->ref; if ($outbarcode) $opt.=' ('.$outbarcode.')'; $opt.=' - '.dol_trunc($label, $maxlengtharticle); + // Units + if($conf->global->PRODUCT_USE_UNITS) { + $opt .= ' (' . $objp->unit_short . ')'; + } $objRef = $objp->ref; if (! empty($filterkey) && $filterkey != '') $objRef=preg_replace('/('.preg_quote($filterkey).')/i', '$1', $objRef, 1); From 2ee72e2fdf46f8b07b9521cd95db68414e38e7c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 May 2019 02:02:07 +0200 Subject: [PATCH 2/2] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 987331d1e0c..1ad6017b9d4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2085,7 +2085,7 @@ class Form $selectFields.= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx"; } // Units - if($conf->global->PRODUCT_USE_UNITS) { + if (! empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ', u.label as unit_long, u.short_label as unit_short'; $selectFields .= ', unit_long, unit_short'; } @@ -2127,7 +2127,7 @@ class Form $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid"; } // Units - if($conf->global->PRODUCT_USE_UNITS) { + if (! empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_units u ON u.rowid = p.fk_unit"; } // Multilang : we add translation @@ -2392,7 +2392,7 @@ class Form if ($outbarcode) $opt.=' ('.$outbarcode.')'; $opt.=' - '.dol_trunc($label, $maxlengtharticle); // Units - if($conf->global->PRODUCT_USE_UNITS) { + if (! empty($conf->global->PRODUCT_USE_UNITS)) { $opt .= ' (' . $objp->unit_short . ')'; }