@extends('layouts.client') @section('page_title', $isRtl ? 'الرئيسية' : 'Dashboard') @include('client.financing-request._home_theme') @section('content') @php $user = auth()->user(); $name = $user->name; $hour = (int) now()->format('H'); $greeting = $isRtl ? ($hour < 12 ? 'صباح الخير' : 'مساء الخير') : ($hour < 12 ? 'Good morning' : ($hour < 18 ? 'Good afternoon' : 'Good evening')); $stageLabels = [ 'pending_payment' => $isRtl ? 'بانتظار الدفع' : 'Pending Payment', 'paid' => $isRtl ? 'مدفوع' : 'Paid', 'offers' => $isRtl ? 'عرض العروض' : 'Offers', 'offer_selected' => $isRtl ? 'تم اختيار العرض' : 'Offer Selected', 'completed' => $isRtl ? 'مكتمل' : 'Completed', ]; $statusLabels = [ 'pending' => $isRtl ? 'قيد المراجعة' : 'Pending', 'approved' => $isRtl ? 'موافق' : 'Approved', 'rejected' => $isRtl ? 'مرفوض' : 'Rejected', 'canceled' => $isRtl ? 'ملغى' : 'Canceled', 'completed'=> $isRtl ? 'مكتمل' : 'Completed', ]; $statusColors = [ 'pending' => ['#FFF4E5', '#B25C00'], 'approved' => ['#E6F7EA', '#166534'], 'rejected' => ['#FEE2E2', '#991B1B'], 'canceled' => ['#F3F4F6', '#4B5563'], 'completed' => ['#DBEAFE', '#1D4ED8'], ]; $totalAll = max(1, $stats['total']); $completionPct = $stats['total'] > 0 ? round(($stats['completed'] / $stats['total']) * 100) : 0; @endphp
@if(is_null($user->email_verified_at))
{{ $isRtl ? 'تأكيد البريد الإلكتروني مطلوب' : 'Email verification required' }}
{{ $isRtl ? 'لن تتمكن من تقديم طلبات تمويل قبل تأكيد بريدك.' : 'You cannot submit financing requests until you verify your email.' }}
{{ $isRtl ? 'تأكيد البريد' : 'Verify Now' }}
@endif

{{ $isRtl ? "أهلاً $name 👋" : "$greeting, $name 👋" }}

{{ $isRtl ? 'تابع طلبات التمويل وحالتها من مكان واحد.' : 'Track your financing requests and their status in one place.' }}

{{ $isRtl ? 'طلب تمويل جديد' : 'New Financing Request' }}
{{-- Progress + KPIs row --}}
{{ $completionPct }}%

{{ $isRtl ? 'تقدّم طلباتك' : 'Your Progress' }}

{{ $isRtl ? "من إجمالي {$stats['total']} طلب، {$stats['completed']} مكتمل." : "Out of {$stats['total']} requests, {$stats['completed']} completed." }}

{{ number_format($stats['total']) }}

{{ $isRtl ? 'إجمالي الطلبات' : 'Total Requests' }}

{{ number_format($stats['pending']) }}

{{ $isRtl ? 'قيد المراجعة' : 'Under Review' }}

{{ number_format($stats['completed']) }}

{{ $isRtl ? 'مكتملة' : 'Completed' }}
{{-- Secondary row --}}

{{ number_format($stats['awaiting_payment']) }}

{{ $isRtl ? 'بانتظار الدفع' : 'Awaiting Payment' }}

{{ number_format($stats['awaiting_offer']) }}

{{ $isRtl ? 'بانتظار اختيار عرض' : 'Awaiting Offer' }}

{{ number_format($stats['rejected']) }}

{{ $isRtl ? 'مرفوضة' : 'Rejected' }}
{{-- Requests table --}}

{{ $isRtl ? 'طلبات التمويل الأخيرة' : 'Recent Financing Requests' }}

@if($requests->count()) {{ number_format($requests->total() ?? $requests->count()) }} @endif
{{ $isRtl ? 'عرض الكل' : 'View All' }}
@if($requests->count() === 0)

{{ $isRtl ? 'لا توجد طلبات تمويل' : 'No financing requests' }}

{{ $isRtl ? 'ابدأ بتقديم طلبك الأول خلال دقائق.' : 'Submit your first request in minutes.' }}

{{ $isRtl ? 'قدّم طلبك الأول' : 'Submit your first' }}
@else
@foreach($requests as $req) @php $eff = $req->stage === 'completed' || $req->status === 'completed' ? 'completed' : $req->status; [$bg, $fg] = $statusColors[$eff] ?? ['#F3F4F6', '#4B5563']; $label = $eff === 'completed' ? ($isRtl ? 'مكتمل' : 'Completed') : ($statusLabels[$req->status] ?? $req->status); @endphp @endforeach
{{ $isRtl ? 'رقم الطلب' : 'Request #' }} {{ $isRtl ? 'الاسم التجاري' : 'Commercial Name' }} {{ $isRtl ? 'الحالة' : 'Status' }} {{ $isRtl ? 'المرحلة' : 'Stage' }} {{ $isRtl ? 'التاريخ' : 'Date' }}
{{ $req->request_number }}
ID #{{ $req->id }}
{{ $req->commercial_name ?: '—' }} {{ $label }} {{ $stageLabels[$req->stage] ?? ($req->stage ?: '—') }} {{ optional($req->created_at)->format('Y-m-d') }} {{ $isRtl ? 'عرض' : 'View' }}
{{ $requests->links() }}
@endif
@endsection