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