source: pro-violet-viettel/sourcecode/application/modules/admin/controllers/smslog.php @ 442

Last change on this file since 442 was 437, checked in by namnd, 11 years ago
File size: 2.5 KB
Line 
1<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
2
3class Smslog extends MX_Controller
4{
5       
6        const TOKENPW = 'violet';
7       
8        public function __construct()
9        {
10                parent::__construct();
11                $this->load->helper('cookie');
12        }
13       
14        public function index ()
15        {
16           
17                $admin_info = $this->session->userdata('adminInfo');
18                if ($admin_info)
19                {
20                        $data['content'] = $this->get_smslogs();
21                        $this->load->view('smslog/index', $data);
22                }else
23                {
24                        $this->load->view ( 'login');
25                }
26        }
27       
28        public function get_smslogs()
29        {
30                $this->load->helper('pagging');
31                $this->load->model('smslog_model');
32                $data['current_page'] = $this->uri->segment(4, 1);
33                $data['itemsoptions'] = array(10, 25, 50, 100);
34                $data['perpage'] = 10;
35                $data['keyword'] = "";
36                $data['sorting_order'] = "sorting_desc";
37        $data['sorting_field'] = "created_time";
38                if ($this->input->post('sorting_order')) {
39                        if ($this->input->post('sorting_order') != "sorting")
40                        {
41                                $data['sorting_order'] = $this->input->post('sorting_order');
42                                $data['sorting_field'] = $this->input->post('sorting_field');
43                        }
44                }
45                if ($this->input->post('items'))
46                {
47                        $data['perpage'] = $this->input->post('items');
48                }
49                if ($this->input->post('keyword')) {
50            $data['keyword'] = $this->input->post('keyword');
51        }
52                $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
53                $data['total'] = $this->smslog_model->get_total_smslogs($data);
54                $smsls = $this->smslog_model->get_smslogs($data);
55                $smslogs = array();
56                foreach($smsls as $smsl):
57                        $id = $smsl['us_id'];
58                        $username = $this->get_username($id);
59                        $smsl['username'] = $username;
60                        array_push($smslogs, $smsl);
61                endforeach;
62                $data['smslogs'] = $smslogs;
63                $data['paging_url'] = base_url() . "admin/sms_log/trang/";
64                $data['num_links'] = 2;
65                $data['paging'] = pagging($data);
66                if ($this->input->is_ajax_request())
67                {
68                        return $this->load->view('smslog/listview', $data);
69                }
70                return $this->load->view('smslog/listview', $data, true);
71        }
72       
73        private function get_username($us_id)
74        {
75                $src = 'violet';
76                $token = md5($us_id.self::TOKENPW);
77                $this->load->model('user_model');
78                $data = $this->user_model->get_user_info($src, $us_id, $token);
79                if (strlen($data) > 0){
80                        $arr_users = explode("&", $data);
81                        $str_username = $arr_users[1];
82                        $arr_username = explode("=", $str_username);
83                        return $arr_username[1];
84                }else
85                {
86                        return "";
87                }
88
89        }
90}
Note: See TracBrowser for help on using the repository browser.