source: pro-violet-viettel/sourcecode/application/modules/admin/controllers/user_account.php @ 368

Last change on this file since 368 was 368, checked in by namnd, 11 years ago
File size: 2.2 KB
Line 
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3class User_Account 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                        $this->load->model('user_model');
16                        $users = $this->user_model->get_list();
17                        $this->load->view('user_acc', array('users'=>$users));
18                }else
19                {
20                        redirect("/admin/home");
21                }
22        }
23       
24        public function insert()
25        {
26                $admin_info = $this->session->userdata('adminInfo');
27                if($admin_info)
28                {
29                        $cellphone = $this->input->post('cellphone');
30                       
31                        $created_time = date('Y-m-d H:i:s', time());
32                        $updated_time = date('Y-m-d H:i:s', time());
33                        $data = array('cellphone'=>$cellphone, 'created_time'=>$created_time, 'updated_time'=>$updated_time);
34                        $this->load->model('admin_model');
35                        $this->admin_model->insert($data);
36                        redirect("/admin/user_account");
37                       
38                }else
39                {
40                        redirect("/admin/home");
41                }
42        }
43       
44        public function update()
45        {
46                $admin_info = $this->session->userdata('adminInfo');
47                if($admin_info)
48                {
49                        $user_id = (int)$this->input->post('id');
50                        $cellphone = $this->input->post('cellphone');
51                        $balance = $this->input->post('balance');
52                        $updated_time = date('Y-m-d H:i:s', time());
53                        $data = array('cellphone'=>$cellphone, 'acc_balanced'=>$balance, 'updated_time'=>$updated_time);
54                        $this->load->model('user_model');
55                        $this->user_model->update($user_id, $data);
56                        redirect("/admin/user_account");
57                }else
58                {
59                        redirect("/admin/home");
60                }       
61        }
62       
63        public function delete()
64        {
65                $admin_info = $this->session->userdata('adminInfo');
66                if($admin_info)
67                {
68                        $user_id = (int)$this->input->post('id');
69                        $this->load->model('user_model');
70                        $this->user_model->delete($user_id);
71                        redirect("/admin/user_account");
72                }else
73                {
74                        redirect("/admin/home");
75                }       
76        }
77       
78        public function check_data()
79        {
80                $login_name = $this->input->post('username');
81                //var_dump($login_name);
82                $this->load->model('user_model');
83                $check = $this->admin_model->check_data($login_name);
84                if ($check){
85                        echo 1;
86                }else
87                {
88                        echo 0;
89                }
90        }
91}
Note: See TracBrowser for help on using the repository browser.