feat: status presensi per kelas di dropdown input
Dropdown kelas sekarang menampilkan: - ⬜ Nama Kelas → belum ada data presensi - ✅ Nama Kelas (5/36) → sudah terisi (X siswa terdata dari total) - Legend kecil di bawah dropdown sebagai panduan
This commit is contained in:
@@ -105,11 +105,30 @@ class AttendanceController extends Controller
|
|||||||
->orderBy('class_name')
|
->orderBy('class_name')
|
||||||
->pluck('class_name');
|
->pluck('class_name');
|
||||||
|
|
||||||
|
// Cek status presensi per kelas untuk tanggal ini
|
||||||
|
$classAttendanceStatus = [];
|
||||||
|
foreach ($classNames as $cn) {
|
||||||
|
$studentIdsInClass = Student::where('is_active', true)
|
||||||
|
->where('class_name', $cn)
|
||||||
|
->pluck('id');
|
||||||
|
$count = Attendance::where('date', $date)
|
||||||
|
->whereIn('student_id', $studentIdsInClass)
|
||||||
|
->distinct('student_id')
|
||||||
|
->count('student_id');
|
||||||
|
$totalStudents = $studentIdsInClass->count();
|
||||||
|
$classAttendanceStatus[$cn] = [
|
||||||
|
'has_data' => $count > 0,
|
||||||
|
'recorded' => $count,
|
||||||
|
'total' => $totalStudents,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$lessonHours = range(1, 10);
|
$lessonHours = range(1, 10);
|
||||||
|
|
||||||
return view('attendances.create', compact(
|
return view('attendances.create', compact(
|
||||||
'students', 'date', 'className',
|
'students', 'date', 'className',
|
||||||
'classNames', 'lessonHours', 'existing'
|
'classNames', 'lessonHours', 'existing',
|
||||||
|
'classAttendanceStatus'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,19 @@
|
|||||||
class="w-full px-4 py-2.5 border border-gray-200 rounded-xl text-sm bg-gray-50/50 focus:bg-white focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition">
|
class="w-full px-4 py-2.5 border border-gray-200 rounded-xl text-sm bg-gray-50/50 focus:bg-white focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition">
|
||||||
<option value="">Pilih kelas...</option>
|
<option value="">Pilih kelas...</option>
|
||||||
@foreach($classNames as $cn)
|
@foreach($classNames as $cn)
|
||||||
<option value="{{ $cn }}" @selected($className == $cn)>{{ $cn }}</option>
|
@php
|
||||||
|
$stat = $classAttendanceStatus[$cn] ?? ['has_data' => false, 'recorded' => 0, 'total' => 0];
|
||||||
|
$label = $stat['has_data']
|
||||||
|
? '✅ ' . $cn . ' (' . $stat['recorded'] . '/' . $stat['total'] . ')'
|
||||||
|
: '⬜ ' . $cn;
|
||||||
|
@endphp
|
||||||
|
<option value="{{ $cn }}" @selected($className == $cn)>{{ $label }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
<div class="mt-1.5 flex items-center gap-3 text-[10px] text-gray-400">
|
||||||
|
<span>⬜ Belum diisi</span>
|
||||||
|
<span>✅ Sudah diisi (siswa terdata/total)</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1.5">Tanggal <span class="text-red-500">*</span></label>
|
<label class="block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1.5">Tanggal <span class="text-red-500">*</span></label>
|
||||||
|
|||||||
Reference in New Issue
Block a user