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

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