/
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'); ?> <script src="../template/js/plugins/summernote/summernote-bs4.js"></script> <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_blog/form_add.php", { admin_id: admin_id, }, function() { $("select.form-control").select2(); $('#blog_text').summernote({ height: 200, toolbar: [ ['style', ['bold', 'italic', 'underline', 'clear']], ['font', ['strikethrough', 'superscript', 'subscript']], ['fontsize'], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['height', ['height']], ['insert', ['link', 'hr']] ], callbacks: { onPaste: function(e) { var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text'); e.preventDefault(); setTimeout(function() { document.execCommand('insertText', false, bufferText); }, 10); } } }); }); } 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_blog/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, ordering: false, }); $('#show_table').show(); $('#Loading').hide(); } }); } function save_blog() { var formData = new FormData($("#form_blog")[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_blog/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(blog_id) { $.ajax({ type: 'POST', url: 'ajax/ChangeStatus.php', data: { table_name: "tbl_setting_blog", key_name: "blog_id", key_value: blog_id }, dataType: 'json', success: function(data) { load_table(); } }); } function EditContent(blog_id) { $('#myModal').modal('show'); $('#showModal').load("ajax/setting_blog/form_edit.php", { blog_id: blog_id, }, function() { $("select.form-control").select2(); $('#blog_text').summernote({ height: 200, toolbar: [ ['style', ['bold', 'italic', 'underline', 'clear']], ['font', ['strikethrough', 'superscript', 'subscript']], ['fontsize'], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['height', ['height']], ['insert', ['link', 'hr']] ], callbacks: { onPaste: function(e) { var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text'); e.preventDefault(); setTimeout(function() { document.execCommand('insertText', false, bufferText); }, 10); } } }); }); } function update_blog() { var formData = new FormData($("#form_blog")[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_blog/update.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 DeleteContent(blog_id) { swal({ title: 'กรุณายืนยันเพื่อทำรายการ', type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', cancelButtonText: 'ยกเลิก', confirmButtonText: 'ยืนยัน', closeOnConfirm: false }, function() { $.ajax({ type: "post", url: "ajax/setting_blog/delete.php", data: { blog_id: blog_id }, dataType: "json", success: function(data) { if (data.result == 1) { swal({ title: "ดำเนินการสำเร็จ", text: "ลบข้อมูลสำเร็จ", type: "success" }, function() { swal.close(); load_table(); }); } else if (data.result == 0) { swal({ title: "เกิดข้อผิดพลาด", text: "เกิดข้อผิดพลาดระหว่างบันทึก", type: "error" //Please Check Your Account }, function() { //location.reload(); }); } } }); }); } </script> </script> </body> </html>