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 @@
+ + + + +