public function listinterviewerAction() { $this->view->disable(); $manager = $this->session->get('Manager'); if (empty($manager)) { $this->dataReturn(array('error' => '获取用户信息失败,请重新登陆')); return; } $project_id = $manager->project_id; $page = $this->request->get('page'); $rows = $this->request->get('rows'); $offset = $rows * ($page - 1); $limit = $rows; $sidx = $this->request->getQuery('sidx', 'string'); $sord = $this->request->getQuery('sord', 'string'); if ($sidx != null) { $sort = $sidx; } else { $sort = 'id'; $sord = 'desc'; } if ($sord != null) { $sort = $sort . ' ' . $sord; } //default get $search_state = $this->request->get('_search'); if ($search_state == 'false') { $result = $this->modelsManager->createBuilder()->columns(array('Manager.id as id', 'Manager.username as username', 'Manager.name as name', 'Manager.password as password', 'Manager.last_login as last_login', 'count(Interview.examinee_id) as count'))->from('Manager')->where('Manager.project_id = ' . $project_id . " AND Manager.role = 'I'")->leftJoin('Interview', "Interview.manager_id = Manager.id")->groupBy('Manager.id')->limit($limit, $offset)->orderBy($sort)->getQuery()->execute(); $result = $result->toArray(); foreach ($result as &$value) { $term = "remark<>'' AND advantage<>'' AND disadvantage<>'' AND manager_id=:manager_id:"; $interview_info = Interview::find(array($term, 'bind' => array('manager_id' => $value['id']))); $finish = count($interview_info); $value['count'] = $finish . '/' . $value['count']; } $rtn_array = array(); $interviewers = Manager::find(array('project_id=?1 AND role = ?2', 'bind' => array(1 => $project_id, 2 => 'I'))); //获取该项目下答题的总人数 $count = count($interviewers); $rtn_array['total'] = ceil($count / $rows); $rtn_array['records'] = $count; $rtn_array['rows'] = $result; $rtn_array['page'] = $page; $this->dataReturn($rtn_array); return; } else { //处理search情况 $search_field = $this->request->get('searchField'); $search_string = $this->request->get('searchString'); $search_oper = $this->request->get('searchOper'); if ($search_field == 'username') { $filed = 'Manager.' . $search_field; $oper = '='; $value = $search_string; } else { if ($search_field == 'name') { $filed = 'Manager.' . $search_field; $oper = 'LIKE'; $value = '%' . $search_string . '%'; } else { if ($search_field == 'last_login') { $filed = 'Manager.' . $search_field; if ($search_oper == 'bw') { $oper = '>='; } else { if ($search_oper == 'ew') { $oper = '<='; } } $value = $search_string; } else { //.. return; } } } $result = $this->modelsManager->createBuilder()->columns(array('Manager.id as id', 'Manager.username as username', 'Manager.name as name', 'Manager.password as password', 'Manager.last_login as last_login', 'count(Interview.examinee_id) as count'))->from('Manager')->where('Manager.project_id = ' . $project_id . " AND Manager.role = 'I' AND {$filed} {$oper} '{$value}'")->leftJoin('Interview', "Interview.manager_id = Manager.id")->groupBy('Manager.id')->limit($limit, $offset)->orderBy($sort)->getQuery()->execute(); $result = $result->toArray(); foreach ($result as &$value) { $term = "remark<>'' AND advantage<>'' AND disadvantage<>'' AND manager_id=:manager_id:"; $interview_info = Interview::find(array($term, 'bind' => array('manager_id' => $value['id']))); $finish = count($interview_info); $value['count'] = $finish . '/' . $value['count']; } $rtn_array = array(); $interviewers = Manager::find(array('project_id=?1 AND role = ?2', 'bind' => array(1 => $project_id, 2 => 'I'))); //获取该项目下答题的总人数 $count = count($interviewers); $rtn_array['total'] = ceil($count / $rows); $rtn_array['records'] = $count; $rtn_array['rows'] = $result; // foreach($result as $value){ // $rtn_array['rows'][] = $value; // } $rtn_array['page'] = $page; $this->dataReturn($rtn_array); return; } }
public function listexamineeAction() { $this->view->disable(); $manager = $this->session->get('Manager'); if (empty($manager)) { $this->dataReturn(array('error' => '获取用户信息失败,请重新登陆')); return; } $manager_id = $manager->id; $page = $this->request->get('page'); $rows = $this->request->get('rows'); $offset = $rows * ($page - 1); $limit = $rows; $sidx = $this->request->getQuery('sidx', 'string'); $sord = $this->request->getQuery('sord', 'string'); if ($sidx != null) { $sort = $sidx; } else { $sort = 'id'; $sord = 'desc'; } if ($sord != null) { $sort = $sort . ' ' . $sord; } //default get $search_state = $this->request->get('_search'); if ($search_state == 'false') { $result = $this->modelsManager->createBuilder()->columns(array('Examinee.id as id', 'Examinee.number as number', 'Examinee.name as name', 'Examinee.sex as sex', 'Examinee.last_login as last_login', 'Examinee.state as state'))->from('Examinee')->join('Interview', 'Interview.examinee_id = Examinee.id AND Interview.manager_id = ' . $manager_id)->limit($limit, $offset)->orderBy($sort)->getQuery()->execute(); $rtn_array = array(); $examinees = Interview::find(array('manager_id=?1', 'bind' => array(1 => $manager_id))); //获取该项目下答题的总人数 $count = count($examinees); $rtn_array['total'] = ceil($count / $rows); $rtn_array['records'] = $count; $rtn_array['rows'] = array(); foreach ($result as $value) { $rtn_array['rows'][] = $value; } $rtn_array['page'] = $page; $this->dataReturn($rtn_array); return; } else { //处理search情况 $search_field = $this->request->get('searchField'); $search_string = $this->request->get('searchString'); $search_oper = $this->request->get('searchOper'); #分情况讨论 $filed = 'Examinee.' . $search_field; if ($search_oper == 'eq') { if ($search_field == 'name') { $oper = 'LIKE'; $value = "'%{$search_string}%'"; } else { if ($search_field == 'number' || $search_field == 'sex') { $oper = '='; $value = "'{$search_string}'"; } else { if ($search_field == 'exam_state' || $search_field == 'interview_state') { $filed = 'Examinee.state'; if ($search_string == 'true') { $oper = '>='; } else { $oper = '<'; } if ($search_field == 'exam_state') { $value = 1; } else { $value = 4; } } } } } else { if ($search_oper == 'bw' || $search_oper == 'ew') { if ($search_field == 'last_login') { $value = "'{$search_string}'"; } if ($search_oper == 'bw') { $oper = '>='; } else { if ($search_oper == 'ew') { $oper = '<='; } } } else { //add ... } } $result = $this->modelsManager->createBuilder()->columns(array('Examinee.id as id', 'Examinee.number as number', 'Examinee.name as name', 'Examinee.sex as sex', 'Examinee.last_login as last_login', 'Examinee.state as state'))->from('Examinee')->join('Interview', 'Interview.examinee_id = Examinee.id AND Interview.manager_id = ' . $manager_id . " AND {$filed} {$oper} {$value}")->orderBy($sort)->getQuery()->execute(); $rtn_array = array(); $count = count($result); $rtn_array['total'] = ceil($count / $rows); $rtn_array['records'] = $count; $rtn_array['rows'] = array(); foreach ($result as $value) { $rtn_array['rows'][] = $value; } $rtn_array['page'] = $page; $this->dataReturn($rtn_array); return; } }