Esempio n. 1
0
 /**
  * 监考人员 列表
  *
  * @return  void
  */
 public function index()
 {
     if (!$this->check_power('exam_list,exam_manage')) {
         return;
     }
     // 查询条件
     $query = array();
     $param = array();
     $search = array();
     $place_id = $this->input->get_post('place_id');
     if ($place_id) {
         $db_query = $this->db->select('p.place_id,p.place_name,p.address,e.exam_id,e.exam_name,sch.school_id,sch.school_name')->from('exam_place p')->join('exam e', 'p.exam_pid=e.exam_id')->join('school sch', 'p.school_id=sch.school_id')->where('p.place_id', $place_id)->get();
         $place = $db_query->row_array();
     }
     if (empty($place)) {
         message('考场信息不存在');
     }
     //控制考场只能在未开始考试操作
     $no_start = ExamPlaceModel::place_is_no_start($place_id);
     if (!$no_start) {
         message('该考场正在考试或已结束,无法做此操作');
     }
     $data['place'] = $place;
     $search['place_id'] = $place_id;
     $param[] = "place_id={$place_id}";
     $page = (int) $this->input->get_post('page');
     $page = $page ? $page : 1;
     $per_page = (int) $this->input->get_post('per_page');
     $per_page = $per_page ? $per_page : 10;
     $order_bys = array('email' => 'invigilator_email', 'name' => 'invigilator_name', 'memo' => 'invigilator_memo', 'time' => 'invigilator_addtime');
     $order = $this->input->get_post('order');
     !$order && ($order = 'time');
     $search['order'] = $order;
     $param[] = "order={$order}";
     $order_type = $this->input->get_post('order_type');
     !$order_type && ($order_type = 'desc');
     $search['order_type'] = $order_type;
     $param[] = "order_type={$order_type}";
     $order_by = $order_bys[$order] . ' ' . $order_type;
     $selectWhat = '*';
     //拼接查询条件
     $query_email = $this->input->get_post('email');
     if ($query_email) {
         $query['invigilator_email'] = trim($query_email);
         $search['email'] = $query_email;
         $param[] = "email={$query_email}";
     }
     $query_name = $this->input->get_post('name');
     if ($query_name) {
         $query['invigilator_name'] = trim($query_name);
         $search['name'] = $query_name;
         $param[] = "name={$query_name}";
     }
     $query_flag = $this->input->get_post('flag');
     if ($query_flag) {
         $query['invigilator_flag'] = is_string($query_flag) ? (int) $query_flag : $query_flag;
         $search['flag'] = $query_flag;
         $param[] = "flag={$query_flag}";
     }
     $query_is_trash = (int) $this->input->get_post('trash');
     if ($query_is_trash) {
         $query['invigilator_flag'] = '-1';
         $search['trash'] = $query_is_trash;
         $param[] = "trash={$query_is_trash}";
     } else {
         $query['invigilator_flag'] = array('0', '1');
     }
     $query_begin_time = $this->input->get_post('begin_time');
     if ($query_begin_time) {
         $query['invigilator_addtime'] = array('>=' => strtotime($query_begin_time));
         $search['begin_time'] = $query_begin_time;
         $param[] = "begin_time={$query_begin_time}";
     }
     $query_end_time = $this->input->get_post('end_time');
     if ($query_end_time) {
         if (!isset($query['invigilator_addtime'])) {
             $query['invigilator_addtime'] = array();
         }
         $query['invigilator_addtime']['<='] = strtotime($query_end_time);
         $search['end_time'] = $query_end_time;
         $param[] = "end_time={$query_end_time}";
     }
     //查看已分配
     $has_assigned = intval($this->input->get_post('has_assigned'));
     if (!$query_is_trash) {
         if ($has_assigned) {
             $search['has_assigned'] = $has_assigned;
             $param[] = "has_assigned={$has_assigned}";
             $result = ExamInvigilatorModel::get_invigilator_list($query, $page, $per_page, $order_by, $selectWhat, $place_id);
         } else {
             $result = ExamInvigilatorModel::get_invigilator_list($query, $page, $per_page, $order_by, $selectWhat, $place_id, true);
         }
     } else {
         $result = ExamInvigilatorModel::get_invigilator_list($query, $page, $per_page, $order_by, $selectWhat);
     }
     $tmp_result = array();
     if (count($result)) {
         foreach ($result as $v) {
             if ($query_is_trash) {
                 $recycle = RecycleModel::get_recycle_list(array('type' => RECYCLE_EXAM_INVIGILATOR, 'obj_id' => $v['invigilator_id']), null, null, 'ctime asc');
                 $v['recycle'] = $recycle;
             } else {
                 $v['recycle'] = array();
             }
             $tmp_result[] = $v;
         }
     }
     // 分页
     $purl = site_url('admin/exam_invigilator/index/') . (count($param) ? '?' . implode('&', $param) : '');
     if ($has_assigned) {
         $total = ExamInvigilatorModel::count_invigilator_lists($query, $place_id);
     } else {
         $total = ExamInvigilatorModel::count_invigilator_lists($query, $place_id, true);
     }
     $data['pagination'] = multipage($total, $per_page, $page, $purl);
     $data['search'] =& $search;
     $data['list'] =& $tmp_result;
     //排序地址
     unset($param['order=']);
     unset($param['order_type=']);
     $order_url = site_url('admin/exam_invigilator/index/') . (count($param) ? '?' . implode('&', $param) : '');
     $data['order_url'] = $order_url;
     $data['priv_manage'] = $this->check_power('exam_manage', FALSE);
     // 模版
     $this->load->view('exam_invigilator/index', $data);
 }