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