226 lines
6.7 KiB
PHP
226 lines
6.7 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
|
|
|
|
@if (session('warning-status'))
|
|
<script>
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Informasi',
|
|
text: '{{ session('warning-status') }}',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
</script>
|
|
@endif
|
|
|
|
<script>
|
|
$('#submitButton').click(function(e) {
|
|
e.preventDefault();
|
|
|
|
Swal.fire({
|
|
title: 'Apakah Anda yakin?',
|
|
text: 'Pastikan data yang Anda masukkan sudah benar.',
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: 'Ya, kirim!',
|
|
cancelButtonText: 'Batal',
|
|
reverseButtons: true
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
// console.log("Form akan dikirim...");
|
|
|
|
$('#myForm').off('submit').submit(); // Pastikan hanya submit 1x
|
|
}
|
|
});
|
|
});
|
|
|
|
</script>
|
|
<script>
|
|
function showDetail(reason) {
|
|
Swal.fire({
|
|
title: 'Alasan Penolakan', // Judul utama
|
|
html: `
|
|
<div class="card" style="border: none; border-radius: 12px; padding: 15px; text-align: left; background-color: #f8f9fa; max-width: 500px; margin: auto; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); margin-top:0.5rem;">
|
|
<div class="card-body" style="font-size: 14px; color: #555; line-height: 1.6;">
|
|
<p style="margin: 0; padding: 10px 0; font-style: italic; color: #888;">
|
|
${reason || "<i>Tidak ada alasan yang diberikan.</i>"}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
`,
|
|
icon: 'info',
|
|
confirmButtonText: 'Tutup',
|
|
confirmButtonColor: '#3085d6', // Mengubah warna tombol
|
|
padding: '25px', // Padding sekitar modal
|
|
backdrop: true, // Mengaktifkan backdrop
|
|
customClass: {
|
|
popup: 'custom-popup',
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
}
|
|
});
|
|
});
|
|
|
|
function itemConfirm(url, message, buttonText) {
|
|
Swal.fire({
|
|
title: 'Apakah Anda yakin?',
|
|
text: message,
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: buttonText,
|
|
cancelButtonText: 'Batal',
|
|
reverseButtons: true
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
$.ajax({
|
|
type: "POST",
|
|
url: url,
|
|
success: function(response) {
|
|
$('#usersTable').DataTable().ajax.reload();
|
|
Swal.fire(
|
|
'Berhasil!',
|
|
response.message,
|
|
'success'
|
|
).then(() => {
|
|
location.reload();
|
|
});
|
|
},
|
|
error: function(xhr) {
|
|
Swal.fire(
|
|
'Terjadi kesalahan!',
|
|
xhr.responseText,
|
|
'error'
|
|
);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
</script>
|