@extends('layouts.app') @section('title', 'إحصائيات البائعين') @section('page_heading', 'إحصائيات البائعين') @section('content') @include('dashboard.statistics.partials.nav') @php $rankedUsers = collect($usersData)->map(function($u) { $u['score'] = $u['salesCount'] + $u['reservationsCount'] + $u['fittingAppointmentsCount'] + $u['deliveryAppointmentsCount']; return $u; })->sortByDesc('score')->values(); $activeCount = $rankedUsers->filter(fn($u) => $u['score'] > 0)->count(); $totalServiceOps = $totalFittingAppointmentsCount + $totalDeliveryAppointmentsCount; @endphp {{-- Filter --}}
اليوم
{{-- KPIs --}}
@foreach([ ['fa-solid fa-users', '#eff6ff','#2563eb', $activeCount, 'بائعون نشطون', $selectedDate->format('Y-m-d')], ['fa-solid fa-cart-shopping', '#f0fdf4','#16a34a', number_format($totalSalesValue,2), 'إجمالي قيمة المبيعات', number_format($totalSalesCount).' فاتورة'], ['fa-solid fa-calendar-check','#fffbeb','#d97706', number_format($totalReservationsCount), 'عدد الحجوزات', number_format($totalReservationsValue,2).' ج.م'], ['fa-solid fa-screwdriver-wrench','#faf5ff','#7c3aed', number_format($totalServiceOps), 'إجراءات الخدمة', 'معاينات + تسليمات'], ] as [$ic,$bg,$cl,$val,$lbl,$meta])
{{ $val }}
{{ $lbl }}
{{ $meta }}
@endforeach
{{-- Staff Table --}}
أداء البائعين {{ $rankedUsers->count() }}
{{ $selectedDate->format('Y-m-d') }}
@if($rankedUsers->isEmpty())
@include('layouts.partials.index-empty-state',['icon'=>'fa-solid fa-users','title'=>'لا توجد بيانات لهذا اليوم','message'=>''])
@else
@foreach(['الترتيب','البائع','المبيعات','قيمة المبيعات','الحجوزات','قيمة الحجوزات','العربون','معاينات','تسليمات','النشاط الكلي'] as $h) @endforeach @foreach($rankedUsers as $idx => $ud) @php $isActive = $ud['score'] > 0; @endphp @endforeach
{{ $h }}
{{ $idx+1 }}
{{ mb_substr($ud['user']->name,0,1) }}
{{ $ud['user']->name }}
{{ $ud['user']->email }}
{{ $ud['salesCount'] }}
{{ number_format($ud['salesTotalValue'],2) }}
ج.م
{{ $ud['reservationsCount'] }}
{{ number_format($ud['reservationsTotalValue'],2) }}
ج.م
{{ number_format($ud['reservationsDepositSum'],2) }}
ج.م
{{ $ud['fittingAppointmentsCount'] }} {{ $ud['deliveryAppointmentsCount'] }}
@php $maxScore = $rankedUsers->max('score') ?: 1; @endphp
{{ $ud['score'] }}
الإجمالي {{ $totalSalesCount }} {{ number_format($totalSalesValue,2) }} {{ $totalReservationsCount }} {{ number_format($totalReservationsValue,2) }} {{ number_format($totalReservationsDeposit,2) }} {{ $totalFittingAppointmentsCount }} {{ $totalDeliveryAppointmentsCount }} {{ $rankedUsers->sum('score') }}
@endif
@endsection