@extends('layouts.staff') @section('content')
{{-- HEADER & ACTIONS --}}

Deposit Management

Track and process customer security deposits and refunds.

{{-- SEARCH & FILTER FORM --}}
{{-- 1. SEARCH INPUT --}}
{{-- 2. STATUS DROPDOWN --}} @php $currentStatus = request('status', 'requested'); // Default to 'requested' as per logic $statuses = [ 'requested' => 'Refund Requests', 'refunded' => 'Refunded History' ]; $currentLabel = $statuses[$currentStatus] ?? 'Refund Requests'; // Count logic using the $counts array passed from controller $currentCount = $counts[$currentStatus] ?? 0; @endphp
{{-- DEPOSIT LIST (CARD STYLE) --}}
@forelse($bookings as $booking)
{{-- 1. BOOKING INFO --}}
#{{ $booking->bookingID }}
{{ $booking->vehicle->model }}
{{ $booking->vehicle->plateNo }}
@if(in_array($booking->bookingStatus, ['Cancelled', 'Rejected'])) {{ $booking->bookingStatus }} @endif
{{-- 2. CUSTOMER INFO --}}

Customer

{{ $booking->customer->fullName }}
{{ $booking->customer->phoneNo }}
{{-- 3. FINANCIALS --}}

Refund Amount

@php $depositAmount = $booking->payments->sum('depoAmount'); $totalPaid = $booking->payments->whereNotIn('paymentStatus', ['Void', 'Rejected'])->sum('amount'); $isFullRefund = in_array($booking->bookingStatus, ['Cancelled', 'Rejected']); $finalAmount = $isFullRefund ? $totalPaid : $depositAmount; $label = $isFullRefund ? 'Full Refund' : 'Deposit Only'; $depositPayment = $booking->payments->where('depoAmount', '>', 0)->first(); $currentDepoStatus = $depositPayment ? $depositPayment->depoStatus : 'Unknown'; @endphp
RM {{ number_format($finalAmount, 2) }} {{ $label }}
{{-- 4. STATUS --}}

Status

@php $statusClasses = match($currentDepoStatus) { 'Requested' => 'bg-orange-50 text-orange-600 border-orange-100 animate-pulse', 'Refunded' => 'bg-green-50 text-green-600 border-green-100', 'Pending' => 'bg-yellow-50 text-yellow-600 border-yellow-100', 'Forfeited', 'Void' => 'bg-slate-800 text-white border-slate-900', default => 'bg-gray-100 text-gray-500 border-gray-200' }; @endphp {{ $currentDepoStatus }}
{{-- 5. ACTION --}}
@if($status === 'requested') @else
@endif
@empty

No deposits found in this category.

@endforelse
{{-- PAGINATION --}} @if($bookings->hasPages())
{{ $bookings->appends(['status' => $status, 'search' => request('search')])->links() }}
@endif
{{-- REFUND MODAL --}} @endsection