/
home
/
efamember
/
domains
/
efa-member.com
/
public_html
/
backoffice
/
up file
home
<?php include('header.php'); $secure = "cAh3DrJACzw4RbU"; $connection = connectDB($secure); $blog_id = $_GET['id']; $sql = "SELECT * FROM tbl_blog WHERE blog_id ='$blog_id' "; $rs = mysqli_query($connection, $sql) or die($connection->error); $row = mysqli_fetch_assoc($rs); ?> <body class="top-navigation"> <!-- <div class="row wrapper border-bottom white-bg page-heading"> <div class="col-lg-12"> <h2 class="text-navy">แก้ไขเนื้อหา Blog</h2> <ol class="breadcrumb"> <li class="breadcrumb-item"> <a href="index.php">หน้าแรก</a> </li> <li class="breadcrumb-item"> <a href="blog_list.php">Blog</a> </li> <li class="breadcrumb-item active"> <strong><a href="blog_content.php?id=<?php echo $_GET["id"]; ?>">แก้ไขเนื้อหา Blog</a></strong> </li> </ol> </div> </div> --> <div class="wrapper wrapper-content animated fadeInRight"> <input type="hidden" name="blog_id" id="blog_id" value="<?php echo $blog_id ?>"> <div class="row"> <div class="col-md-3 col-sm-12"> <a href="blogs_member_setting.php?id=<?php echo $blog_id ?>"> <div class="widget style1 p-2 text-dark"> <div class="row vertical-align text-center"> <div class="col-12"> <h3 class="font-bold mb-0">1. ข้อมูล Blog</h3> </div> </div> </div> </a> </div> <div class="col-md-3 col-sm-12"> <a href="blogs_member_content.php?id=<?php echo $blog_id ?>"> <div class="widget style1 navy-bg p-2"> <div class="row vertical-align text-center"> <div class="col-12"> <h3 class="font-bold mb-0">2. เนื้อหา Blog</h3> </div> </div> </div> </a> </div> <!-- <div class="col-md-3 col-sm-12"> <a href="blogs_member_sort.php?id=<?php echo $blog_id ?>"> <div class="widget style1 p-2"> <div class="row vertical-align text-center text-dark"> <div class="col-12"> <h3 class="font-bold mb-0">3. จัดเรียงเนื้อหา</h3> </div> </div> </div> </a> </div> --> </div> <div class="row mt-3"> <div class="col-12"> <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="ShowForm"></div> </div> </div> </div> <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" id="loader_modal"> <div id="showModal"></div> </div> </div> </div> <div class="modal" id="subModal" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content animated fadeIn"> <div id="showSubModal"></div> </div> </div> </div> <?php include('footer.php'); ?> <script> $(document).ready(function() { LoadData(); }); function LoadData() { let blog_id = $("#blog_id").val(); $.ajax({ type: 'POST', url: 'ajax/blog_setting_member/from_content_sort.php', data: { blog_id: blog_id, }, dataType: 'html', success: function(data) { $('#ShowForm').html(data); $("#ShowSortContent").sortable(); $(".tr_move").css({ "cursor": "move", "border": "2px dashed" }); $('#Loading').hide(); } }); } // function LoadData() { // let blog_id = $("#blog_id").val(); // $.ajax({ // type: 'POST', // url: 'ajax/blog_setting_member/form_content_edit.php', // data: { // blog_id: blog_id, // }, // dataType: 'html', // success: function(data) { // $('#ShowForm').html(data); // $('#Loading').hide(); // } // }); // } 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, 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; } } function VideoReadURL(input, value, show_position) { var fty = ["mp4"]; var permiss = 0; var file_type = value.split('.'); file_type = file_type[file_type.length - 1]; if (jQuery.inArray(file_type, fty) !== -1) { $(show_position).html(input.value.replace("C:\\fakepath\\", '')); } else if (value == "") { $(show_position).html("เลือกไฟล์..."); $(input).val(""); } else { swal({ title: "เกิดข้อผิดพลาด!", text: "อัพโหลดได้เฉพาะไฟล์นามสกุล (.mp4) เท่านั้น!", type: "warning" }); $(show_position).html("เลือกไฟล์..."); $(input).val(""); return false; } } function SetIFrame(value) { let content_yt_id = value.value; $('#iframe_label').attr('src', "https://www.youtube.com/embed/" + content_yt_id); } function AddContent(content_type) { let blog_id = $("#blog_id").val(); $('#myModal').modal('show'); $('#showModal').load("ajax/blog_setting_member/form_content_add.php", { "content_type": content_type, "blog_id": blog_id, }, function() { //$(".wrapper-content").LoadingOverlay("hide", true); $('#content_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); } } }); // $('.tagsinput').tagsinput({ // tagClass: 'label label-primary' // }); $("#AddFormSubmit").click(function() { let content_type = $('#content_type').val(); if ((content_type == 1 && $('#content_text').val() == "") || (content_type == 2 && $('#content_image').val() == "") || (content_type == 3 && $('#content_yt_id').val() == "")) { swal({ title: 'แจ้งเตือน', text: 'กรุณากรอกข้อมูลให้ครบ', type: "warning", showConfirmButton: false }); setTimeout(function() { swal.close(); }, 1500); return false; } swal({ title: "ยืนยัน การเพิ่มข้อมูล ?", type: "warning", showCancelButton: true, confirmButtonColor: "#1AB394", confirmButtonText: "ยืนยัน", cancelButtonText: "ตรวจสอบอีกครั้ง", closeOnConfirm: false }, function() { $(".confirm").prop('disabled', true); let myForm = document.getElementById('form_add'); let formData = new FormData(myForm); $.ajax({ url: 'ajax/blog_setting_member/content_insert.php', type: 'POST', dataType: 'json', contentType: false, cache: false, processData: false, data: formData, success: function(data) { $(".confirm").prop('disabled', false); if (data.result == 1) { LoadData(); swal({ title: "แจ้งเตือน", text: "เพิ่มข้อมูลสำเร็จ", type: "success", showConfirmButton: false }); setTimeout(function() { $('#myModal').modal('hide'); 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 DeleteNewsContent(blog_id, list_order) { swal({ title: "ยืนยัน การลบข้อมูล ?", type: "warning", showCancelButton: true, confirmButtonColor: "#ED5565", confirmButtonText: "ยืนยัน", cancelButtonText: "ตรวจสอบอีกครั้ง", closeOnConfirm: false }, function() { $(".confirm").prop('disabled', true); $.ajax({ url: 'ajax/blog_setting_member/content_delete.php', type: 'POST', dataType: 'json', data: { blog_id: blog_id, list_order: list_order, }, success: function(data) { $(".confirm").prop('disabled', false); if (data.result == 1) { LoadData(); swal({ title: "แจ้งเตือน", text: "ลบข้อมูลสำเร็จ", type: "success", showConfirmButton: false }); setTimeout(function() { $('#myModal').modal('hide'); swal.close(); }, 2000); } else if (data.result == 0) { swal({ title: "แจ้งเตือน", text: "ลบข้อมูลไม่สำเร็จ", type: "error", showConfirmButton: false }); setTimeout(function() { swal.close(); }, 2000); } } }); }); } function EditNewsContent(blog_id, list_order) { $('#myModal').modal('show'); $('#showModal').load("ajax/blog_setting_member/content_modal_edit.php", { "blog_id": blog_id, "list_order": list_order, }, function() { // $(".wrapper-content").LoadingOverlay("hide", true); $('#content_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); } } }); $('.tagsinput').tagsinput({ tagClass: 'label label-primary' }); $("#EditFormSubmit").click(function() { let content_type = $('#content_type').val(); if ((content_type == 1 && $('#content_text').val() == "") || (content_type == 2 && $('#content_image').val() == "") || (content_type == 3 && $('#content_yt_id').val() == "") || (content_type == 4 && $('#content_video').val() == "")) { swal({ title: 'แจ้งเตือน', text: 'กรุณากรอกข้อมูลให้ครบ', type: "warning", showConfirmButton: false }); setTimeout(function() { swal.close(); }, 1500); return false; } swal({ title: "ยืนยัน การแก้ไขข้อมูล ?", type: "warning", showCancelButton: true, confirmButtonColor: "#1AB394", confirmButtonText: "ยืนยัน", cancelButtonText: "ตรวจสอบอีกครั้ง", closeOnConfirm: false }, function() { $(".confirm").prop('disabled', true); let myForm = document.getElementById('form_edit'); let formData = new FormData(myForm); $.ajax({ url: 'ajax/blog_setting_member/content_edit.php', type: 'POST', dataType: 'json', contentType: false, cache: false, processData: false, data: formData, success: function(data) { $(".confirm").prop('disabled', false); if (data.result == 1) { swal({ title: "แจ้งเตือน", text: "แก้ไขข้อมูลสำเร็จ", type: "success", showConfirmButton: false }); setTimeout(function() { $('#myModal').modal('hide'); swal.close(); LoadData(); }, 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 SortData() { let blog_id = $("#blog_id").val(); let content_id = $("input[name='content_id[]']").map(function() { return $(this).val(); }).get(); swal({ title: "ยืนยัน การจัดลำดับข้อมูล ?", type: "warning", showCancelButton: true, confirmButtonColor: "#1AB394", confirmButtonText: "ยืนยัน", cancelButtonText: "ตรวจสอบอีกครั้ง", closeOnConfirm: false }, function() { $.ajax({ url: 'ajax/blog_setting_member/content_sort.php', type: 'POST', data: { blog_id: blog_id, content_id: content_id, }, dataType: 'json', success: function(data) { $(".confirm").prop('disabled', false); if (data.result == 1) { LoadData(); 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 }); } } }); }); } </script> </body> </html>