[505] | 1 | function updateInfo(us_id) {
|
---|
| 2 | $.ajax({
|
---|
[838] | 3 | url: '/frontend/user/update_user/' + us_id,
|
---|
[505] | 4 | type: 'POST',
|
---|
| 5 | data: $("#frm1").serialize(),
|
---|
| 6 | success: function (data, textStatus, jqXHR)
|
---|
| 7 | {
|
---|
| 8 | result = jQuery.parseJSON(data);
|
---|
| 9 | if (result.success == "1")
|
---|
| 10 | {
|
---|
[540] | 11 | $("#updateInfoSuccess").modal('show');
|
---|
| 12 | $("#close").click(function(){
|
---|
| 13 | window.location.reload(true);
|
---|
| 14 | });
|
---|
| 15 |
|
---|
[505] | 16 | }
|
---|
| 17 | else
|
---|
| 18 | {
|
---|
| 19 | for (var key in result.errors)
|
---|
| 20 | {
|
---|
| 21 | $('#' + key).html(result.errors[key]);
|
---|
| 22 | }
|
---|
| 23 | }
|
---|
| 24 | }
|
---|
| 25 | });
|
---|
[504] | 26 | }
|
---|
[505] | 27 | $("#package_register").submit(function (event)
|
---|
[530] | 28 | {
|
---|
[701] | 29 | //console.log($(this).attr("action"));
|
---|
[530] | 30 | $.ajax({
|
---|
[505] | 31 | url: $(this).attr("action"),
|
---|
| 32 | type: "POST",
|
---|
| 33 | data: $("#package_register").serialize(),
|
---|
| 34 | success: function (data, textStatus, jqXHR)
|
---|
| 35 | {
|
---|
| 36 |
|
---|
| 37 | var results = jQuery.parseJSON(data);
|
---|
[701] | 38 |
|
---|
[505] | 39 | $('#package_register_modal').replaceWith(results.modal);
|
---|
| 40 | $('#package_register_modal').modal('show');
|
---|
| 41 | $("#package_register_back").click(function () {
|
---|
| 42 | $("#account-info-tab").click();
|
---|
| 43 | });
|
---|
[838] | 44 |
|
---|
| 45 |
|
---|
| 46 | if ($(".form-field-province").val() !== 'undefined'){
|
---|
[883] | 47 | checkSelectedDistrict();
|
---|
[838] | 48 | }
|
---|
| 49 | $(".form-field-province").change(function(){
|
---|
| 50 | changeEventProvince();
|
---|
| 51 | });
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 |
|
---|
[505] | 55 | $("#finish_package_register").click(function () {
|
---|
| 56 | finish_package_register();
|
---|
| 57 | });
|
---|
| 58 |
|
---|
| 59 | },
|
---|
| 60 | error: function (jqXHR, textStatus, errorThrown)
|
---|
| 61 | {
|
---|
| 62 | $(".ajaxloading").hide();
|
---|
| 63 | }
|
---|
| 64 | });
|
---|
[530] | 65 | event.preventDefault();
|
---|
[505] | 66 | });
|
---|
[533] | 67 |
|
---|
[530] | 68 | function finish_package_register()
|
---|
[505] | 69 | {
|
---|
| 70 | $("#package_register_errors").html("");
|
---|
| 71 | $.ajax({
|
---|
| 72 | url: url + "frontend/user/finishRegisterPackage",
|
---|
| 73 | type: "POST",
|
---|
| 74 | data: $("#do_package_register").serialize(),
|
---|
| 75 | success: function (data, textStatus, jqXHR)
|
---|
| 76 | {
|
---|
[530] | 77 | var results = jQuery.parseJSON(data);
|
---|
[505] | 78 | if (results.success == "1")
|
---|
| 79 | {
|
---|
| 80 | $("#package_register_modal").modal("hide");
|
---|
[656] | 81 | $("#success_package_register_content").html(results.message);
|
---|
[505] | 82 | $("#success_package_register_modal").modal("show");
|
---|
| 83 |
|
---|
| 84 | $("#package_register_finish_button").click(function () {
|
---|
[593] | 85 | window.location.href = url+"frontend/user/profile/services-register";
|
---|
[512] | 86 |
|
---|
[505] | 87 | });
|
---|
| 88 | }
|
---|
| 89 | else
|
---|
| 90 | {
|
---|
| 91 | var er = "<div class=\"alert alert-block alert-success\">";
|
---|
| 92 | for (var i = 0; i < results.errors.length; i++)
|
---|
[504] | 93 | {
|
---|
[505] | 94 | var item = results.errors[i];
|
---|
| 95 | er=er+""+item+"<br />";
|
---|
[504] | 96 | }
|
---|
[505] | 97 | $("#package_register_errors").prepend(er+"</div>");
|
---|
| 98 | }
|
---|
| 99 | },
|
---|
| 100 | error: function (jqXHR, textStatus, errorThrown)
|
---|
| 101 | {
|
---|
| 102 | $(".ajaxloading").hide();
|
---|
| 103 | }
|
---|
| 104 | });
|
---|
[530] | 105 | }
|
---|
[505] | 106 | $("#add_money").click(function () {
|
---|
[509] | 107 | $("#account-info-tab").click();
|
---|
[504] | 108 | });
|
---|
[505] | 109 | $("#"+current_tab+"-tab").click();
|
---|
[530] | 110 |
|
---|
[504] | 111 |
|
---|
| 112 | function changePassword(us_id)
|
---|
| 113 | {
|
---|
| 114 | $('#passwd_old_err').html("");
|
---|
| 115 | $('#passwd_new_err').html("");
|
---|
| 116 | $('#confirm_passwd_new_err').html("");
|
---|
| 117 | $.ajax({
|
---|
[617] | 118 | url: url+'frontend/user/change_password/' + us_id,
|
---|
[504] | 119 | type: 'POST',
|
---|
| 120 | data: $("#frm2").serialize(),
|
---|
| 121 | success: function (data, textStatus, jqXHR)
|
---|
| 122 | {
|
---|
| 123 | result = jQuery.parseJSON(data);
|
---|
| 124 | if (result.success == "1")
|
---|
| 125 | {
|
---|
| 126 | $("#changePassSuccess").modal('show');
|
---|
| 127 | }
|
---|
| 128 | else
|
---|
| 129 | {
|
---|
| 130 | for (var key in result.errors)
|
---|
| 131 | {
|
---|
| 132 | $('#'+key).html(result.errors[key]);
|
---|
| 133 | }
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 | });
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | function clearFormFields(id){
|
---|
| 140 | $(id).find('input:text, input:hidden, input:password, input:file, select, textarea').val('');
|
---|
| 141 | $(id).find('input:radio, input:checkbox').removeAttr('checked').removeAttr('selected');
|
---|
| 142 | $(id).find('.help-block').html("");
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | $('body').on('hidden.bs.modal', '.modal', function () {
|
---|
| 146 | clearFormFields('#frm2');
|
---|
[519] | 147 | });
|
---|
| 148 |
|
---|
| 149 | function chargeCard(id)
|
---|
| 150 | {
|
---|
[527] | 151 | $("#charging").css('display', 'block');
|
---|
| 152 | $('#btn-charge').attr("disabled", true);
|
---|
[519] | 153 | $.ajax({
|
---|
[533] | 154 | url: '/services/recharge/recharge_card/'+id,
|
---|
[519] | 155 | type: 'POST',
|
---|
| 156 | data: $("#frm3").serialize(),
|
---|
| 157 | success: function (data, textStatus, jqXHR)
|
---|
| 158 | {
|
---|
[611] | 159 | $("#pin_card").val('');
|
---|
| 160 | $("#card_serial").val('');
|
---|
[527] | 161 | $("#charging").css('display', 'none');
|
---|
| 162 | $('#btn-charge').attr("disabled", false);
|
---|
[519] | 163 | result = jQuery.parseJSON(data);
|
---|
[520] | 164 | if(result.success == "1")
|
---|
[519] | 165 | {
|
---|
[638] | 166 | //$("#success_charge").find('#success_charge_info > center').text("QuÜ vá» Äã nạp thà nh cÃŽng " + result.amount + " VNÄ và o tà i khoản " + result.username + ", tà i khoản ảo cá»§a QuÜ vá» là " + result.acc_balanced + " VNÄ!");
|
---|
| 167 | $("#success_charge").find('#success_charge_info > center').text(result.message);
|
---|
[519] | 168 | $("#success_charge").modal('show');
|
---|
[608] | 169 | $("#vip-regis-money").text(addCommas(result.acc_balanced));
|
---|
[611] | 170 | $("#topup-money").text(addCommas(result.acc_balanced) + ' VNÄ');
|
---|
[519] | 171 | }else
|
---|
| 172 | {
|
---|
[620] | 173 | $("#not_success_charge").find('div#no_success_charge_info > center').html (result.errMsg);
|
---|
[519] | 174 | $("#not_success_charge").modal('show');
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | }
|
---|
| 178 | });
|
---|
[524] | 179 | }
|
---|
| 180 |
|
---|
[574] | 181 | function tradeHistory(id, page)
|
---|
| 182 | {
|
---|
| 183 | $.ajax({
|
---|
| 184 | url: '/frontend/user/trade_history/'+id +'/page/'+page,
|
---|
| 185 | type: 'POST',
|
---|
| 186 | success: function(data)
|
---|
| 187 | {
|
---|
| 188 | results = jQuery.parseJSON(data);
|
---|
| 189 | paging = results.paging;
|
---|
| 190 | result = results.paidlogs;
|
---|
| 191 | content = "";
|
---|
| 192 | if(result.length>0){
|
---|
| 193 | for (var i in result)
|
---|
| 194 | {
|
---|
| 195 | content += '<tr><td class="center">'+result[i].source+'</td><td class="center">'+result[i].amount+'</td><td>'+result[i].paid_time+'</td></tr>';
|
---|
| 196 |
|
---|
| 197 | }
|
---|
| 198 | }else
|
---|
| 199 | {
|
---|
[774] | 200 | content += '<tr><td class="center" colspan=4>Chưa có giao dá»ch nà o!</td></tr>';
|
---|
[574] | 201 | }
|
---|
| 202 | $("#trade-history").find("#content-trade-histoty").html(content);
|
---|
| 203 | $("#trade-history").find(".pagination").html(paging);
|
---|
| 204 | $(".ajax_paging").click(function ()
|
---|
| 205 | {
|
---|
| 206 | $.ajax({
|
---|
| 207 | url: $(this).attr("href"),
|
---|
| 208 | type: "POST",
|
---|
| 209 | success: function (data, textStatus, jqXHR)
|
---|
| 210 | {
|
---|
| 211 | results = jQuery.parseJSON(data);
|
---|
| 212 | tradeHistory(id, results.current_page);
|
---|
| 213 | },
|
---|
| 214 | error: function ()
|
---|
| 215 | {
|
---|
| 216 | $(".ajaxloading").hide();
|
---|
| 217 | }
|
---|
| 218 | });
|
---|
| 219 | return false;
|
---|
| 220 | });
|
---|
| 221 | $("#trade-history").modal('show');
|
---|
| 222 | }
|
---|
| 223 | });
|
---|
| 224 | }
|
---|
[608] | 225 |
|
---|
[642] | 226 | function regisHistory(id, page)
|
---|
| 227 | {
|
---|
| 228 | $.ajax({
|
---|
| 229 | url: '/frontend/user/regis_history/'+id +'/page/'+page,
|
---|
| 230 | type: 'POST',
|
---|
| 231 | success: function(data)
|
---|
| 232 | {
|
---|
[724] | 233 |
|
---|
[642] | 234 | results = jQuery.parseJSON(data);
|
---|
| 235 | paging = results.paging;
|
---|
| 236 | result = results.packagelogs;
|
---|
| 237 | content = "";
|
---|
| 238 | if(result.length>0){
|
---|
| 239 | for (var i in result)
|
---|
| 240 | {
|
---|
[690] | 241 | source = result[i].source;
|
---|
| 242 | if (result[i].source == null || result[i].source == '') source = 'Thẻ cà o';
|
---|
[773] | 243 | content += '<tr><td class="center">'+source+'</td><td class="center">'+result[i].amount+'</td><td class="center">'+result[i].p_name+'</td><td>'+result[i].created_time+'</td></tr>';
|
---|
[642] | 244 |
|
---|
| 245 | }
|
---|
| 246 | }else
|
---|
| 247 | {
|
---|
[644] | 248 | content += '<tr><td class="center" colspan=3>Chưa ÄÄng kà gói dá»ch vụ nà o!</td></tr>';
|
---|
[642] | 249 | }
|
---|
| 250 | $("#regis-history").find("#content-regis-histoty").html(content);
|
---|
| 251 | $("#regis-history").find(".pagination").html(paging);
|
---|
| 252 | $(".ajax_paging").click(function ()
|
---|
| 253 | {
|
---|
| 254 | $.ajax({
|
---|
| 255 | url: $(this).attr("href"),
|
---|
| 256 | type: "POST",
|
---|
| 257 | success: function (data, textStatus, jqXHR)
|
---|
| 258 | {
|
---|
| 259 | results = jQuery.parseJSON(data);
|
---|
| 260 | regisHistory(id, results.current_page);
|
---|
| 261 | },
|
---|
| 262 | error: function ()
|
---|
| 263 | {
|
---|
| 264 | $(".ajaxloading").hide();
|
---|
| 265 | }
|
---|
| 266 | });
|
---|
| 267 | return false;
|
---|
| 268 | });
|
---|
| 269 | $("#regis-history").modal('show');
|
---|
| 270 | }
|
---|
| 271 | });
|
---|
| 272 | }
|
---|
| 273 |
|
---|
[608] | 274 | function addCommas(nStr)
|
---|
| 275 | {
|
---|
| 276 | nStr += '';
|
---|
| 277 | x = nStr.split('.');
|
---|
| 278 | x1 = x[0];
|
---|
| 279 | x2 = x.length > 1 ? '.' + x[1] : '';
|
---|
| 280 | var rgx = /(\d+)(\d{3})/;
|
---|
| 281 | while (rgx.test(x1)) {
|
---|
| 282 | x1 = x1.replace(rgx, '$1' + ',' + '$2');
|
---|
| 283 | }
|
---|
| 284 | return x1 + x2;
|
---|
[838] | 285 | }
|
---|
| 286 |
|
---|
[883] | 287 | function checkSelectedDistrict(){
|
---|
[838] | 288 | provinceId = $(".form-field-province").val();
|
---|
| 289 | $.ajax({
|
---|
| 290 | url: '/frontend/user/getDistrict/' + provinceId,
|
---|
| 291 | type: 'POST',
|
---|
| 292 | success: function (data, textStatus, jqXHR)
|
---|
| 293 | {
|
---|
| 294 | result = jQuery.parseJSON(data);
|
---|
| 295 | content = "";
|
---|
| 296 | if (result != null){
|
---|
| 297 | for (var i in result){
|
---|
| 298 | if (result[i].district_id === district_id){
|
---|
| 299 | content = content + '<option value="' + result[i].district_id + '" selected >' + result[i].type + " " + result[i].district_name + '</option>';
|
---|
| 300 | }else{
|
---|
| 301 | content = content + '<option value="' + result[i].district_id + '">' + result[i].type + " " + result[i].district_name + '</option>';
|
---|
| 302 | }
|
---|
| 303 | }
|
---|
[906] | 304 |
|
---|
[838] | 305 | }
|
---|
[906] | 306 | $(".form-field-district").html(content);
|
---|
[838] | 307 | }
|
---|
| 308 | });
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | function changeEventProvince(){
|
---|
| 312 | $(".form-field-district").html("");
|
---|
| 313 | provinceId = $("#form-field-province").val();
|
---|
| 314 | $.ajax({
|
---|
| 315 | url: '/frontend/user/getDistrict/' + provinceId,
|
---|
| 316 | type: 'POST',
|
---|
| 317 | success: function (data, textStatus, jqXHR)
|
---|
| 318 | {
|
---|
| 319 | result = jQuery.parseJSON(data);
|
---|
[906] | 320 | content = "<option></option>";
|
---|
[838] | 321 | if (result != null){
|
---|
| 322 | for (var i in result){
|
---|
| 323 | content = content + '<option value="' + result[i].district_id + '">'+ result[i].type + " " + result[i].district_name + '</option>'
|
---|
| 324 | }
|
---|
[906] | 325 |
|
---|
[838] | 326 | }
|
---|
[906] | 327 | $(".form-field-district").html(content);
|
---|
[838] | 328 | }
|
---|
| 329 | });
|
---|
| 330 | }
|
---|
[883] | 331 | $(document).ready(function(){
|
---|
| 332 | if ($(".form-field-province").val() !== 'undefined'){
|
---|
| 333 | checkSelectedDistrict();
|
---|
| 334 | }
|
---|
| 335 | $(".form-field-province").change(function(){
|
---|
| 336 | changeEventProvince();
|
---|
| 337 | });
|
---|
[838] | 338 | }); |
---|