@php use Carbon\Carbon; $user = auth()->user(); $role = $user->membership_status ?? $user->role ?? 'member'; switch ($role) { case 'super-admin': $layout = 'layouts.superadmin'; break; case 'advisor': $layout = 'layouts.advisor'; break; case 'admin': case 'moderator': $layout = 'layouts.moderator'; break; default: $layout = 'layouts.member'; } $today = Carbon::today(); // تسميات الأيام $labels = [ $today->copy()->subDay()->toDateString() => 'أمس', $today->toDateString() => 'اليوم', $today->copy()->addDay()->toDateString() => 'غداً', $today->copy()->addDays(2)->toDateString() => 'بعد غد', ]; // مدد الفلاتر $defaultStart = $today->copy()->subDay()->toDateString(); $defaultEnd = $today->copy()->addDays(7)->toDateString(); $weekStart = $today->toDateString(); $weekEnd = $today->copy()->addDays(7)->toDateString(); $monthStart = $today->copy()->startOfMonth()->toDateString(); $monthEnd = $today->copy()->endOfMonth()->toDateString(); // الموجود من الكنترولر (start / end) $currentStart = $start ?? request('start', $defaultStart); $currentEnd = $end ?? request('end', $defaultEnd); $isAdminNav = in_array($role, ['super-admin','admin','moderator']); $onToday = ($currentStart === $today->toDateString() && $currentEnd === $today->toDateString()); // ✅ إعدادات الوقت/التوقيت (من الكنترول أو request/session) $tf = $timeFormat ?? request('tf', session('lives_tf', '24')); // 24|12 if (!in_array($tf, ['24','12'], true)) $tf = '24'; $tz = $tzMode ?? request('tz', session('lives_tz', 'system')); // system|jordan if (!in_array($tz, ['system','jordan'], true)) $tz = 'system'; $displayTz = $displayTz ?? ($tz === 'jordan' ? 'Asia/Amman' : config('app.timezone', 'Asia/Jerusalem')); // ✅ هل الصفحة PDF؟ $isPdf = $isPdf ?? false; // ✅ Helper: AM/PM بالعربي $ampmAr = function(string $s){ return str_replace(['AM','PM'], ['ص','م'], $s); }; @endphp @extends($layout) @section('title', 'عرض اللايفات (عام)') @section('content')
{{-- هيدر ملحمي خفيف --}}
{{-- Glow --}}
نظام فريق الوفاء الذهبي

منظومة اللايفات العامة

متابعة لايفات الأعضاء حسب الأيام – للعرض فقط بدون تحكم أو نقاط

