From d2c853c47bb0a3bb685bc089a033acddafb19da9 Mon Sep 17 00:00:00 2001 From: AXeL-dev Date: Sat, 1 Jun 2019 15:00:15 +0000 Subject: [PATCH 1/2] Fix #11256 --- htdocs/core/class/html.form.class.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f0b116a06fe..054a8ef2b1d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1914,6 +1914,16 @@ class Form $selected_input_value=$producttmpselect->ref; unset($producttmpselect); } + // handle case where product or service module is disabled + no filter specified + if (empty($filtertype)) + { + if (empty($conf->product->enabled)) { // when product module is disabled, show services only + $filtertype = 1; + } + elseif (empty($conf->service->enabled)) { // when service module is disabled, show products only + $filtertype = 0; + } + } // mode=1 means customers products $urloption='htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus; //Price by customer @@ -2165,7 +2175,14 @@ class Form { $sql.= " AND p.tosell = ".$status; } - if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype; + // Filter by product type + if (strval($filtertype) != '') $sql.= " AND p.fk_product_type = ".$filtertype; + elseif (empty($conf->product->enabled)) { // when product module is disabled, show services only + $sql.= " AND p.fk_product_type = 1"; + } + elseif (empty($conf->service->enabled)) { // when service module is disabled, show products only + $sql.= " AND p.fk_product_type = 0"; + } // Add criteria on ref/label if ($filterkey != '') { From 82b37a514cc350bc7d0b6e92d2eef34b37db4b09 Mon Sep 17 00:00:00 2001 From: AXeL-dev Date: Sat, 1 Jun 2019 16:27:06 +0000 Subject: [PATCH 2/2] Fixed empty verification (0 might be considered as empty also, so its better to compare string value with '') --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 054a8ef2b1d..63246fb0287 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1915,7 +1915,7 @@ class Form unset($producttmpselect); } // handle case where product or service module is disabled + no filter specified - if (empty($filtertype)) + if ($filtertype == '') { if (empty($conf->product->enabled)) { // when product module is disabled, show services only $filtertype = 1;