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

Last change on this file since 804 was 777, checked in by namnd, 10 years ago
File size: 4.8 KB
RevLine 
[422]1<?php
2
3if (!defined('BASEPATH'))
4    exit('No direct script access allowed');
5
6class Report extends MX_Controller {
7
[479]8    const TOKENPW = 'violet';
[444]9
[422]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) {
[444]19            $data['statistics'] = $this->getStatistics();
[441]20            $data['content'] = $this->getPaidlogs();
[422]21            $this->load->view('report/index', $data);
22        } else {
23            $this->load->view('login');
24        }
25    }
[444]26
27    public function getStatistics() {
[594]28        $this->load->model('collabolator_model');
29        $data = $this->collabolator_model->getStatistics();
[422]30        return $this->load->view('report/statistics', $data, true);
31    }
[444]32
[441]33
34    public function getPaidlogs($filters = array()) {
[422]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'] = "";
[444]41        $data['sorting_order'] = "sorting_desc";
42        $data['sorting_field'] = "paid_id";
43
[422]44        if ($this->input->post('sorting_order')) {
[444]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');
[422]48            }
49        }
50        if ($this->input->post('items')) {
51            $data['perpage'] = $this->input->post('items');
52        }
53        if ($this->input->post('keyword')) {
[444]54            $data['search_field'] = "";
[422]55            $data['keyword'] = $this->input->post('keyword');
[444]56
57            if (preg_match("/[0-9]/", $data['keyword'])) {
58                $data['search_field'] = "cellphone";
[422]59            }
60        }
[767]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               
[690]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                }
[444]79        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
80        $data['total'] = $this->paidlog_model->countPaidlog($data);
[777]81        $data['paidlogs'] = $this->paidlog_model->getPaidlogs($data)['paid_logs'];
82                $data['total_amount'] = $this->paidlog_model->getPaidlogs($data)['total_amount'];
83               
[441]84        $data['paging_url'] = base_url() . "/admin/doanh_thu_tong_hop/trang/";
[422]85        $data['num_links'] = 2;
86        $data['paging'] = pagging($data);
[444]87        foreach ($data['paidlogs'] as $index => $paidlog) {
[503]88            $data['paidlogs'][$index]['username'] = @$this->get_fullname($paidlog['us_id']);
[442]89        }
[767]90               
[422]91        if ($this->input->is_ajax_request()) {
92            return $this->load->view('report/listview', $data);
93        }
94        return $this->load->view('report/listview', $data, true);
95    }
96
[503]97    private function get_fullname($us_id) {
98        $fullname="";
[444]99        $src = 'violet';
100        $token = md5($us_id . self::TOKENPW);
101        $this->load->model('user_model');
102        $data = $this->user_model->get_user_info($src, $us_id, $token);
[503]103        parse_str($data,$data);
104        if (isset($data['fullname']))
105        {
106            $fullname=$data['fullname'];
[422]107        }
[503]108        return $fullname;
[444]109    }
[422]110
111    public function test() {
[444]112
[479]113        /*
114          for ($i = 1; $i <= 5000; $i++) {
115          $input['us_id'] = rand(1, 100);
116          $input['paid_type'] = rand(1, 2);
117          $input['amount'] = rand(3, 10) * 1000;
118          $time = (rand((time() - (12 * 30 * 24 * 60 * 60)), time()));
119          $input['paid_time'] = date("Y-m-d H:i:s", $time);
120          $this->load->model('paidlog_model');
121          $this->paidlog_model->insert($input);
122          }
[444]123
[479]124          die();
125         */
[461]126        for ($i = 1; $i <= 200; $i++) {
[444]127            $input['us_id'] = $i;
128            $input['cellphone'] = "01234567" . (100 + $i);
129            $input['collaborator'] = rand(1, 100);
130            $input['acc_balanced'] = rand(100000, 1000000);
131            $input['expire_date'] = date("Y-m-d H:i:s", time());
[461]132            $time = (rand((time() - (12 * 30 * 24 * 60 * 60)), time()));
133            $input['created_time'] = date("Y-m-d H:i:s", $time);
134            $input['updated_time'] = date("Y-m-d H:i:s", $time);
[422]135            $this->load->model('user_model');
136            $this->user_model->insert($input);
137        }
138    }
139
140}
Note: See TracBrowser for help on using the repository browser.