| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786 | <?phpif (!defined('BASEPATH'))exit('No direct script access allowed');include_once(FCPATH . 'application/models/Base_model.php');class Repair_model extends Base_model {    protected $table = 'repair_info';    public function __construct() {        parent::__construct();    }        // 根据条件获取维修信息列表    public function getList($filter,$page = null,$limit = null){    	$where_sql = "";    	    	$arrProjectTpl = array('company','province','zone');    	foreach ($arrProjectTpl as $key){    		if (isset($filter[$key]) || !empty($filter[$key])){    			$projectsql = "SELECT * FROM project WHERE $key='".$filter[$key]."'";    			$query = $this->db->query($projectsql);    			$projectList = $query->result_array();    				    			$projectIds = array();    			foreach ($projectList as $p){    				$projectIds[] = $p['id'];    			}    			if (empty($projectIds)){    				$projectIds[] = 0;    			}    			$where_sql.= " AND RI.projectid IN(".implode(',', $projectIds).")";    		}    	}    	if (isset($filter['projectid']) || !empty($filter['projectid'])){    		$where_sql.= " AND RI.projectid='".$filter['projectid']."'";    	}    	    	if (isset($filter['networkid']) || !empty($filter['networkid'])){    		$where_sql.= " AND RI.networkid='".$filter['networkid']."'";    	}    	    	if (isset($filter['projectname']) || !empty($filter['projectname'])){    		    $projectsql = "SELECT * FROM project WHERE projectname LIKE '%".$filter['projectname']."%'";    			$query = $this->db->query($projectsql);    			$projectList = $query->result_array();    				    			$projectIds = array();    			foreach ($projectList as $p){    				$projectIds[] = $p['id'];    			}    			if (empty($projectIds)){    				$projectIds[] = 0;    			}    				    			$where_sql.= " AND RI.projectid IN(".implode(',', $projectIds).")";    	}    	    	if (isset($filter['networkname']) || !empty($filter['networkname'])){    		$networksql = "SELECT * FROM network WHERE networkname LIKE '%".$filter['networkname']."%'";    		$query = $this->db->query($networksql);    		$networkList = $query->result_array();    	    		$networkIds = array();    		foreach ($networkList as $n){    			$networkIds[] = $n['id'];    		}    		    		if (empty($networkIds)){    			$networkIds[] = 0;    		}    		    	    		$where_sql.= " AND RI.networkid IN(".implode(',', $networkIds).")";    		    	}    	    	if (isset($filter['lampnumber']) || !empty($filter['lampnumber'])){    		$lampsql = "SELECT * FROM lampinfo WHERE number LIKE '%".$filter['lampnumber']."%'";    		$query = $this->db->query($lampsql);    		$lampList = $query->result_array();    	    		$lampIds = array();    		foreach ($lampList as $l){    			$lampIds[] = $l['id'];    		}    		    		if (empty($lampIds)){    			$lampIds[] = 0;    		}    	    		$where_sql.= " AND RI.lampid IN(".implode(',', $lampIds).")";    	}        	if (isset($filter['repair_path']) || !empty($filter['repair_path'])){    		$where_sql.= " AND RI.repair_path LIKE'%".$filter['repair_path']."%'";    	}    	    	if (isset($filter['repair_usernumber']) || !empty($filter['repair_usernumber'])){    		$repairusersql = "SELECT * FROM repair_user WHERE number LIKE '%".$filter['repair_usernumber']."%'";    		$query = $this->db->query($repairusersql);    		$repairuserList = $query->result_array();    		     		$repairuserIds = array();    		foreach ($repairuserList as $l){    			$repairuserIds[] = $l['id'];    		}    		     		if (empty($repairuserIds)){    			$repairuserIds[] = 0;    		}    		    		$where_sql.= " AND RI.repair_userid IN(".implode(',', $repairuserIds).")";    	}    	    	if (isset($filter['repair_username']) || !empty($filter['repair_username'])){    		$repairusersql = "SELECT * FROM repair_user WHERE name LIKE '%".$filter['repair_username']."%'";    		$query = $this->db->query($repairusersql);    		$repairuserList = $query->result_array();    		     		$repairuserIds = array();    		foreach ($repairuserList as $l){    			$repairuserIds[] = $l['id'];    		}    		     		if (empty($repairuserIds)){    			$repairuserIds[] = 0;    		}    		$where_sql.= " AND RI.repair_userid IN(".implode(',', $repairuserIds).")";    	}    	    	if (isset($filter['id'])){    		$where_sql = " AND RI.id=".intval($filter['id'])." ";    	}        if (isset($filter['userid'])){            $where_sql = " AND RI.repair_userid=".intval($filter['userid'])." ";        }    	$sql = "SELECT RI.id AS id,    				   RI.repair_userid AS repair_userid,    				   RI.projectid AS projectid,    				   RI.networkid AS networkid,    				   RI.lampid AS lampid,    				   RI.repair_hitch AS repair_hitch,    				   RI.repair_solution AS repair_solution,    				   RI.repair_time AS repair_time,    				   RI.repair_path AS repair_path,    				   RI.created AS created,    				   P.projectname AS projectname,    				   N.networkname AS networkname,    				   RU.number AS repair_usernumber,    				   L.number AS lampnumber,    				   RU.name AS repair_username    				FROM repair_info AS RI LEFT JOIN     				project AS P ON P.id=RI.projectid LEFT JOIN    				network AS N ON N.id=RI.networkid LEFT JOIN    				lampinfo AS L ON L.id=RI.lampid LEFT JOIN    				repair_user AS RU ON RU.id=RI.repair_userid    			WHERE 1=1";    	$limit_sql = "";    	if ($page != null && $limit != null){    		$limit_sql = " LIMIT ".($page-1)*$limit.",".$limit;    	}    	    	$query  = $sql.$where_sql.$limit_sql;    	$query  = $this->db->query($query);    	return  $query->result_array();    }        public function getDispatchList($filter,$page = null,$limit = null){    	$where_sql = "";		       if (isset($filter['user_id'])){       	       	   $repairuserIds = $this->get_repair_user_list($filter['user_id']);       	          	   if (empty($repairuserIds)){       	   		$repairuserIds[] = 0;       	   }       	          	   $where_sql.= " AND RD.repair_userid IN(".implode(',', $repairuserIds).")";       }   	   if (isset($filter['repair_usernumber']) || !empty($filter['repair_usernumber'])){    		$repairusersql = "SELECT * FROM repair_user WHERE number LIKE '%".$filter['repair_usernumber']."%'";    		$query = $this->db->query($repairusersql);    		$repairuserList = $query->result_array();    		     		$repairuserIds = array();    		foreach ($repairuserList as $l){    			$repairuserIds[] = $l['id'];    		}    		     		if (empty($repairuserIds)){    			$repairuserIds[] = 0;    		}    		    		$where_sql.= " AND RD.repair_userid IN(".implode(',', $repairuserIds).")";    	}    	    	if (isset($filter['repair_username']) || !empty($filter['repair_username'])){    		$repairusersql = "SELECT * FROM repair_user WHERE name LIKE '%".$filter['repair_username']."%'";    		$query = $this->db->query($repairusersql);    		$repairuserList = $query->result_array();    		     		$repairuserIds = array();    		foreach ($repairuserList as $l){    			$repairuserIds[] = $l['id'];    		}    		     		if (empty($repairuserIds)){    			$repairuserIds[] = 0;    		}    		$where_sql.= " AND RD.repair_userid IN(".implode(',', $repairuserIds).")";    	}    	    	if (isset($filter['id'])){    		$where_sql = " AND RD.id=".intval($filter['id'])." ";    	}        	$sql = "SELECT RD.id AS id,    	RD.repair_userid AS repair_userid,    	RD.projectid AS projectid,    	RD.networkid AS networkid,    	RD.starttime AS starttime,    	RD.plantime AS plantime,    	RD.finishtime AS finishtime,    	RD.created AS created,    	RD.address AS address,    	P.projectname AS projectname,    	N.networkname AS networkname,    	RU.number AS repair_usernumber,    	RU.name AS repair_username    	FROM repair_dispatch AS RD LEFT JOIN    	project AS P ON P.id=RD.projectid LEFT JOIN    	network AS N ON N.id=RD.networkid LEFT JOIN    	repair_user AS RU ON RU.id=RD.repair_userid    	WHERE 1=1";    	$limit_sql = "";    	if ($page != null && $limit != null){    		$limit_sql = " LIMIT ".($page-1)*$limit.",".$limit;    	}    	     	$query  = $sql.$where_sql.$limit_sql;    	$query  = $this->db->query($query);    	return  $query->result_array();    }    // 通过权限获取故障总数    public function get_total_by_role($filter,$role,$userid,$companyid,$projectid=0){        $data = $this->get_list_by_role($filter,$role,$userid,$companyid,$projectid,"count(*) as total");        return $data[0]['total'];    }    // 通过权限获取维修信息列表    public function get_list_by_role($filter,$role,$userid,$companyid,$projectid=0,$field='*',$page=null,$limit=null){        // 设置筛选条件        $keyword = '';        if (isset($filter['keyword'])) {            $keyword = $filter['keyword'];            unset($filter['keyword']);        }        $temp = array();        foreach ($filter as $key => $value) {            $temp[] = "{$key} = '{$value}'";        }        // 获取用户查看权限        if ($projectid > 0) {            $projectIds = $projectid;        }else{            $projectIds = $this->get_projectid_by_role($role,$userid,$companyid);        }                $where = 'role_'.$role.'='.$userid;        if (empty($projectIds)) {            $where .= " and P.id in (0)";        }else{            $where .= " and P.id in ({$projectIds})";        }        if (!empty($temp)) {            $where .= implode(' AND ', $temp);        }        if (!empty($keyword)) {            $where .= " and (N.networkname LIKE '%{$keyword}%'";            $where .= " or L.number LIKE '%{$keyword}%') ";        }        // 设置分页        $limit = '';        if ($page != null && $limit != null) {            $limit = " LIMIT {($page-1)*$limit},{$limit}";        }                $sql = "SELECT {$field} FROM {$this->table} as R                 left join lampinfo as L on L.id = R.lampid                 left join project as P on P.id = R.projectid                 left join network as N on N.id = R.networkid                 left join repair_user as RU on RU.id = R.repair_userid where {$where} {$limit} order by R.created";        $data = $this->db->query($sql)->result_array();        return $data;    }        public function get_list_by_filter($filter,$field='*'){        $this->db->select($field);        if (!empty($filter)){            foreach ($filter as $k => $v) {                if (is_array($v)) {                    if (!empty($v)) {                        $this->db->where_in($k,$v);                    }else{                        $this->db->where_in($k,array(0));                    }                }else{                    $this->db->where($k,$v);                }            }        }        return $this->db->get($this->table)->result_array();    }    // 获取维修信息列表    public function get_repair_info_list($filter,$field='*'){        $this->db->select($field);        if(!empty($filter['page']) && !empty($filter['count'])){            $this->db->limit($filter['count'],($filter['page']-1)*$filter['count']);            unset($filter['count']);            unset($filter['page']);        }        if (!empty($filter)){            foreach ($filter as $k => $v) {                if (is_array($v)) {                    if (!empty($v)) {                        $this->db->where_in($k,$v);                    }else{                        $this->db->where_in($k,array(0));                    }                }else{                    $this->db->where($k,$v);                }            }        }        $this->db->join('repair_user as RU','RU.id = RI.repair_userid','left');        return $this->db->get($this->table.' as RI')->result_array();    }    public function get_repair_total($filter){        $this->db->select('count(*) as total');        if (!empty($filter)){            foreach ($filter as $k => $v) {                if (is_array($v)) {                    if (!empty($v)) {                        $this->db->where_in($k,$v);                    }else{                        $this->db->where_in($k,array(0));                    }                }else{                    $this->db->where($k,$v);                }            }        }        $this->db->join('repair_user as RU','RU.id = RI.repair_userid','left');        $data = $this->db->get($this->table.' as RI')->row_array();        return $data['total'];    }    // 获取维修人员id    public function get_userid_by_alarm($alarmid){        $sql = "SELECT RD.repair_userid as userid from alarm_info_log AS AI left join repair_dispatch AS RD on AI.lampid = RD.lampid where RD.alarmid = {$alarmid}";        $data = $this->db->query($sql)->row_array();        return $data['userid'];    }    public function getTotal($filter){    	$where_sql = "";    	     	$arrProjectTpl = array('company','province','zone');    	foreach ($arrProjectTpl as $key){    		if (isset($filter[$key]) || !empty($filter[$key])){    			$projectsql = "SELECT * FROM project WHERE $key='".$filter[$key]."'";    			$query = $this->db->query($projectsql);    			$projectList = $query->result_array();    	    			$projectIds = array();    			foreach ($projectList as $p){    				$projectIds[] = $p['id'];    			}    	    			if (empty($projectIds)){    				$projectIds[] = 0;    			}    			    			$where_sql.= " AND RI.projectid IN(".implode(',', $projectIds).")";    		}    	}    	    	if (isset($filter['projectid']) || !empty($filter['projectid'])){    		$where_sql.= " AND RI.projectid='".$filter['projectid']."'";    	}    	     	if (isset($filter['networkid']) || !empty($filter['networkid'])){    		$where_sql.= " AND RI.networkid='".$filter['networkid']."'";    	}    	     	if (isset($filter['projectname']) || !empty($filter['projectname'])){    		$projectsql = "SELECT * FROM project WHERE projectname LIKE '%".$filter['projectname']."%'";    		$query = $this->db->query($projectsql);    		$projectList = $query->result_array();    	    		$projectIds = array();    		foreach ($projectList as $p){    			$projectIds[] = $p['id'];    		}    		if (empty($projectIds)){    			$projectIds[] = 0;    		}    	    		$where_sql.= " AND RI.projectid IN(".implode(',', $projectIds).")";    	}    	     	if (isset($filter['networkname']) || !empty($filter['networkname'])){    		$networksql = "SELECT * FROM network WHERE networkname LIKE '%".$filter['networkname']."%'";    		$query = $this->db->query($networksql);    		$networkList = $query->result_array();    		     		$networkIds = array();    		foreach ($networkList as $n){    			$networkIds[] = $n['id'];    		}    		     		if (empty($networkIds)){    			$networkIds[] = 0;    		}    		$where_sql.= " AND RI.networkid IN(".implode(',', $networkIds).")";    	}    	     	if (isset($filter['lampnumber']) || !empty($filter['lampnumber'])){    		$lampsql = "SELECT * FROM lampinfo WHERE number LIKE '%".$filter['lampnumber']."%'";    		$query = $this->db->query($lampsql);    		$lampList = $query->result_array();    		     		$lampIds = array();    		foreach ($lampList as $l){    			$lampIds[] = $l['id'];    		}    		     		if (empty($lampIds)){    			$lampIds[] = 0;    		}    		    		$where_sql.= " AND RI.lampid IN(".implode(',', $lampIds).")";    	}    	    	if (isset($filter['repair_path']) || !empty($filter['repair_path'])){    		$where_sql.= " AND RI.repair_path LIKE'%".$filter['repair_path']."%'";    	}    	     	if (isset($filter['repair_usernumber']) || !empty($filter['repair_usernumber'])){    		$repairusersql = "SELECT * FROM repair_user WHERE number LIKE '%".$filter['repair_usernumber']."%'";    		$query = $this->db->query($repairusersql);    		$repairuserList = $query->result_array();    		     		$repairuserIds = array();    		foreach ($repairuserList as $l){    			$repairuserIds[] = $l['id'];    		}    		     		if (empty($repairuserIds)){    			$repairuserIds[] = 0;    		}    		    		$where_sql.= " AND RI.repair_userid IN(".implode(',', $repairuserIds).")";    	}    	     	if (isset($filter['repair_username']) || !empty($filter['repair_username'])){    		$repairusersql = "SELECT * FROM repair_user WHERE name LIKE '%".$filter['repair_username']."%'";    		$query = $this->db->query($repairusersql);    		$repairuserList = $query->result_array();    		     		$repairuserIds = array();    		foreach ($repairuserList as $l){    			$repairuserIds[] = $l['id'];    		}    		     		if (empty($repairuserIds)){    			$repairuserIds[] = 0;    		}    		$where_sql.= " AND RI.repair_userid IN(".implode(',', $repairuserIds).")";    	}        if (isset($filter['userid'])){            $where_sql = " AND RI.repair_userid=".intval($filter['userid'])." ";        }    	     	     	$sql = "SELECT COUNT(RI.id) AS total    	FROM repair_info AS RI LEFT JOIN    	project AS P ON P.id=RI.projectid LEFT JOIN    	network AS N ON N.id=RI.networkid LEFT JOIN    	lampinfo AS L ON L.id=RI.lampid LEFT JOIN    	repair_user AS RU ON RU.id=RI.repair_userid    	WHERE 1=1";    	    	$limit_sql = "";    	$query  = $sql.$where_sql.$limit_sql;    	    	$query  = $this->db->query($query);    	$row =   $query->row_array();    	return $row['total'];    }        public function getDispatchTotal($filter){    		    $where_sql = "";				    if (isset($filter['user_id'])){	    	$repairuserIds = $this->get_repair_user_list($filter['user_id']);	    	 	    	if (empty($repairuserIds)){	    		$repairuserIds[] = 0;	    	}	    	 	    	$where_sql.= " AND RD.repair_userid IN(".implode(',', $repairuserIds).")";	    	    }       	   if (isset($filter['repair_usernumber']) || !empty($filter['repair_usernumber'])){    		$repairusersql = "SELECT * FROM repair_user WHERE number LIKE '%".$filter['repair_usernumber']."%'";    		$query = $this->db->query($repairusersql);    		$repairuserList = $query->result_array();    		     		$repairuserIds = array();    		foreach ($repairuserList as $l){    			$repairuserIds[] = $l['id'];    		}    		     		if (empty($repairuserIds)){    			$repairuserIds[] = 0;    		}    		    		$where_sql.= " AND RD.repair_userid IN(".implode(',', $repairuserIds).")";    	}    	    	if (isset($filter['repair_username']) || !empty($filter['repair_username'])){    		$repairusersql = "SELECT * FROM repair_user WHERE name LIKE '%".$filter['repair_username']."%'";    		$query = $this->db->query($repairusersql);    		$repairuserList = $query->result_array();    		     		$repairuserIds = array();    		foreach ($repairuserList as $l){    			$repairuserIds[] = $l['id'];    		}    		     		if (empty($repairuserIds)){    			$repairuserIds[] = 0;    		}    		$where_sql.= " AND RD.repair_userid IN(".implode(',', $repairuserIds).")";    	}    	    	if (isset($filter['id'])){    		$where_sql = " AND RD.id=".intval($filter['id'])." ";    	}        	$sql = "SELECT COUNT(RD.id) AS total    	FROM repair_dispatch AS RD LEFT JOIN    	project AS P ON P.id=RD.projectid LEFT JOIN    	network AS N ON N.id=RD.networkid LEFT JOIN    	repair_user AS RU ON RU.id=RD.repair_userid    	WHERE 1=1";    	     	$limit_sql = "";    	$query  = $sql.$where_sql.$limit_sql;    	     	$query  = $this->db->query($query);    	$row =   $query->row_array();    	return $row['total'];    }            public function insertDispatch($data){    	$this->db->insert('repair_dispatch', $data);    	return $this->db->insert_id();    }    public function updateDispatch($filter,$data){    	if (empty($filter)){    		return false;    	}        	foreach ($data as $key => $value) {    		if ($value === '') {    			$data[$key] = NULL;    		}    	}        	$sql =  $this->db->update_string('repair_dispatch',$data,$filter);    	return $this->db->query($sql);    }        public function delData($condition) {    	if (!empty($condition)){    		foreach ($condition as $k => $v) {    			if (is_array($v)) {                    if (!empty($v)) {                        $this->db->where_in($k,$v);                    }else{                        $this->db->where_in($k,array(0));                    }                }else{                    $this->db->where($k,$v);                }    		}    	}else{            return false;        }    	$this->db->delete($this->table);    	if ($this->db->affected_rows() > 0) {    		return true;    	} else {    		return false;    	}    }        public function delDispatchData($condition) {    	if (!empty($condition)){    		foreach ($condition as $k => $v) {    			$this->db->where($k,$v);    		}    	}    	$this->db->delete('repair_dispatch');    	if ($this->db->affected_rows() > 0) {    		return true;    	} else {    		return false;    	}    }        public function getDispatchOne($id){    	$this->db->where('id',$id);    	$this->db->limit('1');    	$query = $this->db->get('repair_dispatch');    	return $query->row_array();    }    // 获取调度信息    public function getDispatchData($filter,$field = '*'){        if (empty($filter)) {            return array();        }        $this->db->select($field);        foreach ($filter as $key => $value) {            if (is_array($value)) {                if (!empty($value)) {                    $this->db->where_in($key,$value);                }else{                    $this->db->where_in($key,array(0));                }            }else{                $this->db->where($key,$value);            }        }        $this->db->order_by('created','desc');        $query = $this->db->get('repair_dispatch');        return $query->row_array();    }        public function delDispatchOne($id) {    	$this->db->where('id', $id);    	$this->db->delete('repair_dispatch');    	if ($this->db->affected_rows() == 1) {    		return true;    	} else {    		return false;    	}    }        // 获取维修人员信息列表    public function get_repair_user_list($user_id){    	    	$query = "SELECT * FROM user WHERE id={$user_id}";    	$query = $this->db->query($query);    	$user  = $query->row_array();    	if (empty($user)) {    		return array();    	}        	$colum = 'role_'.$user['role'];    	$query = "SELECT id AS id    	FROM repair_user     	WHERE {$colum}={$user_id}";        	$query = $this->db->query($query);    	$result =  $query->result_array();    	    	$userIds = array();    	foreach ($result as $v) {    		$userIds[] = $v['id'];    	}    	return $userIds;    }    // 获取维修人员总数    public function get_repair_user_total($userinfo){        $colum = 'role_'.$userinfo['role'];        $sql = "SELECT count(*) as total from repair_user where {$colum}={$userinfo['id']}";        $data = $this->db->query($sql)->row_array();        return $data['total'];    }    // 删除维修人员    public function del_repair_user($filter){        foreach ($filter as $key => $value) {            $this->db->where($key,$value);        }        if (!empty($filter)) {            $this->db->delete('repair_user');        }            }    // 添加维修人员维修数    public function add_repaircount($userid){        $sql = "update repair_user set repaircount = repaircount + 1 where id={$userid}";        $this->db->query($sql);    }    // 减少维修人员维修数    public function minus_repaircount($userid){        $sql = "update repair_user set repaircount = repaircount - 1 where id={$userid} and repaircount >= 1";        $this->db->query($sql);    }    public function get_repair_user_id($filter,$id=0){        $temp = array();        foreach ($filter as $key => $value) {            $temp[] = "{$key}='{$value}'";        }        $where = '';        if (!empty($temp)) {            $where = "where ".implode(' AND ', $temp);        }        $sql = "SELECT id from repair_user ".$where;        $data = $this->db->query($sql)->row_array();        if (empty($data['id'])) {            return 0;        }else{            return $id == $data['id'] ? 0 : 1;        }    }    public function get_repair_user_by_filter($filter,$field='*'){        $this->db->select($field);        if(!empty($filter['page']) && !empty($filter['count'])){            $this->db->limit($filter['count'],($filter['page']-1)*$filter['count']);            unset($filter['count']);            unset($filter['page']);        }        if (!empty($filter)){            foreach ($filter as $k => $v) {                if (is_array($v)) {                    if (!empty($v)) {                        $this->db->where_in($k,$v);                    }else{                        $this->db->where_in($k,array(0));                    }                }else{                    $this->db->where($k,$v);                }            }        }        return $this->db->get('repair_user')->result_array();    }}
 |