From b271e1a3b0517a2441f8371524c64f744f3b72bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 10 Nov 2018 07:27:20 +0100 Subject: [PATCH 1/2] The variable $i seems to be never defined. --- htdocs/product/class/api_products.class.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 30940c95509..6d84a6d1352 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -110,7 +110,7 @@ class Products extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" * @return array Array of product objects */ - function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode=0, $category=0, $sqlfilters = '') + function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '') { global $db, $conf; @@ -129,11 +129,12 @@ class Products extends DolibarrApi $sql.= " AND c.fk_categorie = ".$db->escape($category); $sql.= " AND c.fk_product = t.rowid "; } - // Show products - if ($mode == 1) { $sql.= " AND t.fk_product_type = 0"; - } - // Show services - if ($mode == 2) { $sql.= " AND t.fk_product_type = 1"; + if ($mode == 1) { + // Show only products + $sql.= " AND t.fk_product_type = 0"; + } elseif ($mode == 2) { + // Show only services + $sql.= " AND t.fk_product_type = 1"; } // Add sql filters if ($sqlfilters) { @@ -158,6 +159,7 @@ class Products extends DolibarrApi if ($result) { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; while ($i < $min) { $obj = $db->fetch_object($result); From 20acf440a3cfcb84c72412359547f3054fbd02e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 10 Nov 2018 07:55:01 +0100 Subject: [PATCH 2/2] Update api_products.class.php --- htdocs/product/class/api_products.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 6d84a6d1352..afacbb158b5 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -132,7 +132,7 @@ class Products extends DolibarrApi if ($mode == 1) { // Show only products $sql.= " AND t.fk_product_type = 0"; - } elseif ($mode == 2) { + } elseif ($mode == 2) { // Show only services $sql.= " AND t.fk_product_type = 1"; }