{{-- resources/views/superadmin/proactive/command/proofs.blade.php --}} @extends('layouts.superadmin') @section('title', 'ProActive — الإثباتات') @section('page-title', 'إثباتات ProActive') @section('content') @php use Illuminate\Support\Facades\Route; // ✅ safe_route داخل نفس الـView if (!function_exists('safe_route')) { function safe_route(string $name, array $params = [], bool $absolute = true, string $fallback = '#'): string { try { return Route::has($name) ? route($name, $params, $absolute) : $fallback; } catch (\Throwable $e) { return $fallback; } } } $qs = request()->query(); $q = fn($k,$d=null) => request()->get($k,$d); $date = $date ?? $q('date', now()->toDateString()); $tab = (string)($tab ?? $q('tab','pending')); // pending|approved|rejected|all $view = (string)($view ?? $q('view','table')); // table|cards if(!in_array($tab, ['pending','approved','rejected','all'], true)) $tab = 'pending'; if(!in_array($view,['table','cards'],true)) $view = 'table'; // items: proofs list (collection/array) $items = $items ?? collect(); // stats $stats = $stats ?? [ 'pending' => (int)($pendingCount ?? 0), 'approved' => (int)($approvedCount ?? 0), 'rejected' => (int)($rejectedCount ?? 0), 'all' => (int)($allCount ?? 0), ]; // routes $rCommand = safe_route('superadmin.proactive.command', [], true, url('/superadmin/proactive/command')); $rProofs = safe_route('superadmin.proactive.proofs', [], true, url()->current()); // ✅ قرار الإثبات (إذا عندك راوتات مختلفة غيّر الاسماء) $rApprove = fn($id) => safe_route('superadmin.proactive.proofs.approve', ['id'=>$id], true, '#'); $rReject = fn($id) => safe_route('superadmin.proactive.proofs.reject', ['id'=>$id], true, '#'); $chip = fn($cls) => "px-2.5 py-1 rounded-xl border text-[11px] font-extrabold $cls"; $tabBtn = function($key, $label, $count, $activeCls, $idleCls) use ($tab, $qs, $rProofs) { $url = $rProofs.'?'.http_build_query(array_merge($qs, ['tab'=>$key])); $is = $tab===$key; return [ 'url'=>$url, 'cls'=>$is ? $activeCls : $idleCls, 'label'=>$label, 'count'=>$count, ]; }; $badgeStatus = function($st) use ($chip){ $st = (string)$st; if($st==='pending' || $st==='pending_proof') return $chip('border-amber-400/25 bg-amber-500/10 text-amber-100'); if($st==='approved' || $st==='proof_approved') return $chip('border-emerald-400/25 bg-emerald-500/10 text-emerald-100'); if($st==='rejected' || $st==='proof_rejected') return $chip('border-rose-400/25 bg-rose-500/10 text-rose-100'); return $chip('border-white/10 bg-white/5 text-white/70'); }; $typeBadge = function($type) use ($chip){ $type = (string)$type; return $type==='plus' ? $chip('border-fuchsia-400/25 bg-fuchsia-500/10 text-fuchsia-100') : $chip('border-emerald-400/25 bg-emerald-500/10 text-emerald-100'); }; $tabs = [ $tabBtn('pending','بانتظار', (int)($stats['pending'] ?? 0), 'border-amber-400/40 bg-amber-500/15 text-amber-100', 'border-white/10 bg-white/5 text-white/80 hover:text-white hover:bg-white/10'), $tabBtn('approved','مقبولة', (int)($stats['approved'] ?? 0), 'border-emerald-400/40 bg-emerald-500/15 text-emerald-100', 'border-white/10 bg-white/5 text-white/80 hover:text-white hover:bg-white/10'), $tabBtn('rejected','مرفوضة', (int)($stats['rejected'] ?? 0), 'border-rose-400/40 bg-rose-500/15 text-rose-100', 'border-white/10 bg-white/5 text-white/80 hover:text-white hover:bg-white/10'), $tabBtn('all','الكل', (int)($stats['all'] ?? 0), 'border-cyan-400/40 bg-cyan-500/15 text-cyan-100', 'border-white/10 bg-white/5 text-white/80 hover:text-white hover:bg-white/10'), ]; @endphp
{{-- HERO --}}
ProActive • إثباتات رسمية

