[426] | 1 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
---|
| 2 |
|
---|
| 3 | class Cardlog extends MX_Controller
|
---|
| 4 | {
|
---|
| 5 | const TOKENPW = 'violet';
|
---|
| 6 |
|
---|
| 7 | public function __construct()
|
---|
| 8 | {
|
---|
| 9 | parent::__construct();
|
---|
| 10 | $this->load->helper('cookie');
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | public function index ()
|
---|
| 14 | {
|
---|
| 15 |
|
---|
| 16 | $admin_info = $this->session->userdata('adminInfo');
|
---|
| 17 | if ($admin_info)
|
---|
| 18 | {
|
---|
| 19 | $data['content'] = $this->get_cardlogs();
|
---|
| 20 | $this->load->view('cardlog/index', $data);
|
---|
| 21 | }else
|
---|
| 22 | {
|
---|
| 23 | $this->load->view ( 'login');
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | public function get_cardlogs()
|
---|
| 28 | {
|
---|
| 29 | $this->load->helper('pagging');
|
---|
| 30 | $this->load->model('cardlog_model');
|
---|
| 31 | $data['current_page'] = $this->uri->segment(4, 1);
|
---|
| 32 | $data['itemsoptions'] = array(10, 25, 50, 100);
|
---|
| 33 | $data['perpage'] = 10;
|
---|
| 34 | $data['keyword'] = "";
|
---|
| 35 | $data['sorting_order'] = "sorting_desc";
|
---|
| 36 | $data['sorting_field'] = "created_time";
|
---|
| 37 | if ($this->input->post('sorting_order')) {
|
---|
| 38 | if ($this->input->post('sorting_order') != "sorting")
|
---|
| 39 | {
|
---|
| 40 | $data['sorting_order'] = $this->input->post('sorting_order');
|
---|
| 41 | $data['sorting_field'] = $this->input->post('sorting_field');
|
---|
| 42 | }
|
---|
| 43 | }
|
---|
| 44 | if ($this->input->post('items'))
|
---|
| 45 | {
|
---|
| 46 | $data['perpage'] = $this->input->post('items');
|
---|
| 47 | }
|
---|
| 48 | if ($this->input->post('keyword')) {
|
---|
| 49 | $data['keyword'] = $this->input->post('keyword');
|
---|
| 50 | }
|
---|
| 51 | $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
|
---|
| 52 | $data['total'] = $this->cardlog_model->get_total_cardlogs($data);
|
---|
| 53 | $cls = $this->cardlog_model->get_cardlogs($data);
|
---|
| 54 | $cardlogs = array();
|
---|
| 55 | foreach($cls as $cl):
|
---|
| 56 | $id = $cl['us_id'];
|
---|
| 57 | $username = $this->get_username($id);
|
---|
[540] | 58 | $servicename = $this->get_servicename($cl['service_id']);
|
---|
[426] | 59 | $cl['username'] = $username;
|
---|
[540] | 60 | $cl['servicename'] = $servicename;
|
---|
[426] | 61 | array_push($cardlogs, $cl);
|
---|
| 62 | endforeach;
|
---|
| 63 | $data['cardlogs'] = $cardlogs;
|
---|
| 64 | $data['paging_url'] = base_url() . "admin/card_log/trang/";
|
---|
| 65 | $data['num_links'] = 2;
|
---|
| 66 | $data['paging'] = pagging($data);
|
---|
| 67 | if ($this->input->is_ajax_request())
|
---|
| 68 | {
|
---|
| 69 | return $this->load->view('cardlog/listview', $data);
|
---|
| 70 | }
|
---|
| 71 | return $this->load->view('cardlog/listview', $data, true);
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | private function get_username($us_id)
|
---|
| 75 | {
|
---|
| 76 | $src = 'violet';
|
---|
| 77 | $token = md5($us_id.self::TOKENPW);
|
---|
[437] | 78 | $this->load->model('user_model');
|
---|
| 79 | $data = $this->user_model->get_user_info($src, $us_id, $token);
|
---|
[426] | 80 | if (strlen($data) > 0){
|
---|
| 81 | $arr_users = explode("&", $data);
|
---|
| 82 | $str_username = $arr_users[1];
|
---|
| 83 | $arr_username = explode("=", $str_username);
|
---|
| 84 | return $arr_username[1];
|
---|
| 85 | }else
|
---|
| 86 | {
|
---|
| 87 | return "";
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | }
|
---|
| 91 |
|
---|
[540] | 92 | private function get_servicename($service_id)
|
---|
| 93 | {
|
---|
| 94 | $this->load->model('webservice_model');
|
---|
| 95 | $service = $this->webservice_model->search_by_id($service_id);
|
---|
| 96 | return $service['service_name'];
|
---|
| 97 | }
|
---|
| 98 |
|
---|
[426] | 99 | } |
---|