From 315830c9245b9862885663b9b7d7ee62aff9e68f Mon Sep 17 00:00:00 2001 From: Ray1111-aa Date: Wed, 28 Oct 2026 14:39:10 +0700 Subject: [PATCH] feat(p2h): add soft delete feature for p2h heavy equipment records with confirmation modal and trash support --- .../Qma/P2hInspectionController.php | 16 +++++ resources/views/qma/p2h_index.blade.php | 58 ++++++++++++++++ resources/views/qma/p2h_show.blade.php | 66 +++++++++++++++++++ routes/web.php | 1 + tests/Feature/P2hInspectionTest.php | 39 +++++++++++ 5 files changed, 180 insertions(+) diff --git a/app/Http/Controllers/Qma/P2hInspectionController.php b/app/Http/Controllers/Qma/P2hInspectionController.php index a4976fe..6b8f667 100644 --- a/app/Http/Controllers/Qma/P2hInspectionController.php +++ b/app/Http/Controllers/Qma/P2hInspectionController.php @@ -767,4 +767,20 @@ class P2hInspectionController extends Controller return back()->with('success', "Inspeksi P2H [{$record->transaction_no}] untuk unit {$record->vehicle->code} DITOLAK. Status unit diubah ke Breakdown."); } + + /** + * Hapus pemeriksaan P2H Heavy Equipment (Soft Delete). + * Data yang dihapus akan dipindahkan ke Tong Sampah dan dapat dipulihkan sewaktu-waktu. + */ + public function destroy(int $id): RedirectResponse + { + $record = P2hRecord::findOrFail($id); + $trxNo = $record->transaction_no; + + // Cascade soft delete record items + $record->items()->delete(); + $record->delete(); + + return redirect()->route('qma.p2h.index')->with('success', "Data pemeriksaan P2H [{$trxNo}] berhasil dihapus dan dipindahkan ke Tong Sampah."); + } } diff --git a/resources/views/qma/p2h_index.blade.php b/resources/views/qma/p2h_index.blade.php index df9586f..0462254 100644 --- a/resources/views/qma/p2h_index.blade.php +++ b/resources/views/qma/p2h_index.blade.php @@ -205,6 +205,12 @@ + @@ -312,12 +318,64 @@ function closeGuideModal() { document.addEventListener('keydown', function(e) { if (e.key === 'Escape') { closeGuideModal(); + closeDeleteP2hModal(); const exportMenu = document.getElementById('exportMenuP2h'); if (exportMenu) exportMenu.style.display = 'none'; } }); + + 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'; + } + } + + + + + diff --git a/resources/views/qma/p2h_show.blade.php b/resources/views/qma/p2h_show.blade.php index 702af57..8e35620 100644 --- a/resources/views/qma/p2h_show.blade.php +++ b/resources/views/qma/p2h_show.blade.php @@ -25,6 +25,15 @@ Ekspor Excel (.xlsx) + + +
@if($record->isPending()) @@ -230,6 +239,63 @@
+ + + + +