/
home
/
efamember
/
domains
/
efa-member.com
/
public_html
/
backoffice
/
up file
home
<?php include('header.php'); $datenow = date('Y-m-d'); ?> <body class="top-navigation"> <div id="wrapper"> <div id="page-wrapper" class="gray-bg"> <div class="wrapper wrapper-content animated fadeInRight"> <div class="ibox"> <div class="ibox-title"> <div class="row"> <div class="col-lg-3 mb-2"> <button class="btn btn-md btn-primary" onclick="AddCoupon()"><i class="fa fa-plus"></i> เพิ่มโค้ดส่วนลด</button> </div> </div> </div> <div class="ibox-content"> <!----- ตาราง ----> <div id="Loading"> <div class="spiner-example"> <div class="sk-spinner sk-spinner-wave"> <div class="sk-rect1"></div> <div class="sk-rect2"></div> <div class="sk-rect3"></div> <div class="sk-rect4"></div> <div class="sk-rect5"></div> </div> </div> </div> <div id="show_table"></div> <!----- ตาราง ----> </div> </div> </div> </div> </div> <!--- init layout --> <?php include('footer.php'); ?> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog modal-lg modal-dialog-centered"> <div class="modal-content animated fadeIn"> <div id="showModal"></div> </div> </div> </div> <script> $(document).ready(function() { load_table(); }); function AddCoupon() { let admin_id = localStorage.getItem("admin_id"); $('#myModal').modal('show'); $('#showModal').load("ajax/discount_coupon/modal_add.php", { admin_id: admin_id, }, function() { $("select.form-control").select2(); }); } function load_table() { $('#show_table').hide(); $('#Loading').show(); $("#show_table").load("ajax/discount_coupon/get_table.php", {}, function(response, status, request) { $('.dataTables-example').DataTable({ pageLength: 25, responsive: true, }); $('#show_table').show(); $('#Loading').hide(); }); } function SubmitCoupon() { var formData = new FormData($("#coupon_form")[0]); swal({ title: 'กรุณายืนยันเพื่อทำรายการ', type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', cancelButtonText: 'ยกเลิก', confirmButtonText: 'ยืนยัน', closeOnConfirm: false }, function() { $.ajax({ type: 'POST', url: 'ajax/discount_coupon/insert_coupon.php', contentType: false, cache: false, processData: false, data: formData, dataType: 'json', beforeSend: function() { swal({ title: "กำลังทำการบันทึก", text: "กรุณารอสักครู่", imageUrl: "ajax-loader.gif", showConfirmButton: false, allowOutsideClick: false }); }, error: function(data) { console.log("error : " + data.responseText); swal({ title: "เกิดข้อผิดพลาด", text: "ไม่สามารถบันทึกรายการได้ กรุณาแจ้งทีมงาน", type: "error", }); }, success: function(data) { if (data.result == 1) { swal({ title: "ดำเนินการสำเร็จ", text: "เพิ่มโค้ดส่วนลดสำเร็จ", type: "success" }, function() { swal.close(); $('#myModal').modal('hide'); load_table(); }); } else if (data.result == 0) { swal({ title: "เกิดข้อผิดพลาด", text: "เกิดข้อผิดพลาดระหว่างบันทึก", type: "error" //Please Check Your Account }, function() { //location.reload(); }); } } }) }); } function UpdateCoupon() { var formData = new FormData($("#coupon_update")[0]); $.ajax({ type: 'POST', url: 'ajax/discount_coupon/update_coupon.php', contentType: false, cache: false, processData: false, data: formData, dataType: 'json', beforeSend: function() { swal({ title: "กำลังทำการบันทึก", text: "กรุณารอสักครู่", imageUrl: "ajax-loader.gif", showConfirmButton: false, allowOutsideClick: false }); }, error: function(data) { console.log("error : " + data.responseText); swal({ title: "เกิดข้อผิดพลาด", text: "ไม่สามารถบันทึกรายการได้ กรุณาแจ้งทีมงาน", type: "error", }); }, success: function(data) { if (data.result == 1) { swal({ title: "ดำเนินการสำเร็จ", text: "แก้ไขสำเร็จ", type: "success" }, function() { swal.close(); $('#myModal').modal('hide'); load_table(); }); } else if (data.result == 0) { swal({ title: "เกิดข้อผิดพลาด", text: "เกิดข้อผิดพลาดระหว่างบันทึก", type: "error" }, function() { }); } } }) } function DeleteCoupon(coupon_id) { swal({ title: 'กรุณายืนยันเพื่อทำรายการ', type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', cancelButtonText: 'ยกเลิก', confirmButtonText: 'ยืนยัน', closeOnConfirm: false }, function() { $.ajax({ type: 'POST', url: 'ajax/discount_coupon/delete_coupon.php', data: { coupon_id: coupon_id }, dataType: 'json', beforeSend: function() { swal({ title: "กำลังทำการบันทึก", text: "กรุณารอสักครู่", imageUrl: "ajax-loader.gif", showConfirmButton: false, allowOutsideClick: false }); }, error: function(data) { console.log("error : " + data.responseText); swal({ title: "เกิดข้อผิดพลาด", text: "ไม่สามารถบันทึกรายการได้ กรุณาแจ้งทีมงาน", type: "error", }); }, success: function(data) { if (data.result == 1) { swal({ title: "ดำเนินการสำเร็จ", text: "ลบส่วนลดสำเร็จ", type: "success" }, function() { swal.close(); $('#myModal').modal('hide'); load_table(); }); } else if (data.result == 0) { swal({ title: "เกิดข้อผิดพลาด", text: "เกิดข้อผิดพลาดระหว่างบันทึก", type: "error" //Please Check Your Account }, function() { //location.reload(); }); } } }) }); } function EditCoupon(coupon_id) { $('#myModal').modal('show'); $('#showModal').load("ajax/discount_coupon/modal_edit.php", { coupon_id: coupon_id, }, function() { $("select.form-control").select2(); }); } function Changestatus(coupon_id) { $.ajax({ type: 'POST', url: 'ajax/ChangeStatus.php', data: { table_name: "tbl_discount_coupon", key_name: "coupon_id", key_value: coupon_id }, dataType: 'json', success: function(data) { load_table(); } }); } </script> </body> </html>