diff --git a/application/controllers/items.php b/application/controllers/items.php index efdbfdb72..2dce9bddc 100644 --- a/application/controllers/items.php +++ b/application/controllers/items.php @@ -11,18 +11,19 @@ class Items extends Secure_area implements iData_controller function index($limit_from=0) { - $stock_location=$this->item_lib->get_item_location(); - $stock_locations=$this->Stock_location->get_allowed_locations(); + $stock_location = $this->item_lib->get_item_location(); + $stock_locations = $this->Stock_location->get_allowed_locations(); - $data['controller_name']=$this->get_controller_name(); - $data['form_width']=$this->get_form_width(); + $data['controller_name'] = $this->get_controller_name(); + $data['form_width'] = $this->get_form_width(); $lines_per_page = $this->Appconfig->get('lines_per_page'); $items = $this->Item->get_all($stock_location,$lines_per_page,$limit_from); $data['links'] = $this->_initialize_pagination($this->Item,$lines_per_page,$limit_from); - $data['stock_location']=$stock_location; - $data['stock_locations']=$stock_locations; - $data['manage_table']=get_items_manage_table( $this->Item->get_all( $stock_location, $lines_per_page, $limit_from), $this ); + $data['stock_location'] = $stock_location; + $data['stock_locations'] = $stock_locations; + $data['manage_table'] = get_items_manage_table( $this->Item->get_all( $stock_location, $lines_per_page, $limit_from), $this ); + $this->load->view('items/manage',$data); $this->_remove_duplicate_cookies(); } @@ -89,7 +90,8 @@ class Items extends Secure_area implements iData_controller */ function suggest() { - $suggestions = $this->Item->get_search_suggestions($this->input->post('q'), $this->input->post('limit'), $this->input->post('is_deleted')); + $suggestions = $this->Item->get_search_suggestions($this->input->post('q'), $this->input->post('limit'), + $this->input->post('search_custom'), $this->input->post('is_deleted')); echo implode("\n",$suggestions); } @@ -243,6 +245,7 @@ class Items extends Secure_area implements iData_controller $location_array[$location['location_id']] = array('location_name'=>$location['location_name'], 'quantity'=>$quantity); $data['stock_locations'] = $location_array; } + $this->load->view("items/form", $data); } diff --git a/application/models/item.php b/application/models/item.php index c210a9ca0..7b71924d2 100644 --- a/application/models/item.php +++ b/application/models/item.php @@ -90,7 +90,7 @@ class Item extends CI_Model /* Returns all the items */ - function get_all($stock_location_id=-1, $rows = 0, $limit_from = 0) + function get_all($stock_location_id=-1, $rows=0, $limit_from=0) { $this->db->from('items'); $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left'); @@ -226,7 +226,7 @@ class Item extends CI_Model /* Get search suggestions to find items */ - function get_search_suggestions($search, $limit=25, $is_deleted=0) + function get_search_suggestions($search, $limit=25, $search_custom=0, $is_deleted=0) { $suggestions = array(); @@ -292,24 +292,27 @@ class Item extends CI_Model } //Search by custom fields -/* $this->db->from('items'); - $this->db->like('custom1', $search); - $this->db->or_like('custom2', $search); - $this->db->or_like('custom3', $search); - $this->db->or_like('custom4', $search); - $this->db->or_like('custom5', $search); - $this->db->or_like('custom6', $search); - $this->db->or_like('custom7', $search); - $this->db->or_like('custom8', $search); - $this->db->or_like('custom9', $search); - $this->db->or_like('custom10', $search); - $this->db->where('deleted', $is_deleted); - $this->db->order_by("name", "asc"); - $by_name = $this->db->get(); - foreach($by_name->result() as $row) + if ($search_custom != 0) { - $suggestions[]=$row->name; - } */ + $this->db->from('items'); + $this->db->like('custom1', $search); + $this->db->or_like('custom2', $search); + $this->db->or_like('custom3', $search); + $this->db->or_like('custom4', $search); + $this->db->or_like('custom5', $search); + $this->db->or_like('custom6', $search); + $this->db->or_like('custom7', $search); + $this->db->or_like('custom8', $search); + $this->db->or_like('custom9', $search); + $this->db->or_like('custom10', $search); + $this->db->where('deleted', $is_deleted); + $this->db->order_by("name", "asc"); + $by_name = $this->db->get(); + foreach($by_name->result() as $row) + { + $suggestions[] = $row->name; + } + } //only return $limit suggestions if(count($suggestions > $limit)) @@ -320,7 +323,7 @@ class Item extends CI_Model return $suggestions; } - function get_item_search_suggestions($search, $limit=25, $is_deleted=0) + function get_item_search_suggestions($search, $limit=25, $search_custom=0, $is_deleted=0) { $suggestions = array(); @@ -363,24 +366,27 @@ class Item extends CI_Model } //Search by custom fields -/* $this->db->from('items'); - $this->db->where('deleted', $is_deleted); - $this->db->like('custom1', $search); - $this->db->or_like('custom2', $search); - $this->db->or_like('custom3', $search); - $this->db->or_like('custom4', $search); - $this->db->or_like('custom5', $search); - $this->db->or_like('custom6', $search); - $this->db->or_like('custom7', $search); - $this->db->or_like('custom8', $search); - $this->db->or_like('custom9', $search); - $this->db->or_like('custom10', $search); - $this->db->order_by("name", "asc"); - $by_description = $this->db->get(); - foreach($by_description->result() as $row) + if ($search_custom != 0) { - $suggestions[] = $row->item_id.'|'.$row->name; - } */ + $this->db->from('items'); + $this->db->where('deleted', $is_deleted); + $this->db->like('custom1', $search); + $this->db->or_like('custom2', $search); + $this->db->or_like('custom3', $search); + $this->db->or_like('custom4', $search); + $this->db->or_like('custom5', $search); + $this->db->or_like('custom6', $search); + $this->db->or_like('custom7', $search); + $this->db->or_like('custom8', $search); + $this->db->or_like('custom9', $search); + $this->db->or_like('custom10', $search); + $this->db->order_by("name", "asc"); + $by_description = $this->db->get(); + foreach($by_description->result() as $row) + { + $suggestions[] = $row->item_id.'|'.$row->name; + } + } //only return $limit suggestions if(count($suggestions > $limit)) @@ -621,7 +627,7 @@ class Item extends CI_Model } if (!empty($search)) { - if ($search_custom==0) + if ($search_custom == 0) { $this->db->where("(name LIKE '%" . $this->db->escape_like_str($search) . "%' OR " . "item_number LIKE '" . $this->db->escape_like_str($search) . "%' OR " .