{{-- resources/views/superadmin/unit-hours/index.blade.php --}} @extends('layouts.superadmin') @section('title','غرفة الصقر — ساعات الفعاليات') @section('page-title','⏱️ لوحة ساعات الفعاليات — ProActive / ProActive+') @php $tz = config('app.timezone','Asia/Jerusalem'); $items = ($rows ?? collect()); $now = \Carbon\Carbon::now($tz); // ========================= // Helpers // ========================= $labelStatus = function($s){ return [ 'upcoming' => 'قادمة', 'active' => 'نشطة', 'finished' => 'منتهية', 'cancelled' => 'ملغاة', ][$s] ?? $s; }; $toneStatus = function($s){ return match($s){ 'active' => 'bg-emerald-500/12 text-emerald-100 border border-emerald-300/15', 'upcoming' => 'bg-amber-500/12 text-amber-100 border border-amber-300/15', 'finished' => 'bg-white/10 text-white/75 border border-white/12', 'cancelled' => 'bg-rose-500/12 text-rose-100 border border-rose-300/15', default => 'bg-white/10 text-white/70 border border-white/12', }; }; $badgeType = function($t){ return ($t === 'plus') ? 'bg-fuchsia-500/12 text-fuchsia-100 border border-fuchsia-300/15' : 'bg-amber-500/10 text-amber-100 border border-amber-300/15'; }; // حساب مدة بالدقائق $calcMinutes = function($row) use($tz, $now){ if (isset($row->duration_minutes) && is_numeric($row->duration_minutes)) { return max(0, (int)$row->duration_minutes); } if (($row->status ?? '') === 'finished') { $st = !empty($row->started_at) ? \Carbon\Carbon::parse($row->started_at, $tz) : \Carbon\Carbon::parse(trim(($row->event_date ?? '').' '.($row->event_time ?? '00:00')), $tz); $fi = !empty($row->finished_at) ? \Carbon\Carbon::parse($row->finished_at, $tz) : $now; return max(0, $fi->diffInMinutes($st)); } if (($row->status ?? '') === 'active') { $st = !empty($row->started_at) ? \Carbon\Carbon::parse($row->started_at, $tz) : \Carbon\Carbon::parse(trim(($row->event_date ?? '').' '.($row->event_time ?? '00:00')), $tz); return max(0, $now->diffInMinutes($st)); } return 0; }; // تحويل دقائق إلى (ساعات، دقائق) $toHM = function(int $mins){ $mins = max(0, (int)$mins); return [intdiv($mins,60), $mins % 60]; }; // ========================= // Stats // ========================= $sumToday = 0; $sumWeek = 0; $sumAll = 0; $todayStr = $now->toDateString(); $weekEnd = $now->copy()->endOfWeek(); $thisWeek = [$now->copy()->startOfWeek()->toDateString(), $weekEnd->toDateString()]; foreach ($items as $it) { $mins = $calcMinutes($it); $sumAll += $mins; if (($it->event_date ?? '') === $todayStr) { $sumToday += $mins; } if (($it->event_date ?? '') >= $thisWeek[0] && ($it->event_date ?? '') <= $thisWeek[1]) { $sumWeek += $mins; } } [$hToday, $mToday] = $toHM($sumToday); [$hWeek, $mWeek ] = $toHM($sumWeek); [$hAll, $mAll ] = $toHM($sumAll); $countActiveToday = $items->filter(fn($r) => ($r->status ?? '')==='active' && ($r->event_date ?? '')===$todayStr)->count(); @endphp @section('content')
{{-- SOCRATIC HERO --}}
غرفة الصقر • ساعات الفعاليات • ProActive / ProActive+

⏱️ ساعات الفعاليات — عرض سقراطي موحّد

الصفحة تعرض المدة الفعلية للفعاليات: نشطة = من وقت البدء حتى الآن، منتهية = الفارق بين البدء والانتهاء — وكل شيء محسوب بدقة.

TZ: {{ $tz }} ProActive ProActive+
{{-- STATS (Hours:Minutes) --}}
اليوم
{{ number_format($hToday) }}س {{ $mToday }}د
{{ number_format($sumToday) }} دقيقة
هذا الأسبوع
{{ number_format($hWeek) }}س {{ $mWeek }}د
{{ number_format($sumWeek) }} دقيقة
الإجمالي
{{ number_format($hAll) }}س {{ $mAll }}د
{{ number_format($sumAll) }} دقيقة
@if($countActiveToday > 0)
هناك {{ $countActiveToday }} فعالية نشطة اليوم — يتم تحديث المدة لحظياً حتى الإنهاء.
@endif
{{-- SOCRATIC GRID --}}
@forelse($items as $it) @php $minutes = $calcMinutes($it); [$hh, $mm] = $toHM($minutes); $badgeCls = $badgeType($it->event_type ?? 'regular'); $toneCls = $toneStatus($it->status ?? ''); $dateTxt = ($it->event_date ?? '') . ( !empty($it->event_time ?? '') ? ' — ' . \Carbon\Carbon::parse($it->event_time)->format('H:i') : '' ); $isPlus = (($it->event_type ?? 'regular') === 'plus'); $glow = $isPlus ? 'bg-fuchsia-400/10' : 'bg-amber-300/10'; $st = (string)($it->status ?? 'upcoming'); $dot = match($st){ 'active' => 'bg-emerald-300', 'upcoming' => 'bg-amber-300', 'cancelled' => 'bg-rose-300', 'finished' => 'bg-white/35', default => 'bg-white/35', }; @endphp
{{ $isPlus ? 'PROACTIVE+ (PLUS)' : 'PROACTIVE (REG)' }}
{{ $it->event_title ?? '—' }}
{{ $isPlus ? '+Plus' : 'عادية' }}
{{ $labelStatus($it->status ?? '') }} @if(!empty($it->platform)) {{ strtoupper($it->platform) }} @endif @if(!empty($it->leader_name)) {{ $it->leader_name }} @endif
{{ $dateTxt }} {{ number_format($minutes) }} د
{{-- مدة الفعالية (سقراطي/واضح) --}}
المدة
{{ $hh }} س {{ $mm }} د
@if(($it->status ?? '') === 'active')
* تتحدّث لحظيًا حتى الإنهاء.
@endif @if(($it->status ?? '') === 'finished' && empty($it->duration_minutes))
* تم حسابها من أوقات البدء/الانتهاء لعدم توفر القيمة المخزّنة.
@endif
@if(!empty($it->event_description))
{{ \Illuminate\Support\Str::limit($it->event_description, 140) }}
@endif
@empty
لا توجد سجلات ساعات بعد.
@endforelse
{{-- TABLE (Socratic Glass) --}}
Socratic Table
جدول تفصيلي
{{ number_format($items->count()) }} سجل
@foreach($items as $i => $it) @php $m = $calcMinutes($it); [$hh,$mm] = $toHM($m); $isPlusRow = (($it->event_type ?? 'regular') === 'plus'); @endphp @endforeach
# العنوان النوع الحالة التاريخ/الوقت القائد المنصة المدة الدقائق
{{ $i+1 }} {{ $it->event_title ?? '—' }} {{ $isPlusRow ? 'Plus' : 'عادية' }} {{ $labelStatus($it->status ?? '') }} {{ $it->event_date ?? '—' }} @if(!empty($it->event_time)) — {{ \Carbon\Carbon::parse($it->event_time)->format('H:i') }} @endif {{ $it->leader_name ?? '—' }} {{ strtoupper($it->platform ?? '—') }} {{ $hh }}س {{ $mm }}د {{ number_format($m) }}
@endsection