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