From aa9cd1fe6a146a8f66e81d86f547aebde50cb8bc Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Tue, 22 Sep 2015 18:37:30 +0100 Subject: [PATCH] #132 Make sure we don't show multiple times the same item given a range --- application/models/item.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/application/models/item.php b/application/models/item.php index 38f9ed02f..e961e4d2c 100644 --- a/application/models/item.php +++ b/application/models/item.php @@ -39,7 +39,7 @@ class Item extends CI_Model */ function get_found_rows($search, $filters) { - $this->db->from("items"); + $this->db->from('items'); $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left'); $this->db->join('inventory', 'inventory.trans_items = items.item_id'); @@ -97,6 +97,8 @@ class Item extends CI_Model $this->db->where('items.description', ''); } + $this->db->group_by('items.name'); + return $this->db->get()->num_rows(); } @@ -105,7 +107,7 @@ class Item extends CI_Model */ function search($search, $filters, $rows=0, $limit_from=0) { - $this->db->from("items"); + $this->db->from('items'); $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left'); $this->db->join('inventory', 'inventory.trans_items = items.item_id'); @@ -163,6 +165,7 @@ class Item extends CI_Model $this->db->where('items.description', ''); } + $this->db->group_by('items.name'); $this->db->order_by('items.name', 'asc'); if ($rows > 0)