@extends('layouts.superadmin') @section('title','مؤشر الالتزام - ProMission') @section('page-title','مؤشر الالتزام - ProMission') @section('content') @php $from = $from ?? request('from'); $to = $to ?? request('to'); $badge = function($pct){ $pct = (float)$pct; if ($pct >= 70) return 'bg-emerald-500/15 text-emerald-200 border-emerald-500/25'; if ($pct >= 40) return 'bg-amber-500/15 text-amber-200 border-amber-500/25'; return 'bg-rose-500/15 text-rose-200 border-rose-500/25'; }; $label = function($pct, $streak){ $pct = (float)$pct; $streak = (int)$streak; if ($pct >= 70 || $streak >= 7) return 'ملتزم ✅'; if ($pct >= 40 || $streak >= 3) return 'متذبذب ⚠️'; return 'متقطع 🧊'; }; $rows = collect($rows ?? []); $avgCommit = round((float)($rows->avg('commitment_pct') ?? 0), 1); $maxStreak = (int)($rows->max('streak_days') ?? 0); $avgActive = round((float)($rows->avg('active_days') ?? 0), 1); $countGood = $rows->filter(fn($r)=> ((float)$r['commitment_pct'] >= 70) || ((int)$r['streak_days'] >= 7))->count(); $countMid = $rows->filter(fn($r)=> (((float)$r['commitment_pct'] >= 40) && ((float)$r['commitment_pct'] < 70)) || (((int)$r['streak_days'] >= 3) && ((int)$r['streak_days'] < 7)))->count(); $countLow = max(0, $rows->count() - $countGood - $countMid); $isCards = (request('view','table') === 'cards'); @endphp
{{-- Header --}}

مؤشر الالتزام (Commitment Index)

يحسب أيام النشاط داخل الفترة (لايف/قست/سهرة)، ويعرض نسبة الالتزام + أعلى سلاسل الاستمرارية (Streak).

{{-- Toggle --}}
{{-- Summary Cards --}}
عدد الأعضاء
{{ $rows->count() }}
متوسط الالتزام
{{ $avgCommit }}%
متوسط أيام النشاط
{{ $avgActive }}
أعلى Streak
{{ $maxStreak }} يوم
التصنيف
ملتزم: {{ $countGood }}
متذبذب: {{ $countMid }}
متقطع: {{ $countLow }}
{{-- Filters --}}
إعادة ضبط الالتزام = (أيام نشطة ÷ أيام الفترة) × 100
{{-- Cards view --}} @if($isCards)
@forelse($rows as $r) @php $pct = (float)$r['commitment_pct']; $st = (int)$r['streak_days']; $act = (int)$r['active_days']; $per = (int)$r['period_days']; $lbl = $label($pct,$st); @endphp
{{ $r['name'] }}
{{ $r['username'] ? '@'.$r['username'] : '' }}
{{ $lbl }}
الالتزام
{{ $pct }}%
أيام نشطة
{{ $act }} / {{ $per }}
Streak
{{ $st }} يوم
توصية: {{ $pct >= 70 ? 'ثبّت الأداء وحافظ على الاستمرارية.' : ($pct >= 40 ? 'ارفع الأيام النشطة بثبات.' : 'ابدأ بخطة 3 أيام نشاط متتالي.') }}
@empty
لا يوجد بيانات ضمن الفلاتر الحالية.
@endforelse
{{-- Table view --}} @else

جدول مؤشر الالتزام

يعرض الالتزام + الأيام النشطة + أعلى سلسلة (streak).

صفوف: {{ $rows->count() }}
@forelse($rows as $r) @php $pct = (float)$r['commitment_pct']; $st = (int)$r['streak_days']; $lbl = $label($pct,$st); @endphp @empty @endforelse
العضو الالتزام % أيام نشطة أيام الفترة Streak وضعه
{{ $r['name'] }}
{{ $r['username'] ? '@'.$r['username'] : '' }}
{{ $pct }}% {{ (int)$r['active_days'] }} {{ (int)$r['period_days'] }} {{ (int)$r['streak_days'] }} {{ $lbl }}
لا يوجد بيانات.
@endif
مؤشر الالتزام يساعد القيادة: من ثابت، من متذبذب، ومن يحتاج متابعة.
@endsection