1 | <?php |
---|
2 | |
---|
3 | if (!defined('BASEPATH')) |
---|
4 | exit('No direct script access allowed'); |
---|
5 | |
---|
6 | class Reportprovince extends MX_Controller { |
---|
7 | |
---|
8 | const TOKENPW = 'violet'; |
---|
9 | |
---|
10 | public function __construct() { |
---|
11 | parent::__construct(); |
---|
12 | $this->load->helper('cookie'); |
---|
13 | $this->load->helper('language'); |
---|
14 | $this->lang->load('messages', 'message'); |
---|
15 | } |
---|
16 | |
---|
17 | public function index() { |
---|
18 | $data = array(); |
---|
19 | $admin_info = $this->session->userdata('adminInfo'); |
---|
20 | if ($admin_info) { |
---|
21 | $data['content'] = $this->getProvince(); |
---|
22 | $this->load->view('reportprovince/index', $data); |
---|
23 | } else { |
---|
24 | $this->load->view('login'); |
---|
25 | } |
---|
26 | |
---|
27 | } |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | public function getProvince($filters = array()) { |
---|
32 | |
---|
33 | $this->load->model('reportmodel'); |
---|
34 | $data['month']=date("m"); |
---|
35 | $data['year']=date("Y"); |
---|
36 | if ($this->input->post('month')) { |
---|
37 | $data['month']=$this->input->post('month'); |
---|
38 | $data['year']=$this->input->post('year'); |
---|
39 | } |
---|
40 | $data['month_days']=1; |
---|
41 | if("".$data['year']."-".$data['month'].""==date("Y-m")) |
---|
42 | { |
---|
43 | $data['month_days']=date("d"); |
---|
44 | } |
---|
45 | else |
---|
46 | { |
---|
47 | $data['month_days']=cal_days_in_month(CAL_GREGORIAN, $data['month'], $data['year']); // 31 |
---|
48 | } |
---|
49 | $data['year_days']=1; |
---|
50 | if($data['year']== date("Y")) |
---|
51 | { |
---|
52 | $data['year_days']=date('z') + 1; |
---|
53 | } |
---|
54 | else |
---|
55 | { |
---|
56 | $data['year_days']=date("z", mktime(0,0,0,12,31,$data['year'])) + 1; |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | $data['provinces'] = $this->reportmodel->getProvinces($data); |
---|
61 | |
---|
62 | foreach ($data['provinces'] as $index => $paidlog) { |
---|
63 | $data['provinces'][$index]['username'] = @$this->get_fullname($paidlog['us_id']); |
---|
64 | } |
---|
65 | |
---|
66 | if ($this->input->is_ajax_request()) { |
---|
67 | return $this->load->view('reportprovince/province', $data); |
---|
68 | } |
---|
69 | return $this->load->view('reportprovince/province', $data, true); |
---|
70 | } |
---|
71 | |
---|
72 | private function get_fullname($us_id) { |
---|
73 | $fullname=""; |
---|
74 | $src = 'violet'; |
---|
75 | $token = md5($us_id . self::TOKENPW); |
---|
76 | $this->load->model('user_model'); |
---|
77 | $data = $this->user_model->get_user_info($src, $us_id, $token); |
---|
78 | parse_str($data,$data); |
---|
79 | if (isset($data['fullname'])) |
---|
80 | { |
---|
81 | $fullname=$data['fullname']; |
---|
82 | } |
---|
83 | return $fullname; |
---|
84 | } |
---|
85 | |
---|
86 | public function test() { |
---|
87 | |
---|
88 | $provinces=lang('_PROVINCES_'); |
---|
89 | $sql="SELECT * FROM tbluser"; |
---|
90 | $query = $this->db->query ($sql); |
---|
91 | $result = $query->result_array(); |
---|
92 | foreach ($result as $user) |
---|
93 | { |
---|
94 | $p=$provinces[rand(0,62)]; |
---|
95 | $user['province']=$p; |
---|
96 | $this->db->where('us_id', $user['us_id']); |
---|
97 | $this->db->update('tbluser', $user); |
---|
98 | } |
---|
99 | } |
---|
100 | |
---|
101 | } |
---|