1 | <?php
|
---|
2 |
|
---|
3 | if (!defined('BASEPATH'))
|
---|
4 | exit('No direct script access allowed');
|
---|
5 |
|
---|
6 | class User 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 profile() {
|
---|
18 | $user_info = $this->session->userdata('userInfo');
|
---|
19 |
|
---|
20 | if ($user_info) {
|
---|
21 | $this->load->model('User_model');
|
---|
22 | $this->load->model('Servicepackage_model');
|
---|
23 | $user = $user_info['user'];
|
---|
24 | $us_id = $user_info['us_id'];
|
---|
25 | $src = "SBG";
|
---|
26 | $token = md5($us_id . self::TOKENPW);
|
---|
27 | $data = $this->get_data($src, $token, $us_id);
|
---|
28 | $data['can_edit'] = 0;
|
---|
29 | $u = $this->User_model->get_user_by_id($us_id);
|
---|
30 | if ($u['p_id'] < 1) {
|
---|
31 | $data['can_edit'] = 1;
|
---|
32 | }
|
---|
33 | if ($data['fullname']=="")
|
---|
34 | {
|
---|
35 | $data['can_edit'] = 1;
|
---|
36 | }
|
---|
37 | $data['current_tab'] = $this->uri->segment(4, 'edit-basic');
|
---|
38 | $data['packages'] = $this->Servicepackage_model->getAllPackages();
|
---|
39 | $data['is_viettel'] = isset($user_info['is_viettel']) ? $user_info['is_viettel']:FALSE;
|
---|
40 | $data['provinces'] = lang('_PROVINCES_');
|
---|
41 |
|
---|
42 | $data = (is_array($u)) ? array_merge($data, $u) : $data;
|
---|
43 | $data = (is_array($user_info)) ? array_merge($data, $user_info):$data;
|
---|
44 |
|
---|
45 | $this->load->view('frontend/user_profile', $data);
|
---|
46 | } else {
|
---|
47 | redirect('frontend/home');
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | public function packageRegister() {
|
---|
52 | $result = array();
|
---|
53 | $input = $this->input->post();
|
---|
54 | $this->load->model('user_model');
|
---|
55 | $user_info = $this->session->userdata('userInfo');
|
---|
56 | if ($user_info) {
|
---|
57 | parse_str($user_info['user'], $info);
|
---|
58 | $this->load->model('servicepackage_model');
|
---|
59 |
|
---|
60 | $package = $this->servicepackage_model->getPackage($input['p_id']);
|
---|
61 | $user = $user_info['user'];
|
---|
62 | $us_id = $user_info['us_id'];
|
---|
63 | $user = $this->user_model->get_user_by_id($us_id);
|
---|
64 | $result['can_buy'] = 1;
|
---|
65 | $result['can_edit'] = 0;
|
---|
66 |
|
---|
67 | if ($user['acc_balanced'] < $package['p_price']) {
|
---|
68 | $result['can_buy'] = 0;
|
---|
69 | }
|
---|
70 |
|
---|
71 | if(strtotime($user['expire_date'])<strtotime(date('Y-m-d'))){
|
---|
72 | $result['can_edit'] = 1;
|
---|
73 | }
|
---|
74 | if ($user['p_id'] < 1) {
|
---|
75 | $result['can_edit'] = 1;
|
---|
76 | }
|
---|
77 | if ($info['fullname']=="")
|
---|
78 | {
|
---|
79 | $result['can_edit'] = 1;
|
---|
80 | }
|
---|
81 | $result['info'] = $info;
|
---|
82 | $result['user'] = $user;
|
---|
83 | $result['package'] = $package;
|
---|
84 | $result['modal'] = $this->load->view('frontend/package_register_modal', $result, true);
|
---|
85 | } else {
|
---|
86 |
|
---|
87 | }
|
---|
88 | echo json_encode($result);
|
---|
89 | }
|
---|
90 |
|
---|
91 | public function finishRegisterPackage() {
|
---|
92 | $result = array();
|
---|
93 | $result['success'] = 0;
|
---|
94 | $this->load->model('user_model');
|
---|
95 | $input = $this->input->post();
|
---|
96 | //print_r($input);
|
---|
97 | $user_info = $this->session->userdata('userInfo');
|
---|
98 | parse_str($user_info['user'], $info);
|
---|
99 | if (isset($input['fullname'])) {
|
---|
100 | if (strlen($input['fullname']) < 1) {
|
---|
101 | $result['errors'][] = lang('_SBG_REGISTER_VIP_FULLNAME_REQUIRED_MSG');
|
---|
102 | }
|
---|
103 | if (strlen($input['school']) < 1) {
|
---|
104 | $result['errors'][] = lang('_SBG_REGISTER_VIP_SCHOOL_REQUIRED_MSG');
|
---|
105 | }
|
---|
106 | if (!isset($result['errors'])) {
|
---|
107 | $user_info = $this->session->userdata('userInfo');
|
---|
108 | if ($user_info) {
|
---|
109 |
|
---|
110 | $src = "SBG";
|
---|
111 | $us_id = $user_info['us_id'];
|
---|
112 | $input['password'] = '';
|
---|
113 | $input['oldpass'] = '';
|
---|
114 | $input['gender'] = '';
|
---|
115 | $input['email'] = '';
|
---|
116 | //$input['province'] = '';
|
---|
117 | $info['fullname'] = $input['fullname'];
|
---|
118 | $info['school'] = $input['school'];
|
---|
119 | $token = md5($us_id . self::TOKENPW);
|
---|
120 | $user = $this->get_data($src, $token, $us_id);
|
---|
121 | //$input['district'] = '';
|
---|
122 | if ($input) {
|
---|
123 | $this->load->model('user_model');
|
---|
124 | $update = $this->user_model->update_user($src, $token, $input, $us_id);
|
---|
125 | $info = urldecode(http_build_query($info));
|
---|
126 | $userdata = array('username' => $user_info['username'], 'user' => $info, 'us_id' => $user_info['us_id'], 'logined_in' => TRUE, 'is_viettel' => $user_info['is_viettel']);
|
---|
127 | $this->session->set_userdata('userInfo', $userdata);
|
---|
128 | }
|
---|
129 | }
|
---|
130 | }
|
---|
131 | }
|
---|
132 |
|
---|
133 | if (isset($result['errors'])) {
|
---|
134 | echo json_encode($result);
|
---|
135 | exit();
|
---|
136 | }
|
---|
137 |
|
---|
138 | $this->load->model('servicepackage_model');
|
---|
139 | $us_id = $user_info['us_id'];
|
---|
140 | //$user = $this->user_model->get_user_by_id($us_id);
|
---|
141 | $user = $this->user_model->getUserById($us_id);
|
---|
142 | $package = $this->servicepackage_model->getPackage($input['p_id']);
|
---|
143 | $user['acc_balanced'] = $user['acc_balanced'] - $package['p_price'];
|
---|
144 |
|
---|
145 | $today_dt = new DateTime(date('Y-m-d 00:00:00'));
|
---|
146 | $expire_dt = new DateTime($user['expire_date']);
|
---|
147 |
|
---|
148 | $currentExpireDate = $user['expire_date'] == NULL || trim($user['expire_date']) == '' || $today_dt > $expire_dt ? date('Y-m-d 00:00:00') : $user['expire_date'];
|
---|
149 | $user['expire_date'] = date('Y-m-d', strtotime("+" . $package['p_period'] . " ".$package['p_unit'], strtotime($currentExpireDate)));
|
---|
150 | $user['p_id'] = $package['p_id'];
|
---|
151 | $user['province'] = $input['province'];
|
---|
152 | $this->user_model->updateUser($us_id, $user);
|
---|
153 | $user['expire_date'] = date("d-m-Y", (strtotime($user['expire_date'])));
|
---|
154 | $result['expire_date'] = $user['expire_date'];
|
---|
155 | $result['success'] = 1;
|
---|
156 | $message = str_replace(':period:', date("d/m/Y", (strtotime($user['expire_date']))), lang('_SBG_REGISTER_VIP_SUCCESS_MSG'));
|
---|
157 | $result['message'] = $message;
|
---|
158 |
|
---|
159 | $toDate = date("Y-m-d", (strtotime($result['expire_date'])));
|
---|
160 | $this->user_model->insertRegisterVipLog($user['cellphone'],$package['p_code'], false);
|
---|
161 | echo json_encode($result);
|
---|
162 | }
|
---|
163 |
|
---|
164 | public function regpackage() {
|
---|
165 | $user_info = $this->session->userdata('userInfo');
|
---|
166 | parse_str($user_info['user'], $info);
|
---|
167 | $p_id = $this->input->post('p_id', TRUE);
|
---|
168 |
|
---|
169 | $us_id = (int) $info['id'];
|
---|
170 | $this->load->model('servicepackage_model');
|
---|
171 | $this->load->model('user_model');
|
---|
172 |
|
---|
173 | $user = $this->user_model->get_user_by_id($us_id);
|
---|
174 | $package = $this->servicepackage_model->getPackage($p_id);
|
---|
175 |
|
---|
176 | if ($user['acc_balanced'] < $package['p_price']) {
|
---|
177 | $aryPatterns = array('/:acc_balanced:/');
|
---|
178 | $message = preg_replace($aryPatterns, array(number_format($user['acc_balanced'], 0)), lang('_SBG_ACC_BALANCE_LESS_PACKAGE_PRICE_MSG'));
|
---|
179 | } else {
|
---|
180 | $user['acc_balanced'] = $user['acc_balanced'] - $package['p_price'];
|
---|
181 |
|
---|
182 | $today_dt = new DateTime(date('Y-m-d 00:00:00'));
|
---|
183 | $expire_dt = new DateTime($user['expire_date']);
|
---|
184 |
|
---|
185 | $currentExpireDate = $user['expire_date'] == NULL || trim($user['expire_date']) == '' || $today_dt > $expire_dt ? date('Y-m-d 00:00:00') : $user['expire_date'];
|
---|
186 |
|
---|
187 | $user['expire_date'] = date('Y-m-d', strtotime("+" . $package['p_period'] . " " . $package['p_unit'], strtotime($currentExpireDate)));
|
---|
188 | //$user['expire_date'] = date("Y-m-d", (strtotime($user['expire_date']) - 1));
|
---|
189 |
|
---|
190 | $user['p_id'] = $package['p_id'];
|
---|
191 |
|
---|
192 | $this->user_model->updateUser($us_id, $user);
|
---|
193 | $aryPatterns = array('/:period:/');
|
---|
194 | $message = preg_replace($aryPatterns, array(date('d-m-Y', strtotime($user['expire_date']))), lang('_SBG_REGISTER_VIP_SUCCESS_MS'));
|
---|
195 | $this->user_model->insertRegisterVipLog($user['cellphone'], $package['p_code'], false);
|
---|
196 | }
|
---|
197 |
|
---|
198 | $this->session->set_flashdata('message', $message);
|
---|
199 | redirect('frontend/user/profile#services-register');
|
---|
200 | }
|
---|
201 |
|
---|
202 | private function get_data($src, $token, $us_id) {
|
---|
203 | $this->load->model('user_model');
|
---|
204 | $user = $this->user_model->get_user_info($src, $token, $us_id);
|
---|
205 |
|
---|
206 | if (strpos($user, '&')) {
|
---|
207 | parse_str($user);
|
---|
208 | $us = $this->user_model->get_user_by_id($us_id);
|
---|
209 | $data = array('us_id' => $us_id, 'username' => $username, 'fullname' => $fullname,
|
---|
210 | 'gender' => $gender, 'email' => $email, 'phone' => $phone, 'school' => $school, 'province' => $province,
|
---|
211 | 'acc_balanced' => $us['acc_balanced'], 'expire_date' => $us['expire_date'], 'date_diff' => $this->dateDiff($us['expire_date'])
|
---|
212 | );
|
---|
213 | return $data;
|
---|
214 | } else {
|
---|
215 | return "";
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | private function dateDiff($expire_date) {
|
---|
220 | $date1 = date("Y-m-d");
|
---|
221 | if ((strtotime($expire_date) - strtotime($date1)) < 0)
|
---|
222 | return "0 ngà y còn lại";
|
---|
223 | $diff = strtotime($expire_date) - strtotime($date1);
|
---|
224 | $years = floor($diff / (365 * 60 * 60 * 24));
|
---|
225 | $months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));
|
---|
226 | $days = floor(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24) / (60 * 60 * 24));
|
---|
227 | if ($years > 0) {
|
---|
228 | return $years . " nÄm, " . $months . " tháng, " . $days . " ngà y còn lại";
|
---|
229 | } else {
|
---|
230 | if ($months > 0) {
|
---|
231 | return $months . " tháng, " . $days . " ngà y còn lại";
|
---|
232 | } else {
|
---|
233 | return $days . " ngà y còn lại";
|
---|
234 | }
|
---|
235 | }
|
---|
236 | }
|
---|
237 |
|
---|
238 | public function update_info() {
|
---|
239 | $result['success'] = 0;
|
---|
240 | $user_info = $this->session->userdata('userInfo');
|
---|
241 | if ($user_info) {
|
---|
242 | $us_id = $user_info['us_id'];
|
---|
243 | $result = array();
|
---|
244 | $result['success'] = 0;
|
---|
245 | $src = "SBG";
|
---|
246 | $token = md5($us_id . self::TOKENPW);
|
---|
247 | $user = $this->get_data($src, $token, $us_id);
|
---|
248 | $input = $this->input->post();
|
---|
249 | parse_str($user_info['user'], $info);
|
---|
250 | if ($input) {
|
---|
251 | if (array_key_exists('fullname', $input)) {
|
---|
252 | if (strlen($input['fullname']) == 0) {
|
---|
253 | $result['errors'][] = array("content"=>lang('_SBG_FULLNAME_REQUIRED_MSG'),"field"=>"fullname");
|
---|
254 | }
|
---|
255 | }else{
|
---|
256 | $input['fullname'] = $user['fullname'];
|
---|
257 | }
|
---|
258 | if (strlen($input['school']) == 0) {
|
---|
259 | $result['errors'][] = array("content"=>lang('_SBG_REGISTER_VIP_SCHOOL_REQUIRED_MSG'),"field"=>"school");
|
---|
260 | }
|
---|
261 | if (strlen($input['province']) == 0) {
|
---|
262 | $result['errors'][] = array("content"=>lang('_SBG_PROVINCE_REQUIRED_MSG'),"field"=>"province");
|
---|
263 | }
|
---|
264 | $input['password'] = '';
|
---|
265 | $input['oldpass'] = '';
|
---|
266 | $this->load->model('user_model');
|
---|
267 | if (!isset($result['errors'])) {
|
---|
268 | $result['data'] = $this->user_model->update_user($src, $token, $input, $us_id);
|
---|
269 | $result['success'] = 1;
|
---|
270 | $info['fullname'] = $input['fullname'];
|
---|
271 | $info['school'] = $input['school'];
|
---|
272 | $info = urldecode(http_build_query($info));
|
---|
273 | $userdata = array('username' => $user_info['username'], 'user' => $info, 'us_id' => $user_info['us_id'], 'logined_in' => TRUE, 'is_viettel' => $user_info['is_viettel']);
|
---|
274 | $this->session->set_userdata('userInfo', $userdata);
|
---|
275 | }
|
---|
276 | echo json_encode($result);
|
---|
277 | }
|
---|
278 | } else {
|
---|
279 | redirect('frontend/home');
|
---|
280 | }
|
---|
281 | }
|
---|
282 |
|
---|
283 | public function update_user() {
|
---|
284 | $us_id = $this->uri->segment(4);
|
---|
285 | $user_info = $this->session->userdata('userInfo');
|
---|
286 | if ($user_info) {
|
---|
287 | $result = array();
|
---|
288 | $result['success'] = 0;
|
---|
289 | $src = "SBG";
|
---|
290 | $token = md5($us_id . self::TOKENPW);
|
---|
291 | $user = $this->get_data($src, $token, $us_id);
|
---|
292 | $input = $this->input->post();
|
---|
293 | if ($input) {
|
---|
294 | $input['username'] = $user['username'];
|
---|
295 | if (array_key_exists('fullname', $input)) {
|
---|
296 | if (strlen($input['fullname']) == 0) {
|
---|
297 | $result['errors']['fullname_err'] = lang('_SBG_FULLNAME_REQUIRED_MSG');
|
---|
298 | }
|
---|
299 | } else {
|
---|
300 | $input['fullname'] = $user['fullname'];
|
---|
301 | }
|
---|
302 |
|
---|
303 | $input['password'] = '';
|
---|
304 | $input['oldpass'] = '';
|
---|
305 | $this->load->model('user_model');
|
---|
306 | if (!isset($result['errors'])) {
|
---|
307 | $result['data'] = $this->user_model->update_user($src, $token, $input, $us_id);
|
---|
308 | $result['success'] = 1;
|
---|
309 | }
|
---|
310 | echo json_encode($result);
|
---|
311 | }
|
---|
312 | } else {
|
---|
313 | redirect('frontend/home');
|
---|
314 | }
|
---|
315 | }
|
---|
316 |
|
---|
317 | public function change_password() {
|
---|
318 | $us_id = $this->uri->segment(4);
|
---|
319 | $user_info = $this->session->userdata('userInfo');
|
---|
320 | if ($user_info) {
|
---|
321 | $this->load->model('user_model');
|
---|
322 | $us_id = $user_info['us_id'];
|
---|
323 | $src = "SBG";
|
---|
324 | $token = md5($us_id . self::TOKENPW);
|
---|
325 | $input = $this->input->post();
|
---|
326 |
|
---|
327 | if (strlen($input['passwd']) == 0) {
|
---|
328 | $result['errors']['passwd_old_err'] = lang('_SBG_PASSWORD_REQUIRED_MSG');
|
---|
329 | }
|
---|
330 |
|
---|
331 | if (strlen($input['passwd_new']) == 0) {
|
---|
332 | $result['errors']['passwd_new_err'] = lang('_SBG_PASSWORD_REQUIRED_MSG');
|
---|
333 | } else if (strcmp($input['passwd'], $input['passwd_new']) == 0) {
|
---|
334 | $result['errors']['passwd_new_err'] = lang('_SBG_PASSWORD_DUPLICATE_MSG');
|
---|
335 | }else
|
---|
336 | {
|
---|
337 | if (!preg_match('/^([0-9a-zA-Z]{6,65})*$/', $input['passwd_new']))
|
---|
338 | {
|
---|
339 | $result['errors']['passwd_new_err'] = lang('_SBG_USER_PASSWORD_CHANGE_REQUIRED_MSG');
|
---|
340 | }
|
---|
341 | }
|
---|
342 |
|
---|
343 | if ($input['passwd_new'] != $input['confirm_passwd_new']) {
|
---|
344 | $result['errors']['confirm_passwd_new_err'] = lang('_SBG_PASSWORD_CONFIRM_MSG');
|
---|
345 | }
|
---|
346 |
|
---|
347 | if (!isset($result['errors'])) {
|
---|
348 | $user = array('username' => $user_info['username'], 'fullname' => null, 'gender' => null, 'email' => null, 'school' => null, 'province' => null, 'password' => $input['passwd_new'], 'oldpass' => $input['passwd']);
|
---|
349 | $data = $this->user_model->update_user($src, $token, $user, $us_id);
|
---|
350 | parse_str($data);
|
---|
351 | error_log('API return ---- Data: '. var_export($data, TRUE). "\n", 3, '/srv/www/sbg/log/changepass.log');
|
---|
352 | switch ((int)$status) {
|
---|
353 | case 0:
|
---|
354 | $result['success'] = 1;
|
---|
355 | break;
|
---|
356 | case 6:
|
---|
357 | $result['errors']['passwd_old_err'] = lang('_SBG_OLD_PASSWORD_FAIL_MSG');
|
---|
358 | break;
|
---|
359 | default:
|
---|
360 | break;
|
---|
361 | }
|
---|
362 | }
|
---|
363 |
|
---|
364 | echo json_encode($result);
|
---|
365 | } else {
|
---|
366 | redirect('frontend/home');
|
---|
367 | }
|
---|
368 | }
|
---|
369 |
|
---|
370 | public function trade_history()
|
---|
371 | {
|
---|
372 | $this->load->helper('pagging');
|
---|
373 | $us_id = $this->uri->segment(4);
|
---|
374 |
|
---|
375 | $user_info = $this->session->userdata('userInfo');
|
---|
376 | $admin_info = $this->session->userdata('adminInfo');
|
---|
377 |
|
---|
378 | if ($user_info || $admin_info)
|
---|
379 | {
|
---|
380 | $data['us_id'] = $us_id;
|
---|
381 | $data['perpage'] = 10;
|
---|
382 | $data['current_page'] = $this->uri->segment(6, 1);
|
---|
383 | $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
|
---|
384 | $this->load->model('user_model');
|
---|
385 | $result = $this->user_model->getPaidlog($data);
|
---|
386 | $data['total'] = $this->user_model->countPaiglogs($us_id);
|
---|
387 | $data['num_links'] = 2;
|
---|
388 | $data['paging_url'] = base_url() . "frontend/user/trade_history/".$us_id."/page/";
|
---|
389 | $data['paging'] = pagging($data);
|
---|
390 | $paidlogs = array();
|
---|
391 | foreach ($result as $paidlog):
|
---|
392 | $paidlog['amount'] = number_format($paidlog['amount'], 0);
|
---|
393 | $paidlog['paid_time'] = date('d/m/Y H:i:s', strtotime($paidlog['paid_time']));
|
---|
394 | array_push($paidlogs, $paidlog);
|
---|
395 | endforeach;
|
---|
396 | $data['paidlogs'] = $paidlogs;
|
---|
397 | echo json_encode($data);
|
---|
398 | }else {
|
---|
399 | redirect('frontend/home');
|
---|
400 | }
|
---|
401 | }
|
---|
402 | public function getUserInfor()
|
---|
403 | {
|
---|
404 | $this->load->model('User_model');
|
---|
405 | $data=array();
|
---|
406 | $us_id = $this->uri->segment(4);
|
---|
407 | $src = "SBG";
|
---|
408 | $token = md5($us_id . self::TOKENPW);
|
---|
409 | $user = $this->User_model->get_user_info($src, $token, $us_id);
|
---|
410 | parse_str($user,$user);
|
---|
411 | $local=$this->User_model->get_user_by_id($us_id);
|
---|
412 | $data['user']= array_merge($user,$local);
|
---|
413 | $this->lang->load('messages', 'message');
|
---|
414 | $admin=$this->session->userdata('adminInfo');
|
---|
415 | $roles=array();
|
---|
416 | foreach ($admin['roles'] as $role)
|
---|
417 | {
|
---|
418 | $roles[]=$role['role_name'];
|
---|
419 | }
|
---|
420 | $data['roles']=$roles;
|
---|
421 | $data['provinces'] = lang('_PROVINCES_');
|
---|
422 | $result['modal']=$this->load->view('frontend/user_infor', $data, TRUE);
|
---|
423 | echo json_encode($result);
|
---|
424 |
|
---|
425 | }
|
---|
426 | public function adminUpdateUser()
|
---|
427 | {
|
---|
428 | $this->load->model('User_model');
|
---|
429 | $input=$input = $this->input->post();
|
---|
430 | $us_id=$input["us_id"];
|
---|
431 | $src = "SBG";
|
---|
432 | $token = md5($us_id . self::TOKENPW);
|
---|
433 | $api['fullname']=$input['fullname'];
|
---|
434 | $api['school']=$input['school'];
|
---|
435 | $local['district']=$input['district'];
|
---|
436 | $local['province']=$input['province'];
|
---|
437 | $update = $this->User_model->update_user($src, $token, $api, $us_id);
|
---|
438 | $this->User_model->update_local_user($local,$us_id);
|
---|
439 | $result['success']=1;
|
---|
440 | echo json_encode($result);
|
---|
441 | }
|
---|
442 | public function regis_history()
|
---|
443 | {
|
---|
444 | $this->load->helper('pagging');
|
---|
445 | $us_id = $this->uri->segment(4);
|
---|
446 | $this->load->model('user_model');
|
---|
447 | $user = $this->user_model->get_user_by_id($us_id);
|
---|
448 | $username = $user['cellphone'];
|
---|
449 | $user_info = $this->session->userdata('userInfo');
|
---|
450 | $admin_info = $this->session->userdata('adminInfo');
|
---|
451 | if ($user_info || $admin_info)
|
---|
452 | {
|
---|
453 | $data['username'] = $username;
|
---|
454 | $data['perpage'] = 10;
|
---|
455 | $data['current_page'] = $this->uri->segment(6, 1);
|
---|
456 | $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
|
---|
457 | $this->load->model('user_model');
|
---|
458 | $result = $this->user_model->getPackagelog($data);
|
---|
459 | $data['total'] = $this->user_model->countPackagelogs($username);
|
---|
460 | $data['num_links'] = 2;
|
---|
461 | $data['paging_url'] = base_url() . "frontend/user/regis_history/".$us_id."/page/";
|
---|
462 | $data['paging'] = pagging($data);
|
---|
463 | $packagelogs = array();
|
---|
464 | foreach ($result as $packagelog):
|
---|
465 | $packagelog['created_time'] = date('d/m/Y H:i:s', strtotime($packagelog['created_time']));
|
---|
466 | array_push($packagelogs, $packagelog);
|
---|
467 | endforeach;
|
---|
468 | $data['packagelogs'] = $packagelogs;
|
---|
469 | echo json_encode($data);
|
---|
470 | }else
|
---|
471 | {
|
---|
472 | redirect('frontend/home');
|
---|
473 | }
|
---|
474 |
|
---|
475 | }
|
---|
476 |
|
---|
477 | }
|
---|