@auth @php $surveyModal = null; try { $u = auth()->user(); // === Helpers داخل Blade (بدون use statements) === $matchesTargets = function($survey) use ($u) { $targets = \App\Models\SocraticSurveyTarget::where('survey_id', $survey->id)->get(); if ($targets->isEmpty()) return true; if ($targets->where('target_type','all')->count() > 0) return true; foreach ($targets as $t) { if ($t->target_type === 'user' && (string)$u->id === (string)$t->target_value) return true; if ($t->target_type === 'membership_status' && (string)($u->membership_status ?? '') === (string)$t->target_value) return true; if ($t->target_type === 'gender' && (string)($u->gender ?? '') === (string)$t->target_value) return true; // role (spatie) if ($t->target_type === 'role' && $t->target_value && method_exists($u,'hasRole')) { try { if ($u->hasRole($t->target_value)) return true; } catch(\Throwable $e){} } } return false; }; $alreadySubmitted = function($survey) use ($u) { // إذا allow_multiple_submissions = 1 => ما في منع if ((int)($survey->allow_multiple_submissions ?? 0) === 1) return false; // نفس منطق الكنترولر $key = null; if ((int)($survey->is_anonymous ?? 0) === 1) { $anon = hash_hmac('sha256', (string)$u->id, config('app.key')); $key = 'anon:' . $anon . ':survey:' . $survey->id; } else { $key = 'user:' . $u->id . ':survey:' . $survey->id; } return \App\Models\SocraticSurveySubmission::where('survey_id', $survey->id) ->where('submission_key', $key) ->exists(); }; // ✅ جيب أحدث استطلاع Active ويكون مفتوح الآن ومناسب لهدفه ولسه ما انعمل $candidates = \App\Models\SocraticSurvey::query() ->where('status','active') ->orderByDesc('id') ->get(); foreach ($candidates as $s) { if (!$s->isOpenNow()) continue; if (!$matchesTargets($s)) continue; if ($alreadySubmitted($s)) continue; $surveyModal = \App\Models\SocraticSurvey::query() ->where('id', $s->id) ->with(['questions' => function($q){ $q->where('is_active', true) ->orderBy('sort_order') ->with(['options' => function($o){ $o->where('is_active', true)->orderBy('sort_order'); }]); }]) ->first(); break; } } catch (\Throwable $e) { $surveyModal = null; } // ✅ Daily Reading (Widget) $dailyReading = \App\Models\DailyReading::activeForToday()->first(); $hasRead = false; if ($dailyReading && auth()->check()) { $hasRead = $dailyReading->readers() ->where('user_id', auth()->id()) ->exists(); } @endphp @if($surveyModal) @include('surveys.partials.active-modal', ['survey' => $surveyModal]) @endif @include('partials.site-updates-slider') {{-- Redirect to pending site updates (إن وجد) --}} {{-- =========================== | ✅ GLOBAL UI UPGRADE (CSS) |=========================== --}} {{-- =========================== | ✅ DAILY READING (NEW UI) |=========================== --}} @if($dailyReading && !$hasRead)
{{-- Header --}} {{-- Body --}}
{{-- ✅ Scroll area fixed + not huge --}}
{!! $dailyReading->body_html !!}

بنقرة الزر أدناه، أنت تؤكد:
"موافق، قرأت وأقسم بالله أني قرأته بالكامل."

@endif {{-- =========================== | ✅ PROACTIVE (SERVER PREP) |=========================== --}} @php $tz = config('app.timezone','Asia/Jerusalem'); $today = now($tz)->toDateString(); $proTodayActiveNow = $proTodayActiveNow ?? null; $proTodayTotal = $proTodayTotal ?? null; $plusTodayCount = $plusTodayCount ?? null; $notesToday = $notesToday ?? ($falconRolaNotesToday ?? 0); $proSchedulesToday = collect(); $proRecentStatus = collect(); $proLatestChangeIso = now($tz)->toIso8601String(); try { if ($proTodayActiveNow === null || $proTodayTotal === null || $plusTodayCount === null) { $proTodayActiveNow = (int) DB::table('proactive_schedules') ->whereDate('event_date', $today) ->where('status','active') ->count(); $proTodayTotal = (int) DB::table('proactive_schedules') ->whereDate('event_date', $today) ->whereIn('status',['upcoming','active']) ->count(); $plusTodayCount = (int) DB::table('proactive_schedules') ->where('event_type','plus') ->whereIn('status',['upcoming','active']) ->whereDate('event_date',$today) ->count(); } else { $proTodayActiveNow = (int) $proTodayActiveNow; $proTodayTotal = (int) $proTodayTotal; $plusTodayCount = (int) $plusTodayCount; } $proSchedulesToday = DB::table('proactive_schedules') ->select('id','event_date','event_time','event_type','status') ->whereDate('event_date', $today) ->orderBy('event_time','asc') ->limit(25) ->get(); $proRecentStatus = DB::table('proactive_reports as pr') ->leftJoin('users as u', 'u.id', '=', 'pr.created_by') ->select( 'pr.id','pr.activity_date','pr.activity_type','pr.program_status', 'pr.live_host','pr.live_owner_name','pr.platform','pr.rejection_reason','pr.updated_at', 'u.name as creator_name' ) ->whereIn('pr.program_status',['approved','rejected']) ->orderByDesc('pr.updated_at') ->orderByDesc('pr.id') ->limit(12) ->get(); if ($proRecentStatus->first() && $proRecentStatus->first()->updated_at) { $proLatestChangeIso = \Illuminate\Support\Carbon::parse($proRecentStatus->first()->updated_at)->toIso8601String(); } } catch (\Throwable $e) { $proTodayActiveNow = (int)($proTodayActiveNow ?? 0); $proTodayTotal = (int)($proTodayTotal ?? 0); $plusTodayCount = (int)($plusTodayCount ?? 0); $proSchedulesToday = collect(); $proRecentStatus = collect(); } $proStatusMap = [ 'upcoming' => 'قادم', 'active' => 'نشط', 'done' => 'تم', 'canceled' => 'ملغي', 'cancelled'=> 'ملغي', ]; // ✅ Initial badge (show live count OR today count) — بدون داخل الدائرة $proInitBadgeKind = 'none'; $proInitBadgeValue = 0; if ((int)$proTodayActiveNow > 0) { $proInitBadgeKind = 'live'; $proInitBadgeValue = (int)$proTodayActiveNow; } elseif ((int)$proTodayTotal > 0) { $proInitBadgeKind = 'today'; $proInitBadgeValue = (int)$proTodayTotal; } @endphp {{-- =========================== | ✅ PROACTIVE UI (CSS) |=========================== --}} {{-- =========================== | ✅ PROACTIVE ORB (OUTSIDE SMART DOCK ✅) | ✅ Badge pill فوق الدائرة + بدون نص تحت |=========================== --}}
{{-- ✅✅ Badge pill فوق الدائرة بالنص --}} {{ (int)$proInitBadgeValue }}
{{-- =========================== | ✅ PROACTIVE MODAL (TABS + SCROLL) |=========================== --}} {{-- ✅✅ Scroll Lock Manager (يحمي من تعارض overflow-hidden بين المودالات) --}} {{-- ✅ PROACTIVE JS (FIXED + NO-CONFLICT + NO-FALSE-AUTO-OPEN) --}} {{-- =========================== | ✅ SMART FAB DOCK (NEW UI) |=========================== --}}
{{-- Menu --}}
{{-- TikTok Coins FAB --}}
{{-- Group Chat FAB --}} {{-- Socratic --}}
@include('partials.socratic-modal')
{{-- Support FAB --}}
{{-- Toggle Button --}}
{{-- ✅ Smart Dock JS: | 1) يرفع ProActive لفوق لما تفتح السمارت | 2) Badge مجموع بادجات الداخل --}} {{-- TikTok Coins Modal (كما هو) --}} {{-- ======= BADGES (UNREAD) ======= --}} {{-- ======= SAFETY (AS IS) ======= --}} {{-- FIX: بدون حذف سطر — نخلي @endaut موجود لكن داخل تعليق حتى لا يكسر Blade --}} {{-- @endaut --}} @endauth