/
home
/
efamember
/
domains
/
efa-member.com
/
public_html
/
backoffice
/
up file
home
<?php include('header.php'); ?> <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="ibox-tools"> <button class="btn btn-primary btn-sm" onclick="AddContent()">เพิ่มเนื้อหา</button> </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" 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() { $('#Loading').show(); getTable(); }); function getTable() { $.ajax({ type: "POST", url: "ajax/setting_content/get_table.php", dataType: "html", success: function(response) { $("#show_table").html(response); $('.dataTables-example').DataTable({ ordering: false, pageLength: 25, responsive: true, }); $('#Loading').hide(); } }); } function AddContent() { $('#myModal').modal('show'); $('#showModal').load("ajax/setting_content/modal_add.php", { "setting_id": setting_id, }, function() { if ($("#setting_type").val() == "1") { $('#setting_content').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); } } }); } $("#EditFormSubmit").click(function() { let setting_content = $('#setting_content').val(); if (setting_content == "") { swal({ title: 'แจ้งเตือน', text: 'กรุณากรอกข้อมูลให้ครบ', type: "warning", showConfirmButton: false }); setTimeout(function() { swal.close(); }, 1500); return false; } swal({ title: "แจ้งเตือน", text: "ยืนยัน แก้ไขข้อมูล ?", type: "warning", showCancelButton: true, confirmButtonColor: "#1AB394", confirmButtonText: "ยืนยัน", cancelButtonText: "ตรวจสอบอีกครั้ง", closeOnConfirm: false }, function() { let myForm = document.getElementById('form_edit'); let formData = new FormData(myForm); $.ajax({ url: 'ajax/setting_content/edit.php', type: 'POST', dataType: 'json', contentType: false, cache: false, processData: false, data: formData, success: function(data) { if (data.result == 1) { $('#myModal').modal('hide'); getTable(); 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 EditData(setting_id) { $('#myModal').modal('show'); $('#showModal').load("ajax/setting_content/modal_edit.php", { "setting_id": setting_id, }, function() { if ($("#setting_type").val() == "1") { $('#setting_content').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); } } }); } $("#EditFormSubmit").click(function() { let setting_content = $('#setting_content').val(); if (setting_content == "") { swal({ title: 'แจ้งเตือน', text: 'กรุณากรอกข้อมูลให้ครบ', type: "warning", showConfirmButton: false }); setTimeout(function() { swal.close(); }, 1500); return false; } swal({ title: "แจ้งเตือน", text: "ยืนยัน แก้ไขข้อมูล ?", type: "warning", showCancelButton: true, confirmButtonColor: "#1AB394", confirmButtonText: "ยืนยัน", cancelButtonText: "ตรวจสอบอีกครั้ง", closeOnConfirm: false }, function() { let myForm = document.getElementById('form_edit'); let formData = new FormData(myForm); $.ajax({ url: 'ajax/setting_content/edit.php', type: 'POST', dataType: 'json', contentType: false, cache: false, processData: false, data: formData, success: function(data) { if (data.result == 1) { $('#myModal').modal('hide'); getTable(); 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 ImageReadURL(input, value, show_position) { let fty = ["jpg", "jpeg", "png"]; let permiss = 0; let file_type = value.split('.'); file_type = file_type[file_type.length - 1]; if (jQuery.inArray(file_type.toLowerCase(), fty) !== -1) { let reader = new FileReader(); reader.onload = function(e) { $(show_position).attr('src', e.target.result); } reader.readAsDataURL(input.files[0]); } else if (value == "") { $(show_position).attr('src', 'image/no-image.png'); $(input).val(""); } else { swal({ title: "เกิดข้อผิดพลาด", text: "อัพโหลดได้เฉพาะไฟล์นามสกุล (.jpg .jpeg .png) เท่านั้น", type: "warning" }); $(show_position).attr('src', 'image/no-image.png'); $(input).val(""); return false; } } </script> </body> </html>