@extends('layouts.app') @section('title', 'لوحة التحكم') @push('head') @endpush @php $userInitials = collect(preg_split('/\s+/u', trim($user->name))) ->filter()->take(2)->map(fn ($w) => mb_substr($w, 0, 1))->implode('') ?: '؟'; $planUsageDoctorsPct = ($planUsage['max_doctors'] ?? null) > 0 ? min(100, (int) round(($planUsage['doctors'] / $planUsage['max_doctors']) * 100)) : null; $planUsagePatientsPct = ($planUsage['max_patients'] ?? null) > 0 ? min(100, (int) round(($planUsage['patients'] / $planUsage['max_patients']) * 100)) : null; // Two tiers of KPIs — primary (eye-catching) and secondary // (compact). Each tile carries its color hex for the top accent // line so the row reads as varied without random per-card whim. $primaryKpis = [ ['key' => 'today_appointments', 'label' => 'مواعيد اليوم', 'icon' => 'calendar-event', 'color' => 'primary', 'accent' => '#0ea5e9'], ['key' => 'today_revenue', 'label' => 'إيرادات اليوم', 'icon' => 'cash', 'color' => 'success', 'accent' => '#16a34a', 'is_currency' => true], ['key' => 'new_patients_today', 'label' => 'مرضى جدد اليوم', 'icon' => 'user-plus', 'color' => 'info', 'accent' => '#0891b2'], ['key' => 'outstanding_total', 'label' => 'ذمم مستحقة', 'icon' => 'alert-circle', 'color' => 'danger', 'accent' => '#dc2626', 'is_currency' => true], ]; $secondaryKpis = [ ['key' => 'month_revenue', 'label' => 'إيرادات الشهر', 'icon' => 'building-bank', 'color' => 'success', 'is_currency' => true], ['key' => 'pending_labs', 'label' => 'تحاليل قيد الانتظار', 'icon' => 'flask', 'color' => 'warning'], ['key' => 'rx_today', 'label' => 'وصفات اليوم', 'icon' => 'prescription', 'color' => 'purple'], ['key' => 'avg_consultation', 'label' => 'متوسط الكشف', 'icon' => 'clock', 'color' => 'cyan', 'unit' => 'دقيقة'], ]; @endphp @section('content') {{-- ============================================================ --}} {{-- HERO --}} {{-- ============================================================ --}}

{{ $greeting }}، {{ $user->name }} 👋

{{ now()->translatedFormat('l، j F Y') }} · {{ $clinic?->name ?? config('app.name') }} تحديث مباشر
موعد اليوم مريض جديد إيرادات @if($plan) باقة {{ $plan->name }} @endif
{{ now()->format('h:i') }}
{{ now()->format('A') === 'AM' ? 'صباحاً' : 'مساءً' }} · {{ now()->format('s') }}ث
{{-- Quick actions ribbon — moved up so the most-used buttons are immediately reachable without scrolling past KPIs. --}}
مريض جديد حجز موعد وصفة طبية @feature('invoices') فاتورة @endfeature @feature('lab_tests') طلب تحليل @endfeature @feature('reports') التقارير @endfeature
{{-- Pending alerts strip — only shows when there's something to act on. --}}
{{-- ============================================================ --}} {{-- PRIMARY KPIs — 4 prominent cards with deltas --}} {{-- ============================================================ --}}
@foreach($primaryKpis as $tile)
{{ $tile['label'] }}
@endforeach
{{-- ============================================================ --}} {{-- SECONDARY KPIs — slim row, no accent line --}} {{-- ============================================================ --}}
@foreach($secondaryKpis as $tile)
{{ $tile['label'] }}
@endforeach
{{-- ============================================================ --}} {{-- MAIN ROW — combo chart + countdown + today's timeline --}} {{-- ============================================================ --}}

النشاط — آخر 30 يوم

المواعيد + الإيرادات
{{-- Live countdown to next appointment --}}

جدول اليوم

جاري التحميل…
{{-- ============================================================ --}} {{-- WIDGETS — distribution + diagnoses + demographics --}} {{-- ============================================================ --}}

حالات المواعيد

أكثر التشخيصات

التركيبة العمرية

{{-- ============================================================ --}} {{-- BOTTOM ROW — feed + recent patients + top doctors --}} {{-- ============================================================ --}}

آخر النشاطات

جاري التحميل…

آخر المرضى

عرض الكل ←
جاري التحميل…
@if($user->isOwner())

الأطباء الأعلى أداءً

جاري التحميل…
@endif
{{-- ============================================================ --}} {{-- PLAN STRIP --}} {{-- ============================================================ --}} @if($plan)
{{ $plan->name }} @if($planUsageDoctorsPct !== null)
الأطباء {{ $planUsage['doctors'] }} / {{ $planUsage['max_doctors'] }}
@endif @if($planUsagePatientsPct !== null)
المرضى {{ number_format($planUsage['patients']) }} / {{ number_format($planUsage['max_patients']) }}
@endif
@endif @endsection @push('scripts') @endpush