@extends('layouts.app') @section('title', $roleDashboard['title']) @section('content')
{{-- Page Header --}}

{{ $roleDashboard['title'] }}

Welcome back, {{ $user->name }} | {{ now()->format('l, F j, Y') }}

{{ $user->getRoleNames()->first() }}
{{-- Stat Cards --}}
@foreach($roleDashboard['cards'] as $card)
@if(isset($card['trend'])) {{ $card['trend'] }} @endif

{{ $card['value'] }}

{{ $card['label'] }}

@endforeach
@if($user->isSuperAdmin()) {{-- Admin Dashboard Content --}}
{{-- Revenue Chart --}}

Revenue Trend (Last 7 Days)

View Report
{{-- Order Status Distribution --}}

Order Status Distribution

{{-- Pending Tasks & Alerts --}}
{{-- Pending Tasks --}}

Pending Tasks

Real-time
@foreach($roleDashboard['pending_tasks'] as $task => $count) @php $taskConfig = [ 'confirmations' => ['label' => 'Customer Confirmations', 'icon' => 'phone', 'color' => 'yellow', 'route' => route('orders.index', ['order_status' => 'order_received'])], 'preparations' => ['label' => 'Warehouse Preparations', 'icon' => 'box', 'color' => 'blue', 'route' => route('warehouse.pending-orders')], 'shipping_approvals' => ['label' => 'Shipping Approvals', 'icon' => 'shipping-fast', 'color' => 'green', 'route' => route('operations.pending-shipping')], 'low_stock_alerts' => ['label' => 'Low Stock Alerts', 'icon' => 'exclamation-triangle', 'color' => 'red', 'route' => route('warehouse.low-stock')], ][$task] ?? ['label' => $task, 'icon' => 'circle', 'color' => 'gray', 'route' => '#']; @endphp
{{ $taskConfig['label'] }}
{{ $count }}
@endforeach
{{-- Recent Orders --}}

Recent Orders

View All
@forelse($roleDashboard['recent_orders'] ?? [] as $order) @empty @endforelse
Order Customer Status Amount
#{{ $order->order_number }} {{ $order->customer_name ?? 'N/A' }} @php $statusColors = [ 'order_received' => 'badge-warning', 'confirmed_with_customer' => 'badge-info', 'prepared_in_warehouse' => 'badge-primary', 'approved_for_shipping' => 'badge-success', 'shipped' => 'badge-info', 'delivered' => 'badge-success', 'cancelled' => 'badge-danger', ]; @endphp {{ $order->order_status_label }} {{ number_format($order->total_amount, 2) }} SAR
No recent orders
{{-- Alerts Section --}} @if(!empty($roleDashboard['alerts']))
@foreach($roleDashboard['alerts'] as $alert)
{{ $alert['message'] }} View
@endforeach
@endif @endif @if($user->isCustomerService()) {{-- Customer Service Dashboard --}}

Orders Requiring Confirmation

@if(!empty($roleDashboard['assigned_orders']))
@foreach($roleDashboard['assigned_orders'] as $order)
#{{ $order->order_number }}

{{ $order->customer_name }}

{{ $order->created_at->diffForHumans() }}
@endforeach
@else

No orders pending confirmation

@endif

Today's Performance

{{ $roleDashboard['recent_calls'] ?? 0 }}

Calls Made Today

{{ $roleDashboard['cards'][1]['value'] ?? 0 }}

Confirmations Today

@endif @if($user->isWarehouseStaff()) {{-- Warehouse Dashboard --}}

Orders to Prepare

View All
@if(!empty($roleDashboard['pending_orders']))
@foreach($roleDashboard['pending_orders'] as $order)
#{{ $order->order_number }}

{{ $order->customer_name }} - {{ $order->items->sum('quantity') }} items

@csrf
@endforeach
@else

No orders pending preparation

@endif

Low Stock Items

View All
@if(!empty($roleDashboard['low_stock_items']))
@foreach($roleDashboard['low_stock_items'] as $item)

{{ $item->product->name_en ?? 'Unknown' }}

{{ $item->name_en }} - Size: {{ $item->size ?? 'N/A' }}

{{ $item->stock_quantity }} left
@endforeach
@else

No low stock items

@endif
@endif @if($user->isOperationsStaff()) {{-- Operations Dashboard --}}

Orders Pending Shipping Approval

View All
@if(!empty($roleDashboard['pending_approval']))
@foreach($roleDashboard['pending_approval'] as $order)
#{{ $order->order_number }}

{{ $order->customer_name }} | Prepared by: {{ $order->preparedByUser->name ?? 'N/A' }}

{{ $order->items->sum('quantity') }} items | {{ number_format($order->total_amount, 2) }} SAR

@csrf
@endforeach
@else

No orders pending shipping approval

@endif
@endif
@endsection @push('scripts') @if($user->isSuperAdmin()) @endif @endpush