@extends('layouts.admin.home') @section('title') {{ __('admin.dashboard.title') }} @endsection @section('css') @endsection @section('content') @php $isAr = app()->getLocale() === 'ar'; $tr = function ($key, $fallback, $replace = []) { $translated = __($key, $replace); return $translated === $key ? $fallback : $translated; }; $dashboard = $dashboard ?? []; $totals = $dashboard['totals'] ?? []; $charts = $dashboard['charts'] ?? []; $recentOrders = collect($dashboard['recent_orders'] ?? []); $lowStockProducts = collect($dashboard['low_stock_products'] ?? []); $ordersTotal = (int) ($totals['orders'] ?? 0); $paidOrders = (int) ($totals['paid_orders'] ?? 0); $unpaidOrders = (int) ($totals['unpaid_orders'] ?? 0); $processingOrders = (int) ($totals['processing_orders'] ?? 0); $lowStock = (int) ($totals['low_stock'] ?? 0); $paidPercent = $ordersTotal > 0 ? round(($paidOrders / $ordersTotal) * 100, 1) : 0; @endphp
{{ $tr('admin.dashboard.eyebrow', $isAr ? 'لوحة الإدارة' : 'Admin Dashboard') }}

{{ $tr('admin.dashboard.title', $isAr ? 'لوحة التحكم' : 'Dashboard') }}

{{ $isAr ? 'تابع أهم أرقام المنصة: الطلبات، المدفوعات، الطلبات قيد التنفيذ، وتنبيهات المخزون من مكان واحد.' : 'Track the most important platform numbers: orders, payments, processing orders, and stock alerts from one place.' }}

{{ $isAr ? 'مدفوع' : 'Paid' }}: {{ number_format($paidOrders) }} {{ $isAr ? 'غير مدفوع' : 'Unpaid' }}: {{ number_format($unpaidOrders) }} {{ $isAr ? 'آخر تحديث' : 'Updated' }}: {{ now()->format('Y-m-d H:i') }}
{{ $tr('admin.dashboard.orders_revenue_trend', $isAr ? 'اتجاه الطلبات والإيرادات' : 'Orders & Revenue Trend') }}

{{ $isAr ? 'رسم بياني بسيط يوضح حركة الطلبات والإيرادات.' : 'A simple chart showing orders and revenue movement.' }}

{{ $tr('admin.dashboard.monthly_analytics', $isAr ? 'تحليلات شهرية' : 'Monthly Analytics') }}
{{ $tr('admin.dashboard.recent_orders', $isAr ? 'أحدث الطلبات' : 'Recent Orders') }}

{{ $isAr ? 'آخر الطلبات التي تم إنشاؤها داخل المنصة.' : 'Latest orders created in the platform.' }}

{{ $tr('admin.dashboard.view_all', $isAr ? 'عرض الكل' : 'View All') }}
@forelse($recentOrders as $order) @empty @endforelse
{{ $isAr ? 'رقم الطلب' : 'Order ID' }} {{ $isAr ? 'العميل' : 'Customer' }} {{ $isAr ? 'المورد' : 'Provider' }} {{ $isAr ? 'الإجمالي' : 'Total' }} {{ $isAr ? 'الدفع' : 'Payment' }} {{ $isAr ? 'التاريخ' : 'Date' }}
#{{ $order->id }} {{ optional($order->user)->name ?? '-' }} {{ optional($order->provider)->name ?? '-' }} {{ number_format((float) ($order->total_cost ?? 0), 2) }} @if((int) ($order->payment_status ?? 0) === 1) {{ $isAr ? 'مدفوع' : 'Paid' }} @else {{ $isAr ? 'معلق' : 'Pending' }} @endif {{ optional($order->created_at)->format('Y-m-d H:i') ?? '-' }}
{{ $isAr ? 'لا توجد طلبات حديثة.' : 'No recent orders.' }}
{{ $tr('admin.dashboard.low_stock_alerts', $isAr ? 'تنبيهات المخزون' : 'Low Stock Alerts') }}

{{ $isAr ? 'منتجات تحتاج مراجعة المخزون.' : 'Products that need stock review.' }}

{{ number_format($lowStock) }}
@forelse($lowStockProducts as $product)
{{ $isAr ? 'المتبقي' : 'Left' }}: {{ $product->stock_quantity ?? 0 }}
{{ $product->name ?? '-' }}
{{ $isAr ? 'المورد' : 'Supplier' }}: {{ optional($product->provider)->name ?? '-' }}
@empty

{{ $isAr ? 'كل المنتجات لديها مخزون كافٍ.' : 'All products are sufficiently stocked.' }}

@endforelse
@endsection @section('script') @endsection