✨ feat(slik): implementasi fitur laporan SLIK dengan integrasi SweetAlert
- Menambahkan tombol aksi "Pindahkan ke Laporan SLIK" pada halaman index & detail - Integrasi SweetAlert2 untuk konfirmasi, loading state, dan notifikasi sukses/gagal - Implementasi auto-refresh DataTable setelah pemindahan berhasil - Disable tombol otomatis setelah sukses untuk mencegah duplikasi data - LaporanSlikController: method store() dengan transaksi DB & auto-delete dari tabel sliks - Routing baru untuk index, datatables, store, dan export laporan SLIK - Penyesuaian views (index & show) dengan tombol, script SweetAlert, dan feedback visual - Proteksi keamanan: CSRF token, validasi input, transaksi DB, dan error logging - Testing checklist: pindahkan data, refresh tabel, disable tombol, error handling, responsif mobile/desktop
This commit is contained in:
@@ -14,6 +14,11 @@
|
||||
<p class="mt-1 text-sm text-gray-600">Informasi lengkap debitur {{ $slik->nama_debitur }}</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button class="btn btn-sm btn-primary" onclick="moveToLaporan({{ $slik->id }})"
|
||||
title="Pindahkan ke Laporan SLIK">
|
||||
<i class="ki-filled ki-file-up"></i>
|
||||
SLIK
|
||||
</button>
|
||||
<a href="{{ route('admin-kredit.slik.index') }}" class="btn btn-sm btn-light">
|
||||
<i class="ki-filled ki-arrow-left"></i>
|
||||
Kembali
|
||||
@@ -165,6 +170,87 @@
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
/**
|
||||
* Fungsi untuk memindahkan data SLIK ke laporan
|
||||
* @param {number} id - ID data SLIK yang akan dipindahkan
|
||||
*/
|
||||
function moveToLaporan(id) {
|
||||
window.Swal.fire({
|
||||
title: 'Konfirmasi',
|
||||
text: 'Apakah Anda yakin ingin memindahkan data ini ke laporan SLIK?',
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Ya, Pindahkan!',
|
||||
cancelButtonText: 'Batal',
|
||||
reverseButtons: true
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Tampilkan loading
|
||||
window.Swal.fire({
|
||||
title: 'Memproses...',
|
||||
text: 'Sedang memindahkan data ke laporan SLIK',
|
||||
allowOutsideClick: false,
|
||||
showConfirmButton: false,
|
||||
willOpen: () => {
|
||||
window.Swal.showLoading();
|
||||
}
|
||||
});
|
||||
|
||||
fetch(`{{ route('admin-kredit.laporan-slik.store') }}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
slik_id: id
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
window.Swal.close();
|
||||
|
||||
if (data.success) {
|
||||
window.Swal.fire({
|
||||
title: 'Berhasil!',
|
||||
text: data.message || 'Data berhasil dipindahkan ke laporan SLIK',
|
||||
icon: 'success',
|
||||
confirmButtonText: 'OK'
|
||||
}).then(() => {
|
||||
// Disable tombol setelah berhasil
|
||||
const button = document.querySelector(
|
||||
`button[onclick="moveToLaporan(${id})"]`);
|
||||
if (button) {
|
||||
button.disabled = true;
|
||||
button.innerHTML =
|
||||
'<i class="ki-filled ki-check"></i> Sudah di SLIK';
|
||||
}
|
||||
});
|
||||
} else {
|
||||
window.Swal.fire({
|
||||
title: 'Gagal!',
|
||||
text: data.message || 'Gagal memindahkan data',
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
window.Swal.close();
|
||||
window.Swal.fire({
|
||||
title: 'Error!',
|
||||
text: 'Terjadi kesalahan saat memindahkan data',
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Add any additional JavaScript for detail page
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Initialize any required components
|
||||
|
||||
Reference in New Issue
Block a user