diff --git a/application/libraries/Datatables.php b/application/libraries/Datatables.php index c6de11f..9f7fc06 100644 --- a/application/libraries/Datatables.php +++ b/application/libraries/Datatables.php @@ -324,16 +324,28 @@ private function get_filtering() $sSearch = $this->ci->db->escape_like_str(trim($search['value'])); $columns = array_values(array_diff($this->columns, $this->unset_columns)); - if($sSearch != '') - for($i = 0; $i < count($mColArray); $i++) + if($sSearch != ''){ + for($i = 0; $i < count($mColArray); $i++){ if ($mColArray[$i]['searchable'] == 'true' && !array_key_exists($mColArray[$i]['data'], $this->add_columns)) if($this->check_cType()) $sWhere .= $this->select[$mColArray[$i]['data']] . " LIKE '%" . $sSearch . "%' OR "; else $sWhere .= $this->select[$this->columns[$i]] . " LIKE '%" . $sSearch . "%' OR "; - - - $sWhere = substr_replace($sWhere, '', -3); + } + $sWhere = substr_replace($sWhere, '', -3); + } + else{ + for($i = 0; $i < count($mColArray); $i++){ + if ($mColArray[$i]['searchable'] == 'true' && !array_key_exists($mColArray[$i]['data'], $this->add_columns) && $mColArray[$i]['search']['value']!=''){ + $sSearch = $this->ci->db->escape_like_str(trim($mColArray[$i]['search']['value'])); + if($this->check_cType()) + $sWhere .= $this->select[$mColArray[$i]['data']] . " LIKE '%" . $sSearch . "%' AND "; + else + $sWhere .= $this->select[$this->columns[$i]] . " LIKE '%" . $sSearch . "%' AND "; + } + } + $sWhere = substr_replace($sWhere, '', -4); + } if($sWhere != '') $this->ci->db->where('(' . $sWhere . ')');