[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;
|
---|
[765] | 66 |
|
---|
[503] | 67 | if ($user['acc_balanced'] < $package['p_price']) {
|
---|
| 68 | $result['can_buy'] = 0;
|
---|
| 69 | }
|
---|
[580] | 70 |
|
---|
[706] | 71 | if(strtotime($user['expire_date'])<strtotime(date('Y-m-d'))){
|
---|
| 72 | $result['can_edit'] = 1;
|
---|
| 73 | }
|
---|
[503] | 74 | if ($user['p_id'] < 1) {
|
---|
| 75 | $result['can_edit'] = 1;
|
---|
| 76 | }
|
---|
[580] | 77 | if ($info['fullname']=="")
|
---|
| 78 | {
|
---|
| 79 | $result['can_edit'] = 1;
|
---|
| 80 | }
|
---|
[503] | 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 | }
|
---|
[554] | 90 |
|
---|
[503] | 91 | public function finishRegisterPackage() {
|
---|
| 92 | $result = array();
|
---|
| 93 | $result['success'] = 0;
|
---|
| 94 | $this->load->model('user_model');
|
---|
| 95 | $input = $this->input->post();
|
---|
[701] | 96 | //print_r($input);
|
---|
[503] | 97 | $user_info = $this->session->userdata('userInfo');
|
---|
[508] | 98 | parse_str($user_info['user'], $info);
|
---|
[503] | 99 | if (isset($input['fullname'])) {
|
---|
[548] | 100 | if (strlen($input['fullname']) < 1) {
|
---|
[636] | 101 | $result['errors'][] = lang('_SBG_REGISTER_VIP_FULLNAME_REQUIRED_MSG');
|
---|
[503] | 102 | }
|
---|
[548] | 103 | if (strlen($input['school']) < 1) {
|
---|
[636] | 104 | $result['errors'][] = lang('_SBG_REGISTER_VIP_SCHOOL_REQUIRED_MSG');
|
---|
[503] | 105 | }
|
---|
| 106 | if (!isset($result['errors'])) {
|
---|
[490] | 107 | $user_info = $this->session->userdata('userInfo');
|
---|
[503] | 108 | if ($user_info) {
|
---|
[508] | 109 |
|
---|
[503] | 110 | $src = "SBG";
|
---|
[508] | 111 | $us_id = $user_info['us_id'];
|
---|
[503] | 112 | $input['password'] = '';
|
---|
| 113 | $input['oldpass'] = '';
|
---|
| 114 | $input['gender'] = '';
|
---|
[508] | 115 | $input['email'] = '';
|
---|
[701] | 116 | //$input['province'] = '';
|
---|
[508] | 117 | $info['fullname'] = $input['fullname'];
|
---|
| 118 | $info['school'] = $input['school'];
|
---|
[503] | 119 | $token = md5($us_id . self::TOKENPW);
|
---|
| 120 | $user = $this->get_data($src, $token, $us_id);
|
---|
[701] | 121 | //$input['district'] = '';
|
---|
[503] | 122 | if ($input) {
|
---|
[490] | 123 | $this->load->model('user_model');
|
---|
[503] | 124 | $update = $this->user_model->update_user($src, $token, $input, $us_id);
|
---|
[508] | 125 | $info = urldecode(http_build_query($info));
|
---|
[554] | 126 | $userdata = array('username' => $user_info['username'], 'user' => $info, 'us_id' => $user_info['us_id'], 'logined_in' => TRUE, 'is_viettel' => $user_info['is_viettel']);
|
---|
[503] | 127 | $this->session->set_userdata('userInfo', $userdata);
|
---|
| 128 | }
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 | }
|
---|
[647] | 132 |
|
---|
[503] | 133 | if (isset($result['errors'])) {
|
---|
[554] | 134 | echo json_encode($result);
|
---|
[647] | 135 | exit();
|
---|
[503] | 136 | }
|
---|
[647] | 137 |
|
---|
[503] | 138 | $this->load->model('servicepackage_model');
|
---|
| 139 | $us_id = $user_info['us_id'];
|
---|
[700] | 140 | //$user = $this->user_model->get_user_by_id($us_id);
|
---|
| 141 | $user = $this->user_model->getUserById($us_id);
|
---|
[503] | 142 | $package = $this->servicepackage_model->getPackage($input['p_id']);
|
---|
[508] | 143 | $user['acc_balanced'] = $user['acc_balanced'] - $package['p_price'];
|
---|
[556] | 144 |
|
---|
[765] | 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'];
|
---|
[556] | 149 | $user['expire_date'] = date('Y-m-d', strtotime("+" . $package['p_period'] . " ".$package['p_unit'], strtotime($currentExpireDate)));
|
---|
[508] | 150 | $user['p_id'] = $package['p_id'];
|
---|
[701] | 151 | $user['province'] = $input['province'];
|
---|
[508] | 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'];
|
---|
[503] | 155 | $result['success'] = 1;
|
---|
[647] | 156 | $message = str_replace(':period:', date("d/m/Y", (strtotime($user['expire_date']))), lang('_SBG_REGISTER_VIP_SUCCESS_MSG'));
|
---|
| 157 | $result['message'] = $message;
|
---|
| 158 |
|
---|
[633] | 159 | $toDate = date("Y-m-d", (strtotime($result['expire_date'])));
|
---|
[646] | 160 | $this->user_model->insertRegisterVipLog($user['cellphone'],$package['p_code'], false);
|
---|
[503] | 161 | echo json_encode($result);
|
---|
| 162 | }
|
---|
[554] | 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']) {
|
---|
[636] | 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'));
|
---|
[554] | 179 | } else {
|
---|
| 180 | $user['acc_balanced'] = $user['acc_balanced'] - $package['p_price'];
|
---|
[765] | 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'];
|
---|
[554] | 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);
|
---|
[636] | 193 | $aryPatterns = array('/:period:/');
|
---|
| 194 | $message = preg_replace($aryPatterns, array(date('d-m-Y', strtotime($user['expire_date']))), lang('_SBG_REGISTER_VIP_SUCCESS_MS'));
|
---|
[646] | 195 | $this->user_model->insertRegisterVipLog($user['cellphone'], $package['p_code'], false);
|
---|
[554] | 196 | }
|
---|
| 197 |
|
---|
| 198 | $this->session->set_flashdata('message', $message);
|
---|
| 199 | redirect('frontend/user/profile#services-register');
|
---|
[521] | 200 | }
|
---|
[503] | 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 | }
|
---|
[604] | 237 |
|
---|
| 238 | public function update_info() {
|
---|
[636] | 239 | $result['success'] = 0;
|
---|
[580] | 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) {
|
---|
[717] | 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 | }
|
---|
[580] | 258 | if (strlen($input['school']) == 0) {
|
---|
[636] | 259 | $result['errors'][] = array("content"=>lang('_SBG_REGISTER_VIP_SCHOOL_REQUIRED_MSG'),"field"=>"school");
|
---|
[580] | 260 | }
|
---|
[721] | 261 | if (strlen($input['province']) == 0) {
|
---|
| 262 | $result['errors'][] = array("content"=>lang('_SBG_PROVINCE_REQUIRED_MSG'),"field"=>"province");
|
---|
| 263 | }
|
---|
[580] | 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;
|
---|
[636] | 270 | $info['fullname'] = $input['fullname'];
|
---|
| 271 | $info['school'] = $input['school'];
|
---|
[580] | 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 | }
|
---|
[604] | 282 |
|
---|
[503] | 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'];
|
---|
[508] | 295 | if (array_key_exists('fullname', $input)) {
|
---|
| 296 | if (strlen($input['fullname']) == 0) {
|
---|
[636] | 297 | $result['errors']['fullname_err'] = lang('_SBG_FULLNAME_REQUIRED_MSG');
|
---|
[508] | 298 | }
|
---|
| 299 | } else {
|
---|
| 300 | $input['fullname'] = $user['fullname'];
|
---|
| 301 | }
|
---|
[604] | 302 |
|
---|
[503] | 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 | }
|
---|
[490] | 310 | echo json_encode($result);
|
---|
[503] | 311 | }
|
---|
| 312 | } else {
|
---|
| 313 | redirect('frontend/home');
|
---|
[490] | 314 | }
|
---|
[508] | 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();
|
---|
[554] | 326 |
|
---|
[508] | 327 | if (strlen($input['passwd']) == 0) {
|
---|
[636] | 328 | $result['errors']['passwd_old_err'] = lang('_SBG_PASSWORD_REQUIRED_MSG');
|
---|
[508] | 329 | }
|
---|
[602] | 330 |
|
---|
[508] | 331 | if (strlen($input['passwd_new']) == 0) {
|
---|
[636] | 332 | $result['errors']['passwd_new_err'] = lang('_SBG_PASSWORD_REQUIRED_MSG');
|
---|
[614] | 333 | } else if (strcmp($input['passwd'], $input['passwd_new']) == 0) {
|
---|
[636] | 334 | $result['errors']['passwd_new_err'] = lang('_SBG_PASSWORD_DUPLICATE_MSG');
|
---|
[602] | 335 | }else
|
---|
| 336 | {
|
---|
| 337 | if (!preg_match('/^([0-9a-zA-Z]{6,65})*$/', $input['passwd_new']))
|
---|
| 338 | {
|
---|
[636] | 339 | $result['errors']['passwd_new_err'] = lang('_SBG_USER_PASSWORD_CHANGE_REQUIRED_MSG');
|
---|
[602] | 340 | }
|
---|
| 341 | }
|
---|
| 342 |
|
---|
[554] | 343 | if ($input['passwd_new'] != $input['confirm_passwd_new']) {
|
---|
[636] | 344 | $result['errors']['confirm_passwd_new_err'] = lang('_SBG_PASSWORD_CONFIRM_MSG');
|
---|
[508] | 345 | }
|
---|
[554] | 346 |
|
---|
[508] | 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);
|
---|
[716] | 351 | error_log('API return ---- Data: '. var_export($data, TRUE). "\n", 3, '/srv/www/sbg/log/changepass.log');
|
---|
| 352 | switch ((int)$status) {
|
---|
[508] | 353 | case 0:
|
---|
| 354 | $result['success'] = 1;
|
---|
| 355 | break;
|
---|
| 356 | case 6:
|
---|
[636] | 357 | $result['errors']['passwd_old_err'] = lang('_SBG_OLD_PASSWORD_FAIL_MSG');
|
---|
[508] | 358 | break;
|
---|
| 359 | default:
|
---|
| 360 | break;
|
---|
| 361 | }
|
---|
| 362 | }
|
---|
| 363 |
|
---|
| 364 | echo json_encode($result);
|
---|
| 365 | } else {
|
---|
| 366 | redirect('frontend/home');
|
---|
| 367 | }
|
---|
| 368 | }
|
---|
[574] | 369 |
|
---|
| 370 | public function trade_history()
|
---|
| 371 | {
|
---|
| 372 | $this->load->helper('pagging');
|
---|
| 373 | $us_id = $this->uri->segment(4);
|
---|
[698] | 374 |
|
---|
[574] | 375 | $user_info = $this->session->userdata('userInfo');
|
---|
[698] | 376 | $admin_info = $this->session->userdata('adminInfo');
|
---|
| 377 |
|
---|
| 378 | if ($user_info || $admin_info)
|
---|
[574] | 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);
|
---|
[690] | 393 | $paidlog['paid_time'] = date('d/m/Y H:i:s', strtotime($paidlog['paid_time']));
|
---|
[574] | 394 | array_push($paidlogs, $paidlog);
|
---|
| 395 | endforeach;
|
---|
| 396 | $data['paidlogs'] = $paidlogs;
|
---|
| 397 | echo json_encode($data);
|
---|
| 398 | }else {
|
---|
| 399 | redirect('frontend/home');
|
---|
| 400 | }
|
---|
| 401 | }
|
---|
[730] | 402 | public function getUserInfor()
|
---|
[729] | 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');
|
---|
[771] | 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;
|
---|
[729] | 421 | $data['provinces'] = lang('_PROVINCES_');
|
---|
[731] | 422 | $result['modal']=$this->load->view('frontend/user_infor', $data, TRUE);
|
---|
[729] | 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 | }
|
---|
[642] | 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');
|
---|
[698] | 450 | $admin_info = $this->session->userdata('adminInfo');
|
---|
| 451 | if ($user_info || $admin_info)
|
---|
[642] | 452 | {
|
---|
[773] | 453 | $data['us_id'] = $us_id;
|
---|
[642] | 454 | $data['username'] = $username;
|
---|
| 455 | $data['perpage'] = 10;
|
---|
| 456 | $data['current_page'] = $this->uri->segment(6, 1);
|
---|
| 457 | $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
|
---|
| 458 | $this->load->model('user_model');
|
---|
| 459 | $result = $this->user_model->getPackagelog($data);
|
---|
| 460 | $data['total'] = $this->user_model->countPackagelogs($username);
|
---|
| 461 | $data['num_links'] = 2;
|
---|
| 462 | $data['paging_url'] = base_url() . "frontend/user/regis_history/".$us_id."/page/";
|
---|
| 463 | $data['paging'] = pagging($data);
|
---|
| 464 | $packagelogs = array();
|
---|
| 465 | foreach ($result as $packagelog):
|
---|
[643] | 466 | $packagelog['created_time'] = date('d/m/Y H:i:s', strtotime($packagelog['created_time']));
|
---|
[642] | 467 | array_push($packagelogs, $packagelog);
|
---|
| 468 | endforeach;
|
---|
| 469 | $data['packagelogs'] = $packagelogs;
|
---|
| 470 | echo json_encode($data);
|
---|
| 471 | }else
|
---|
| 472 | {
|
---|
| 473 | redirect('frontend/home');
|
---|
| 474 | }
|
---|
| 475 |
|
---|
| 476 | }
|
---|
[508] | 477 |
|
---|
[554] | 478 | }
|
---|