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 | $("#updateInfoSuccess").modal('show');
|
---|
12 | $("#close").click(function(){
|
---|
13 | window.location.reload(true);
|
---|
14 | });
|
---|
15 |
|
---|
16 | }
|
---|
17 | else
|
---|
18 | {
|
---|
19 | for (var key in result.errors)
|
---|
20 | {
|
---|
21 | $('#' + key).html(result.errors[key]);
|
---|
22 | }
|
---|
23 | }
|
---|
24 | }
|
---|
25 | });
|
---|
26 | }
|
---|
27 | $("#package_register").submit(function (event)
|
---|
28 | {
|
---|
29 | $.ajax({
|
---|
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 | });
|
---|
52 | event.preventDefault();
|
---|
53 | });
|
---|
54 |
|
---|
55 | function finish_package_register()
|
---|
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 | {
|
---|
64 | var results = jQuery.parseJSON(data);
|
---|
65 | if (results.success == "1")
|
---|
66 | {
|
---|
67 | $("#package_register_modal").modal("hide");
|
---|
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);
|
---|
69 | $("#success_package_register_modal").modal("show");
|
---|
70 |
|
---|
71 | $("#package_register_finish_button").click(function () {
|
---|
72 | window.location.href = url+"frontend/user/profile/services-register";
|
---|
73 |
|
---|
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++)
|
---|
80 | {
|
---|
81 | var item = results.errors[i];
|
---|
82 | er=er+""+item+"<br />";
|
---|
83 | }
|
---|
84 | $("#package_register_errors").prepend(er+"</div>");
|
---|
85 | }
|
---|
86 | },
|
---|
87 | error: function (jqXHR, textStatus, errorThrown)
|
---|
88 | {
|
---|
89 | $(".ajaxloading").hide();
|
---|
90 | }
|
---|
91 | });
|
---|
92 | }
|
---|
93 | $("#add_money").click(function () {
|
---|
94 | $("#account-info-tab").click();
|
---|
95 | });
|
---|
96 | $("#"+current_tab+"-tab").click();
|
---|
97 |
|
---|
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: url+'frontend/user/change_password/' + us_id,
|
---|
106 | type: 'POST',
|
---|
107 | data: $("#frm2").serialize(),
|
---|
108 | success: function (data, textStatus, jqXHR)
|
---|
109 | {
|
---|
110 | console.log(data);
|
---|
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');
|
---|
135 | });
|
---|
136 |
|
---|
137 | function chargeCard(id)
|
---|
138 | {
|
---|
139 | $("#charging").css('display', 'block');
|
---|
140 | $('#btn-charge').attr("disabled", true);
|
---|
141 | $.ajax({
|
---|
142 | url: '/services/recharge/recharge_card/'+id,
|
---|
143 | type: 'POST',
|
---|
144 | data: $("#frm3").serialize(),
|
---|
145 | success: function (data, textStatus, jqXHR)
|
---|
146 | {
|
---|
147 | $("#pin_card").val('');
|
---|
148 | $("#card_serial").val('');
|
---|
149 | $("#charging").css('display', 'none');
|
---|
150 | $('#btn-charge').attr("disabled", false);
|
---|
151 | result = jQuery.parseJSON(data);
|
---|
152 | if(result.success == "1")
|
---|
153 | {
|
---|
154 | $("#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Ä!");
|
---|
155 | $("#success_charge").modal('show');
|
---|
156 | $("#vip-regis-money").text(addCommas(result.acc_balanced));
|
---|
157 | $("#topup-money").text(addCommas(result.acc_balanced) + ' VNÄ');
|
---|
158 | }else
|
---|
159 | {
|
---|
160 | /*var notSuccessMsg = 'Mã thẻ hoặc Serial khÃŽng Äúng hoặc Äã ÄÆ°á»£c sá» dụng. Quà vá» vui lòng kiá»m tra lại!';
|
---|
161 | if (result.isLocked == 1) {
|
---|
162 | notSuccessMsg = 'QuÜ vá» Äã nháºp sai thÃŽng tin thẻ cà o ' + result.maxReach + ' lần liên tiếp.<br />Xin chá» ' + result.timeToUnlock + ' phút sau Äá» thao tác lại!';
|
---|
163 | }*/
|
---|
164 |
|
---|
165 | $("#not_success_charge").find('div#no_success_charge_info > center').html (result.errMsg);
|
---|
166 | $("#not_success_charge").modal('show');
|
---|
167 | }
|
---|
168 |
|
---|
169 | }
|
---|
170 | });
|
---|
171 | }
|
---|
172 |
|
---|
173 | function tradeHistory(id, page)
|
---|
174 | {
|
---|
175 | $.ajax({
|
---|
176 | url: '/frontend/user/trade_history/'+id +'/page/'+page,
|
---|
177 | type: 'POST',
|
---|
178 | success: function(data)
|
---|
179 | {
|
---|
180 | results = jQuery.parseJSON(data);
|
---|
181 | paging = results.paging;
|
---|
182 | result = results.paidlogs;
|
---|
183 | content = "";
|
---|
184 | if(result.length>0){
|
---|
185 | for (var i in result)
|
---|
186 | {
|
---|
187 | content += '<tr><td class="center">'+result[i].source+'</td><td class="center">'+result[i].amount+'</td><td>'+result[i].paid_time+'</td></tr>';
|
---|
188 |
|
---|
189 | }
|
---|
190 | }else
|
---|
191 | {
|
---|
192 | content += '<tr><td class="center" colspan=3>Quà vá» chưa có giao dá»ch nà o!</td></tr>';
|
---|
193 | }
|
---|
194 | $("#trade-history").find("#content-trade-histoty").html(content);
|
---|
195 | $("#trade-history").find(".pagination").html(paging);
|
---|
196 | $(".ajax_paging").click(function ()
|
---|
197 | {
|
---|
198 | $.ajax({
|
---|
199 | url: $(this).attr("href"),
|
---|
200 | type: "POST",
|
---|
201 | success: function (data, textStatus, jqXHR)
|
---|
202 | {
|
---|
203 | results = jQuery.parseJSON(data);
|
---|
204 | tradeHistory(id, results.current_page);
|
---|
205 | },
|
---|
206 | error: function ()
|
---|
207 | {
|
---|
208 | $(".ajaxloading").hide();
|
---|
209 | }
|
---|
210 | });
|
---|
211 | return false;
|
---|
212 | });
|
---|
213 | $("#trade-history").modal('show');
|
---|
214 | }
|
---|
215 | });
|
---|
216 | }
|
---|
217 |
|
---|
218 | function addCommas(nStr)
|
---|
219 | {
|
---|
220 | nStr += '';
|
---|
221 | x = nStr.split('.');
|
---|
222 | x1 = x[0];
|
---|
223 | x2 = x.length > 1 ? '.' + x[1] : '';
|
---|
224 | var rgx = /(\d+)(\d{3})/;
|
---|
225 | while (rgx.test(x1)) {
|
---|
226 | x1 = x1.replace(rgx, '$1' + ',' + '$2');
|
---|
227 | }
|
---|
228 | return x1 + x2;
|
---|
229 | } |
---|