الإثباتات — Proofs

هذا المكان يثبت “من جد حضر/نفّذ”: قبول/رفض + ملاحظة إدارية. بدون إثبات = تقرير التزام ناقص.

التاريخ: {{ $date }} بانتظار: {{ (int)($stats['pending'] ?? 0) }} مقبولة: {{ (int)($stats['approved'] ?? 0) }} مرفوضة: {{ (int)($stats['rejected'] ?? 0) }}
{{-- FILTER --}}
تصفير
* زر قبول/رفض يعمل فقط إذا الروتات موجودة.
{{-- TABS --}}
@foreach($tabs as $t) {{ $t['label'] }} ({{ (int)$t['count'] }}) @endforeach
{{-- LIST --}} @php $hasItems = ($items instanceof \Illuminate\Support\Collection) ? $items->isNotEmpty() : (is_array($items) && count($items)>0); @endphp @if($hasItems) @if($view === 'cards')
@foreach($items as $p) @php $id = (int)($p->id ?? 0); $st = (string)($p->proof_status ?? $p->status ?? 'pending'); $evType = (string)($p->event_type ?? 'regular'); $approveUrl = $rApprove($id); $rejectUrl = $rReject($id); $canApprove = $approveUrl !== '#'; $canReject = $rejectUrl !== '#'; $proofUrl = (string)($p->proof_url ?? $p->attachment_url ?? ''); @endphp
{{ $p->event_title ?? ('#'.$id) }}
{{ $p->leader_name_safe ?? $p->leader_name ?? '-' }} • {{ $p->platform ?? 'other' }}
{{ $evType==='plus' ? 'PLUS' : 'REG' }} {{ strtoupper($st) }}
التاريخ
{{ $p->event_date ?? $date }}
الوقت
{{ $p->event_time ?? '—' }}
ID
{{ $id }}
@if($proofUrl !== '') فتح الإثبات @else
لا يوجد رابط إثبات واضح.
@endif
قرار سريع
@if(!$canApprove || !$canReject)
⚠️ Route قبول/رفض غير موجود (superadmin.proactive.proofs.approve / reject)
@endif
@csrf
@csrf
* إذا بدك ملاحظة إلزامية للرفض، بنربطها بالكنترول.
@endforeach
@else
قائمة الإثباتات
استخدم “قبول/رفض” لاتخاذ القرار.
@foreach($items as $p) @php $id = (int)($p->id ?? 0); $st = (string)($p->proof_status ?? $p->status ?? 'pending'); $evType = (string)($p->event_type ?? 'regular'); $approveUrl = $rApprove($id); $rejectUrl = $rReject($id); $canApprove = $approveUrl !== '#'; $canReject = $rejectUrl !== '#'; $proofUrl = (string)($p->proof_url ?? $p->attachment_url ?? ''); @endphp @endforeach
الفعالية القائد المنصة التاريخ/الوقت الحالة الإثبات قرار
{{ $p->event_title ?? ('#'.$id) }}
{{ $evType==='plus' ? 'PLUS' : 'REG' }} ID: {{ $id }}
{{ $p->leader_name_safe ?? $p->leader_name ?? '-' }} {{ $p->platform ?? 'other' }}
{{ $p->event_date ?? $date }}
{{ $p->event_time ?? '—' }}
{{ strtoupper($st) }} @if($proofUrl !== '') فتح @else لا يوجد @endif @if(!$canApprove || !$canReject)
⚠️ Route قبول/رفض غير موجود
@endif
@csrf
@csrf
@if(isset($items) && method_exists($items,'links'))
{{ $items->links() }}
@endif
@endif @else
لا توجد إثباتات ضمن هذا الفلتر ✅
غيّر التبويب أو التاريخ إذا بدك تشوف عناصر.
@endif
@endsection