@isset($myTodayLivesCount) @endisset
{{-- ✅ شريط أدوات: 24/12 + توقيت + PDF --}}
@php $baseParams = ['start' => $currentStart, 'end' => $currentEnd]; $params24 = array_merge($baseParams, ['tf'=>'24','tz'=>$tz]); $params12 = array_merge($baseParams, ['tf'=>'12','tz'=>$tz]); $paramsSys = array_merge($baseParams, ['tf'=>$tf,'tz'=>'system']); $paramsJo = array_merge($baseParams, ['tf'=>$tf,'tz'=>'jordan']); $pdfParams = array_merge($baseParams, ['tf'=>$tf,'tz'=>$tz]); @endphp 24 ساعة 12 ساعة توقيت النظام توقيت الأردن PDF عرضي {{ $displayTz }}
{{-- تنقّل سريع بسيط --}} {{-- فلاتر الأيام --}}
@php $dayFilters = [ ['label' => 'أمس', 'date' => $today->copy()->subDay()->toDateString()], ['label' => 'اليوم', 'date' => $today->toDateString()], ['label' => 'غداً', 'date' => $today->copy()->addDay()->toDateString()], ['label' => 'بعد غد', 'date' => $today->copy()->addDays(2)->toDateString()], ]; @endphp @foreach($dayFilters as $f) @php $active = ($currentStart === $f['date'] && $currentEnd === $f['date']); @endphp {{ $f['label'] }} @endforeach @php $weekActive = ($currentStart === $weekStart && $currentEnd === $weekEnd); $monthActive = ($currentStart === $monthStart && $currentEnd === $monthEnd); $defaultActive = ($currentStart === $defaultStart && $currentEnd === $defaultEnd); @endphp هذا الأسبوع هذا الشهر الافتراضي
من {{ $currentStart }} إلى {{ $currentEnd }}
{{-- جدول اللايفات مجمّع حسب التاريخ --}} @forelse($streams as $date => $items) @php $day = Carbon::parse($date)->startOfDay(); $dateKey = $day->toDateString(); $prefix = $labels[$dateKey] ?? null; $dateText = $day->format('Y-m-d'); $headerTxt = $prefix ? "{$prefix} - {$dateText}" : $dateText; $confirmed = $items->where('status', 'confirmed')->count(); $excuse = $items->where('status', 'missed_excuse')->count(); $noexcuse = $items->where('status', 'missed_no_excuse')->count(); $pending = $items->whereIn('status', ['scheduled','pending_excuse','pending_proof'])->count(); @endphp
{{ $headerTxt }} ({{ $items->count() }} بث)
مؤكد: {{ $confirmed }} عذر: {{ $excuse }} بدون: {{ $noexcuse }}
@foreach($items as $live) @php $u = $live->user ?? null; $name = $u ? ($u->name ?: $u->username) : ('عضو #' . ($live->user_id ?? '')); $hours = round(($live->duration_hours ?? 0) + (($live->duration_minutes ?? 0)/60), 2); $typeLabel = match($live->type) { 'guests' => 'قستات', 'tours' => 'تحديات', 'both' => 'قستات + تحديات', default => (string) $live->type, }; $statusLabel = match($live->status) { 'confirmed' => 'مؤكد', 'missed_excuse' => 'مع عذر', 'missed_no_excuse' => 'بدون عذر', 'pending_excuse' => 'بانتظار عذر', 'pending_proof' => 'بانتظار إثبات', 'scheduled' => 'غير مؤكد', default => (string) $live->status, }; $statusCls = match($live->status) { 'confirmed' => 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-200', 'missed_excuse' => 'bg-amber-100 text-amber-800 dark:bg-amber-900/40 dark:text-amber-200', 'missed_no_excuse' => 'bg-rose-100 text-rose-800 dark:bg-rose-900/40 dark:text-rose-200', 'pending_excuse' => 'bg-sky-100 text-sky-800 dark:bg-sky-900/40 dark:text-sky-200', 'pending_proof' => 'bg-sky-100 text-sky-800 dark:bg-sky-900/40 dark:text-sky-200', default => 'bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-100', }; // ✅✅✅ وقت مع تبديل 24/12 + توقيت (FIX: منع دمج تاريخين) $timeText = '—'; if (!empty($live->scheduled_time)) { $rawDate = (string) ($live->scheduled_date ?: $dateKey); // ممكن DATE أو DATETIME $rawTime = trim((string) $live->scheduled_time); // ممكن TIME أو DATETIME كامل // ✅ نظّف التاريخ: خذ فقط YYYY-MM-DD لو فيه وقت $rawDateOnly = $dateKey; if (preg_match('/^\d{4}-\d{2}-\d{2}/', $rawDate, $m)) { $rawDateOnly = $m[0]; } // ✅ إذا scheduled_time جاي DATETIME كامل: استخدمه كما هو if (preg_match('/^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}(:\d{2})?$/', $rawTime)) { $dt = Carbon::parse($rawTime, config('app.timezone', 'Asia/Jerusalem')); } // ✅ إذا جاي TIME فقط else { // خذ HH:MM أو HH:MM:SS if (preg_match('/^\d{2}:\d{2}(:\d{2})?$/', $rawTime)) { $dt = Carbon::parse($rawDateOnly . ' ' . $rawTime, config('app.timezone', 'Asia/Jerusalem')); } else { // fallback: أي تنسيق غريب، حاول parse مباشر $dt = Carbon::parse($rawTime, config('app.timezone', 'Asia/Jerusalem')); } } $dt = $dt->setTimezone($displayTz); if ($tf === '12') { $timeText = $ampmAr($dt->format('h:i A')); } else { $timeText = $dt->format('H:i'); } } $isProactive = str_contains((string)($live->description ?? ''), '[PROACTIVE_SCHEDULE_ID='); // ✅✅ تمييز ProActive Plus (بدون تغيير منطق ProActive الأساسي) $isProactivePlus = $isProactive && str_contains((string)($live->description ?? ''), '[PROACTIVE_EVENT_TYPE=plus]'); $proRowClass = $isProactivePlus ? 'pro-plus-row' : ($isProactive ? 'pro-row' : ''); // ✅ الفترة: إذا ProActive خليها ProActive، غير هيك slot_label $periodCell = $isProactive ? 'ProActive' : ($live->slot_label ?: '—'); // ✅ للـ ProActive: ما نطبع اسم عضو $memberText = $isProactive ? null : $name; @endphp {{-- 1) العضو --}} {{-- 2) الوقت --}} {{-- 3) الفترة --}} @if(!$isProactive) {{-- 4) النوع --}} @endif {{-- 5) الحالة --}} {{-- 6) المدة --}} @endforeach
العضو الوقت الفترة النوع الحالة المدة
@if($isProactive) {{-- ✅ يطلع واضح حتى لو العمود ضيق --}}
{{ $isProactivePlus ? '(كل التيم)' : 'ما تنسو تقارير' }}
{{ $isProactivePlus ? 'ProActive Plus' : 'ProActive' }}
@else
{{ $memberText }} @if($live->is_sahra) 🔥 سهرة @endif
@endif
{{ $timeText }} {{ $periodCell }} {{ $typeLabel }} {{ $statusLabel }} {{ $hours }} ساعة
@empty

لا توجد لايفات ضمن الفترة الحالية.

عند إضافة لايفات جديدة ستظهر تلقائياً في هذا الجدول.

@endforelse
@endsection