[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');
|
---|
[707] | 19 |
|
---|
[503] | 20 | if ($user_info) {
|
---|
[691] | 21 | $this->load->model('User_model');
|
---|
| 22 | $this->load->model('Servicepackage_model');
|
---|
[503] | 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);
|
---|
[706] | 28 | $data['can_edit'] = 0;
|
---|
[691] | 29 | $u = $this->User_model->get_user_by_id($us_id);
|
---|
[706] | 30 | if ($u['p_id'] < 1) {
|
---|
| 31 | $data['can_edit'] = 1;
|
---|
| 32 | }
|
---|
| 33 | if ($data['fullname']=="")
|
---|
| 34 | {
|
---|
| 35 | $data['can_edit'] = 1;
|
---|
| 36 | }
|
---|
[508] | 37 | $data['current_tab'] = $this->uri->segment(4, 'edit-basic');
|
---|
[691] | 38 | $data['packages'] = $this->Servicepackage_model->getAllPackages();
|
---|
| 39 | $data['is_viettel'] = isset($user_info['is_viettel']) ? $user_info['is_viettel']:FALSE;
|
---|
[701] | 40 | $data['provinces'] = lang('_PROVINCES_');
|
---|
| 41 |
|
---|
[691] | 42 | $data = (is_array($u)) ? array_merge($data, $u) : $data;
|
---|
| 43 | $data = (is_array($user_info)) ? array_merge($data, $user_info):$data;
|
---|
[559] | 44 |
|
---|
[503] | 45 | $this->load->view('frontend/user_profile', $data);
|
---|
[508] | 46 | } else {
|
---|
[503] | 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');
|
---|
[508] | 59 |
|
---|
[503] | 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 | if ($user['acc_balanced'] < $package['p_price']) {
|
---|
| 67 | $result['can_buy'] = 0;
|
---|
| 68 | }
|
---|
[580] | 69 |
|
---|
[706] | 70 | if(strtotime($user['expire_date'])<strtotime(date('Y-m-d'))){
|
---|
| 71 | $result['can_edit'] = 1;
|
---|
| 72 | }
|
---|
[503] | 73 | if ($user['p_id'] < 1) {
|
---|
| 74 | $result['can_edit'] = 1;
|
---|
| 75 | }
|
---|
[580] | 76 | if ($info['fullname']=="")
|
---|
| 77 | {
|
---|
| 78 | $result['can_edit'] = 1;
|
---|
| 79 | }
|
---|
[503] | 80 | $result['info'] = $info;
|
---|
| 81 | $result['user'] = $user;
|
---|
| 82 | $result['package'] = $package;
|
---|
| 83 | $result['modal'] = $this->load->view('frontend/package_register_modal', $result, true);
|
---|
| 84 | } else {
|
---|
| 85 |
|
---|
| 86 | }
|
---|
| 87 | echo json_encode($result);
|
---|
| 88 | }
|
---|
[554] | 89 |
|
---|
[503] | 90 | public function finishRegisterPackage() {
|
---|
| 91 | $result = array();
|
---|
| 92 | $result['success'] = 0;
|
---|
| 93 | $this->load->model('user_model');
|
---|
| 94 | $input = $this->input->post();
|
---|
[701] | 95 | //print_r($input);
|
---|
[503] | 96 | $user_info = $this->session->userdata('userInfo');
|
---|
[508] | 97 | parse_str($user_info['user'], $info);
|
---|
[503] | 98 | if (isset($input['fullname'])) {
|
---|
[548] | 99 | if (strlen($input['fullname']) < 1) {
|
---|
[636] | 100 | $result['errors'][] = lang('_SBG_REGISTER_VIP_FULLNAME_REQUIRED_MSG');
|
---|
[503] | 101 | }
|
---|
[548] | 102 | if (strlen($input['school']) < 1) {
|
---|
[636] | 103 | $result['errors'][] = lang('_SBG_REGISTER_VIP_SCHOOL_REQUIRED_MSG');
|
---|
[503] | 104 | }
|
---|
| 105 | if (!isset($result['errors'])) {
|
---|
[490] | 106 | $user_info = $this->session->userdata('userInfo');
|
---|
[503] | 107 | if ($user_info) {
|
---|
[508] | 108 |
|
---|
[503] | 109 | $src = "SBG";
|
---|
[508] | 110 | $us_id = $user_info['us_id'];
|
---|
[503] | 111 | $input['password'] = '';
|
---|
| 112 | $input['oldpass'] = '';
|
---|
| 113 | $input['gender'] = '';
|
---|
[508] | 114 | $input['email'] = '';
|
---|
[701] | 115 | //$input['province'] = '';
|
---|
[508] | 116 | $info['fullname'] = $input['fullname'];
|
---|
| 117 | $info['school'] = $input['school'];
|
---|
[503] | 118 | $token = md5($us_id . self::TOKENPW);
|
---|
| 119 | $user = $this->get_data($src, $token, $us_id);
|
---|
[701] | 120 | //$input['district'] = '';
|
---|
[503] | 121 | if ($input) {
|
---|
[490] | 122 | $this->load->model('user_model');
|
---|
[503] | 123 | $update = $this->user_model->update_user($src, $token, $input, $us_id);
|
---|
[508] | 124 | $info = urldecode(http_build_query($info));
|
---|
[554] | 125 | $userdata = array('username' => $user_info['username'], 'user' => $info, 'us_id' => $user_info['us_id'], 'logined_in' => TRUE, 'is_viettel' => $user_info['is_viettel']);
|
---|
[503] | 126 | $this->session->set_userdata('userInfo', $userdata);
|
---|
| 127 | }
|
---|
| 128 | }
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
[647] | 131 |
|
---|
[503] | 132 | if (isset($result['errors'])) {
|
---|
[554] | 133 | echo json_encode($result);
|
---|
[647] | 134 | exit();
|
---|
[503] | 135 | }
|
---|
[647] | 136 |
|
---|
[503] | 137 | $this->load->model('servicepackage_model');
|
---|
| 138 | $us_id = $user_info['us_id'];
|
---|
[700] | 139 | //$user = $this->user_model->get_user_by_id($us_id);
|
---|
| 140 | $user = $this->user_model->getUserById($us_id);
|
---|
[503] | 141 | $package = $this->servicepackage_model->getPackage($input['p_id']);
|
---|
[508] | 142 | $user['acc_balanced'] = $user['acc_balanced'] - $package['p_price'];
|
---|
[556] | 143 |
|
---|
| 144 | $currentExpireDate = $user['expire_date'] == NULL || trim($user['expire_date']) == '' ? date('Y-m-d 00:00:00') : $user['expire_date'];
|
---|
| 145 | $user['expire_date'] = date('Y-m-d', strtotime("+" . $package['p_period'] . " ".$package['p_unit'], strtotime($currentExpireDate)));
|
---|
[508] | 146 | $user['p_id'] = $package['p_id'];
|
---|
[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) {
|
---|
[717] | 243 | if (array_key_exists('fullname', $input)) {
|
---|
| 244 | if (strlen($input['fullname']) == 0) {
|
---|
| 245 | $result['errors'][] = array("content"=>lang('_SBG_FULLNAME_REQUIRED_MSG'),"field"=>"fullname");
|
---|
| 246 | }
|
---|
| 247 | }else{
|
---|
| 248 | $input['fullname'] = $user['fullname'];
|
---|
| 249 | }
|
---|
[580] | 250 | if (strlen($input['school']) == 0) {
|
---|
[636] | 251 | $result['errors'][] = array("content"=>lang('_SBG_REGISTER_VIP_SCHOOL_REQUIRED_MSG'),"field"=>"school");
|
---|
[580] | 252 | }
|
---|
[721] | 253 | if (strlen($input['province']) == 0) {
|
---|
| 254 | $result['errors'][] = array("content"=>lang('_SBG_PROVINCE_REQUIRED_MSG'),"field"=>"province");
|
---|
| 255 | }
|
---|
[580] | 256 | $input['password'] = '';
|
---|
| 257 | $input['oldpass'] = '';
|
---|
| 258 | $this->load->model('user_model');
|
---|
| 259 | if (!isset($result['errors'])) {
|
---|
| 260 | $result['data'] = $this->user_model->update_user($src, $token, $input, $us_id);
|
---|
| 261 | $result['success'] = 1;
|
---|
[636] | 262 | $info['fullname'] = $input['fullname'];
|
---|
| 263 | $info['school'] = $input['school'];
|
---|
[580] | 264 | $info = urldecode(http_build_query($info));
|
---|
| 265 | $userdata = array('username' => $user_info['username'], 'user' => $info, 'us_id' => $user_info['us_id'], 'logined_in' => TRUE, 'is_viettel' => $user_info['is_viettel']);
|
---|
| 266 | $this->session->set_userdata('userInfo', $userdata);
|
---|
| 267 | }
|
---|
| 268 | echo json_encode($result);
|
---|
| 269 | }
|
---|
| 270 | } else {
|
---|
| 271 | redirect('frontend/home');
|
---|
| 272 | }
|
---|
| 273 | }
|
---|
[604] | 274 |
|
---|
[503] | 275 | public function update_user() {
|
---|
| 276 | $us_id = $this->uri->segment(4);
|
---|
| 277 | $user_info = $this->session->userdata('userInfo');
|
---|
| 278 | if ($user_info) {
|
---|
| 279 | $result = array();
|
---|
| 280 | $result['success'] = 0;
|
---|
| 281 | $src = "SBG";
|
---|
| 282 | $token = md5($us_id . self::TOKENPW);
|
---|
| 283 | $user = $this->get_data($src, $token, $us_id);
|
---|
| 284 | $input = $this->input->post();
|
---|
| 285 | if ($input) {
|
---|
| 286 | $input['username'] = $user['username'];
|
---|
[508] | 287 | if (array_key_exists('fullname', $input)) {
|
---|
| 288 | if (strlen($input['fullname']) == 0) {
|
---|
[636] | 289 | $result['errors']['fullname_err'] = lang('_SBG_FULLNAME_REQUIRED_MSG');
|
---|
[508] | 290 | }
|
---|
| 291 | } else {
|
---|
| 292 | $input['fullname'] = $user['fullname'];
|
---|
| 293 | }
|
---|
[604] | 294 |
|
---|
[503] | 295 | $input['password'] = '';
|
---|
| 296 | $input['oldpass'] = '';
|
---|
| 297 | $this->load->model('user_model');
|
---|
| 298 | if (!isset($result['errors'])) {
|
---|
| 299 | $result['data'] = $this->user_model->update_user($src, $token, $input, $us_id);
|
---|
| 300 | $result['success'] = 1;
|
---|
| 301 | }
|
---|
[490] | 302 | echo json_encode($result);
|
---|
[503] | 303 | }
|
---|
| 304 | } else {
|
---|
| 305 | redirect('frontend/home');
|
---|
[490] | 306 | }
|
---|
[508] | 307 | }
|
---|
| 308 |
|
---|
| 309 | public function change_password() {
|
---|
| 310 | $us_id = $this->uri->segment(4);
|
---|
| 311 | $user_info = $this->session->userdata('userInfo');
|
---|
| 312 | if ($user_info) {
|
---|
| 313 | $this->load->model('user_model');
|
---|
| 314 | $us_id = $user_info['us_id'];
|
---|
| 315 | $src = "SBG";
|
---|
| 316 | $token = md5($us_id . self::TOKENPW);
|
---|
| 317 | $input = $this->input->post();
|
---|
[554] | 318 |
|
---|
[508] | 319 | if (strlen($input['passwd']) == 0) {
|
---|
[636] | 320 | $result['errors']['passwd_old_err'] = lang('_SBG_PASSWORD_REQUIRED_MSG');
|
---|
[508] | 321 | }
|
---|
[602] | 322 |
|
---|
[508] | 323 | if (strlen($input['passwd_new']) == 0) {
|
---|
[636] | 324 | $result['errors']['passwd_new_err'] = lang('_SBG_PASSWORD_REQUIRED_MSG');
|
---|
[614] | 325 | } else if (strcmp($input['passwd'], $input['passwd_new']) == 0) {
|
---|
[636] | 326 | $result['errors']['passwd_new_err'] = lang('_SBG_PASSWORD_DUPLICATE_MSG');
|
---|
[602] | 327 | }else
|
---|
| 328 | {
|
---|
| 329 | if (!preg_match('/^([0-9a-zA-Z]{6,65})*$/', $input['passwd_new']))
|
---|
| 330 | {
|
---|
[636] | 331 | $result['errors']['passwd_new_err'] = lang('_SBG_USER_PASSWORD_CHANGE_REQUIRED_MSG');
|
---|
[602] | 332 | }
|
---|
| 333 | }
|
---|
| 334 |
|
---|
[554] | 335 | if ($input['passwd_new'] != $input['confirm_passwd_new']) {
|
---|
[636] | 336 | $result['errors']['confirm_passwd_new_err'] = lang('_SBG_PASSWORD_CONFIRM_MSG');
|
---|
[508] | 337 | }
|
---|
[554] | 338 |
|
---|
[508] | 339 | if (!isset($result['errors'])) {
|
---|
| 340 | $user = array('username' => $user_info['username'], 'fullname' => null, 'gender' => null, 'email' => null, 'school' => null, 'province' => null, 'password' => $input['passwd_new'], 'oldpass' => $input['passwd']);
|
---|
| 341 | $data = $this->user_model->update_user($src, $token, $user, $us_id);
|
---|
| 342 | parse_str($data);
|
---|
[716] | 343 | error_log('API return ---- Data: '. var_export($data, TRUE). "\n", 3, '/srv/www/sbg/log/changepass.log');
|
---|
| 344 | switch ((int)$status) {
|
---|
[508] | 345 | case 0:
|
---|
| 346 | $result['success'] = 1;
|
---|
| 347 | break;
|
---|
| 348 | case 6:
|
---|
[636] | 349 | $result['errors']['passwd_old_err'] = lang('_SBG_OLD_PASSWORD_FAIL_MSG');
|
---|
[508] | 350 | break;
|
---|
| 351 | default:
|
---|
| 352 | break;
|
---|
| 353 | }
|
---|
| 354 | }
|
---|
| 355 |
|
---|
| 356 | echo json_encode($result);
|
---|
| 357 | } else {
|
---|
| 358 | redirect('frontend/home');
|
---|
| 359 | }
|
---|
| 360 | }
|
---|
[574] | 361 |
|
---|
| 362 | public function trade_history()
|
---|
| 363 | {
|
---|
| 364 | $this->load->helper('pagging');
|
---|
| 365 | $us_id = $this->uri->segment(4);
|
---|
[698] | 366 |
|
---|
[574] | 367 | $user_info = $this->session->userdata('userInfo');
|
---|
[698] | 368 | $admin_info = $this->session->userdata('adminInfo');
|
---|
| 369 |
|
---|
| 370 | if ($user_info || $admin_info)
|
---|
[574] | 371 | {
|
---|
| 372 | $data['us_id'] = $us_id;
|
---|
| 373 | $data['perpage'] = 10;
|
---|
| 374 | $data['current_page'] = $this->uri->segment(6, 1);
|
---|
| 375 | $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
|
---|
| 376 | $this->load->model('user_model');
|
---|
| 377 | $result = $this->user_model->getPaidlog($data);
|
---|
| 378 | $data['total'] = $this->user_model->countPaiglogs($us_id);
|
---|
| 379 | $data['num_links'] = 2;
|
---|
| 380 | $data['paging_url'] = base_url() . "frontend/user/trade_history/".$us_id."/page/";
|
---|
| 381 | $data['paging'] = pagging($data);
|
---|
| 382 | $paidlogs = array();
|
---|
| 383 | foreach ($result as $paidlog):
|
---|
| 384 | $paidlog['amount'] = number_format($paidlog['amount'], 0);
|
---|
[690] | 385 | $paidlog['paid_time'] = date('d/m/Y H:i:s', strtotime($paidlog['paid_time']));
|
---|
[574] | 386 | array_push($paidlogs, $paidlog);
|
---|
| 387 | endforeach;
|
---|
| 388 | $data['paidlogs'] = $paidlogs;
|
---|
| 389 | echo json_encode($data);
|
---|
| 390 | }else {
|
---|
| 391 | redirect('frontend/home');
|
---|
| 392 | }
|
---|
| 393 | }
|
---|
[730] | 394 | public function getUserInfor()
|
---|
[729] | 395 | {
|
---|
| 396 | $this->load->model('User_model');
|
---|
| 397 | $data=array();
|
---|
| 398 | $us_id = $this->uri->segment(4);
|
---|
| 399 | $src = "SBG";
|
---|
| 400 | $token = md5($us_id . self::TOKENPW);
|
---|
| 401 | $user = $this->User_model->get_user_info($src, $token, $us_id);
|
---|
| 402 | parse_str($user,$user);
|
---|
| 403 | $local=$this->User_model->get_user_by_id($us_id);
|
---|
| 404 | $data['user']= array_merge($user,$local);
|
---|
| 405 | $this->lang->load('messages', 'message');
|
---|
| 406 | $data['provinces'] = lang('_PROVINCES_');
|
---|
[731] | 407 | $result['modal']=$this->load->view('frontend/user_infor', $data, TRUE);
|
---|
[729] | 408 | echo json_encode($result);
|
---|
| 409 |
|
---|
| 410 | }
|
---|
| 411 | public function adminUpdateUser()
|
---|
| 412 | {
|
---|
| 413 | $this->load->model('User_model');
|
---|
| 414 | $input=$input = $this->input->post();
|
---|
| 415 | $us_id=$input["us_id"];
|
---|
| 416 | $src = "SBG";
|
---|
| 417 | $token = md5($us_id . self::TOKENPW);
|
---|
| 418 | $api['fullname']=$input['fullname'];
|
---|
| 419 | $api['school']=$input['school'];
|
---|
| 420 | $local['district']=$input['district'];
|
---|
| 421 | $local['province']=$input['province'];
|
---|
| 422 | $update = $this->User_model->update_user($src, $token, $api, $us_id);
|
---|
| 423 | $this->User_model->update_local_user($local,$us_id);
|
---|
| 424 | $result['success']=1;
|
---|
| 425 | echo json_encode($result);
|
---|
| 426 | }
|
---|
[642] | 427 | public function regis_history()
|
---|
| 428 | {
|
---|
| 429 | $this->load->helper('pagging');
|
---|
| 430 | $us_id = $this->uri->segment(4);
|
---|
| 431 | $this->load->model('user_model');
|
---|
| 432 | $user = $this->user_model->get_user_by_id($us_id);
|
---|
| 433 | $username = $user['cellphone'];
|
---|
| 434 | $user_info = $this->session->userdata('userInfo');
|
---|
[698] | 435 | $admin_info = $this->session->userdata('adminInfo');
|
---|
| 436 | if ($user_info || $admin_info)
|
---|
[642] | 437 | {
|
---|
| 438 | $data['username'] = $username;
|
---|
| 439 | $data['perpage'] = 10;
|
---|
| 440 | $data['current_page'] = $this->uri->segment(6, 1);
|
---|
| 441 | $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
|
---|
| 442 | $this->load->model('user_model');
|
---|
| 443 | $result = $this->user_model->getPackagelog($data);
|
---|
| 444 | $data['total'] = $this->user_model->countPackagelogs($username);
|
---|
| 445 | $data['num_links'] = 2;
|
---|
| 446 | $data['paging_url'] = base_url() . "frontend/user/regis_history/".$us_id."/page/";
|
---|
| 447 | $data['paging'] = pagging($data);
|
---|
| 448 | $packagelogs = array();
|
---|
| 449 | foreach ($result as $packagelog):
|
---|
[643] | 450 | $packagelog['created_time'] = date('d/m/Y H:i:s', strtotime($packagelog['created_time']));
|
---|
[642] | 451 | array_push($packagelogs, $packagelog);
|
---|
| 452 | endforeach;
|
---|
| 453 | $data['packagelogs'] = $packagelogs;
|
---|
| 454 | echo json_encode($data);
|
---|
| 455 | }else
|
---|
| 456 | {
|
---|
| 457 | redirect('frontend/home');
|
---|
| 458 | }
|
---|
| 459 |
|
---|
| 460 | }
|
---|
[508] | 461 |
|
---|
[554] | 462 | }
|
---|