Fix custom search

This commit is contained in:
jekkos-t520
2015-02-27 16:03:52 +01:00
parent 8981efbd2a
commit ffb8501276
2 changed files with 31 additions and 4 deletions

View File

@@ -41,12 +41,13 @@ class Items extends Secure_area implements iData_controller
$low_inventory=$this->input->post('low_inventory');
$is_serialized=$this->input->post('is_serialized');
$no_description=$this->input->post('no_description');
$search_custom=$this->input->post('search_custom');
$is_deleted=$this->input->post('is_deleted'); // Parq 131215
$limit_from = $this->input->post('limit_from');
$lines_per_page = $this->Appconfig->get('lines_per_page');
$items = $this->Item->search($search,$stock_location,$low_inventory,$is_serialized,$no_description,$is_deleted,$lines_per_page,$limit_from);
$items = $this->Item->search($search,$stock_location,$low_inventory,$is_serialized,$no_description,$search_custom,$is_deleted,$lines_per_page,$limit_from);
$data_rows=get_items_manage_table_data_rows($items,$this);
$total_rows = $this->Item->get_found_rows($search,$stock_location,$low_inventory,$is_serialized,$no_description,$is_deleted);
$total_rows = $this->Item->get_found_rows($search,$stock_location,$low_inventory,$is_serialized,$no_description,$search_custom,$is_deleted);
$links = $this->_initialize_pagination($this->Item, $lines_per_page, $limit_from, $total_rows);
$data_rows=get_items_manage_table_data_rows($items,$this);
echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links));

View File

@@ -32,7 +32,7 @@ class Item extends CI_Model
return $this->db->count_all_results();
}
function get_found_rows($search,$stock_location_id=-1,$low_inventory=0,$is_serialized=0,$no_description,$is_deleted=0)
function get_found_rows($search,$stock_location_id=-1,$low_inventory=0,$is_serialized=0,$no_description=0,$search_custom=0,$is_deleted=0)
{
$this->db->from("items");
@@ -60,6 +60,19 @@ class Item extends CI_Model
{
$this->db->where('description','');
}
if ($search_custom!=0 )
{
$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);
}
return $this->db->get()->num_rows();
}
@@ -558,7 +571,7 @@ class Item extends CI_Model
/*
Persform a search on items
*/
function search($search,$stock_location_id=-1,$low_inventory=0,$is_serialized=0,$no_description=0,$deleted=0,$rows = 0,$limit_from = 0)
function search($search,$stock_location_id=-1,$low_inventory=0,$is_serialized=0,$no_description=0,$search_custom=0,$deleted=0,$rows = 0,$limit_from = 0)
{
$this->db->from("items");
if ($stock_location_id > -1)
@@ -589,6 +602,19 @@ class Item extends CI_Model
{
$this->db->where('description','');
}
if ($search_custom!=0 )
{
$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");
if ($rows > 0) {
$this->db->limit($rows, $limit_from);