@extends('layouts.admin') @section('page_title', $isRtl ? 'الرئيسية' : 'Dashboard') @push('styles') @endpush @section('content') @php $fmt = fn($n) => number_format((float) $n, 0); $money = fn($n) => number_format((float) $n, 0) . ' ' . ($isRtl ? 'ر.س' : 'SAR'); $statusColors = [ 'pending' => '#f59e0b', 'approved' => '#10b981', 'rejected' => '#ef4444', 'canceled' => '#6b7280', 'completed' => '#e31e24', ]; $statusLabels = [ 'pending' => $isRtl ? 'قيد المراجعة' : 'Pending', 'approved' => $isRtl ? 'مقبول' : 'Approved', 'rejected' => $isRtl ? 'مرفوض' : 'Rejected', 'canceled' => $isRtl ? 'ملغي' : 'Canceled', 'completed' => $isRtl ? 'مكتمل' : 'Completed', ]; $totalStatus = max(1, array_sum($statusDistribution)); @endphp {{-- Welcome banner --}}

{{ $isRtl ? 'مرحباً،' : 'Welcome back,' }} {{ auth()->user()->name }} 👋

{{ $isRtl ? 'إليك نظرة عامة على أداء المنصة اليوم' : "Here's what's happening on your platform today" }} — {{ now()->locale(app()->getLocale())->isoFormat('dddd، D MMMM YYYY') }}

{{ $isRtl ? 'الطلبات' : 'Requests' }} {{ $isRtl ? 'المستخدمون' : 'Users' }}
{{-- KPI Cards --}}

{{ $isRtl ? 'المستخدمون' : 'Total Users' }}

{{ $fmt($metrics['users']) }}

{{ $metrics['users_delta']['percent'] }}%  {{ $metrics['users_this_month'] }} {{ $isRtl ? 'جديد هذا الشهر' : 'new this month' }}

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

{{ $fmt($metrics['requests']) }}

{{ $metrics['requests_delta']['percent'] }}%  {{ $metrics['requests_this_month'] }} {{ $isRtl ? 'جديد هذا الشهر' : 'new this month' }}

{{ $isRtl ? 'إجمالي قيمة التمويل' : 'Total Loan Volume' }}

{{ $money($metrics['loan_volume']) }}

{{ $isRtl ? 'متوسط القرض' : 'Avg. loan' }}: {{ $money($metrics['avg_loan']) }}

{{ $isRtl ? 'طلبات بانتظار المراجعة' : 'Pending Review' }}

{{ $fmt($metrics['pending_requests']) }}

{{-- Secondary metrics row --}}

{{ $isRtl ? 'طلبات مقبولة' : 'Approved' }}

{{ $fmt($metrics['approved_requests']) }}

{{ $money($metrics['approved_volume']) }}

{{ $isRtl ? 'طلبات مكتملة' : 'Completed' }}

{{ $fmt($metrics['completed_requests']) }}

{{ $isRtl ? 'طلبات مرفوضة' : 'Rejected' }}

{{ $fmt($metrics['rejected_requests']) }}

{{ $isRtl ? 'رسائل جديدة' : 'New Messages' }}

{{ $fmt($metrics['new_contacts']) }}

{{-- Charts --}}

{{ $isRtl ? 'نشاط آخر 12 شهر' : 'Activity — Last 12 Months' }}

{{ $isRtl ? 'الطلبات' : 'Requests' }} {{ $isRtl ? 'المستخدمون' : 'Users' }}

{{ $isRtl ? 'توزيع حالات الطلبات' : 'Requests by Status' }}

@foreach($statusLabels as $key => $label) @php $count = $statusDistribution[$key] ?? 0; $pct = $totalStatus > 0 ? round(($count / $totalStatus) * 100, 1) : 0; @endphp
{{ $label }}
{{ $count }} ({{ $pct }}%)
@endforeach
{{-- Volume chart + System overview --}}

{{ $isRtl ? 'حجم التمويل الشهري' : 'Monthly Loan Volume' }}

{{ $isRtl ? 'نظرة على المحتوى' : 'Content Overview' }}

{{ $isRtl ? 'الخدمات' : 'Services' }}
{{ $metrics['services'] }}
{{ $isRtl ? 'البنوك' : 'Banks' }}
{{ $metrics['banks'] }}
{{ $isRtl ? 'العروض' : 'Offers' }}
{{ $metrics['offers'] }}
{{ $isRtl ? 'المقالات' : 'Articles' }}
{{ $metrics['articles'] }}
{{ $isRtl ? 'الطلبات القديمة' : 'Legacy Applications' }}
{{ $metrics['applications'] }}
{{-- Recent activity tables --}}

{{ $isRtl ? 'أحدث طلبات التمويل' : 'Recent Financing Requests' }}

{{ $isRtl ? 'عرض الكل' : 'View All' }}
@forelse($recentRequests as $r) @empty @endforelse
{{ $isRtl ? 'رقم الطلب' : 'Request #' }} {{ $isRtl ? 'العميل' : 'Client' }} {{ $isRtl ? 'المبلغ' : 'Amount' }} {{ $isRtl ? 'الحالة' : 'Status' }} {{ $isRtl ? 'التاريخ' : 'Date' }}
{{ $r->request_number }} {{ $r->client_name ?? '—' }} {{ $r->loan_amount ? $fmt($r->loan_amount) : '—' }} {{ $r->status_label }} {{ $r->created_at?->diffForHumans() }}
{{ $isRtl ? 'لا توجد طلبات' : 'No requests yet' }}

{{ $isRtl ? 'أحدث المستخدمين' : 'Recent Users' }}

{{ $isRtl ? 'عرض الكل' : 'View All' }}
@forelse($recentUsers as $u) @empty @endforelse
{{ $isRtl ? 'الاسم' : 'Name' }} {{ $isRtl ? 'البريد' : 'Email' }} {{ $isRtl ? 'التحقق' : 'Verified' }} {{ $isRtl ? 'التاريخ' : 'Date' }}
{{ $u->name }} {{ $u->email }} @if($u->email_verified_at) @else {{ $isRtl ? 'غير مؤكد' : 'Pending' }} @endif {{ $u->created_at?->diffForHumans() }}
{{ $isRtl ? 'لا يوجد مستخدمون' : 'No users yet' }}
@push('scripts') @endpush @endsection