/
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="form_add()"><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" 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 form_add() { let admin_id = localStorage.getItem("admin_id"); $('#myModal').modal('show'); $('#showModal').load("ajax/setting_slide/form_add.php", { admin_id: admin_id, }, function() { $("select.form-control").select2( ); }); } function load_table() { $('#show_table').hide(); $('#Loading').show(); // var site_id = $('#site_id').val(); // var status = $('#status').val(); // let isCheck = $("#handicap").is(":checked"); // if (isCheck) { // var handicap = $('#handicap').val(); // } else { // var handicap = 0; // } $.ajax({ type: 'POST', url: 'ajax/setting_slide/get_table.php', data: { // site_id: site_id, // status: status, // handicap: handicap }, dataType: 'html', success: function(response) { $('#show_table').html(response); $('.dataTables-example').DataTable({ pageLength: 25, responsive: true, }); $('#show_table').show(); $('#Loading').hide(); } }); } function save_slide() { var formData = new FormData($("#form_slide")[0]); var member_level = $('#access_level').val(); if ($('#upload_file').get(0).files.length === 0 || member_level == "") { swal({ title: "เกิดข้อผิดพลาด", text: "กรูณากรอกข้อมูลให้ครบถ้วน", type: "error" }); } swal({ title: 'กรุณายืนยันเพื่อทำรายการ', type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', cancelButtonText: 'ยกเลิก', confirmButtonText: 'ยืนยัน', closeOnConfirm: false }, function() { $.ajax({ type: 'POST', url: 'ajax/setting_slide/insert.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 Changestatus(slide_id) { $.ajax({ type: 'POST', url: 'ajax/ChangeStatus.php', data: { table_name: "tbl_setting_slide", key_name: "slide_id", key_value: slide_id }, dataType: 'json', success: function(data) { load_table(); } }); } function ShowButtonSet() { $("#ShowButton").hide(); $("#HideButton").show(); $("#SortButton").show(); $(".td_move").show(); $("#dataTables-example tbody").sortable(); $(".tr_move").css({ "cursor": "move", "border": "2px dashed" }); $('#dataTables-example').DataTable().destroy(); } function HideButtonSet() { load_table() } function SortData() { let slide_id = $("input[name='slide_id[]']").map(function() { return $(this).val(); }).get(); swal({ title: "ยืนยัน การจัดลำดับข้อมูล ?", type: "warning", showCancelButton: true, confirmButtonColor: "#1AB394", confirmButtonText: "ยืนยัน", cancelButtonText: "ตรวจสอบอีกครั้ง", closeOnConfirm: false }, function() { $.ajax({ url: 'ajax/setting_slide/SortFile.php', type: 'POST', data: { slide_id: slide_id, }, dataType: 'json', success: function(data) { $(".confirm").prop('disabled', false); if (data.result == 1) { load_table(); swal({ title: "แจ้งเตือน", text: "เรียงข้อมูลสำเร็จ", type: "success", showConfirmButton: false }); setTimeout(function() { swal.close(); }, 2000); } else if (data.result == 0) { swal({ title: "แจ้งเตือน", text: "เรียงข้อมูลไม่สำเร็จ", type: "error", showConfirmButton: false }); setTimeout(function() { swal.close(); }, 2000); } else { swal({ title: "แจ้งเตือน", text: "ไม่สามารถติดต่อเซิฟเวอร์ได้ กรุณาลองใหม่อีกครั้ง", type: "error", showConfirmButton: true }); } } }); }); } function Delete(slide_id) { swal({ title: 'กรุณายืนยันเพื่อทำรายการ', type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', cancelButtonText: 'ยกเลิก', confirmButtonText: 'ยืนยัน', closeOnConfirm: false }, function() { $.ajax({ type: "POST", url: "ajax/setting_slide/delete.php", data: { slide_id: slide_id }, dataType: "json", success: function(data) { if (data.result == 1) { swal({ title: 'ลบข้อมูลเรียบร้อย', type: 'success', showConfirmButton: false, timer: 1500 }, function() { swal.close(); load_table() }); } else if (data.result == 0) { swal({ title: 'แจ้งเตือน', text: 'ไม่สามารถดำเนินการได้ กรุณาลองใหม่', type: 'warning', showConfirmButton: false, timer: 1500 }); } else if (data.result == 9) { swal({ title: 'แจ้งเตือน', text: 'ไม่สามารถติดต่อเซิฟเวอร์ได้ กรุณาลองใหม่อีกครั้ง', type: 'warning', showConfirmButton: false, timer: 1500 }); } } }); }) } </script> </body> </html>