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

Last change on this file since 624 was 594, checked in by quyenla, 10 years ago
File size: 4.1 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        }
[444]61
62        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
63        $data['total'] = $this->paidlog_model->countPaidlog($data);
[441]64        $data['paidlogs'] = $this->paidlog_model->getPaidlogs($data);
[422]65
[441]66        $data['paging_url'] = base_url() . "/admin/doanh_thu_tong_hop/trang/";
[422]67        $data['num_links'] = 2;
68        $data['paging'] = pagging($data);
[444]69        foreach ($data['paidlogs'] as $index => $paidlog) {
[503]70            $data['paidlogs'][$index]['username'] = @$this->get_fullname($paidlog['us_id']);
[442]71        }
[444]72
[422]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
[503]79    private function get_fullname($us_id) {
80        $fullname="";
[444]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);
[503]85        parse_str($data,$data);
86        if (isset($data['fullname']))
87        {
88            $fullname=$data['fullname'];
[422]89        }
[503]90        return $fullname;
[444]91    }
[422]92
93    public function test() {
[444]94
[479]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          }
[444]105
[479]106          die();
107         */
[461]108        for ($i = 1; $i <= 200; $i++) {
[444]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());
[461]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);
[422]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.