[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 | {
|
---|
| 11 | window.location.reload(true);
|
---|
| 12 | }
|
---|
| 13 | else
|
---|
| 14 | {
|
---|
| 15 | for (var key in result.errors)
|
---|
| 16 | {
|
---|
| 17 | $('#' + key).html(result.errors[key]);
|
---|
| 18 | }
|
---|
| 19 | }
|
---|
| 20 | }
|
---|
| 21 | });
|
---|
[504] | 22 | }
|
---|
[505] | 23 | $("#package_register").submit(function (event)
|
---|
[530] | 24 | {
|
---|
| 25 | $.ajax({
|
---|
[505] | 26 | url: $(this).attr("action"),
|
---|
| 27 | type: "POST",
|
---|
| 28 | data: $("#package_register").serialize(),
|
---|
| 29 | success: function (data, textStatus, jqXHR)
|
---|
| 30 | {
|
---|
| 31 |
|
---|
| 32 | var results = jQuery.parseJSON(data);
|
---|
| 33 | $('#package_register_modal').replaceWith(results.modal);
|
---|
| 34 | $('#package_register_modal').modal('show');
|
---|
| 35 | $("#package_register_back").click(function () {
|
---|
| 36 | $("#account-info-tab").click();
|
---|
| 37 | });
|
---|
| 38 | $("#finish_package_register").click(function () {
|
---|
| 39 | finish_package_register();
|
---|
| 40 | });
|
---|
| 41 |
|
---|
| 42 | },
|
---|
| 43 | error: function (jqXHR, textStatus, errorThrown)
|
---|
| 44 | {
|
---|
| 45 | $(".ajaxloading").hide();
|
---|
| 46 | }
|
---|
| 47 | });
|
---|
[530] | 48 | event.preventDefault();
|
---|
[505] | 49 | });
|
---|
[533] | 50 |
|
---|
[530] | 51 | function finish_package_register()
|
---|
[505] | 52 | {
|
---|
| 53 | $("#package_register_errors").html("");
|
---|
| 54 | $.ajax({
|
---|
| 55 | url: url + "frontend/user/finishRegisterPackage",
|
---|
| 56 | type: "POST",
|
---|
| 57 | data: $("#do_package_register").serialize(),
|
---|
| 58 | success: function (data, textStatus, jqXHR)
|
---|
| 59 | {
|
---|
[530] | 60 | var results = jQuery.parseJSON(data);
|
---|
[505] | 61 | if (results.success == "1")
|
---|
| 62 | {
|
---|
| 63 | $("#package_register_modal").modal("hide");
|
---|
| 64 | $("#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);
|
---|
| 65 | $("#success_package_register_modal").modal("show");
|
---|
| 66 |
|
---|
| 67 | $("#package_register_finish_button").click(function () {
|
---|
| 68 | window.location.href = url+"frontend/user/profile/account-info";
|
---|
[512] | 69 |
|
---|
[505] | 70 | });
|
---|
| 71 | }
|
---|
| 72 | else
|
---|
| 73 | {
|
---|
| 74 | var er = "<div class=\"alert alert-block alert-success\">";
|
---|
| 75 | for (var i = 0; i < results.errors.length; i++)
|
---|
[504] | 76 | {
|
---|
[505] | 77 | var item = results.errors[i];
|
---|
| 78 | er=er+""+item+"<br />";
|
---|
[504] | 79 | }
|
---|
[505] | 80 | $("#package_register_errors").prepend(er+"</div>");
|
---|
| 81 | }
|
---|
| 82 | },
|
---|
| 83 | error: function (jqXHR, textStatus, errorThrown)
|
---|
| 84 | {
|
---|
| 85 | $(".ajaxloading").hide();
|
---|
| 86 | }
|
---|
| 87 | });
|
---|
[530] | 88 | }
|
---|
[505] | 89 | $("#add_money").click(function () {
|
---|
[509] | 90 | $("#account-info-tab").click();
|
---|
[504] | 91 | });
|
---|
[505] | 92 | $("#"+current_tab+"-tab").click();
|
---|
[530] | 93 |
|
---|
[504] | 94 |
|
---|
| 95 | function changePassword(us_id)
|
---|
| 96 | {
|
---|
| 97 | $('#passwd_old_err').html("");
|
---|
| 98 | $('#passwd_new_err').html("");
|
---|
| 99 | $('#confirm_passwd_new_err').html("");
|
---|
| 100 | $.ajax({
|
---|
| 101 | url: 'change_password/' + us_id,
|
---|
| 102 | type: 'POST',
|
---|
| 103 | data: $("#frm2").serialize(),
|
---|
| 104 | success: function (data, textStatus, jqXHR)
|
---|
| 105 | {
|
---|
[519] | 106 | console.log(data);
|
---|
[504] | 107 | result = jQuery.parseJSON(data);
|
---|
| 108 | if (result.success == "1")
|
---|
| 109 | {
|
---|
| 110 | $("#changePassSuccess").modal('show');
|
---|
| 111 | }
|
---|
| 112 | else
|
---|
| 113 | {
|
---|
| 114 | for (var key in result.errors)
|
---|
| 115 | {
|
---|
| 116 | $('#'+key).html(result.errors[key]);
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
| 119 | }
|
---|
| 120 | });
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | function clearFormFields(id){
|
---|
| 124 | $(id).find('input:text, input:hidden, input:password, input:file, select, textarea').val('');
|
---|
| 125 | $(id).find('input:radio, input:checkbox').removeAttr('checked').removeAttr('selected');
|
---|
| 126 | $(id).find('.help-block').html("");
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | $('body').on('hidden.bs.modal', '.modal', function () {
|
---|
| 130 | clearFormFields('#frm2');
|
---|
[519] | 131 | });
|
---|
| 132 |
|
---|
| 133 | function chargeCard(id)
|
---|
| 134 | {
|
---|
[527] | 135 | $("#charging").css('display', 'block');
|
---|
| 136 | $('#btn-charge').attr("disabled", true);
|
---|
[519] | 137 | $.ajax({
|
---|
[533] | 138 | url: '/services/recharge/recharge_card/'+id,
|
---|
[519] | 139 | type: 'POST',
|
---|
| 140 | data: $("#frm3").serialize(),
|
---|
| 141 | success: function (data, textStatus, jqXHR)
|
---|
| 142 | {
|
---|
[527] | 143 | $("#charging").css('display', 'none');
|
---|
| 144 | $('#btn-charge').attr("disabled", false);
|
---|
[519] | 145 | result = jQuery.parseJSON(data);
|
---|
[520] | 146 | if(result.success == "1")
|
---|
[519] | 147 | {
|
---|
[520] | 148 | $("#success_charge").find('#success_charge_info').text("Quà vá» Äã nạp thà nh cÃŽng " + result.amount + " và o tà i khoản " + result.username + ", tà i khoản ảo cá»§a quà vá» là " + result.acc_balanced + " VND!");
|
---|
[519] | 149 | $("#success_charge").modal('show');
|
---|
| 150 | }else
|
---|
| 151 | {
|
---|
| 152 | $("#not_success_charge").modal('show');
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | }
|
---|
| 156 | });
|
---|
[524] | 157 | }
|
---|
| 158 |
|
---|
[530] | 159 |
|
---|