@extends('layouts.main') @section('title', 'Peserta Aktivitas') @section('css') @endsection @section('content')
@php // Pastikan selectedAttendanceId hanya ada jika benar-benar ada nilai dan valid dari controller // Jangan auto-select, hanya gunakan nilai dari controller $selectedAttendanceId = isset($selectedAttendanceId) && $selectedAttendanceId ? (int) $selectedAttendanceId : null; $selectedAttendance = null; if ($selectedAttendanceId && isset($attendances)) { $selectedAttendance = $attendances->where('id', $selectedAttendanceId)->first(); // Jika ID tidak ditemukan, reset ke null if (!$selectedAttendance) { $selectedAttendanceId = null; } } @endphp @if(isset($selectedActivity))

{{ $selectedActivity->name ?? 'Pilih Aktivitas' }}

@if(isset($selectedActivity->date)) {{ \Carbon\Carbon::parse($selectedActivity->date)->format('d F Y') }} @endif @if(isset($selectedActivity->location)) {{ $selectedActivity->location }} @endif

{{ method_exists($participants, 'total') ? $participants->total() : $participants->count() }}

Total Peserta

{{ $attendances->count() ?? 0 }}

Total Jenis Absen

Jumlah absen
@php $presentCount = $presentCount ?? 0; @endphp

{{ $presentCount }}

Peserta Hadir

{{ $selectedAttendance ? $selectedAttendance->name : 'Pilih Jenis Absen' }}
@php $presentCount = $presentCount ?? 0; @endphp

{{ (method_exists($participants, 'total') ? $participants->total() : $participants->count()) - $presentCount }}

Peserta Tidak Hadir

{{ $selectedAttendance ? $selectedAttendance->name : 'Pilih Jenis Absen' }}
@if($selectedAttendanceId && (method_exists($participants, 'total') ? $participants->total() : $participants->count()) > 0)
@php $totalParticipants = (method_exists($participants, 'total') ? $participants->total() : $participants->count()); $presentCount = $presentCount ?? 0; $attendancePercentage = $totalParticipants > 0 ? ($presentCount / $totalParticipants) * 100 : 0; @endphp
Progres Kehadiran: {{ number_format($attendancePercentage, 1) }}%
{{ $presentCount }} dari {{ $totalParticipants }} peserta
@endif

List Absen

@if($attendances && $attendances->count() > 0)
@foreach($attendances as $index => $attendance)
{{ $index + 1 }} {{ $attendance->name }} {{ $attendance->jenis_absen ?? '-' }}
@php $jenisAbsen = $attendance->jenis_absen ?? ''; $isMandiri = ($jenisAbsen === 'Mandiri'); $isQRMandiri = ($jenisAbsen === 'QR Mandiri'); $isManual = ($jenisAbsen === 'Manual'); $isQRManual = ($jenisAbsen === 'QR Manual'); @endphp @if($isMandiri) @php // Baca status enabled dari description $description = json_decode($attendance->description ?? '{}', true); $isEnabled = isset($description['enabled']) ? (bool) $description['enabled'] : false; // Default disabled @endphp @elseif($isQRMandiri) @elseif($isManual) @elseif($isQRManual) @endif @if(auth()->user() && isset($selectedActivity) && $selectedActivity->canManageRegistration(auth()->id())) @endif
@endforeach
@else
Belum ada jenis absen yang ditambahkan.
@endif

{{ $selectedAttendance ? 'Daftar Absen: ' . $selectedAttendance->name : 'Daftar Peserta Aktivitas' }}

@if(isset($selectedActivity)) Download @endif
@if($selectedAttendanceId) @php $selectedAttendanceForManual = $attendances->where('id', $selectedAttendanceId)->first(); $isManualType = $selectedAttendanceForManual && ($selectedAttendanceForManual->jenis_absen === 'Manual'); @endphp @if($isManualType) @endif @endif @forelse($participants as $index => $participant) @php $attendanceStatus = []; if($attendances) { foreach($attendances as $attendance) { $isPresent = false; if(isset($attendanceTableExists) && $attendanceTableExists) { $isPresent = DB::table($attendanceTable) ->where('activity_id', $selectedActivity->id) ->where('user_id', $participant->user_id) ->where('attendance_id', $attendance->id) ->exists(); } $attendanceStatus[$attendance->id] = $isPresent; } } @endphp @if($selectedAttendanceId) @php $selectedAttendanceForManual = $attendances->where('id', $selectedAttendanceId)->first(); $isManualType = $selectedAttendanceForManual && ($selectedAttendanceForManual->jenis_absen === 'Manual'); @endphp @if($isManualType) @endif @endif @empty @php $selectedAttendanceForManual = isset($attendances) && $selectedAttendanceId ? $attendances->where('id', $selectedAttendanceId)->first() : null; $isManualType = $selectedAttendanceForManual && ($selectedAttendanceForManual->jenis_absen === 'Manual'); $colspanCount = $selectedAttendanceId ? ($isManualType ? '6' : '5') : '4'; @endphp @endforelse
Nama Provinsi KabupatenStatus Kehadiran
Aksi
{{ $participant->user->name ?? '-' }} {{ optional($participant->user->profile)->province->name ?? '-' }} {{ optional($participant->user->profile)->regency->name ?? '-' }} @php $isPresent = false; $timestamp = null; if(isset($attendanceTableExists) && $attendanceTableExists) { $isPresent = DB::table($attendanceTable) ->where('activity_id', $selectedActivity->id) ->where('user_id', $participant->user_id) ->where('attendance_id', $selectedAttendanceId) ->exists(); $timestamp = DB::table($attendanceTable) ->where('activity_id', $selectedActivity->id) ->where('user_id', $participant->user_id) ->where('attendance_id', $selectedAttendanceId) ->value('created_at'); } @endphp
{{ $isPresent ? 'Hadir' : 'Tidak Hadir' }} @if($isPresent && $timestamp) @endif
Tidak ada peserta ditemukan.
@if(!request('search') && $participants->hasPages())
Menampilkan {{ $participants->firstItem() ?? 0 }} - {{ $participants->lastItem() ?? 0 }} dari {{ $participants->total() }} peserta
{{ $participants->appends(request()->query())->links() }}
@endif
@else
Silakan pilih aktivitas untuk melihat data peserta.
@endif
@endsection @section('scripts') @endsection