@extends('layouts.admin') @section('page_title', $isRtl ? 'طلبات التمويل' : 'Financing Requests') @push('styles') @endpush @section('content') @php $statusMeta = [ 'pending' => ['label' => $isRtl ? 'قيد المراجعة' : 'Pending', 'color' => '#f59e0b'], 'approved' => ['label' => $isRtl ? 'مقبول' : 'Approved', 'color' => '#10b981'], 'rejected' => ['label' => $isRtl ? 'مرفوض' : 'Rejected', 'color' => '#ef4444'], 'canceled' => ['label' => $isRtl ? 'ملغي' : 'Canceled', 'color' => '#6b7280'], 'completed' => ['label' => $isRtl ? 'مكتمل' : 'Completed', 'color' => '#e31e24'], ]; $stageLabels = [ 'pending_payment' => $isRtl ? 'بانتظار الدفع' : 'Pending Payment', 'paid' => $isRtl ? 'تم الدفع' : 'Paid', 'offers' => $isRtl ? 'عرض العروض' : 'Offers', 'offer_selected' => $isRtl ? 'تم اختيار العرض' : 'Offer Selected', 'completed' => $isRtl ? 'مكتمل' : 'Completed', ]; $productLabels = [ 'personal' => $isRtl ? 'تمويل شخصي' : 'Personal Financing', 'auto' => $isRtl ? 'تمويل سيارات' : 'Auto Financing', 'mortgage' => $isRtl ? 'تمويل عقاري' : 'Mortgage', 'credit_card' => $isRtl ? 'بطاقة ائتمان' : 'Credit Card', 'sme' => $isRtl ? 'تمويل منشآت' : 'SME Financing', ]; @endphp

{{ $isRtl ? 'طلبات التمويل' : 'Financing Requests' }}

{{ $isRtl ? 'إدارة ومتابعة كل طلبات التمويل والتواصل مع العملاء' : 'Manage and track all financing requests and customer communications' }}

{{ $isRtl ? 'إجمالي قيمة التمويل' : 'Total Loan Volume' }}
{{ number_format($totalVolume) }} {{ $isRtl ? 'ر.س' : 'SAR' }}
{{-- Status filter chips --}}
{{ $isRtl ? 'الكل' : 'All' }} {{ $totalAll }} @foreach($statuses as $st) @php $meta = $statusMeta[$st] ?? ['label' => $st, 'color' => '#6b7280']; @endphp {{ $meta['label'] }} {{ $counts[$st] ?? 0 }} @endforeach
{{-- Search + extra filter --}}
@if($currentStatus)@endif
@if($q || $currentStage || $currentStatus) {{ $isRtl ? 'مسح' : 'Clear' }} @endif
@if($requests->isEmpty())

{{ $isRtl ? 'لا توجد طلبات تطابق البحث' : 'No requests match your search' }}

{{ $isRtl ? 'جرب تغيير الفلاتر أو البحث بكلمة أخرى' : 'Try adjusting your filters or searching with different keywords' }}

@else
@foreach($requests as $r) @php $initial = mb_substr($r->client_name ?? 'U', 0, 1); @endphp @endforeach
{{ $isRtl ? 'رقم الطلب' : 'Request #' }} {{ $isRtl ? 'العميل' : 'Client' }} {{ $isRtl ? 'الهاتف' : 'Phone' }} {{ $isRtl ? 'المنتج' : 'Product' }} {{ $isRtl ? 'قيمة التمويل' : 'Amount' }} {{ $isRtl ? 'الحالة' : 'Status' }} {{ $isRtl ? 'المرحلة' : 'Stage' }} {{ $isRtl ? 'التاريخ' : 'Date' }} {{ $isRtl ? 'إجراءات' : 'Actions' }}
{{ $r->request_number }} #{{ $r->id }}
{{ mb_strtoupper($initial) }}
{{ $r->client_name ?? '—' }} @if($r->user){{ $r->user->email }}@endif
{{ $r->phone ?? '—' }} {{ $productLabels[$r->product_id] ?? $r->product_id }} @if($r->sub_product_id)
{{ $productLabels[$r->sub_product_id] ?? $r->sub_product_id }} @endif
@if($r->loan_amount) {{ number_format((float)$r->loan_amount) }}{{ $isRtl ? 'ر.س' : 'SAR' }} @if($r->loan_term_months) {{ $r->loan_term_months }} {{ $isRtl ? 'شهر' : 'mo' }} @endif @else @endif {{ $r->status_label }} @if($r->stage) {{ $stageLabels[$r->stage] ?? $r->stage }} @else @endif @if($r->facilitation_requested_at) {{ $isRtl ? 'تسهيلات' : 'Facilitation' }} @endif {{ $r->created_at?->format('Y-m-d') }}
{{ $r->created_at?->diffForHumans() }}
@csrf @method('DELETE')
{{ $requests->links() }}
@endif @endsection