From 372c3ab6bfd3b528c9de76020c3bdd03a29c861f Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Tue, 12 Sep 2017 13:28:50 +0400 Subject: [PATCH] Disables unique check and fixes return - If allow duplicate barcodes is enabled then this function automatically returns FALSE allowing item imports and new items to no longer balk. - Modified the code to return TRUE not only when there is 1 row but when there are one or more rows. This will fix problems with users that allow duplicate barcodes and who upgraded from older versions before unique barcode was required. --- application/models/Item.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/application/models/Item.php b/application/models/Item.php index 231d4af4c..671178455 100644 --- a/application/models/Item.php +++ b/application/models/Item.php @@ -44,6 +44,11 @@ class Item extends CI_Model */ public function item_number_exists($item_number, $item_id = '') { + if($this->config->item('allow_duplicate_barcodes') != FALSE) + { + return FALSE; + } + $this->db->from('items'); $this->db->where('item_number', (string) $item_number); if(ctype_digit($item_id)) @@ -51,7 +56,7 @@ class Item extends CI_Model $this->db->where('item_id !=', (int) $item_id); } - return ($this->db->get()->num_rows() == 1); + return ($this->db->get()->num_rows() >= 1); } /*