partial update close modal on all page and disable create transaction with no stock
This commit is contained in:
@@ -1,101 +1,112 @@
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
});
|
||||
|
||||
var table = $('#kt_table').DataTable({
|
||||
var table = $("#kt_table").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: $("input[name='ajax_url']"),
|
||||
columns: [
|
||||
{data: 'name', name: 'name'},
|
||||
{data: 'form', name: 'form'},
|
||||
{data: 'action', name: 'action', orderable: false, searchable: false},
|
||||
]
|
||||
{ data: "name", name: "name" },
|
||||
{ data: "form", name: "form" },
|
||||
{ data: "action", name: "action", orderable: false, searchable: false },
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
$("#addCategory").click(function() {
|
||||
$("#categoryModal").modal("show")
|
||||
let form_action = $("input[name='store_url']").val()
|
||||
$("#categoryForm").attr('action', form_action)
|
||||
$("#categoryForm input[name='_method']").remove()
|
||||
$("#categoryForm").attr('data-form', 'store')
|
||||
$("#categoryForm").trigger("reset")
|
||||
})
|
||||
|
||||
$("#addCategory").click(function () {
|
||||
$("#categoryModal").modal("show");
|
||||
let form_action = $("input[name='store_url']").val();
|
||||
$("#categoryForm").attr("action", form_action);
|
||||
$("#categoryForm input[name='_method']").remove();
|
||||
$("#categoryForm").attr("data-form", "store");
|
||||
$("#categoryForm").trigger("reset");
|
||||
});
|
||||
|
||||
function destroyCategory(id) {
|
||||
let action = $("#destroyCategory"+id).attr("data-action")
|
||||
console.log(action)
|
||||
let action = $("#destroyCategory" + id).attr("data-action");
|
||||
console.log(action);
|
||||
Swal.fire({
|
||||
title: 'Hapus Kategori?',
|
||||
title: "Hapus Kategori?",
|
||||
icon: "question",
|
||||
text: "Data Pekerjaan yang terkait dengan kategori ini juga akan terhapus!",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#dedede',
|
||||
confirmButtonText: 'Hapus'
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#dedede",
|
||||
confirmButtonText: "Hapus",
|
||||
}).then((result) => {
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: 'POST',
|
||||
type: "POST",
|
||||
data: {
|
||||
_token: $('meta[name="csrf-token"]').attr('content'),
|
||||
_method: 'DELETE'
|
||||
_token: $('meta[name="csrf-token"]').attr("content"),
|
||||
_method: "DELETE",
|
||||
},
|
||||
success: function(res) {
|
||||
Swal.fire(
|
||||
'Kategori Dihapus!'
|
||||
)
|
||||
table.ajax.reload()
|
||||
}
|
||||
})
|
||||
success: function (res) {
|
||||
Swal.fire("Kategori Dihapus!");
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function editCategory(id) {
|
||||
let form_action = $("#editCategory"+id).attr("data-action")
|
||||
let edit_url = $("#editCategory"+id).attr("data-url")
|
||||
$("#categoryModal").modal("show")
|
||||
$("#categoryForm").append('<input type="hidden" name="_method" value="PUT">')
|
||||
$("#categoryForm").attr('action', form_action)
|
||||
$("#categoryForm").attr('data-form', 'update')
|
||||
$.get(edit_url, function(res) {
|
||||
$("#categoryForm input[name='name']").val(res.data.name)
|
||||
$("#categoryForm option[value='"+ res.data.form +"']").prop('selected', true);
|
||||
})
|
||||
let form_action = $("#editCategory" + id).attr("data-action");
|
||||
let edit_url = $("#editCategory" + id).attr("data-url");
|
||||
$("#categoryModal").modal("show");
|
||||
$("#categoryForm").append(
|
||||
'<input type="hidden" name="_method" value="PUT">'
|
||||
);
|
||||
$("#categoryForm").attr("action", form_action);
|
||||
$("#categoryForm").attr("data-form", "update");
|
||||
$.get(edit_url, function (res) {
|
||||
$("#categoryForm input[name='name']").val(res.data.name);
|
||||
$("#categoryForm option[value='" + res.data.form + "']").prop(
|
||||
"selected",
|
||||
true
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#categoryForm").submit(function(e) {
|
||||
e.preventDefault();
|
||||
let dataForm = $("#categoryForm").attr('data-form')
|
||||
if(dataForm == 'store') {
|
||||
$.ajax({
|
||||
url: $('#categoryForm').attr("action"),
|
||||
type: 'POST',
|
||||
data: $('#categoryForm').serialize(),
|
||||
success: function(res) {
|
||||
$("#categoryModal").modal("hide")
|
||||
$('#categoryForm').trigger("reset")
|
||||
table.ajax.reload()
|
||||
}
|
||||
})
|
||||
}else if(dataForm == 'update') {
|
||||
$.ajax({
|
||||
url: $('#categoryForm').attr("action"),
|
||||
type: 'POST',
|
||||
data: $('#categoryForm').serialize(),
|
||||
success: function(res) {
|
||||
$("#categoryModal").modal("hide")
|
||||
$('#categoryForm').trigger("reset")
|
||||
table.ajax.reload()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
// Add event handlers for modal close buttons
|
||||
$('.close, [data-dismiss="modal"]').on("click", function () {
|
||||
$("#categoryModal").modal("hide");
|
||||
});
|
||||
|
||||
});
|
||||
// Also handle the "Batal" button
|
||||
$('.btn-secondary[data-dismiss="modal"]').on("click", function () {
|
||||
$("#categoryModal").modal("hide");
|
||||
});
|
||||
|
||||
$("#categoryForm").submit(function (e) {
|
||||
e.preventDefault();
|
||||
let dataForm = $("#categoryForm").attr("data-form");
|
||||
if (dataForm == "store") {
|
||||
$.ajax({
|
||||
url: $("#categoryForm").attr("action"),
|
||||
type: "POST",
|
||||
data: $("#categoryForm").serialize(),
|
||||
success: function (res) {
|
||||
$("#categoryModal").modal("hide");
|
||||
$("#categoryForm").trigger("reset");
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
} else if (dataForm == "update") {
|
||||
$.ajax({
|
||||
url: $("#categoryForm").attr("action"),
|
||||
type: "POST",
|
||||
data: $("#categoryForm").serialize(),
|
||||
success: function (res) {
|
||||
$("#categoryModal").modal("hide");
|
||||
$("#categoryForm").trigger("reset");
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,128 +1,136 @@
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
});
|
||||
|
||||
var table = $('#kt_table').DataTable({
|
||||
var table = $("#kt_table").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: $("input[name='ajax_url']"),
|
||||
columns: [
|
||||
{data: 'dealer_code', name: 'dealer_code'},
|
||||
{data: 'name', name: 'name'},
|
||||
{data: 'pic_name', name: 'u.name'},
|
||||
{data: 'address', name: 'address'},
|
||||
{data: 'action', name: 'action', orderable: false, searchable: false},
|
||||
]
|
||||
{ data: "dealer_code", name: "dealer_code" },
|
||||
{ data: "name", name: "name" },
|
||||
{ data: "pic_name", name: "u.name" },
|
||||
{ data: "address", name: "address" },
|
||||
{ data: "action", name: "action", orderable: false, searchable: false },
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
$("#addDealer").click(function() {
|
||||
$("#dealerModal").modal("show")
|
||||
let form_action = $("input[name='store_url']").val()
|
||||
$("#dealerForm").attr('action', form_action)
|
||||
$("#dealerForm input[name='_method']").remove()
|
||||
$("#dealerForm").attr('data-form', 'store')
|
||||
$("#dealerForm").trigger("reset")
|
||||
})
|
||||
$("#addDealer").click(function () {
|
||||
$("#dealerModal").modal("show");
|
||||
let form_action = $("input[name='store_url']").val();
|
||||
$("#dealerForm").attr("action", form_action);
|
||||
$("#dealerForm input[name='_method']").remove();
|
||||
$("#dealerForm").attr("data-form", "store");
|
||||
$("#dealerForm").trigger("reset");
|
||||
});
|
||||
|
||||
function destroyDealer(id) {
|
||||
let action = $("#destroyDealer"+id).attr("data-action")
|
||||
let action = $("#destroyDealer" + id).attr("data-action");
|
||||
Swal.fire({
|
||||
title: 'Hapus Dealer?',
|
||||
title: "Hapus Dealer?",
|
||||
text: "Data pengguna yang terkait dengan dealer ini juga akan terhapus!",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#dedede',
|
||||
confirmButtonText: 'Hapus'
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#dedede",
|
||||
confirmButtonText: "Hapus",
|
||||
}).then((result) => {
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: 'POST',
|
||||
type: "POST",
|
||||
data: {
|
||||
_token: $('meta[name="csrf-token"]').attr('content'),
|
||||
_method: 'DELETE'
|
||||
_token: $('meta[name="csrf-token"]').attr("content"),
|
||||
_method: "DELETE",
|
||||
},
|
||||
success: function(res) {
|
||||
Swal.fire(
|
||||
'Dealer Dihapus!'
|
||||
)
|
||||
table.ajax.reload()
|
||||
}
|
||||
})
|
||||
success: function (res) {
|
||||
Swal.fire("Dealer Dihapus!");
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function editDealer(id) {
|
||||
let form_action = $("#editDealer"+id).attr("data-action")
|
||||
let edit_url = $("#editDealer"+id).attr("data-url")
|
||||
$("#dealerModal").modal("show")
|
||||
$("#dealerForm").append('<input type="hidden" name="_method" value="PUT">')
|
||||
$("#dealerForm").attr('action', form_action)
|
||||
$("#dealerForm").attr('data-form', 'update')
|
||||
$.get(edit_url, function(res) {
|
||||
$("#dealerForm input[name='name']").val(res.data.name)
|
||||
$("#dealerForm input[name='dealer_code']").val(res.data.dealer_code)
|
||||
$("#dealerForm input[name='address']").val(res.data.address)
|
||||
})
|
||||
let form_action = $("#editDealer" + id).attr("data-action");
|
||||
let edit_url = $("#editDealer" + id).attr("data-url");
|
||||
$("#dealerModal").modal("show");
|
||||
$("#dealerForm").append('<input type="hidden" name="_method" value="PUT">');
|
||||
$("#dealerForm").attr("action", form_action);
|
||||
$("#dealerForm").attr("data-form", "update");
|
||||
$.get(edit_url, function (res) {
|
||||
$("#dealerForm input[name='name']").val(res.data.name);
|
||||
$("#dealerForm input[name='dealer_code']").val(res.data.dealer_code);
|
||||
$("#dealerForm input[name='address']").val(res.data.address);
|
||||
});
|
||||
}
|
||||
|
||||
function addPic(id) {
|
||||
let form_action = $("#addPic"+id).attr("data-action")
|
||||
let edit_url = $("#addPic"+id).attr("data-url")
|
||||
$("#picModal").modal("show")
|
||||
$("#picForm").append('<input type="hidden" name="_method" value="PUT">')
|
||||
$("#picForm").attr('action', form_action)
|
||||
$.get(edit_url, function(res) {
|
||||
$("#picForm input[name='name']").val(res.data.name)
|
||||
$("#picForm input[name='dealer_code']").val(res.data.dealer_code)
|
||||
})
|
||||
let form_action = $("#addPic" + id).attr("data-action");
|
||||
let edit_url = $("#addPic" + id).attr("data-url");
|
||||
$("#picModal").modal("show");
|
||||
$("#picForm").append('<input type="hidden" name="_method" value="PUT">');
|
||||
$("#picForm").attr("action", form_action);
|
||||
$.get(edit_url, function (res) {
|
||||
$("#picForm input[name='name']").val(res.data.name);
|
||||
$("#picForm input[name='dealer_code']").val(res.data.dealer_code);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#picForm").submit(function(e) {
|
||||
e.preventDefault()
|
||||
$.ajax({
|
||||
url: $('#picForm').attr("action"),
|
||||
type: 'POST',
|
||||
data: {pic: $('#picForm select[name="pic_id"]').val()},
|
||||
success: function(res) {
|
||||
$("#picModal").modal("hide")
|
||||
$('#picForm').trigger("reset")
|
||||
table.ajax.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
// Add event handlers for modal close buttons
|
||||
$('.close, [data-dismiss="modal"]').on("click", function () {
|
||||
$("#dealerModal").modal("hide");
|
||||
$("#picModal").modal("hide");
|
||||
});
|
||||
|
||||
$("#dealerForm").submit(function(e) {
|
||||
// Also handle the "Batal" button
|
||||
$('.btn-secondary[data-dismiss="modal"]').on("click", function () {
|
||||
$("#dealerModal").modal("hide");
|
||||
$("#picModal").modal("hide");
|
||||
});
|
||||
|
||||
$("#picForm").submit(function (e) {
|
||||
e.preventDefault();
|
||||
let dataForm = $("#dealerForm").attr('data-form')
|
||||
if(dataForm == 'store') {
|
||||
$.ajax({
|
||||
url: $('#dealerForm').attr("action"),
|
||||
type: 'POST',
|
||||
data: $('#dealerForm').serialize(),
|
||||
success: function(res) {
|
||||
$("#dealerModal").modal("hide")
|
||||
$('#dealerForm').trigger("reset")
|
||||
table.ajax.reload()
|
||||
}
|
||||
})
|
||||
}else if(dataForm == 'update') {
|
||||
$.ajax({
|
||||
url: $('#dealerForm').attr("action"),
|
||||
type: 'POST',
|
||||
data: $('#dealerForm').serialize(),
|
||||
success: function(res) {
|
||||
$("#dealerModal").modal("hide")
|
||||
$('#dealerForm').trigger("reset")
|
||||
table.ajax.reload()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
$.ajax({
|
||||
url: $("#picForm").attr("action"),
|
||||
type: "POST",
|
||||
data: { pic: $('#picForm select[name="pic_id"]').val() },
|
||||
success: function (res) {
|
||||
$("#picModal").modal("hide");
|
||||
$("#picForm").trigger("reset");
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
$("#dealerForm").submit(function (e) {
|
||||
e.preventDefault();
|
||||
let dataForm = $("#dealerForm").attr("data-form");
|
||||
if (dataForm == "store") {
|
||||
$.ajax({
|
||||
url: $("#dealerForm").attr("action"),
|
||||
type: "POST",
|
||||
data: $("#dealerForm").serialize(),
|
||||
success: function (res) {
|
||||
$("#dealerModal").modal("hide");
|
||||
$("#dealerForm").trigger("reset");
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
} else if (dataForm == "update") {
|
||||
$.ajax({
|
||||
url: $("#dealerForm").attr("action"),
|
||||
type: "POST",
|
||||
data: $("#dealerForm").serialize(),
|
||||
success: function (res) {
|
||||
$("#dealerModal").modal("hide");
|
||||
$("#dealerForm").trigger("reset");
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,105 +1,125 @@
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
});
|
||||
|
||||
var table = $('#kt_table').DataTable({
|
||||
var table = $("#kt_table").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: $("input[name='ajax_url']").val(),
|
||||
columns: [
|
||||
{data: 'DT_RowIndex', name: 'DT_RowIndex', orderable: false, searchable: false},
|
||||
{data: 'dealer_name', name: 'd.name'},
|
||||
{data: 'role_name', name: 'r.name'},
|
||||
{data: 'name', name: 'users.name'},
|
||||
{data: 'email', name: 'users.email'},
|
||||
{data: 'action', name: 'action', orderable: false, searchable: false},
|
||||
]
|
||||
{
|
||||
data: "DT_RowIndex",
|
||||
name: "DT_RowIndex",
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
},
|
||||
{ data: "dealer_name", name: "d.name" },
|
||||
{ data: "role_name", name: "r.name" },
|
||||
{ data: "name", name: "users.name" },
|
||||
{ data: "email", name: "users.email" },
|
||||
{ data: "action", name: "action", orderable: false, searchable: false },
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
$("#addUser").click(function() {
|
||||
$("#userModal").modal("show")
|
||||
let form_action = $("input[name='store_url']").val()
|
||||
$("#userForm").attr('action', form_action)
|
||||
$("#userForm input[name='_method']").remove()
|
||||
$("#userForm").attr('data-form', 'store')
|
||||
$("#userForm").trigger("reset")
|
||||
$("#modalHeading").html("Tambah Pengguna")
|
||||
})
|
||||
$("#addUser").click(function () {
|
||||
$("#userModal").modal("show");
|
||||
let form_action = $("input[name='store_url']").val();
|
||||
$("#userForm").attr("action", form_action);
|
||||
$("#userForm input[name='_method']").remove();
|
||||
$("#userForm").attr("data-form", "store");
|
||||
$("#userForm").trigger("reset");
|
||||
$("#modalHeading").html("Tambah Pengguna");
|
||||
});
|
||||
|
||||
function destroyUser(id) {
|
||||
let action = $("#destroyUser"+id).attr("data-action")
|
||||
let action = $("#destroyUser" + id).attr("data-action");
|
||||
Swal.fire({
|
||||
title: 'Hapus User?',
|
||||
title: "Hapus User?",
|
||||
icon: "warning",
|
||||
text: "Semua data yang terkait dengan Pengguna ini juga akan terhapus!",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#dedede',
|
||||
confirmButtonText: 'Hapus'
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#dedede",
|
||||
confirmButtonText: "Hapus",
|
||||
}).then((result) => {
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: 'POST',
|
||||
type: "POST",
|
||||
data: {
|
||||
_token: $('meta[name="csrf-token"]').attr('content'),
|
||||
_method: 'DELETE'
|
||||
_token: $('meta[name="csrf-token"]').attr("content"),
|
||||
_method: "DELETE",
|
||||
},
|
||||
success: function(res) {
|
||||
Swal.fire(
|
||||
'Pengguna Dihapus!'
|
||||
)
|
||||
table.ajax.reload()
|
||||
}
|
||||
})
|
||||
success: function (res) {
|
||||
Swal.fire("Pengguna Dihapus!");
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function editUser(id) {
|
||||
let form_action = $("#editUser"+id).attr("data-action")
|
||||
let edit_url = $("#editUser"+id).attr("data-url")
|
||||
$("#userModal").modal("show")
|
||||
$("#userForm").append('<input type="hidden" name="_method" value="PUT">')
|
||||
$("#userForm").attr('action', form_action)
|
||||
$("#userForm").attr('data-form', 'update')
|
||||
$.get(edit_url, function(res) {
|
||||
$("#userForm input[name='name']").val(res.data.name)
|
||||
$("#userForm input[name='email']").val(res.data.email)
|
||||
$("#userForm select[name='dealer_id'] option[value='"+ res.data.dealer_id +"']").prop('selected', true);
|
||||
$("#userForm select[name='role'] option[value='"+ res.data.role_id +"']").prop('selected', true);
|
||||
})
|
||||
let form_action = $("#editUser" + id).attr("data-action");
|
||||
let edit_url = $("#editUser" + id).attr("data-url");
|
||||
$("#userModal").modal("show");
|
||||
$("#userForm").append('<input type="hidden" name="_method" value="PUT">');
|
||||
$("#userForm").attr("action", form_action);
|
||||
$("#userForm").attr("data-form", "update");
|
||||
$.get(edit_url, function (res) {
|
||||
$("#userForm input[name='name']").val(res.data.name);
|
||||
$("#userForm input[name='email']").val(res.data.email);
|
||||
$(
|
||||
"#userForm select[name='dealer_id'] option[value='" +
|
||||
res.data.dealer_id +
|
||||
"']"
|
||||
).prop("selected", true);
|
||||
$(
|
||||
"#userForm select[name='role'] option[value='" +
|
||||
res.data.role_id +
|
||||
"']"
|
||||
).prop("selected", true);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#userForm").submit(function(e) {
|
||||
e.preventDefault();
|
||||
let dataForm = $("#userForm").attr('data-form')
|
||||
if(dataForm == 'store') {
|
||||
$.ajax({
|
||||
url: $('#userForm').attr("action"),
|
||||
type: 'POST',
|
||||
data: $('#userForm').serialize(),
|
||||
success: function(res) {
|
||||
$("#userModal").modal("hide")
|
||||
$('#userForm').trigger("reset")
|
||||
table.ajax.reload()
|
||||
}
|
||||
})
|
||||
}else if(dataForm == 'update') {
|
||||
$.ajax({
|
||||
url: $('#userForm').attr("action"),
|
||||
type: 'POST',
|
||||
data: $('#userForm').serialize(),
|
||||
success: function(res) {
|
||||
$("#userModal").modal("hide")
|
||||
$('#userForm').trigger("reset")
|
||||
table.ajax.reload()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
// Add event handlers for modal close buttons
|
||||
$('.close, [data-dismiss="modal"]').on("click", function () {
|
||||
$("#userModal").modal("hide");
|
||||
});
|
||||
|
||||
});
|
||||
// Also handle the "Batal" button
|
||||
$('.btn-secondary[data-dismiss="modal"]').on("click", function () {
|
||||
$("#userModal").modal("hide");
|
||||
});
|
||||
|
||||
$("#userForm").submit(function (e) {
|
||||
e.preventDefault();
|
||||
let dataForm = $("#userForm").attr("data-form");
|
||||
if (dataForm == "store") {
|
||||
$.ajax({
|
||||
url: $("#userForm").attr("action"),
|
||||
type: "POST",
|
||||
data: $("#userForm").serialize(),
|
||||
success: function (res) {
|
||||
$("#userModal").modal("hide");
|
||||
$("#userForm").trigger("reset");
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
} else if (dataForm == "update") {
|
||||
$.ajax({
|
||||
url: $("#userForm").attr("action"),
|
||||
type: "POST",
|
||||
data: $("#userForm").serialize(),
|
||||
success: function (res) {
|
||||
$("#userModal").modal("hide");
|
||||
$("#userForm").trigger("reset");
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user