@extends('layouts.app') @php $isMarketing = auth()->user()->unit_type === 'marketing'; @endphp @section('title', $isMarketing ? 'Consumer Insight' : 'Isi Panel Test') @section('content')

{{ $isMarketing ? 'Consumer Contact Plan Aktif' : 'Panel Test Aktif' }}

{{ $isMarketing ? 'Pilih consumer contact plan dan input data setiap consumer' : 'Pilih panel test dan input data setiap responden' }}

{{-- Notifikasi target tercapai --}} @if($isMarketing) @foreach($availableTests as $test) @php $myCount = $test->testSessions->where('user_id', auth()->id())->where('status','completed')->count(); $target = $test->target_responden ?? 0; @endphp @if($target > 0 && $myCount >= $target)
🎉
Target Tercapai! — {{ $test->title }}
Anda telah menyelesaikan {{ $myCount }} consumer contact dari target {{ $target }}. Kerja bagus!
@elseif($target > 0 && $myCount > 0 && ($myCount / $target) >= 0.8)
âš¡
Hampir Tercapai! — {{ $test->title }}
{{ $myCount }}/{{ $target }} consumer contact selesai. Kurang {{ $target - $myCount }} lagi untuk mencapai target!
@endif @endforeach @endif {{-- Daftar Plan/Test Aktif --}} @if($availableTests->count() > 0)
@foreach($availableTests as $test) @php $myCount = $test->testSessions->where('user_id', auth()->id())->where('status','completed')->count(); $target = $isMarketing ? ($test->target_responden ?? 0) : 0; $pct = ($target > 0) ? min(100, round($myCount / $target * 100)) : 0; $pctColor = $pct >= 100 ? '#16a34a' : ($pct >= 80 ? '#d97706' : ($pct >= 50 ? '#2563eb' : '#94a3b8')); @endphp
{{-- Header --}}
Aktif {{ $test->test_date->format('d M Y') }}
{{ $test->title }}

{{ $test->product->name }} @if(!$isMarketing && $test->location)  |  {{ $test->location }} @endif

{{-- Progress pencapaian --}} @if($isMarketing && $target > 0)
{{-- Label --}}
{{ $myCount >= $target ? 'TARGET TERCAPAI!' : 'Progres Consumer Contact' }} {{ $myCount }} / {{ $target }}
{{-- Progress bar --}}
{{-- Info bawah --}}
{{ $pct }}% @if($myCount < $target) Kurang {{ $target - $myCount }} lagi @else 🎉 +{{ $myCount - $target }} melebihi target @endif
@else {{-- Non-marketing: tampilkan responden biasa --}}
Responden diinput: {{ $myCount }} orang
@endif {{-- Tombol aksi --}}
@endforeach
@else
Belum ada {{ $isMarketing ? 'consumer contact plan' : 'panel test' }} aktif
@endif {{-- Sesi hari ini --}} @if($mySessionsToday->count() > 0)
{{ $isMarketing ? 'Consumer Contact Hari Ini' : 'Input Hari Ini' }} — {{ today()->format('d M Y') }} {{ $mySessionsToday->count() }}
@foreach($mySessionsToday as $i => $session) @endforeach
# {{ $isMarketing ? 'Consumer Contact Plan' : 'Panel Test' }} Nama {{ $isMarketing ? 'Consumer' : 'Responden' }} Usia Gender Waktu Status
{{ $i + 1 }} {{ $session->panelTest->title }} {{ $session->respondent_name ?: '-' }} {{ $session->respondent_age ? $session->respondent_age . ' th' : '-' }} {{ $session->respondent_gender ?: '-' }} {{ $session->completed_at ? $session->completed_at->format('H:i') : 'Belum selesai' }} @if($session->status === 'completed') Selesai @else
Lanjutkan
@csrf @method('DELETE')
@endif
@endif {{-- Semua Riwayat --}} @if($allMySessions->count() > 0)
Semua Riwayat {{ $isMarketing ? 'Consumer Contact' : 'Input' }} {{ $allMySessions->count() }}
@foreach($allMySessions as $i => $session) @endforeach
# {{ $isMarketing ? 'Consumer Contact Plan' : 'Panel Test' }} {{ $isMarketing ? 'APS/SPG/TL' : 'Produk' }} Nama {{ $isMarketing ? 'Consumer' : 'Responden' }} Tanggal Status
{{ $i + 1 }} {{ $session->panelTest->title }} {{ $session->panelTest->product->name }} {{ $session->respondent_name ?: '-' }} {{ $session->completed_at ? $session->completed_at->format('d M Y, H:i') : '-' }} @if($session->status === 'completed') Selesai @else Berlangsung @endif
@endif @push('scripts') @endpush @endsection