Exemple #1
0
 /**
  * @description 学校列表
  * @author
  * @final
  * @param int $province 省
  * @param int $city 市
  * @param int $area 区/县
  * @param int $school_id 学校
  * @param int $grade_period 学校类别
  * @param int $keyword 关键字
  */
 public function index()
 {
     Fn::ajax_call($this, 'removeSchool');
     $grade_periods = $this->config->item('grade_period');
     $param = array('province' => $this->input->get('province'), 'city' => $this->input->get('city'), 'area' => $this->input->get('area'), 'grade_period' => $this->input->get('grade_period'), 'keyword' => $this->input->get('keyword'), 'order_by' => 'school_id');
     if (!is_array($param['grade_period'])) {
         $param['grade_period'] = array();
     }
     $total = SchoolModel::schoolListCount($param);
     $size = 15;
     $page = 1;
     if (isset($_GET['page']) && intval($_GET['page']) > 1) {
         $page = intval($_GET['page']);
     }
     $offset = ($page - 1) * $size;
     $data = array();
     if ($total) {
         $rows = SchoolModel::schoolList('*', $param, $page, $size);
         foreach ($rows as &$row) {
             $row['periods'] = explode(',', $row['grade_period']);
             $row['period'] = array();
             foreach ($row['periods'] as $period) {
                 $row['period'][] = isset($grade_periods[$period]) ? $grade_periods[$period] : '';
             }
             $row['period'] = implode(',', $row['period']);
         }
         $data['list'] =& $rows;
     } else {
         $data['list'] = array();
     }
     //是否异步选择
     $is_ajax = $this->input->get('is_ajax') ? TRUE : FALSE;
     $data['is_ajax'] = $is_ajax;
     $param['is_ajax'] = $is_ajax;
     $get = $_GET;
     unset($get['page']);
     $url = site_url('admin/school/index') . '?' . http_build_query($get);
     $data['pagination'] = multipage($total, $size, $page, $url);
     $data['province_list'] = RegionModel::get_regions(1);
     $data['city_list'] = RegionModel::get_regions($param['province'], FALSE, 2);
     $data['area_list'] = RegionModel::get_regions($param['city'], FALSE, 3);
     $data['grade_periods'] = $grade_periods;
     $data['param'] = $param;
     $data['has_class_manage_priv'] = $this->check_power_new('school_editclass,school_updateclass,school_deleteclass', false);
     $data['has_teacher_manage_priv'] = $this->check_power_new('school_teacherlist,school_editteacher,school_importteacher,school_deleteteacher', false);
     // 模版
     $this->load->view('school/index', $data);
 }