[375] | 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 | $('#editAdmin').on('show.bs.modal', function(e) {
|
---|
| 35 | var id = $(e.relatedTarget).data('admin-id');
|
---|
| 36 | $.ajax({
|
---|
| 37 | url: "quan_tri_vien/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 | $("input[name='full_name']").val(item['full_name']);
|
---|
| 46 | $("input[name='login_name']").val(item['login_name']);
|
---|
| 47 | $("input[name='email']").val(item['email']);
|
---|
| 48 | $("input[name='phone']").val(item['phone']);
|
---|
| 49 | }else
|
---|
| 50 | {
|
---|
| 51 | console.log("Item not found !");
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 | });
|
---|
| 55 |
|
---|
| 56 | $(".btn#edit").click(function(){
|
---|
| 57 | $.ajax({
|
---|
| 58 | url: "quan_tri_vien/sua/" + id,
|
---|
| 59 | type: "POST",
|
---|
| 60 | success: function (data, textStatus, jqXHR)
|
---|
| 61 | {
|
---|
| 62 | result = jQuery.parseJSON(data)
|
---|
| 63 | if (result.success=="1"){
|
---|
| 64 | filter();
|
---|
| 65 | $('#editAdmin').modal('hide');
|
---|
| 66 | }else
|
---|
| 67 | {
|
---|
| 68 | console.log("Edit error !");
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 | });
|
---|
| 72 | });
|
---|
| 73 | });
|
---|
| 74 |
|
---|
| 75 | $('#deleteAdmin').on('show.bs.modal', function(e) {
|
---|
| 76 | var id = $(e.relatedTarget).data('admin-id');
|
---|
| 77 | //$(e.currentTarget).find('input[name="id"]').val(id);
|
---|
| 78 | $(".btn#delete").click(function(){
|
---|
| 79 | $.ajax({
|
---|
| 80 | url: "quan_tri_vien/xoa/" + id,
|
---|
| 81 | type: "POST",
|
---|
| 82 | success: function (data, textStatus, jqXHR)
|
---|
| 83 | {
|
---|
| 84 | result = jQuery.parseJSON(data)
|
---|
| 85 | if (result.success=="1"){
|
---|
| 86 | filter();
|
---|
| 87 | $('#deleteAdmin').modal('hide');
|
---|
| 88 | }else
|
---|
| 89 | {
|
---|
| 90 | console.log("Delete error !");
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 | });
|
---|
| 94 | });
|
---|
| 95 | }); |
---|