fix: rekap alpha proporsional berdasarkan max 10 jam/hari

Sebelum: alpha = alphaCount / totalRecord (jika jadwal 1 jam,
  1 alpha = 1 hari — tidak akurat)
Sesudah: alpha = alphaCount / 10 (max jam sekolah per hari)
  1 alpha = 0.1 hari, 10 alpha = 1 hari
- Berlaku untuk rekap mingguan dan bulanan
This commit is contained in:
Bro
2026-07-24 13:12:55 +07:00
parent a1dfd75d7d
commit 91b7f1e591
@@ -293,15 +293,15 @@ class AttendanceController extends Controller
$key = $dateStr . '-' . $student->id; $key = $dateStr . '-' . $student->id;
$studentAtt = $allAttendances->get($key, collect()); $studentAtt = $allAttendances->get($key, collect());
// Per hari: 1 jika ada minimal 1 record status tsb // Per hari: binary untuk hadir/sakit/izin/terlambat
$hadir = $studentAtt->where('status', 'hadir')->count() > 0 ? 1 : 0; $hadir = $studentAtt->where('status', 'hadir')->count() > 0 ? 1 : 0;
// Alpha proporsional: jumlah jam alpha / total jam // Alpha proporsional: jumlah jam alpha / 10 (max jam sekolah per hari)
$total = $studentAtt->count();
$alphaCount = $studentAtt->where('status', 'alpha')->count(); $alphaCount = $studentAtt->where('status', 'alpha')->count();
$alpha = $total > 0 ? round($alphaCount / $total, 1) : 0; $alpha = round($alphaCount / 10, 1);
$sakit = $studentAtt->where('status', 'sakit')->count() > 0 ? 1 : 0; $sakit = $studentAtt->where('status', 'sakit')->count() > 0 ? 1 : 0;
$izin = $studentAtt->where('status', 'izin')->count() > 0 ? 1 : 0; $izin = $studentAtt->where('status', 'izin')->count() > 0 ? 1 : 0;
$terlambat = $studentAtt->where('status', 'terlambat')->count() > 0 ? 1 : 0; $terlambat = $studentAtt->where('status', 'terlambat')->count() > 0 ? 1 : 0;
$total = $studentAtt->count();
$row['students'][$student->id] = [ $row['students'][$student->id] = [
'name' => $student->full_name, 'name' => $student->full_name,
@@ -407,12 +407,9 @@ class AttendanceController extends Controller
if ($hasIzin) $iCount++; if ($hasIzin) $iCount++;
if ($hasTerlambat) $tCount++; if ($hasTerlambat) $tCount++;
// Alpha proporsional: jika semua jam di hari itu alpha // Alpha proporsional: jumlah jam alpha / 10 (max jam sekolah per hari)
$totalJam = $dayAtt->count();
$alphaJam = $dayAtt->where('status', 'alpha')->count(); $alphaJam = $dayAtt->where('status', 'alpha')->count();
if ($totalJam > 0) { $aCount += round($alphaJam / 10, 1);
$aCount += round($alphaJam / $totalJam, 1);
}
} }
$row['students'][$student->id] = [ $row['students'][$student->id] = [