1 | $(".btn#add").click(function (){
|
---|
2 | $('#full_name_err').html("");
|
---|
3 | $('#login_name_err').html("");
|
---|
4 | $('#pwd1_err').html("");
|
---|
5 | $('#pwd2_err').html("");
|
---|
6 | $('#email_err').html("");
|
---|
7 | $('#phone_err').html("");
|
---|
8 | $.ajax({
|
---|
9 | url: "quan_tri_vien/them",
|
---|
10 | type: "POST",
|
---|
11 | data: $("#add_frm").serialize(),
|
---|
12 | success: function (data, textStatus, jqXHR)
|
---|
13 | {
|
---|
14 | result = jQuery.parseJSON(data);
|
---|
15 | if (result.success == "1")
|
---|
16 | {
|
---|
17 | filter();
|
---|
18 | $('#addAdmin').modal('hide');
|
---|
19 | }
|
---|
20 | else
|
---|
21 | {
|
---|
22 | for (var key in result.errors)
|
---|
23 | {
|
---|
24 | $('#'+key).html(result.errors[key]);
|
---|
25 | }
|
---|
26 | }
|
---|
27 |
|
---|
28 | },
|
---|
29 |
|
---|
30 | });
|
---|
31 |
|
---|
32 | });
|
---|
33 |
|
---|
34 | $('#editUser').on('show.bs.modal', function(e) {
|
---|
35 | var id = $(e.relatedTarget).data('us-id');
|
---|
36 | $.ajax({
|
---|
37 | url: "nguoi_dung/id/" + id,
|
---|
38 | type: "POST",
|
---|
39 | success: function (data, textStatus, jqXHR)
|
---|
40 | {
|
---|
41 | result = jQuery.parseJSON(data);
|
---|
42 | if (result.success=="1")
|
---|
43 | {
|
---|
44 | item = result.item;
|
---|
45 | $("#edit_cellphone").val(item['cellphone']);
|
---|
46 | $("#edit_acc_balanced").val(item['acc_balanced']);
|
---|
47 | }else
|
---|
48 | {
|
---|
49 | console.log("Item not found !");
|
---|
50 | }
|
---|
51 | }
|
---|
52 | });
|
---|
53 |
|
---|
54 | $(".btn#edit").click(function(){
|
---|
55 | $.ajax({
|
---|
56 | url: "nguoi_dung/sua/" + id,
|
---|
57 | type: "POST",
|
---|
58 | data: $("#edit_frm").serialize(),
|
---|
59 | success: function (data, textStatus, jqXHR)
|
---|
60 | {
|
---|
61 | result = jQuery.parseJSON(data)
|
---|
62 | console.log(result);
|
---|
63 | if (result.success=="1"){
|
---|
64 | filter();
|
---|
65 | $('#editUser').modal('hide');
|
---|
66 | }else
|
---|
67 | {
|
---|
68 | console.log("Edit error !");
|
---|
69 | }
|
---|
70 | }
|
---|
71 | });
|
---|
72 | });
|
---|
73 | });
|
---|
74 |
|
---|
75 | $('#deleteUser').on('show.bs.modal', function(e) {
|
---|
76 | var id = $(e.relatedTarget).data('us-id');
|
---|
77 | $(".btn#delete").click(function(){
|
---|
78 | $.ajax({
|
---|
79 | url: "nguoi_dung/xoa/" + id,
|
---|
80 | type: "POST",
|
---|
81 | success: function (data, textStatus, jqXHR)
|
---|
82 | {
|
---|
83 | result = jQuery.parseJSON(data)
|
---|
84 | if (result.success=="1"){
|
---|
85 | filter();
|
---|
86 | $('#deleteUser').modal('hide');
|
---|
87 | }else
|
---|
88 | {
|
---|
89 | console.log("Delete error !");
|
---|
90 | }
|
---|
91 | }
|
---|
92 | });
|
---|
93 | });
|
---|
94 | });
|
---|
95 |
|
---|
96 | (function($){
|
---|
97 | $.fn.setCursorToTextEnd = function() {
|
---|
98 | $initialVal = this.val();
|
---|
99 | this.val($initialVal + ' ');
|
---|
100 | this.val($initialVal);
|
---|
101 | };
|
---|
102 | })(jQuery); |
---|