feat(p2h): add soft delete feature for p2h heavy equipment records with confirmation modal and trash support

This commit is contained in:
Ray1111-aa
2026-10-28 14:39:10 +07:00
parent 7675c3e500
commit 315830c924
5 changed files with 180 additions and 0 deletions
+66
View File
@@ -25,6 +25,15 @@
<span>Ekspor Excel (.xlsx)</span>
</a>
<!-- Tombol Hapus P2H -->
<button type="button"
onclick="openDeleteP2hModal({{ $record->id }}, '{{ $record->transaction_no }}', '{{ $record->vehicle->code ?? '' }}')"
class="inline-flex items-center space-x-1.5 text-xs font-bold text-rose-700 bg-rose-50 hover:bg-rose-100 border border-rose-200 px-3 py-1.5 rounded-xl transition shadow-xs cursor-pointer"
title="Hapus Pemeriksaan P2H">
<i class="fa-regular fa-trash-can text-[13px] text-rose-600"></i>
<span>Hapus P2H</span>
</button>
<!-- Badge Status Validasi -->
<div>
@if($record->isPending())
@@ -230,6 +239,63 @@
</div>
</div>
<!-- MODAL POPUP: HAPUS PEMERIKSAAN P2H -->
<div id="deleteP2hModal" class="hidden fixed inset-0 z-50 overflow-y-auto" style="display: none;">
<div class="fixed inset-0 bg-slate-900/60 backdrop-blur-xs transition-opacity" onclick="closeDeleteP2hModal()"></div>
<div class="flex min-h-full items-center justify-center p-4">
<div class="relative w-full max-w-md bg-white rounded-2xl shadow-xl border border-slate-100 p-6 text-center transform transition-all">
<div class="w-12 h-12 rounded-full bg-rose-50 text-rose-600 flex items-center justify-center mx-auto mb-4 border border-rose-100">
<i class="fa-solid fa-triangle-exclamation text-xl"></i>
</div>
<h3 class="text-sm font-bold text-slate-900 mb-1">Hapus Data Pemeriksaan P2H?</h3>
<p class="text-xs text-slate-500 mb-4 leading-relaxed">
Apakah Anda yakin ingin menghapus inspeksi P2H <span id="deleteP2hTxNo" class="font-mono font-bold text-rose-600">-</span> untuk unit <span id="deleteP2hUnitCode" class="font-bold text-slate-800">-</span>? Data akan dipindahkan ke <strong>Tong Sampah</strong> dan dapat dipulihkan sewaktu-waktu.
</p>
<form id="deleteP2hForm" method="POST" action="">
@csrf
@method('DELETE')
<div class="flex items-center justify-center space-x-3">
<button type="button" onclick="closeDeleteP2hModal()" class="bg-slate-100 hover:bg-slate-200 text-slate-700 px-4 py-2 rounded-xl text-xs font-semibold transition cursor-pointer">
Batal
</button>
<button type="submit" class="bg-rose-600 hover:bg-rose-700 text-white px-5 py-2 rounded-xl text-xs font-bold transition shadow-xs cursor-pointer">
Ya, Hapus
</button>
</div>
</form>
</div>
</div>
</div>
<script>
function openDeleteP2hModal(id, trxNo, unitCode) {
document.getElementById('deleteP2hForm').action = `/qma/p2h-records/${id}`;
document.getElementById('deleteP2hTxNo').textContent = trxNo;
document.getElementById('deleteP2hUnitCode').textContent = unitCode || '-';
const modal = document.getElementById('deleteP2hModal');
if (modal) {
modal.classList.remove('hidden');
modal.style.display = 'block';
}
}
function closeDeleteP2hModal() {
const modal = document.getElementById('deleteP2hModal');
if (modal) {
modal.classList.add('hidden');
modal.style.display = 'none';
}
}
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeDeleteP2hModal();
}
});
</script>
<style>
@media print {
.no-print, header, nav, aside, #mobileDrawer, #topNavbar, .sidebar-container {