/
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/officer_list/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/officer_list/modal_add_officer.php"); } function GetModalEdit(admin_id) { $("#myModal").modal("show"); $("#showModal").load("ajax/officer_list/modal_edit_officer.php", { admin_id: admin_id }); } function GetModalMenuAccess(admin_id) { $("#myModal").modal("show"); $("#showModal").load("ajax/officer_list/modal_menu_access.php", { admin_id: admin_id }); } function add_officer() { const admin_id = $("#admin_id").val(); const username = $("#username").val(); const admin_name = $("#admin_name").val(); const password = $("#password").val(); const re_password = $("#re_password").val(); const menu_access = []; const update_user_id = localStorage.getItem("admin_id"); if (password != re_password) { swal({ title: 'รหัสผ่านยืนยันไม่ตรงกัน', text: '', type: 'warning', showConfirmButton: false, timer: 1500 }); return false; } $("input[name='menu_access[]']:checked").each(function(i) { menu_access.push($(this).val()); }); $.ajax({ type: "POST", url: "ajax/officer_list/add_officer.php", data: { admin_id: admin_id, username: username, admin_name: admin_name, password: password, menu_access: menu_access, update_user_id: update_user_id }, 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 SubmitMenuAccess() { const admin_id = $("#admin_id").val(); const menu_access = []; $("input[name='menu']:checked").each(function(i) { menu_access[i] = $(this).val(); }); $.ajax({ type: "POST", url: "ajax/officer_list/update_access.php", data: { admin_id: admin_id, menu_access: menu_access }, dataType: "json", success: function(data) { if (data.result == 1) { swal({ title: 'บันทึกข้อมูลเรียบร้อย', type: 'success', showConfirmButton: false, timer: 1500 }, function() { 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 update_user_id = localStorage.getItem("admin_id"); const formData = new FormData($("#frm_edit_officer")[0]); formData.append('update_user_id', update_user_id); $.ajax({ type: "POST", url: "ajax/officer_list/update_admin.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, admin_id) { $.ajax({ type: "post", url: "ajax/officer_list/ChangeStatus.php", data: { admin_id: admin_id }, dataType: "json", success: function(response) { if (response.result == 1) { if (response.status == 1) { $(button).addClass('btn-primary').removeClass('btn-danger').html('ใช้งาน'); } else if (response.status == 0) { $(button).addClass('btn-danger').removeClass('btn-primary').html('ไม่ใช้งาน'); if ($("#show_all").is(':checked')) { $('#tr_' + admin_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 }); } }); } </script> </body> </html>