[505] | 1 | function updateInfo(us_id) {
|
---|
| 2 | $.ajax({
|
---|
| 3 | url: 'update_user/' + us_id,
|
---|
| 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 | {
|
---|
| 29 | $.ajax({
|
---|
[505] | 30 | url: $(this).attr("action"),
|
---|
| 31 | type: "POST",
|
---|
| 32 | data: $("#package_register").serialize(),
|
---|
| 33 | success: function (data, textStatus, jqXHR)
|
---|
| 34 | {
|
---|
| 35 |
|
---|
| 36 | var results = jQuery.parseJSON(data);
|
---|
| 37 | $('#package_register_modal').replaceWith(results.modal);
|
---|
| 38 | $('#package_register_modal').modal('show');
|
---|
| 39 | $("#package_register_back").click(function () {
|
---|
| 40 | $("#account-info-tab").click();
|
---|
| 41 | });
|
---|
| 42 | $("#finish_package_register").click(function () {
|
---|
| 43 | finish_package_register();
|
---|
| 44 | });
|
---|
| 45 |
|
---|
| 46 | },
|
---|
| 47 | error: function (jqXHR, textStatus, errorThrown)
|
---|
| 48 | {
|
---|
| 49 | $(".ajaxloading").hide();
|
---|
| 50 | }
|
---|
| 51 | });
|
---|
[530] | 52 | event.preventDefault();
|
---|
[505] | 53 | });
|
---|
[533] | 54 |
|
---|
[530] | 55 | function finish_package_register()
|
---|
[505] | 56 | {
|
---|
| 57 | $("#package_register_errors").html("");
|
---|
| 58 | $.ajax({
|
---|
| 59 | url: url + "frontend/user/finishRegisterPackage",
|
---|
| 60 | type: "POST",
|
---|
| 61 | data: $("#do_package_register").serialize(),
|
---|
| 62 | success: function (data, textStatus, jqXHR)
|
---|
| 63 | {
|
---|
[530] | 64 | var results = jQuery.parseJSON(data);
|
---|
[505] | 65 | if (results.success == "1")
|
---|
| 66 | {
|
---|
| 67 | $("#package_register_modal").modal("hide");
|
---|
[625] | 68 | $("#success_package_register_content").html("QuÜ vá» Äã ÄÄng kà sá» dụng CÃŽng cụ Soạn Bà i giảng trức tuyến. QuÜ vá» ÄÆ°á»£c sá» dụng dá»ch vụ Äến hết 24h ngà y "+results.expire_date);
|
---|
[505] | 69 | $("#success_package_register_modal").modal("show");
|
---|
| 70 |
|
---|
| 71 | $("#package_register_finish_button").click(function () {
|
---|
[593] | 72 | window.location.href = url+"frontend/user/profile/services-register";
|
---|
[512] | 73 |
|
---|
[505] | 74 | });
|
---|
| 75 | }
|
---|
| 76 | else
|
---|
| 77 | {
|
---|
| 78 | var er = "<div class=\"alert alert-block alert-success\">";
|
---|
| 79 | for (var i = 0; i < results.errors.length; i++)
|
---|
[504] | 80 | {
|
---|
[505] | 81 | var item = results.errors[i];
|
---|
| 82 | er=er+""+item+"<br />";
|
---|
[504] | 83 | }
|
---|
[505] | 84 | $("#package_register_errors").prepend(er+"</div>");
|
---|
| 85 | }
|
---|
| 86 | },
|
---|
| 87 | error: function (jqXHR, textStatus, errorThrown)
|
---|
| 88 | {
|
---|
| 89 | $(".ajaxloading").hide();
|
---|
| 90 | }
|
---|
| 91 | });
|
---|
[530] | 92 | }
|
---|
[505] | 93 | $("#add_money").click(function () {
|
---|
[509] | 94 | $("#account-info-tab").click();
|
---|
[504] | 95 | });
|
---|
[505] | 96 | $("#"+current_tab+"-tab").click();
|
---|
[530] | 97 |
|
---|
[504] | 98 |
|
---|
| 99 | function changePassword(us_id)
|
---|
| 100 | {
|
---|
| 101 | $('#passwd_old_err').html("");
|
---|
| 102 | $('#passwd_new_err').html("");
|
---|
| 103 | $('#confirm_passwd_new_err').html("");
|
---|
| 104 | $.ajax({
|
---|
[617] | 105 | url: url+'frontend/user/change_password/' + us_id,
|
---|
[504] | 106 | type: 'POST',
|
---|
| 107 | data: $("#frm2").serialize(),
|
---|
| 108 | success: function (data, textStatus, jqXHR)
|
---|
| 109 | {
|
---|
[519] | 110 | console.log(data);
|
---|
[504] | 111 | result = jQuery.parseJSON(data);
|
---|
| 112 | if (result.success == "1")
|
---|
| 113 | {
|
---|
| 114 | $("#changePassSuccess").modal('show');
|
---|
| 115 | }
|
---|
| 116 | else
|
---|
| 117 | {
|
---|
| 118 | for (var key in result.errors)
|
---|
| 119 | {
|
---|
| 120 | $('#'+key).html(result.errors[key]);
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 | }
|
---|
| 124 | });
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | function clearFormFields(id){
|
---|
| 128 | $(id).find('input:text, input:hidden, input:password, input:file, select, textarea').val('');
|
---|
| 129 | $(id).find('input:radio, input:checkbox').removeAttr('checked').removeAttr('selected');
|
---|
| 130 | $(id).find('.help-block').html("");
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | $('body').on('hidden.bs.modal', '.modal', function () {
|
---|
| 134 | clearFormFields('#frm2');
|
---|
[519] | 135 | });
|
---|
| 136 |
|
---|
| 137 | function chargeCard(id)
|
---|
| 138 | {
|
---|
[527] | 139 | $("#charging").css('display', 'block');
|
---|
| 140 | $('#btn-charge').attr("disabled", true);
|
---|
[519] | 141 | $.ajax({
|
---|
[533] | 142 | url: '/services/recharge/recharge_card/'+id,
|
---|
[519] | 143 | type: 'POST',
|
---|
| 144 | data: $("#frm3").serialize(),
|
---|
| 145 | success: function (data, textStatus, jqXHR)
|
---|
| 146 | {
|
---|
[611] | 147 | $("#pin_card").val('');
|
---|
| 148 | $("#card_serial").val('');
|
---|
[527] | 149 | $("#charging").css('display', 'none');
|
---|
| 150 | $('#btn-charge').attr("disabled", false);
|
---|
[519] | 151 | result = jQuery.parseJSON(data);
|
---|
[520] | 152 | if(result.success == "1")
|
---|
[519] | 153 | {
|
---|
[638] | 154 | //$("#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Ä!");
|
---|
| 155 | $("#success_charge").find('#success_charge_info > center').text(result.message);
|
---|
[519] | 156 | $("#success_charge").modal('show');
|
---|
[608] | 157 | $("#vip-regis-money").text(addCommas(result.acc_balanced));
|
---|
[611] | 158 | $("#topup-money").text(addCommas(result.acc_balanced) + ' VNÄ');
|
---|
[519] | 159 | }else
|
---|
| 160 | {
|
---|
[620] | 161 | $("#not_success_charge").find('div#no_success_charge_info > center').html (result.errMsg);
|
---|
[519] | 162 | $("#not_success_charge").modal('show');
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | }
|
---|
| 166 | });
|
---|
[524] | 167 | }
|
---|
| 168 |
|
---|
[574] | 169 | function tradeHistory(id, page)
|
---|
| 170 | {
|
---|
| 171 | $.ajax({
|
---|
| 172 | url: '/frontend/user/trade_history/'+id +'/page/'+page,
|
---|
| 173 | type: 'POST',
|
---|
| 174 | success: function(data)
|
---|
| 175 | {
|
---|
| 176 | results = jQuery.parseJSON(data);
|
---|
| 177 | paging = results.paging;
|
---|
| 178 | result = results.paidlogs;
|
---|
| 179 | content = "";
|
---|
| 180 | if(result.length>0){
|
---|
| 181 | for (var i in result)
|
---|
| 182 | {
|
---|
| 183 | content += '<tr><td class="center">'+result[i].source+'</td><td class="center">'+result[i].amount+'</td><td>'+result[i].paid_time+'</td></tr>';
|
---|
| 184 |
|
---|
| 185 | }
|
---|
| 186 | }else
|
---|
| 187 | {
|
---|
[625] | 188 | content += '<tr><td class="center" colspan=3>QuÜ vá» chưa có giao dá»ch nà o!</td></tr>';
|
---|
[574] | 189 | }
|
---|
| 190 | $("#trade-history").find("#content-trade-histoty").html(content);
|
---|
| 191 | $("#trade-history").find(".pagination").html(paging);
|
---|
| 192 | $(".ajax_paging").click(function ()
|
---|
| 193 | {
|
---|
| 194 | $.ajax({
|
---|
| 195 | url: $(this).attr("href"),
|
---|
| 196 | type: "POST",
|
---|
| 197 | success: function (data, textStatus, jqXHR)
|
---|
| 198 | {
|
---|
| 199 | results = jQuery.parseJSON(data);
|
---|
| 200 | tradeHistory(id, results.current_page);
|
---|
| 201 | },
|
---|
| 202 | error: function ()
|
---|
| 203 | {
|
---|
| 204 | $(".ajaxloading").hide();
|
---|
| 205 | }
|
---|
| 206 | });
|
---|
| 207 | return false;
|
---|
| 208 | });
|
---|
| 209 | $("#trade-history").modal('show');
|
---|
| 210 | }
|
---|
| 211 | });
|
---|
| 212 | }
|
---|
[608] | 213 |
|
---|
[642] | 214 | function regisHistory(id, page)
|
---|
| 215 | {
|
---|
| 216 | $.ajax({
|
---|
| 217 | url: '/frontend/user/regis_history/'+id +'/page/'+page,
|
---|
| 218 | type: 'POST',
|
---|
| 219 | success: function(data)
|
---|
| 220 | {
|
---|
| 221 | results = jQuery.parseJSON(data);
|
---|
| 222 | paging = results.paging;
|
---|
| 223 | result = results.packagelogs;
|
---|
| 224 | content = "";
|
---|
| 225 | if(result.length>0){
|
---|
| 226 | for (var i in result)
|
---|
| 227 | {
|
---|
| 228 | content += '<tr><td class="center">'+result[i].source+'</td><td class="center">'+result[i].p_code+'</td><td>'+result[i].created_time+'</td></tr>';
|
---|
| 229 |
|
---|
| 230 | }
|
---|
| 231 | }else
|
---|
| 232 | {
|
---|
| 233 | content += '<tr><td class="center" colspan=3>QuÜ vá» chưa ÄÄng kà gói dá»ch vụ nà o!</td></tr>';
|
---|
| 234 | }
|
---|
| 235 | $("#regis-history").find("#content-regis-histoty").html(content);
|
---|
| 236 | $("#regis-history").find(".pagination").html(paging);
|
---|
| 237 | $(".ajax_paging").click(function ()
|
---|
| 238 | {
|
---|
| 239 | $.ajax({
|
---|
| 240 | url: $(this).attr("href"),
|
---|
| 241 | type: "POST",
|
---|
| 242 | success: function (data, textStatus, jqXHR)
|
---|
| 243 | {
|
---|
| 244 | results = jQuery.parseJSON(data);
|
---|
| 245 | regisHistory(id, results.current_page);
|
---|
| 246 | },
|
---|
| 247 | error: function ()
|
---|
| 248 | {
|
---|
| 249 | $(".ajaxloading").hide();
|
---|
| 250 | }
|
---|
| 251 | });
|
---|
| 252 | return false;
|
---|
| 253 | });
|
---|
| 254 | $("#regis-history").modal('show');
|
---|
| 255 | }
|
---|
| 256 | });
|
---|
| 257 | }
|
---|
| 258 |
|
---|
[608] | 259 | function addCommas(nStr)
|
---|
| 260 | {
|
---|
| 261 | nStr += '';
|
---|
| 262 | x = nStr.split('.');
|
---|
| 263 | x1 = x[0];
|
---|
| 264 | x2 = x.length > 1 ? '.' + x[1] : '';
|
---|
| 265 | var rgx = /(\d+)(\d{3})/;
|
---|
| 266 | while (rgx.test(x1)) {
|
---|
| 267 | x1 = x1.replace(rgx, '$1' + ',' + '$2');
|
---|
| 268 | }
|
---|
| 269 | return x1 + x2;
|
---|
| 270 | } |
---|