Server IP : 150.95.80.236 / Your IP : 18.227.24.74 Web Server : Apache System : Linux host-150-95-80-236 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : social-telecare ( 10000) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/pcu.in.th/sc.pcu.in.th/ |
Upload File : |
<?php include "function.php"; ?> <!--begin::Content--> <div class="content d-flex flex-column flex-column-fluid" id="kt_content"> <!--begin::Container--> <div class="container-fluid" id="kt_content_container"> <!--begin::Card--> <div class="card"> <!--begin::Card header--> <div class="card-header border-0 pt-6"> <!--begin::Card title--> <div class="card-title"> </div> <!--begin::Card title--> <!--begin::Card toolbar--> <div class="card-toolbar"> <!--begin::Toolbar--> <div class="d-flex justify-content-end" data-kt-customer-table-toolbar="base"> <!--begin::Add customer--> <!-- <a class="btn btn-primary" href="index.php?p=add_case">เพิ่มสื่อการเรียนรู้</a> --> <a href="#" class="btn btn-primary align-self-center" data-bs-toggle="modal" data-bs-target="#add_media">เพิ่มสื่อการเรียนรู้</a> <!--end::Add customer--> </div> <!--end::Toolbar--> </div> <!--end::Card toolbar--> </div> <!--end::Card header--> <!--begin::Card body--> <div class="card-body pt-0"> <!--begin::Table--> <table class="table align-middle table-row-dashed fs-6 gy-5" id="kt_datatable_example_5"> <!--begin::Table head--> <thead> <!--begin::Table row--> <tr class="text-start text-gray-400 fw-bolder fs-7 text-uppercase gs-0"> <!-- <th class="w-10px pe-2"> <div class="form-check form-check-sm form-check-custom form-check-solid me-3"> <input class="form-check-input" type="checkbox" data-kt-check="true" data-kt-check-target="#kt_customers_table .form-check-input" value="1" /> </div> </th> --> <th class="min-w-20px">ลำดับ</th> <th class="min-w-125px">หัวข้อ</th> <th class="min-w-125px">รายละเอียด</th> <th class="min-w-125px">url วิดีโอ</th> <th class="min-w-125px">รูปภาพ</th> <th class="min-w-125px">ไฟล์</th> <th class="text-center min-w-125px">Actions</th> </tr> <!--end::Table row--> </thead> <!--end::Table head--> <!--begin::Table body--> <tbody class="fw-bold text-gray-600"> <?php $query_media = $conn->query("SELECT * FROM media_learn WHERE doctor_id = '".$_SESSION['user_id']."' "); $i = 1; while ($fet_media = $query_media->fetch_object()) { ?> <tr> <!--begin::Checkbox--> <!-- <td> <div class="form-check form-check-sm form-check-custom form-check-solid"> <input class="form-check-input" type="checkbox" value="1" /> </div> </td> --> <!--end::Checkbox--> <!--begin::Name=--> <td><?php echo $i; ?></td> <td> <?php echo $fet_media->media_title ?> <!-- <a href="index.php?p=case_detail&case_id=<?php echo $fet_case->user_id; ?>" class="text-gray-800 text-hover-primary mb-1"><?php echo $fet_case->case_tname."".$fet_case->case_name ?></a> --> </td> <!--end::Name=--> <!--begin::Email=--> <td> <?php echo substr($fet_media->media_detail,0,120) ?> </td> <!--end::Email=--> <!--begin::Company=--> <td> <?php $url = $fet_media->media_url; $convert = str_replace("watch?v=", "embed/", $url) ?> <!--begin::Video--> <div class="mb-3"> <?php if ($fet_media->media_url) { ?> <iframe class="embed-responsive-item card-rounded h-100px w-100" src="<?php echo $convert; ?>" allowfullscreen="allowfullscreen"></iframe> <?php }else{ ?> ไม่มีวิดีโอสื่อการสอน <?php } ?> </div> <!--end::Video--> </td> <!--end::Company=--> <!--begin::Payment method=--> <td> <a href="#" class="btn btn-sm btn-light btn-active-light-info" data-bs-toggle="modal" data-bs-target="#img_media" id="btn_show_img" data-media_img="<?php echo $fet_media->media_img ?>">เปิดรูปภาพ</a> <?php echo $fet_media->case_privilege ?> </td> <!--end::Payment method=--> <!--begin::Date=--> <td><a href=" <?php if($fet_media->media_file){ echo ' media_learn/file/'.$fet_media->media_file; }else{ echo '#'; } ?> " class="btn btn-sm btn-light btn-active-light-info" target="<?php if($fet_media->media_file){ echo '_blank'; } ?>"> เปิดไฟล์ </a></td> <!--end::Date=--> <!--begin::Action=--> <td class="text-center"> <a href="#" class="btn btn-sm btn-light btn-active-light-info" data-bs-toggle="modal" data-bs-target="#edit_media" id="btn_edit_media" data-media_title="<?php echo $fet_media->media_title ?>" data-media_detail="<?php echo $fet_media->media_detail; ?>" data-media_img="<?php echo $fet_media->media_img ?>" data-media_url="<?php echo $fet_media->media_url; ?>" data-media_id="<?php echo $fet_media->media_id ?>">แก้ไข</a> <a href="#" onclick="return del(<?php echo $fet_media->media_id; ?>)" class="btn btn-sm btn-light btn-active-light-danger"> ลบ </a> </td> <!--end::Action=--> </tr> <?php $i++; } ?> </tbody> <!--end::Table body--> </table> <!--end::Table--> </div> <!--end::Card body--> </div> <!--end::Card--> </div> <!--end::Container--> </div> <!--end::Content--> <!-- แก้ไขข้อมูล :: start --> <!--begin::Modals--> <!--begin::Modal - media - Add--> <div class="modal fade" id="edit_media" tabindex="-1" aria-hidden="true"> <!--begin::Modal dialog--> <div class="modal-dialog modal-dialog-centered mw-650px"> <!--begin::Modal content--> <div class="modal-content"> <!--begin::Form--> <form class="form" method="POST" action="api/ac_media_learn.php?ac=edit" id="form_edit_media" enctype="multipart/form-data"> <!--begin::Modal header--> <div class="modal-header" id="kt_modal_add_customer_header"> <!--begin::Modal title--> <h2 class="fw-bolder">แก้ไขสื่อการเรียนรู้</h2> <!--end::Modal title--> <!--begin::Close--> <div id="edit_media_close" class="btn btn-icon btn-sm btn-active-icon-primary"> <!--begin::Svg Icon | path: icons/duotune/arrows/arr061.svg--> <span class="svg-icon svg-icon-1"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> <rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="black" /> <rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="black" /> </svg> </span> <!--end::Svg Icon--> </div> <!--end::Close--> </div> <!--end::Modal header--> <!--begin::Modal body--> <div class="modal-body py-10 px-lg-17"> <!--begin::Scroll--> <div class="scroll-y me-n7 pe-7" id="kt_modal_add_customer_scroll" data-kt-scroll="true" data-kt-scroll-activate="{default: false, lg: true}" data-kt-scroll-max-height="auto" data-kt-scroll-dependencies="#kt_modal_add_customer_header" data-kt-scroll-wrappers="#kt_modal_add_customer_scroll" data-kt-scroll-offset="300px"> <input type="text" class="form-control form-control-solid d-none" name="media_id" value="" id="media_id" /> <!--begin::Input group--> <div class="row g-9 mb-8"> <!--begin::Col--> <div class="col-md-12 fv-row"> <label class="required fs-6 fw-bold mb-2">ชื่อสื่อการเรียนรู้</label> <input type="text" class="form-control form-control-solid" name="media_title" value="" id="media_title" /> </div> <!--end::Col--> </div> <!--end::Input group--> <!--begin::Input group--> <div class="row g-9 mb-8"> <!--begin::Col--> <div class="col-md-12 fv-row"> <label class="required fs-6 fw-bold mb-2">รายละเอียดสื่อการเรียนรู้</label> <!--begin::Textarea--> <textarea name="media_detail" class="form-control form-control-solid mb-8" rows="3" placeholder="รายละเอียด" id="media_detail"></textarea> <!--end::Textarea--> </div> <!--end::Col--> </div> <!--end::Input group--> <!--begin::Input group--> <div class="row mb-6"> <!--begin::Label--> <label class="col-lg-4 col-form-label fw-bold fs-6">รูปภาพประกอบ</label> <!--end::Label--> <!--begin::Col--> <div class="col-lg-8"> <!--begin::Image input--> <div class="image-input image-input-outline" data-kt-image-input="true" style="background-image: url(assets/media/avatars/blank.png)"> <!--begin::Preview existing avatar--> <!-- <div class="image-input-wrapper w-200px h-200px" style="background-image: url(images/profile/nophoto.jpg)"></div> --> <div id="media_img" class="image-input-wrapper w-200px h-200px" ></div> <!--end::Preview existing avatar--> <!--begin::Label--> <label class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="change" data-bs-toggle="tooltip" title="เปลี่ยนรูปรูปภาพประกอบ"> <i class="bi bi-pencil-fill fs-7"></i> <!--begin::Inputs--> <input type="file" name="media_img" accept=".png, .jpg, .jpeg" /> <input type="hidden" name="avatar_remove" /> <!--end::Inputs--> </label> <!--end::Label--> <!--begin::Cancel--> <span class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="cancel" data-bs-toggle="tooltip" title="ยกเลิก"> <i class="bi bi-x fs-2"></i> </span> <!--end::Cancel--> <!--begin::Remove--> <span class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="remove" data-bs-toggle="tooltip" title="นำออก"> <i class="bi bi-x fs-2"></i> </span> <!--end::Remove--> </div> <!--end::Image input--> <!--begin::Hint--> <div class="form-text">เฉพาะไฟล์นามสกุล: png, jpg, jpeg.</div> <!--end::Hint--> </div> <!--end::Col--> </div> <!--end::Input group--> <!--begin::Input group--> <div class="row g-9 mb-8"> <!--begin::Col--> <div class="col-md-12 fv-row"> <label class="required fs-6 fw-bold mb-2">ไฟล์สื่อการสอน</label> <input type="file" class="form-control form-control-solid" name="media_file" value="" /> </div> <!--end::Col--> </div> <!--end::Input group--> <!--begin::Input group--> <div class="row g-9 mb-8"> <!--begin::Col--> <div class="col-md-12 fv-row"> <label class="required fs-6 fw-bold mb-2">url วิดีโอสื่อการสอน (จากYoutube)</label> <input type="text" class="form-control form-control-solid" name="media_url" id="media_url" /> </div> <!--end::Col--> </div> <!--end::Input group--> <!-- start input address --> </div> <!--end::Scroll--> </div> <!--end::Modal body--> <!--begin::Modal footer--> <div class="modal-footer flex-center"> <!--begin::Button--> <button type="reset" id="edit_media_cancel" class="btn btn-light me-3">ยกเลิก</button> <!--end::Button--> <!--begin::Button--> <button type="submit" id="btn_send_edit" class="btn btn-primary"> <span class="indicator-label">บันทึก</span> <span class="indicator-progress">Please wait... <span class="spinner-border spinner-border-sm align-middle ms-2"></span></span> </button> <!--end::Button--> </div> <!--end::Modal footer--> </form> <!--end::Form--> </div> </div> </div> <!--end::Modal - media - Add--> <!--end::Modals--> <!-- แก้ไขข้อมูล :: end --> <!--begin::Modals--> <!--begin::Modal - media - Add--> <div class="modal fade" id="add_media" tabindex="-1" aria-hidden="true"> <!--begin::Modal dialog--> <div class="modal-dialog modal-dialog-centered mw-650px"> <!--begin::Modal content--> <div class="modal-content"> <!--begin::Form--> <form class="form" method="POST" action="api/ac_media_learn.php?ac=add" id="form_add_media" enctype="multipart/form-data"> <!--begin::Modal header--> <div class="modal-header" id="kt_modal_add_customer_header"> <!--begin::Modal title--> <h2 class="fw-bolder">เพิ่มสื่อการเรียนรู้</h2> <!--end::Modal title--> <!--begin::Close--> <div id="add_media_close" class="btn btn-icon btn-sm btn-active-icon-primary"> <!--begin::Svg Icon | path: icons/duotune/arrows/arr061.svg--> <span class="svg-icon svg-icon-1"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> <rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="black" /> <rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="black" /> </svg> </span> <!--end::Svg Icon--> </div> <!--end::Close--> </div> <!--end::Modal header--> <!--begin::Modal body--> <div class="modal-body py-10 px-lg-17"> <!--begin::Scroll--> <div class="scroll-y me-n7 pe-7" id="kt_modal_add_customer_scroll" data-kt-scroll="true" data-kt-scroll-activate="{default: false, lg: true}" data-kt-scroll-max-height="auto" data-kt-scroll-dependencies="#kt_modal_add_customer_header" data-kt-scroll-wrappers="#kt_modal_add_customer_scroll" data-kt-scroll-offset="300px"> <!--begin::Input group--> <div class="row g-9 mb-8"> <!--begin::Col--> <div class="col-md-12 fv-row"> <label class="required fs-6 fw-bold mb-2">ชื่อสื่อการเรียนรู้</label> <input type="text" class="form-control form-control-solid" name="media_title" value="" /> </div> <!--end::Col--> </div> <!--end::Input group--> <!--begin::Input group--> <div class="row g-9 mb-8"> <!--begin::Col--> <div class="col-md-12 fv-row"> <label class="required fs-6 fw-bold mb-2">รายละเอียดสื่อการเรียนรู้</label> <!--begin::Textarea--> <textarea name="media_detail" class="form-control form-control-solid mb-8" rows="3" placeholder="รายละเอียด"></textarea> <!--end::Textarea--> </div> <!--end::Col--> </div> <!--end::Input group--> <!--begin::Input group--> <div class="row mb-6 mt"> <!--begin::Label--> <label class="col-lg-4 col-form-label fw-bolder fs-6">รูปภาพประกอบ</label> <!--end::Label--> <!--begin::Col--> <div class="col-lg-8"> <!--begin::Image input--> <div class="image-input image-input-outline" data-kt-image-input="true"> <!--begin::Preview existing avatar--> <div class="image-input-wrapper w-100px h-100px" style=""></div> <!--end::Preview existing avatar--> <!--begin::Label--> <label class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="change" data-bs-toggle="tooltip" title="รูปภาพประกอบ"> <i class="bi bi-pencil-fill fs-7"></i> <!--begin::Inputs--> <input type="file" name="media_img" accept=".png, .jpg, .jpeg" /> <!-- <input type="hidden" name="avatar_remove" /> --> <!--end::Inputs--> </label> <!--end::Label--> <!--begin::Cancel--> <span class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="cancel" data-bs-toggle="tooltip" title="ยกเลิก"> <i class="bi bi-x fs-2"></i> </span> <!--end::Cancel--> <!--begin::Remove--> <span class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="remove" data-bs-toggle="tooltip" title="นำออก"> <i class="bi bi-x fs-2"></i> </span> <!--end::Remove--> </div> <!--end::Image input--> <!--begin::Hint--> <div class="form-text">เฉพาะไฟล์นามสกุล: png, jpg, jpeg.</div> <!--end::Hint--> </div> <!--end::Col--> </div> <!--end::Input group--> <!--begin::Input group--> <!--begin::Input group--> <div class="row g-9 mb-8"> <!--begin::Col--> <div class="col-md-12 fv-row"> <label class="required fs-6 fw-bold mb-2">ไฟล์สื่อการสอน</label> <input type="file" class="form-control form-control-solid" name="media_file" value="" /> </div> <!--end::Col--> </div> <!--end::Input group--> <!--begin::Input group--> <div class="row g-9 mb-8"> <!--begin::Col--> <div class="col-md-12 fv-row"> <label class="required fs-6 fw-bold mb-2">url วิดีโอสื่อการสอน (จากYoutube)</label> <input type="text" class="form-control form-control-solid" name="media_url" /> </div> <!--end::Col--> </div> <!--end::Input group--> <!-- start input address --> </div> <!--end::Scroll--> </div> <!--end::Modal body--> <!--begin::Modal footer--> <div class="modal-footer flex-center"> <!--begin::Button--> <button type="reset" id="add_media_cancel" class="btn btn-light me-3">ยกเลิก</button> <!--end::Button--> <!--begin::Button--> <button type="submit" id="btn_send_form" class="btn btn-primary"> <span class="indicator-label">บันทึก</span> <span class="indicator-progress">Please wait... <span class="spinner-border spinner-border-sm align-middle ms-2"></span></span> </button> <!--end::Button--> </div> <!--end::Modal footer--> </form> <!--end::Form--> </div> </div> </div> <!--end::Modal - media - Add--> <!--end::Modals--> <!-- รูปภาพ --> <!--begin::Modals--> <!--begin::Modal - media - Add--> <div class="modal fade" id="img_media" tabindex="-1" aria-hidden="true"> <!--begin::Modal dialog--> <div class="modal-dialog modal-dialog-centered mw-650px"> <!--begin::Modal content--> <div class="modal-content"> <form id="show_img" class="form"> <!--begin::Modal header--> <div class="modal-header" id="kt_modal_add_customer_header"> <!--begin::Modal title--> <h2 class="fw-bolder">รูปภาพสื่อการเรียนรู้</h2> <!--end::Modal title--> <!--begin::Close--> <div id="img_media_close" class="btn btn-icon btn-sm btn-active-icon-primary"> <!--begin::Svg Icon | path: icons/duotune/arrows/arr061.svg--> <span class="svg-icon svg-icon-1"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> <rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="black" /> <rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="black" /> </svg> </span> <!--end::Svg Icon--> </div> <!--end::Close--> </div> <!--end::Modal header--> <!--begin::Modal body--> <div class="modal-body py-10 px-lg-17"> <!--begin::Scroll--> <div class="scroll-y me-n7 pe-7" id="kt_modal_add_customer_scroll" data-kt-scroll="true" data-kt-scroll-activate="{default: false, lg: true}" data-kt-scroll-max-height="auto" data-kt-scroll-dependencies="#kt_modal_add_customer_header" data-kt-scroll-wrappers="#kt_modal_add_customer_scroll" data-kt-scroll-offset="300px"> <div id="media_img_show" style="background-image: url(assets/media/avatars/blank.png)" class="image-input-wrapper w-300px h-300px"> </div> </div> <!--end::Scroll--> </div> <!--end::Modal body--> <!--begin::Modal footer--> <div class="modal-footer flex-center"> <!--begin::Button--> <button type="reset" id="img_media_cancel" class="btn btn-light me-3">ยกเลิก</button> <!--end::Button--> </div> <!--end::Modal footer--> </form> </div> </div> </div> <!--end::Modal - media - Add--> <!--end::Modals--> <!-- รูปภาพ : end --> <!--begin::Javascript--> <!--begin::Global Javascript Bundle(used by all pages)--> <script src="assets/plugins/global/plugins.bundle.js"></script> <script src="assets/js/scripts.bundle.js"></script> <!--end::Global Javascript Bundle--> <!--begin::Page Vendors Javascript(used by this page)--> <script src="assets/plugins/custom/datatables/datatables.bundle.js"></script> <!--end::Page Vendors Javascript--> <!--begin::Page Custom Javascript(used by this page)--> <script src="assets/js/custom/apps/customers/list/export.js"></script> <!-- C:\xampp\htdocs\scp\assets\js\custom\modals\form_addmedia_validate.js --> <!-- <script src="assets/js/custom/modals/form_addmedia_validate1.js"></script> --> <script src="assets/js/custom/apps/customers/list/list.js"></script> <script src="assets/js/custom/apps/customers/add.js"></script> <script src="assets/js/custom/widgets.js"></script> <script src="assets/js/custom/apps/chat/chat.js"></script> <script src="assets/js/custom/modals/create-app.js"></script> <script src="assets/js/custom/modals/upgrade-plan.js"></script> <!--end::Page Custom Javascript--> <!--end::Javascript--> <script> var ii = new bootstrap.Modal(document.querySelector("#add_media")) var rr = document.querySelector("#form_add_media") var oo = rr.querySelector("#add_media_close") var cc = rr.querySelector("#add_media_cancel") cc.addEventListener("click", function(t) { rr.reset() ii.hide() }) oo.addEventListener("click", function(t) { rr.reset() ii.hide() }) var i = new bootstrap.Modal(document.querySelector("#edit_media")) var r = document.querySelector("#form_edit_media") var o = r.querySelector("#edit_media_close") var c = r.querySelector("#edit_media_cancel") c.addEventListener("click", function(t) { r.reset() i.hide() }) o.addEventListener("click", function(t) { r.reset() i.hide() }) var z = new bootstrap.Modal(document.querySelector("#img_media")) var x = document.querySelector("#show_img") var a = x.querySelector("#img_media_close") var b = x.querySelector("#img_media_cancel") a.addEventListener("click", function(t) { x.reset() z.hide() }) b.addEventListener("click", function(t) { x.reset() z.hide() }) $(document).on('click', '#btn_edit_media', function(e) { e.preventDefault(); // console.log($(this).data('media_id')) $("#media_id").val($(this).data('media_id')); $("#media_title").val($(this).data('media_title')); $("#media_detail").val($(this).data('media_detail')); $("#media_url").val($(this).data('media_url')); $("#phonenumber").val($(this).data('phonenumber')); // console.log($(this).data('media_detail')) if ($(this).data('media_img') != "") { var imageUrl = 'media_learn/images/' + $(this).data('media_img'); $('#media_img').css('background-image', 'url(' + imageUrl + ')'); }else{ var imageUrl = 'assets/media/avatars/blank.png'; $('#media_img').css('background-image', 'url(' + imageUrl + ')'); } }); $(document).on('click', '#btn_show_img', function(e) { e.preventDefault(); if ($(this).data('media_img') != "") { var imageUrl = 'media_learn/images/' + $(this).data('media_img'); $('#media_img_show').css('background-image', 'url(' + imageUrl + ')'); }else{ var imageUrl = 'assets/media/avatars/blank.png'; $('#media_img_show').css('background-image', 'url(' + imageUrl + ')'); } }); $(document).on("submit", "#form_add_media", function(e) { e.preventDefault(); var url = $(this).attr("action"); var data = new FormData(this); // console.log(this) // console.log(data) // console.log(rr['media_title'].value) // var method = $(this).attr("method"); // console.log(validators(url, data, method)) $.ajax({ url: url, type: $(this).attr("method"), dataType: "JSON", data: data, processData: false, contentType: false, beforeSend: function() { $("#btn_send_form").attr('data-kt-indicator', 'on'); }, success: function(data, status) { console.log("data API"); console.log(data); if (data['status'] == true) { $("#btn_send_form").attr('data-kt-indicator', 'off'); Swal.fire({ text: data['msg'], icon: "success", buttonsStyling: false, confirmButtonText: "ตกลง", customClass: { confirmButton: "btn btn-primary" } }).then(function(result) { window.location.reload(); if (result.isConfirmed) { // window.location.replace("index.php?p=users"); //form.submit(); // submit form } }); } else { $("#btn_send_form").attr('data-kt-indicator', 'off'); Swal.fire({ text: data['msg'], icon: "error", buttonsStyling: false, confirmButtonText: "ตกลง", customClass: { confirmButton: "btn btn-primary" } }); } } }); }); $(document).on("submit", "#form_edit_media", function(e) { e.preventDefault(); var url = $(this).attr("action"); var data = new FormData(this); // console.log(this) // console.log(data) // console.log(rr['media_title'].value) // var method = $(this).attr("method"); // console.log(validators(url, data, method)) $.ajax({ url: url, type: $(this).attr("method"), dataType: "JSON", data: data, processData: false, contentType: false, beforeSend: function() { $("#btn_send_edit").attr('data-kt-indicator', 'on'); }, success: function(data, status) { console.log("data API"); console.log(data); if (data['status'] == true) { $("#btn_send_edit").attr('data-kt-indicator', 'off'); Swal.fire({ text: data['msg'], icon: "success", buttonsStyling: false, confirmButtonText: "ตกลง", customClass: { confirmButton: "btn btn-primary" } }).then(function(result) { window.location.reload(); if (result.isConfirmed) { // window.location.replace("index.php?p=users"); //form.submit(); // submit form } }); } else { $("#btn_send_edit").attr('data-kt-indicator', 'off'); Swal.fire({ text: data['msg'], icon: "error", buttonsStyling: false, confirmButtonText: "ตกลง", customClass: { confirmButton: "btn btn-primary" } }); } } }); }); $("#kt_datatable_example_5").DataTable({ "language": { "lengthMenu": "Show _MENU_", }, "dom": "<'row'" + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + ">" + "<'table-responsive'tr>" + "<'row'" + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + ">" }); </script> <script type="text/javascript"> function del(media_id) { Swal.fire({ title: 'คุณต้องการลบข้อมูลใช่หรือไม่?', text: "ลบข้อมูลทั้งหมดของผู้ป่วยรายนี้ การลบข้อมูลจะไม่สามารถกู้คืนได้ กรุณายืนยันการลบข้อมูลอีกครั้ง", icon: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'ตกลง', cancelButtonText: 'ยกเลิก' }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "api/ac_media_learn.php?ac=del", type: "POST", dataType: "html", data: "ac=del&media_id=" + media_id, success: function(data, status) { // console.log(data) if (data == "OK") { Swal.fire( 'สำเร็จ!', 'ลบข้อมูลเรียบร้อยแล้ว', 'success' ) window.location.reload(); } } }); } }); }; </script>