[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");
|
---|
[574] | 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 () {
|
---|
[542] | 72 | window.location.href = url+"frontend/lecture";
|
---|
[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({
|
---|
| 105 | url: 'change_password/' + us_id,
|
---|
| 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 | {
|
---|
[527] | 147 | $("#charging").css('display', 'none');
|
---|
| 148 | $('#btn-charge').attr("disabled", false);
|
---|
[519] | 149 | result = jQuery.parseJSON(data);
|
---|
[520] | 150 | if(result.success == "1")
|
---|
[519] | 151 | {
|
---|
[540] | 152 | $("#success_charge").find('#success_charge_info').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Ä!");
|
---|
[519] | 153 | $("#success_charge").modal('show');
|
---|
| 154 | }else
|
---|
| 155 | {
|
---|
| 156 | $("#not_success_charge").modal('show');
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | }
|
---|
| 160 | });
|
---|
[524] | 161 | }
|
---|
| 162 |
|
---|
[574] | 163 | function tradeHistory(id, page)
|
---|
| 164 | {
|
---|
| 165 | $.ajax({
|
---|
| 166 | url: '/frontend/user/trade_history/'+id +'/page/'+page,
|
---|
| 167 | type: 'POST',
|
---|
| 168 | success: function(data)
|
---|
| 169 | {
|
---|
| 170 | results = jQuery.parseJSON(data);
|
---|
| 171 | paging = results.paging;
|
---|
| 172 | result = results.paidlogs;
|
---|
| 173 | content = "";
|
---|
| 174 | if(result.length>0){
|
---|
| 175 | for (var i in result)
|
---|
| 176 | {
|
---|
| 177 | content += '<tr><td class="center">'+result[i].source+'</td><td class="center">'+result[i].amount+'</td><td>'+result[i].paid_time+'</td></tr>';
|
---|
| 178 |
|
---|
| 179 | }
|
---|
| 180 | }else
|
---|
| 181 | {
|
---|
| 182 | content += '<tr><td class="center" colspan=3>Quà vá» chưa có giao dá»ch nà o!</td></tr>';
|
---|
| 183 | }
|
---|
| 184 | $("#trade-history").find("#content-trade-histoty").html(content);
|
---|
| 185 | $("#trade-history").find(".pagination").html(paging);
|
---|
| 186 | $(".ajax_paging").click(function ()
|
---|
| 187 | {
|
---|
| 188 | $.ajax({
|
---|
| 189 | url: $(this).attr("href"),
|
---|
| 190 | type: "POST",
|
---|
| 191 | success: function (data, textStatus, jqXHR)
|
---|
| 192 | {
|
---|
| 193 | results = jQuery.parseJSON(data);
|
---|
| 194 | tradeHistory(id, results.current_page);
|
---|
| 195 | },
|
---|
| 196 | error: function ()
|
---|
| 197 | {
|
---|
| 198 | $(".ajaxloading").hide();
|
---|
| 199 | }
|
---|
| 200 | });
|
---|
| 201 | return false;
|
---|
| 202 | });
|
---|
| 203 | $("#trade-history").modal('show');
|
---|
| 204 | }
|
---|
| 205 | });
|
---|
| 206 | }
|
---|