Server IP : 150.95.80.236 / Your IP : 3.141.28.116 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/uat.pcu.in.th/assets/js/custom/modals/ |
Upload File : |
"use strict"; var KTUsersAddPermission = function() { const t = document.getElementById("add_media"), e = t.querySelector("#form_add_media"), n = new bootstrap.Modal(t); return { init: function() { (() => { var o = FormValidation.formValidation(e, { fields: { media_title: { validators: { notEmpty: { message: "กรุณากรอกข้อมูล" } } }, media_detail: { validators: { notEmpty: { message: "กรุณากรอกข้อมูล" } } } }, plugins: { trigger: new FormValidation.plugins.Trigger, bootstrap: new FormValidation.plugins.Bootstrap5({ rowSelector: ".fv-row", eleInvalidClass: "", eleValidClass: "" }) } }); $(document).on("submit", "#form_add_media", function(e) { e.preventDefault(); // console.log(12331) // var rr = document.querySelector("#form_add_media") var url = $(this).attr("action"); var data = new FormData(t.querySelector("#form_add_media")); // console.log(this) // console.log(data) // console.log(formdata.get('media_title')); for (var key in data) { console.log(key, data[key]); data.append(key, data[key]); } o && o.validate().then((function(t) { // console.log("validated!"), "Valid" == t ? $.ajax({ url: url, type: $(this).attr("method"), dataType: "html", 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 == true) { $("#btn_send_form").attr('data-kt-indicator', 'off'); Swal.fire({ text: "แก้ไขข้อมูลสำเร็จ", 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: "แก้ไขข้อมูลไม่สำเร็จ", icon: "error", buttonsStyling: false, confirmButtonText: "ตกลง", customClass: { confirmButton: "btn btn-primary" } }); } } }) : Swal.fire({ text: " ", icon: "error", buttonsStyling: !1, confirmButtonText: "ตกลง", customClass: { confirmButton: "btn btn-primary" } }) })) // console.log("result data : am in "); // console.log(url); // console.log(data); // $.ajax({ // url: url, // type: $(this).attr("method"), // dataType: "html", // 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 == true) { // $("#btn_send_form").attr('data-kt-indicator', 'off'); // Swal.fire({ // text: "แก้ไขข้อมูลสำเร็จ", // 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: "แก้ไขข้อมูลไม่สำเร็จ", // icon: "error", // buttonsStyling: false, // confirmButtonText: "ตกลง", // customClass: { // confirmButton: "btn btn-primary" // } // }); // } // } // }); }); const i = t.querySelector('[data-kt-permissions-modal-action="submit"]'); i.addEventListener("click", (function(t) { t.preventDefault(), o && o.validate().then((function(t) { console.log("validated!"), "Valid" == t ? (i.setAttribute("data-kt-indicator", "on"), i.disabled = !0, setTimeout((function() { i.removeAttribute("data-kt-indicator"), i.disabled = !1, Swal.fire({ text: "Form has been successfully submitted!", icon: "success", buttonsStyling: !1, confirmButtonText: "Ok, got it!", customClass: { confirmButton: "btn btn-primary" } }).then((function(t) { t.isConfirmed && n.hide() })) }), 2e3)) : Swal.fire({ text: "Sorry, looks like there are some errors detected, please try again.", icon: "error", buttonsStyling: !1, confirmButtonText: "Ok, got it!", customClass: { confirmButton: "btn btn-primary" } }) })) })) })() } } }(); KTUtil.onDOMContentLoaded((function() { KTUsersAddPermission.init() }));