1 | (function($){
|
---|
2 | $.fn.setCursorToTextEnd = function() {
|
---|
3 | $initialVal = this.val();
|
---|
4 | this.val($initialVal + ' ');
|
---|
5 | this.val($initialVal);
|
---|
6 | };
|
---|
7 | })(jQuery);
|
---|
8 |
|
---|
9 | function regisHistory(id, page)
|
---|
10 | {
|
---|
11 | $.ajax({
|
---|
12 | url: '/frontend/user/regis_history/'+id +'/page/'+page,
|
---|
13 | type: 'POST',
|
---|
14 | success: function(data)
|
---|
15 | {
|
---|
16 | results = jQuery.parseJSON(data);
|
---|
17 | paging = results.paging;
|
---|
18 | result = results.packagelogs;
|
---|
19 | $("#user-history").find("#topup-money").html(results.acc_balanced);
|
---|
20 | content = "";
|
---|
21 | if(result.length>0){
|
---|
22 | for (var i in result)
|
---|
23 | {
|
---|
24 | content += '<tr><td class="center">'+result[i].source+'</td><td class="center">'+result[i].amount+'</td><td class="center">'+result[i].p_name+'</td><td>'+result[i].created_time+'</td></tr>';
|
---|
25 |
|
---|
26 | }
|
---|
27 | }else
|
---|
28 | {
|
---|
29 | content += '<tr><td class="center" colspan=4>Chưa ÄÄng kà gói dá»ch vụ nà o!</td></tr>';
|
---|
30 | }
|
---|
31 | $("#user-history").find("#content-regis-histoty").html(content);
|
---|
32 | $("#user-history").find("#regis-pagination").html(paging);
|
---|
33 | $("#regis-pagination .ajax_paging").click(function ()
|
---|
34 | {
|
---|
35 | $.ajax({
|
---|
36 | url: $(this).attr("href"),
|
---|
37 | type: "POST",
|
---|
38 | success: function (data, textStatus, jqXHR)
|
---|
39 | {
|
---|
40 | results = jQuery.parseJSON(data);
|
---|
41 | regisHistory(id, results.current_page);
|
---|
42 | },
|
---|
43 | error: function ()
|
---|
44 | {
|
---|
45 | $(".ajaxloading").hide();
|
---|
46 | }
|
---|
47 | });
|
---|
48 | return false;
|
---|
49 | });
|
---|
50 |
|
---|
51 | }
|
---|
52 | });
|
---|
53 | }
|
---|
54 |
|
---|
55 | function tradeHistory(id, page)
|
---|
56 | {
|
---|
57 | $.ajax({
|
---|
58 | url: '/frontend/user/getUserInfor/'+id +'/page/'+page,
|
---|
59 | type: 'POST',
|
---|
60 | success: function(data)
|
---|
61 | {
|
---|
62 | results = jQuery.parseJSON(data);
|
---|
63 | $("#content-trade-histoty").html(results.modal);
|
---|
64 | }
|
---|
65 | });
|
---|
66 | }
|
---|
67 |
|
---|
68 |
|
---|
69 | function getUserHistory(id, page)
|
---|
70 | {
|
---|
71 | regisHistory(id, page);
|
---|
72 | tradeHistory(id, page);
|
---|
73 | $("#user-history").modal('show');
|
---|
74 | }
|
---|
75 |
|
---|
76 | function admin_update_user()
|
---|
77 | {
|
---|
78 |
|
---|
79 | $.ajax({
|
---|
80 | url: '/frontend/user/adminUpdateUser/',
|
---|
81 | type: 'POST',
|
---|
82 | data: $("#admin_update_user_form").serialize(),
|
---|
83 | success: function(data)
|
---|
84 | {
|
---|
85 |
|
---|
86 | results = jQuery.parseJSON(data);
|
---|
87 |
|
---|
88 | if(results.success==1)
|
---|
89 | {
|
---|
90 | $('#user-history').modal('hide');
|
---|
91 |
|
---|
92 | location.reload();
|
---|
93 | }
|
---|
94 |
|
---|
95 | }
|
---|
96 | });
|
---|
97 | }
|
---|
98 |
|
---|
99 | function checkSelectedDistrict(provinceId){
|
---|
100 | $.ajax({
|
---|
101 | url: '/frontend/user/getDistrict/' + provinceId,
|
---|
102 | type: 'POST',
|
---|
103 | success: function (data, textStatus, jqXHR)
|
---|
104 | {
|
---|
105 | result = jQuery.parseJSON(data);
|
---|
106 | content = "<option></option>";
|
---|
107 | if (result != null){
|
---|
108 | for (var i in result){
|
---|
109 | if (result[i].district_id === district_id){
|
---|
110 | content = content + '<option value="' + result[i].district_id + '" selected >' + result[i].type + " " + result[i].district_name + '</option>';
|
---|
111 | }else{
|
---|
112 | content = content + '<option value="' + result[i].district_id + '">' + result[i].type + " " + result[i].district_name + '</option>';
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | }
|
---|
117 | $(".form-field-district").html(content);
|
---|
118 | }
|
---|
119 | });
|
---|
120 | }
|
---|
121 |
|
---|
122 | function changeEventProvince(provinceId){
|
---|
123 | $(".form-field-district").html("");
|
---|
124 | $.ajax({
|
---|
125 | url: '/frontend/user/getDistrict/' + provinceId,
|
---|
126 | type: 'POST',
|
---|
127 | success: function (data, textStatus, jqXHR)
|
---|
128 | {
|
---|
129 | result = jQuery.parseJSON(data);
|
---|
130 | content = "<option></option>";
|
---|
131 | if (result != null){
|
---|
132 | for (var i in result){
|
---|
133 | content = content + '<option value="' + result[i].district_id + '">'+ result[i].type + " " + result[i].district_name + '</option>'
|
---|
134 | }
|
---|
135 | }
|
---|
136 | $(".form-field-district").html(content);
|
---|
137 | }
|
---|
138 | });
|
---|
139 | }
|
---|
140 |
|
---|
141 | $(document).ready(function(){
|
---|
142 | $(".form-field-province").change(function(){
|
---|
143 | changeEventProvince();
|
---|
144 | });
|
---|
145 | if ($(".form-field-province").val() !== 'undefined'){
|
---|
146 | checkSelectedDistrict();
|
---|
147 | }
|
---|
148 | }); |
---|