public function getsubusersAction() { $user_session = new Zend_Session_Namespace('user'); $user = $user_session->user_info['employee_id']; // 请求参数 $request = $this->getRequest()->getParams(); $key = isset($request['search_key']) ? $request['search_key'] : ''; $employee = new Hra_Model_Employee(); // 查询条件 $cols = array("number", "cname", "ename", "id_card", "email", "tel", "address"); $arr = preg_split('/\\s+/', trim($key)); for ($i = 0; $i < count($arr); $i++) { $tmp = array(); foreach ($cols as $c) { $tmp[] = "ifnull({$c},'')"; } $arr[$i] = "concat(" . implode(',', $tmp) . ") like '%" . $arr[$i] . "%'"; } if ($user == 1) { // 管理员 $where = " 1=1"; } else { $where = " (manager_id = " . $user . " or id = {$user})"; } $where .= " and active=1 and " . join(' AND ', $arr); $total = $employee->getJoinCount($where); $data = array(); if ($total > 0) { $data = $employee->getJoinList($where, array(), array('id', 'number', 'cname', 'email'), array('cname')); } $resutl = array('total' => $total, 'rows' => $data); echo Zend_Json::encode($resutl); exit; }
public function getemployeeforselAction() { // 请求参数 $request = $this->getRequest()->getParams(); $limit = $request['limit']; $start = $request['start']; $key = isset($request['search_key']) ? $request['search_key'] : ''; $employee = new Hra_Model_Employee(); // 查询条件 $cols = array("number", "cname", "ename", "id_card", "email", "tel", "address"); $arr = preg_split('/\\s+/', trim($key)); for ($i = 0; $i < count($arr); $i++) { $tmp = array(); foreach ($cols as $c) { $tmp[] = "ifnull({$c},'')"; } $arr[$i] = "concat(" . implode(',', $tmp) . ") like '%" . $arr[$i] . "%'"; } $where = "active=1 and " . join(' AND ', $arr); $total = $employee->getJoinCount($where); $data = array(); if ($total > 0) { $data = $employee->getJoinList($where, array(), array('id', 'number', 'cname', 'email'), array('cname')); } $resutl = array('total' => $total, 'rows' => $data); echo Zend_Json::encode($resutl); exit; }