@extends('admin._layout') @section('title', 'العيادات') @push('head') @endpush @php $statusMeta = [ 'active' => ['label' => 'نشطة', 'color' => 'success', 'icon' => 'check'], 'trial' => ['label' => 'تجريبية', 'color' => 'warning', 'icon' => 'hourglass'], 'suspended' => ['label' => 'موقوفة', 'color' => 'danger', 'icon' => 'ban'], 'expired' => ['label' => 'منتهية', 'color' => 'secondary', 'icon' => 'calendar-x'], 'pending' => ['label' => 'معلّقة', 'color' => 'info', 'icon' => 'clock'], ]; $current = request('status'); $sort = request('sort', 'latest'); @endphp @section('content') {{-- Status filter pills --}}
الكل {{ $statusCounts['_all'] ?? 0 }} @foreach($statusMeta as $key => $meta) {{ $meta['label'] }} {{ $statusCounts[$key] ?? 0 }} @endforeach
{{-- Search + sort row --}}
{{-- Clinics table --}}
@if($clinics->isEmpty())

لا توجد عيادات تطابق الفلاتر

@if(request('q') || request('status')) جرّب تغيير الفلاتر أو عرض كل العيادات. @else ابدأ بإضافة أول عيادة. @endif

@if(! (request('q') || request('status'))) إنشاء عيادة جديدة @endif
@else
@foreach($clinics as $c) @php $m = $tenantSnapshots[$c->id] ?? ['reachable' => false]; $sm = $statusMeta[$c->status] ?? ['label' => $c->status, 'color' => 'secondary', 'icon' => 'circle']; // Pick countdown source: trial wins while in trial, otherwise show the subscription window. $endsAt = $c->status === 'trial' ? $c->trial_ends_at : $c->subscription_ends_at; $daysLeft = ($endsAt && $endsAt->isFuture()) ? (int) max(0, ceil(now()->diffInDays($endsAt, false))) : null; $countdownColor = $daysLeft === null ? 'secondary' : ($daysLeft <= 3 ? 'danger' : ($daysLeft <= 7 ? 'warning' : 'success')); $plan = $c->plan; $docPct = ($plan && $plan->max_doctors && ($m['doctors'] ?? null) !== null) ? (int) min(100, round(($m['doctors'] / $plan->max_doctors) * 100)) : null; $patPct = ($plan && $plan->max_patients && ($m['patients'] ?? null) !== null) ? (int) min(100, round(($m['patients'] / $plan->max_patients) * 100)) : null; $barColor = fn ($pct) => $pct === null ? 'success' : ($pct >= 90 ? 'danger' : ($pct >= 70 ? 'warning' : 'success')); $initials = collect(preg_split('/\s+/u', trim($c->name))) ->filter()->take(2) ->map(fn ($w) => mb_substr($w, 0, 1)) ->implode(''); $avatarClass = match($c->status) { 'trial' => 'bg-trial', 'suspended' => 'bg-suspended', 'expired' => 'bg-expired', default => '', }; @endphp @endforeach
العيادة الباقة الحالة المتبقي الأطباء المرضى تاريخ الإنشاء الإجراءات
{{ $initials ?: '?' }}
{{ $c->name }}
{{ $c->owner_email }} @if($c->currency) @php $ccyMeta = \App\Support\Currency::meta($c->currency); @endphp · {{ $ccyMeta['flag'] }} {{ $c->currency }} @endif
@if($c->phone)
{{ $c->phone }}
@endif
@if($plan) @php $clinicCcy = strtoupper($c->currency ?? 'SAR'); $planPrice = $plan->priceFor($clinicCcy); $shownCcy = $planPrice > 0 ? $clinicCcy : strtoupper($plan->currency); if ($planPrice <= 0) { $planPrice = (float) $plan->price; } @endphp {{ $plan->name }}
{{ number_format($planPrice, 0) }} {{ $shownCcy }} / {{ $plan->duration_days }} يوم
@else — بدون باقة @endif
{{ $sm['label'] }} @if($daysLeft !== null) {{ $daysLeft }} يوم @else @endif @if($m['reachable'] ?? false)
{{ $m['doctors'] ?? 0 }} @if($plan && $plan->max_doctors) / {{ $plan->max_doctors }} @endif @if($docPct !== null){{ $docPct }}%@endif
@if($plan && $plan->max_doctors)
@endif
@else @endif
@if($m['reachable'] ?? false)
{{ number_format($m['patients'] ?? 0) }} @if($plan && $plan->max_patients) / {{ number_format($plan->max_patients) }} @endif @if($patPct !== null){{ $patPct }}%@endif
@if($plan && $plan->max_patients)
@endif
@else @endif
{{ $c->created_at->translatedFormat('j M Y') }}
{{ $c->created_at->diffForHumans() }}
@csrf
@if($c->status === 'suspended') @else @endif
@if($clinics->hasPages()) @endif @endif
@endsection @push('scripts') @endpush