1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
---|
2 |
|
---|
3 | class User extends MX_Controller
|
---|
4 | {
|
---|
5 | public function __construct()
|
---|
6 | {
|
---|
7 | parent::__construct();
|
---|
8 | $this->load->helper('cookie');
|
---|
9 | }
|
---|
10 |
|
---|
11 | public function index()
|
---|
12 | {
|
---|
13 | $admin_info = $this->session->userdata('adminInfo');
|
---|
14 | if ($admin_info)
|
---|
15 | {
|
---|
16 | $data['content'] = $this->get_users();
|
---|
17 | $this->load->view('user/index', $data);
|
---|
18 | }else
|
---|
19 | {
|
---|
20 | $this->load->view('login');
|
---|
21 | }
|
---|
22 | }
|
---|
23 |
|
---|
24 | public function get_users()
|
---|
25 | {
|
---|
26 | $this->load->helper('pagging');
|
---|
27 | $this->load->model('user_model');
|
---|
28 | $data['current_page'] = $this->uri->segment(4, 1);
|
---|
29 | $data['itemsoptions'] = array(1, 25, 50, 100);
|
---|
30 | $data['perpage'] = 1;
|
---|
31 | $data['keyword'] = "";
|
---|
32 | if ($this->input->post('items'))
|
---|
33 | {
|
---|
34 | $data['perpage'] = $this->input->post('items');
|
---|
35 | }
|
---|
36 | if ($this->input->post('keyword')) {
|
---|
37 | $data['keyword'] = $this->input->post('keyword');
|
---|
38 | }
|
---|
39 | $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
|
---|
40 | $data['total'] = $this->user_model->get_total_users($data);
|
---|
41 | $data['users'] = $this->user_model->get_list_users($data);
|
---|
42 | $data['paging_url'] = base_url() . "admin/nguoi_dung/trang/";
|
---|
43 | $data['num_links'] = 2;
|
---|
44 | $data['paging'] = pagging($data);
|
---|
45 | if ($this->input->is_ajax_request())
|
---|
46 | {
|
---|
47 | return $this->load->view('user/listview', $data);
|
---|
48 | }
|
---|
49 | return $this->load->view('user/listview', $data, true);
|
---|
50 | }
|
---|
51 |
|
---|
52 | } |
---|