/
home
/
efamember
/
domains
/
efa-member.com
/
public_html
/
backoffice
/
up file
home
<?php include('header.php'); $datenow = date('Y-m-d'); ?> <style> .select2-dropdown { z-index: 9999; } </style> <body class="top-navigation"> <div id="wrapper" class=""> <div id="page-wrapper" class="gray-bg shadow-sm rounded"> <div class="wrapper wrapper-content animated fadeInDown"> <div id="member_count"></div> <div class="ibox"> <div class="ibox-title"> <div class="row"> <div class="col-lg-9 mb-2 ml-4"> กฎหมายที่เกี่ยวข้อง </div> <div class="ibox-tools"> <button class="btn btn-sm btn-primary" onclick="GetModalAdd()"><i class="fa fa-plus"></i> เพิ่มข้อกฎหมาย</button> </div> </div> </div> <div class="ibox-title"> <div class="col-lg-12"> <!-- <div class="row" style="margin-left: 8px;"> --> <input style=" width: 50px; height: 20px;" id="show_all" name="show_all" type="checkbox" value="1" class="js-switch" onchange="load_table();" checked> <label style="margin-top: 7px; margin-left: 10px;"> แสดงเฉพาะใช้งาน </label> </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-md modal-dialog-centered"> <div class="modal-content animated fadeIn"> <div id="showModal"></div> </div> </div> </div> <script> $(document).ready(function() { load_table(); // GetMemberCount() $(".form-select").select2(); }); const elem = document.querySelector('.js-switch'); const switchery = new Switchery(elem, { color: '#1AB394' }); function load_table() { $.ajax({ type: 'POST', url: 'ajax/setting_law/get_table.php', data: { status: ($("#show_all").is(':checked')) ? '1' : '0' }, dataType: 'html', success: function(response) { $('#show_table').html(response); $('.dataTables-example').DataTable({ ordering: false, pageLength: 50, responsive: true, }); $('#show_table').show(); $('#Loading').hide(); }, error: function(jqXHR, exception) { var msg = ''; if (jqXHR.status === 0) { msg = 'Not connect. Verify Network.'; } else if (jqXHR.status == 404) { msg = 'Requested page not found. [404]'; } else if (jqXHR.status == 500) { msg = 'Internal Server Error [500].'; } else if (exception === 'parsererror') { msg = 'Requested JSON parse failed.'; } else if (exception === 'timeout') { msg = 'Time out error.'; } else if (exception === 'abort') { msg = 'Ajax request aborted.'; } else { msg = 'Uncaught Error. ' + jqXHR.responseText; } swal({ title: "แจ้งเตือน", text: "พบปัญหาการบันทึก กรุณาติดต่อผู้ดูแลระบบ" + msg, type: "error", showConfirmButton: true }); } }); } function GetModalAdd() { $("#myModal").modal("show"); $("#showModal").load("ajax/setting_law/modal_add_law.php"); } function GetModalEdit(law_id) { $("#myModal").modal("show"); $("#showModal").load("ajax/setting_law/modal_edit_law.php", { law_id: law_id }); } function AddLaw() { let formData = new FormData($("#form_add")[0]); formData.append('create_user', localStorage.getItem('admin_id')); $.ajax({ type: "POST", url: "ajax/setting_law/add_law.php", data: formData, contentType: false, cache: false, processData: false, dataType: "json", success: function(data) { if (data.result == 1) { swal({ title: 'บันทึกข้อมูลเรียบร้อย', type: 'success', showConfirmButton: false, timer: 1500 }, function() { load_table() swal.close(); $("#myModal").modal('hide'); }); } 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 }); } }, error: function(jqXHR, exception) { var msg = ''; if (jqXHR.status === 0) { msg = 'Not connect. Verify Network.'; } else if (jqXHR.status == 404) { msg = 'Requested page not found. [404]'; } else if (jqXHR.status == 500) { msg = 'Internal Server Error [500].'; } else if (exception === 'parsererror') { msg = 'Requested JSON parse failed.'; } else if (exception === 'timeout') { msg = 'Time out error.'; } else if (exception === 'abort') { msg = 'Ajax request aborted.'; } else { msg = 'Uncaught Error. ' + jqXHR.responseText; } swal({ title: "แจ้งเตือน", text: "พบปัญหาการบันทึก กรุณาติดต่อผู้ดูแลระบบ" + msg, type: "error", showConfirmButton: true }); } }); } function SubmitEdit() { const formData = new FormData($("#form_edit")[0]); $.ajax({ type: "POST", url: "ajax/setting_law/update_law.php", data: formData, contentType: false, cache: false, processData: false, dataType: "json", success: function(data) { if (data.result == 1) { swal({ title: 'บันทึกข้อมูลสำเร็จ', type: 'success', showConfirmButton: false, timer: 1500 }, function() { load_table() swal.close(); $("#myModal").modal('hide'); }); } 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 }); } }, error: function(jqXHR, exception) { var msg = ''; if (jqXHR.status === 0) { msg = 'Not connect. Verify Network.'; } else if (jqXHR.status == 404) { msg = 'Requested page not found. [404]'; } else if (jqXHR.status == 500) { msg = 'Internal Server Error [500].'; } else if (exception === 'parsererror') { msg = 'Requested JSON parse failed.'; } else if (exception === 'timeout') { msg = 'Time out error.'; } else if (exception === 'abort') { msg = 'Ajax request aborted.'; } else { msg = 'Uncaught Error. ' + jqXHR.responseText; } swal({ title: "แจ้งเตือน", text: "พบปัญหาการบันทึก กรุณาติดต่อผู้ดูแลระบบ" + msg, type: "error", showConfirmButton: true }); } }); } function ChangeStatus(button, law_id) { $.ajax({ type: "post", url: "ajax/setting_law/ChangeStatus.php", data: { law_id: law_id }, dataType: "json", success: function(response) { if (response.result == 1) { if (response.status == 1) { $(button).addClass('btn-primary').removeClass('btn-danger').html('ใช้งาน'); if ($("#show_all").not(':checked')) { $('#tr_' + id).fadeOut(700); } else { } } else if (response.status == 0) { $(button).addClass('btn-danger').removeClass('btn-primary').html('ไม่ใช้งาน'); if ($("#show_all").is(':checked')) { $('#tr_' + law_id).fadeOut(700); } else { } } } else { swal("", "ไม่สามารถทำรายการได้กรุณาติดต่อเจ้าหน้าที่", "error"); } }, error: function(jqXHR, exception) { var msg = ''; if (jqXHR.status === 0) { msg = 'Not connect. Verify Network.'; } else if (jqXHR.status == 404) { msg = 'Requested page not found. [404]'; } else if (jqXHR.status == 500) { msg = 'Internal Server Error [500].'; } else if (exception === 'parsererror') { msg = 'Requested JSON parse failed.'; } else if (exception === 'timeout') { msg = 'Time out error.'; } else if (exception === 'abort') { msg = 'Ajax request aborted.'; } else { msg = 'Uncaught Error. ' + jqXHR.responseText; } swal({ title: "แจ้งเตือน", text: "พบปัญหาการบันทึก กรุณาติดต่อผู้ดูแลระบบ" + msg, type: "error", showConfirmButton: true }); } }); } function Delete(law_id) { swal({ title: 'กรุณายืนยันเพื่อทำรายการ', type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', cancelButtonText: 'ยกเลิก', confirmButtonText: 'ยืนยัน', closeOnConfirm: false }, function() { $.ajax({ type: "POST", url: "ajax/setting_law/delete_law.php", data: { law_id: law_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 }); } }, error: function(jqXHR, exception) { var msg = ''; if (jqXHR.status === 0) { msg = 'Not connect. Verify Network.'; } else if (jqXHR.status == 404) { msg = 'Requested page not found. [404]'; } else if (jqXHR.status == 500) { msg = 'Internal Server Error [500].'; } else if (exception === 'parsererror') { msg = 'Requested JSON parse failed.'; } else if (exception === 'timeout') { msg = 'Time out error.'; } else if (exception === 'abort') { msg = 'Ajax request aborted.'; } else { msg = 'Uncaught Error. ' + jqXHR.responseText; } swal({ title: "แจ้งเตือน", text: "พบปัญหาการบันทึก กรุณาติดต่อผู้ดูแลระบบ" + msg, type: "error", showConfirmButton: true }); } }); }) } function DeleteFile(law_id,doc_id) { swal({ title: 'กรุณายืนยันเพื่อทำรายการ', type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', cancelButtonText: 'ยกเลิก', confirmButtonText: 'ยืนยัน', closeOnConfirm: false }, function() { $.ajax({ type: "POST", url: "ajax/setting_law/delete_file.php", data: { doc_id: doc_id }, dataType: "json", success: function(data) { if (data.result == 1) { swal({ title: 'ดำเนินการเรียบร้อย', type: 'success', showConfirmButton: false, timer: 1500 }, function() { swal.close(); load_table(); GetModalEdit(law_id); }); } 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 }); } }, error: function(jqXHR, exception) { var msg = ''; if (jqXHR.status === 0) { msg = 'Not connect. Verify Network.'; } else if (jqXHR.status == 404) { msg = 'Requested page not found. [404]'; } else if (jqXHR.status == 500) { msg = 'Internal Server Error [500].'; } else if (exception === 'parsererror') { msg = 'Requested JSON parse failed.'; } else if (exception === 'timeout') { msg = 'Time out error.'; } else if (exception === 'abort') { msg = 'Ajax request aborted.'; } else { msg = 'Uncaught Error. ' + jqXHR.responseText; } swal({ title: "แจ้งเตือน", text: "พบปัญหาการบันทึก กรุณาติดต่อผู้ดูแลระบบ" + msg, type: "error", showConfirmButton: true }); } }); }) } </script> </body> </html>