source: pro-violet-viettel/sourcecode/application/modules/admin/controllers/report.php @ 767

Last change on this file since 767 was 767, checked in by namnd, 10 years ago
File size: 4.7 KB
Line 
1<?php
2
3if (!defined('BASEPATH'))
4    exit('No direct script access allowed');
5
6class Report extends MX_Controller {
7
8    const TOKENPW = 'violet';
9
10    public function __construct() {
11        parent::__construct();
12        $this->load->helper('cookie');
13    }
14
15    public function index() {
16        $data = array();
17        $admin_info = $this->session->userdata('adminInfo');
18        if ($admin_info) {
19            $data['statistics'] = $this->getStatistics();
20            $data['content'] = $this->getPaidlogs();
21            $this->load->view('report/index', $data);
22        } else {
23            $this->load->view('login');
24        }
25    }
26
27    public function getStatistics() {
28        $this->load->model('collabolator_model');
29        $data = $this->collabolator_model->getStatistics();
30        return $this->load->view('report/statistics', $data, true);
31    }
32
33
34    public function getPaidlogs($filters = array()) {
35        $this->load->helper('pagging');
36        $this->load->model('paidlog_model');
37        $data['current_page'] = $this->uri->segment(4, 1);
38        $data['itemsoptions'] = array(10, 25, 50, 100);
39        $data['perpage'] = 10;
40        $data['keyword'] = "";
41        $data['sorting_order'] = "sorting_desc";
42        $data['sorting_field'] = "paid_id";
43
44        if ($this->input->post('sorting_order')) {
45            if ($this->input->post('sorting_order') != "sorting") {
46                $data['sorting_order'] = $this->input->post('sorting_order');
47                $data['sorting_field'] = $this->input->post('sorting_field');
48            }
49        }
50        if ($this->input->post('items')) {
51            $data['perpage'] = $this->input->post('items');
52        }
53        if ($this->input->post('keyword')) {
54            $data['search_field'] = "";
55            $data['keyword'] = $this->input->post('keyword');
56
57            if (preg_match("/[0-9]/", $data['keyword'])) {
58                $data['search_field'] = "cellphone";
59            }
60        }
61               
62                $data ['paid_types'] = array (
63                                        0 => "Tất cả",
64                                        1 => "SMS",
65                                        2 => "Card",
66                );
67                $data ['paid_type'] = 0;
68                if ($this->input->post ( 'paid_type' )) {
69                        $data ['paid_type'] = ( int ) $this->input->post ( 'paid_type' );
70                }
71               
72                $data['daterange_start'] = "";
73                $data['daterange_end'] = "";
74                if ($this->input->post('daterange')){
75                        $daterange = explode(" - ", $this->input->post('daterange'));
76                        $data['daterange_start'] = date('Y-m-d H:i:s', strtotime($daterange[0]));
77                        $data['daterange_end'] = date('Y-m-d 23:59:59', strtotime($daterange[1]));
78                }
79        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
80        $data['total'] = $this->paidlog_model->countPaidlog($data);
81        $data['paidlogs'] = $this->paidlog_model->getPaidlogs($data);
82
83        $data['paging_url'] = base_url() . "/admin/doanh_thu_tong_hop/trang/";
84        $data['num_links'] = 2;
85        $data['paging'] = pagging($data);
86        foreach ($data['paidlogs'] as $index => $paidlog) {
87            $data['paidlogs'][$index]['username'] = @$this->get_fullname($paidlog['us_id']);
88        }
89               
90        if ($this->input->is_ajax_request()) {
91            return $this->load->view('report/listview', $data);
92        }
93        return $this->load->view('report/listview', $data, true);
94    }
95
96    private function get_fullname($us_id) {
97        $fullname="";
98        $src = 'violet';
99        $token = md5($us_id . self::TOKENPW);
100        $this->load->model('user_model');
101        $data = $this->user_model->get_user_info($src, $us_id, $token);
102        parse_str($data,$data);
103        if (isset($data['fullname']))
104        {
105            $fullname=$data['fullname'];
106        }
107        return $fullname;
108    }
109
110    public function test() {
111
112        /*
113          for ($i = 1; $i <= 5000; $i++) {
114          $input['us_id'] = rand(1, 100);
115          $input['paid_type'] = rand(1, 2);
116          $input['amount'] = rand(3, 10) * 1000;
117          $time = (rand((time() - (12 * 30 * 24 * 60 * 60)), time()));
118          $input['paid_time'] = date("Y-m-d H:i:s", $time);
119          $this->load->model('paidlog_model');
120          $this->paidlog_model->insert($input);
121          }
122
123          die();
124         */
125        for ($i = 1; $i <= 200; $i++) {
126            $input['us_id'] = $i;
127            $input['cellphone'] = "01234567" . (100 + $i);
128            $input['collaborator'] = rand(1, 100);
129            $input['acc_balanced'] = rand(100000, 1000000);
130            $input['expire_date'] = date("Y-m-d H:i:s", time());
131            $time = (rand((time() - (12 * 30 * 24 * 60 * 60)), time()));
132            $input['created_time'] = date("Y-m-d H:i:s", $time);
133            $input['updated_time'] = date("Y-m-d H:i:s", $time);
134            $this->load->model('user_model');
135            $this->user_model->insert($input);
136        }
137    }
138
139}
Note: See TracBrowser for help on using the repository browser.