1 | <?php |
---|
2 | |
---|
3 | if (!defined('BASEPATH')) |
---|
4 | exit('No direct script access allowed'); |
---|
5 | |
---|
6 | class Report extends MX_Controller { |
---|
7 | |
---|
8 | public function __construct() { |
---|
9 | parent::__construct(); |
---|
10 | $this->load->helper('cookie'); |
---|
11 | } |
---|
12 | |
---|
13 | public function index() { |
---|
14 | $data = array(); |
---|
15 | $admin_info = $this->session->userdata('adminInfo'); |
---|
16 | if ($admin_info) { |
---|
17 | $data['statistics'] = $this->getStatistics(); |
---|
18 | $data['content'] = $this->getSmstemplates(); |
---|
19 | $this->load->view('report/index', $data); |
---|
20 | } else { |
---|
21 | $this->load->view('login'); |
---|
22 | } |
---|
23 | } |
---|
24 | public function getStatistics() |
---|
25 | { |
---|
26 | $data=array(); |
---|
27 | return $this->load->view('report/statistics', $data, true); |
---|
28 | } |
---|
29 | public function getSmstemplates($filters = array()) { |
---|
30 | $this->load->helper('pagging'); |
---|
31 | $this->load->model('paidlog_model'); |
---|
32 | $data['current_page'] = $this->uri->segment(4, 1); |
---|
33 | $data['itemsoptions'] = array(10, 25, 50, 100); |
---|
34 | $data['perpage'] = 10; |
---|
35 | $data['keyword'] = ""; |
---|
36 | $data['sorting_order']="sorting_desc"; |
---|
37 | $data['sorting_field']="paid_id"; |
---|
38 | |
---|
39 | if ($this->input->post('sorting_order')) { |
---|
40 | if ($this->input->post('sorting_order') != "sorting") |
---|
41 | { |
---|
42 | $data['sorting_order']=$this->input->post('sorting_order'); |
---|
43 | $data['sorting_field']=$this->input->post('sorting_field'); |
---|
44 | } |
---|
45 | } |
---|
46 | if ($this->input->post('items')) { |
---|
47 | $data['perpage'] = $this->input->post('items'); |
---|
48 | } |
---|
49 | if ($this->input->post('keyword')) { |
---|
50 | $data['search_field']=""; |
---|
51 | $data['keyword'] = $this->input->post('keyword'); |
---|
52 | |
---|
53 | if (preg_match("/[0-9]/", $data['keyword'])) |
---|
54 | { |
---|
55 | $data['search_field']="cellphone"; |
---|
56 | } |
---|
57 | |
---|
58 | } |
---|
59 | |
---|
60 | $data['start'] = ($data['current_page'] - 1) * $data['perpage']; |
---|
61 | $data['total'] = $this->paidlog_model->countSmstemplate($data); |
---|
62 | |
---|
63 | $data['paidlogs'] = $this->paidlog_model->getSmstemplates($data); |
---|
64 | |
---|
65 | $data['paging_url'] = base_url() . "/admin/mau_tin_nhan/trang/"; |
---|
66 | $data['num_links'] = 2; |
---|
67 | $data['paging'] = pagging($data); |
---|
68 | |
---|
69 | if ($this->input->is_ajax_request()) { |
---|
70 | return $this->load->view('report/listview', $data); |
---|
71 | } |
---|
72 | return $this->load->view('report/listview', $data, true); |
---|
73 | } |
---|
74 | |
---|
75 | public function addSmstemplate() { |
---|
76 | $result['success'] = 0; |
---|
77 | $result = array(); |
---|
78 | $input = $this->input->post(); |
---|
79 | $this->load->model('paidlog_model'); |
---|
80 | if (strlen($input['sms_content'])==0) |
---|
81 | { |
---|
82 | $result['errors'][]="Ná»i dung tin nhắn khÃŽng ÄÆ°á»£c Äá» trá»ng"; |
---|
83 | } |
---|
84 | if (strlen($input['sms_reply'])==0) |
---|
85 | { |
---|
86 | $result['errors'][]="Tin nhắn trả vá» khÃŽng ÄÆ°á»£c Äá» trá»ng"; |
---|
87 | } |
---|
88 | else |
---|
89 | { |
---|
90 | /* |
---|
91 | if ($this->paidlog_model->isExist(array('field'=>'login_name','value'=>$input['login_name'],'id'=>$input['id']))) |
---|
92 | { |
---|
93 | $result['errors'][]="Tên ÄÄng nháºp Äã ÄÆ°á»£c sá» dụng"; |
---|
94 | } |
---|
95 | * |
---|
96 | */ |
---|
97 | } |
---|
98 | if (strlen($input['service_id'])==0) |
---|
99 | { |
---|
100 | $result['errors'][]="Mã dá»ch vụ khÃŽng ÄÆ°á»£c Äá» trá»ng"; |
---|
101 | } |
---|
102 | else |
---|
103 | { |
---|
104 | /* |
---|
105 | if ($this->paidlog_model->isExist(array('field'=>'cellphone','value'=>$input['cellphone'],'id'=>$input['id']))) |
---|
106 | { |
---|
107 | $result['errors'][]="Sá» Äiá»n thoại Äã ÄÆ°á»£c sá» dụng"; |
---|
108 | } |
---|
109 | * |
---|
110 | */ |
---|
111 | } |
---|
112 | if (!isset($result['errors'])) |
---|
113 | { |
---|
114 | $this->load->model('paidlog_model'); |
---|
115 | $this->paidlog_model->insert($input); |
---|
116 | $result['success'] = 1; |
---|
117 | } |
---|
118 | |
---|
119 | |
---|
120 | echo json_encode($result); |
---|
121 | } |
---|
122 | public function viewSms() |
---|
123 | { |
---|
124 | $id=$this->uri->segment(4); |
---|
125 | $this->load->model('paidlog_model'); |
---|
126 | $data=$this->paidlog_model->getSmstemplate($id); |
---|
127 | $this->load->view('report/viewSms',$data); |
---|
128 | } |
---|
129 | public function editSms() |
---|
130 | { |
---|
131 | $id=$this->uri->segment(4); |
---|
132 | $this->load->model('paidlog_model'); |
---|
133 | $data=$this->paidlog_model->getSmstemplate($id); |
---|
134 | $this->load->view('report/editSms',$data); |
---|
135 | } |
---|
136 | public function dodeleteSms() |
---|
137 | { |
---|
138 | $input=$this->input->post(); |
---|
139 | $id=$input['sms_id']; |
---|
140 | $this->load->model('paidlog_model'); |
---|
141 | $data=$this->paidlog_model->delete($id); |
---|
142 | $result['success']=1; |
---|
143 | echo json_encode($result); |
---|
144 | } |
---|
145 | public function deleteSms() |
---|
146 | { |
---|
147 | $id=$this->uri->segment(4); |
---|
148 | $this->load->model('paidlog_model'); |
---|
149 | $data=$this->paidlog_model->getSmstemplate($id); |
---|
150 | $this->load->view('report/deleteSms',$data); |
---|
151 | } |
---|
152 | public function updateSms() |
---|
153 | { |
---|
154 | |
---|
155 | $input= $this->input->post(); |
---|
156 | $this->load->model('paidlog_model'); |
---|
157 | if (strlen($input['sms_content'])==0) |
---|
158 | { |
---|
159 | $result['errors'][]="Ná»i dung tin nhắn khÃŽng ÄÆ°á»£c Äá» trá»ng"; |
---|
160 | } |
---|
161 | if (strlen($input['sms_reply'])==0) |
---|
162 | { |
---|
163 | $result['errors'][]="Tin nhắn trả vá» khÃŽng ÄÆ°á»£c Äá» trá»ng"; |
---|
164 | } |
---|
165 | else |
---|
166 | { |
---|
167 | /* |
---|
168 | if ($this->paidlog_model->isExist(array('field'=>'login_name','value'=>$input['login_name'],'id'=>$input['id']))) |
---|
169 | { |
---|
170 | $result['errors'][]="Tên ÄÄng nháºp Äã ÄÆ°á»£c sá» dụng"; |
---|
171 | } |
---|
172 | * |
---|
173 | */ |
---|
174 | } |
---|
175 | if (strlen($input['service_id'])==0) |
---|
176 | { |
---|
177 | $result['errors'][]="Mã dá»ch vụ khÃŽng ÄÆ°á»£c Äá» trá»ng"; |
---|
178 | } |
---|
179 | else |
---|
180 | { |
---|
181 | /* |
---|
182 | if ($this->paidlog_model->isExist(array('field'=>'cellphone','value'=>$input['cellphone'],'id'=>$input['id']))) |
---|
183 | { |
---|
184 | $result['errors'][]="Sá» Äiá»n thoại Äã ÄÆ°á»£c sá» dụng"; |
---|
185 | } |
---|
186 | * |
---|
187 | */ |
---|
188 | } |
---|
189 | |
---|
190 | if (!isset($result['errors'])) |
---|
191 | { |
---|
192 | $this->load->model('paidlog_model'); |
---|
193 | $this->paidlog_model->update($input['sms_id'],$input); |
---|
194 | $result['success'] = 1; |
---|
195 | } |
---|
196 | echo json_encode($result); |
---|
197 | } |
---|
198 | public function test() { |
---|
199 | |
---|
200 | /* |
---|
201 | for ($i = 1; $i <= 1500; $i++) { |
---|
202 | $input['us_id']=rand(1,100); |
---|
203 | $input['paid_type']=rand(1,2); |
---|
204 | $input['amount']=rand(3,10)*1000; |
---|
205 | $time=(rand((time()-(5*30*24*60*60)),time())); |
---|
206 | $input['paid_time']= date("Y-m-d H:i:s",$time); |
---|
207 | $this->load->model('paidlog_model'); |
---|
208 | $this->paidlog_model->insert($input); |
---|
209 | } |
---|
210 | * |
---|
211 | */ |
---|
212 | for ($i = 1; $i <= 100; $i++) { |
---|
213 | $input['us_id']=$i; |
---|
214 | $input['cellphone']="01234567".(100+$i); |
---|
215 | $input['collaborator']=rand(1,100); |
---|
216 | $input['acc_balanced']=rand(100000,1000000); |
---|
217 | $input['expire_date']=date("Y-m-d H:i:s",time()); |
---|
218 | $input['created_time']=date("Y-m-d H:i:s",time()); |
---|
219 | $input['updated_time']=date("Y-m-d H:i:s",time()); |
---|
220 | $this->load->model('user_model'); |
---|
221 | $this->user_model->insert($input); |
---|
222 | } |
---|
223 | } |
---|
224 | |
---|
225 | } |
---|