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

Last change on this file since 690 was 690, checked in by namnd, 10 years ago
File size: 4.4 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                $data['daterange_start'] = "";
62                $data['daterange_end'] = "";
63                if ($this->input->post('daterange')){
64                        $daterange = explode(" - ", $this->input->post('daterange'));
65                        $data['daterange_start'] = date('Y-m-d H:i:s', strtotime($daterange[0]));
66                        $data['daterange_end'] = date('Y-m-d 23:59:59', strtotime($daterange[1]));
67                }
68        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
69        $data['total'] = $this->paidlog_model->countPaidlog($data);
70        $data['paidlogs'] = $this->paidlog_model->getPaidlogs($data);
71
72        $data['paging_url'] = base_url() . "/admin/doanh_thu_tong_hop/trang/";
73        $data['num_links'] = 2;
74        $data['paging'] = pagging($data);
75        foreach ($data['paidlogs'] as $index => $paidlog) {
76            $data['paidlogs'][$index]['username'] = @$this->get_fullname($paidlog['us_id']);
77        }
78
79        if ($this->input->is_ajax_request()) {
80            return $this->load->view('report/listview', $data);
81        }
82        return $this->load->view('report/listview', $data, true);
83    }
84
85    private function get_fullname($us_id) {
86        $fullname="";
87        $src = 'violet';
88        $token = md5($us_id . self::TOKENPW);
89        $this->load->model('user_model');
90        $data = $this->user_model->get_user_info($src, $us_id, $token);
91        parse_str($data,$data);
92        if (isset($data['fullname']))
93        {
94            $fullname=$data['fullname'];
95        }
96        return $fullname;
97    }
98
99    public function test() {
100
101        /*
102          for ($i = 1; $i <= 5000; $i++) {
103          $input['us_id'] = rand(1, 100);
104          $input['paid_type'] = rand(1, 2);
105          $input['amount'] = rand(3, 10) * 1000;
106          $time = (rand((time() - (12 * 30 * 24 * 60 * 60)), time()));
107          $input['paid_time'] = date("Y-m-d H:i:s", $time);
108          $this->load->model('paidlog_model');
109          $this->paidlog_model->insert($input);
110          }
111
112          die();
113         */
114        for ($i = 1; $i <= 200; $i++) {
115            $input['us_id'] = $i;
116            $input['cellphone'] = "01234567" . (100 + $i);
117            $input['collaborator'] = rand(1, 100);
118            $input['acc_balanced'] = rand(100000, 1000000);
119            $input['expire_date'] = date("Y-m-d H:i:s", time());
120            $time = (rand((time() - (12 * 30 * 24 * 60 * 60)), time()));
121            $input['created_time'] = date("Y-m-d H:i:s", $time);
122            $input['updated_time'] = date("Y-m-d H:i:s", $time);
123            $this->load->model('user_model');
124            $this->user_model->insert($input);
125        }
126    }
127
128}
Note: See TracBrowser for help on using the repository browser.