116 lines
3.4 KiB
PHP
116 lines
3.4 KiB
PHP
<script>
|
|
$(document).ready(function() {
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
}
|
|
});
|
|
});
|
|
|
|
function deleteItem(url, message) {
|
|
Swal.fire({
|
|
title: 'Apakah Anda yakin?',
|
|
text: message,
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: 'Ya, hapus!',
|
|
cancelButtonText: 'Batal',
|
|
reverseButtons: true
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
$.ajax({
|
|
type: "DELETE",
|
|
url: url,
|
|
success: function(response) {
|
|
$('#usersTable').DataTable().ajax.reload();
|
|
Swal.fire(
|
|
'Terhapus!',
|
|
response.message,
|
|
'success'
|
|
).then(() => {
|
|
location.reload();
|
|
});
|
|
},
|
|
error: function(xhr) {
|
|
Swal.fire(
|
|
'Terjadi kesalahan!',
|
|
xhr.responseText,
|
|
'error'
|
|
);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
}
|
|
});
|
|
});
|
|
|
|
function statusAction(url, message, confirmButtonAction) {
|
|
Swal.fire({
|
|
title: 'Apakah Anda yakin?',
|
|
text: message,
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: confirmButtonAction,
|
|
cancelButtonText: 'Batal',
|
|
reverseButtons: true
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
$.ajax({
|
|
type: "PUT",
|
|
url: url,
|
|
success: function(response) {
|
|
$('#usersTable').DataTable().ajax.reload();
|
|
Swal.fire(
|
|
'Proses Berhasil!',
|
|
response.message,
|
|
'success'
|
|
).then(() => {
|
|
location.reload();
|
|
});
|
|
},
|
|
error: function(xhr) {
|
|
Swal.fire(
|
|
'Terjadi kesalahan!',
|
|
xhr.responseText,
|
|
'error'
|
|
);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
@if (session('success-status'))
|
|
<script>
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Sukses',
|
|
text: '{{ session('success-status') }}',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
</script>
|
|
@endif
|
|
|
|
@if (session('failed-status'))
|
|
<script>
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Gagal',
|
|
text: '{{ session('failed-status') }}',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
</script>
|
|
@endif
|