feat: dukung status PKL/Magang (pkl) dari e-jurnal — validasi sync + pkl; rekap mingguan/bulanan kolom P; export Excel kolom P; warna selaras e-jurnal (S=amber, P=violet)

This commit is contained in:
Novy San87
2026-08-22 20:10:34 +07:00
parent f7adecc22c
commit 25da284ca2
53 changed files with 201478 additions and 251 deletions
+38 -21
View File
@@ -414,6 +414,7 @@ class AttendanceController extends Controller
$alpha = round($alphaCount / 10, 1);
$sakit = $studentAtt->where('status', 'sakit')->count() > 0 ? 1 : 0;
$izin = $studentAtt->where('status', 'izin')->count() > 0 ? 1 : 0;
$pkl = $studentAtt->where('status', 'pkl')->count() > 0 ? 1 : 0;
$terlambat = $studentAtt->where('status', 'terlambat')->count() > 0 ? 1 : 0;
$total = $studentAtt->count();
@@ -423,6 +424,7 @@ class AttendanceController extends Controller
'alpha' => $alpha,
'sakit' => $sakit,
'izin' => $izin,
'pkl' => $pkl,
'terlambat' => $terlambat,
'total' => $studentAtt->count(),
];
@@ -433,7 +435,7 @@ class AttendanceController extends Controller
// Hitung total per siswa selama seminggu
$totals = [];
foreach ($students as $student) {
$totals[$student->id] = ['hadir' => 0, 'sakit' => 0, 'izin' => 0, 'alpha' => 0, 'terlambat' => 0];
$totals[$student->id] = ['hadir' => 0, 'sakit' => 0, 'izin' => 0, 'alpha' => 0, 'pkl' => 0, 'terlambat' => 0];
}
foreach ($recap as $row) {
foreach ($row['students'] as $sid => $s) {
@@ -441,6 +443,7 @@ class AttendanceController extends Controller
$totals[$sid]['sakit'] += $s['sakit'];
$totals[$sid]['izin'] += $s['izin'];
$totals[$sid]['alpha'] += $s['alpha'];
$totals[$sid]['pkl'] += $s['pkl'];
$totals[$sid]['terlambat'] += $s['terlambat'];
}
}
@@ -503,7 +506,7 @@ class AttendanceController extends Controller
$row = ['label' => $week['label'], 'start' => $week['start'], 'end' => $week['end'], 'students' => []];
foreach ($students as $student) {
$hCount = 0; $sCount = 0; $iCount = 0; $aCount = 0; $tCount = 0; $totalDaysForStudent = 0;
$hCount = 0; $sCount = 0; $iCount = 0; $aCount = 0; $pCount = 0; $tCount = 0; $totalDaysForStudent = 0;
foreach ($datesInWeek as $dateStr) {
$dayAtt = $weekByDay->get($dateStr, collect())->where('student_id', $student->id);
@@ -513,12 +516,14 @@ class AttendanceController extends Controller
$hasHadir = $dayAtt->where('status', 'hadir')->isNotEmpty();
$hasSakit = $dayAtt->where('status', 'sakit')->isNotEmpty();
$hasIzin = $dayAtt->where('status', 'izin')->isNotEmpty();
$hasPkl = $dayAtt->where('status', 'pkl')->isNotEmpty();
$hasAlpha = $dayAtt->where('status', 'alpha')->isNotEmpty();
$hasTerlambat = $dayAtt->where('status', 'terlambat')->isNotEmpty();
if ($hasHadir) $hCount++;
if ($hasSakit) $sCount++;
if ($hasIzin) $iCount++;
if ($hasPkl) $pCount++;
if ($hasTerlambat) $tCount++;
// Alpha proporsional: jumlah jam alpha / 10 (max jam sekolah per hari)
@@ -532,6 +537,7 @@ class AttendanceController extends Controller
'alpha' => $aCount,
'sakit' => $sCount,
'izin' => $iCount,
'pkl' => $pCount,
'terlambat' => $tCount,
'total' => $totalDaysForStudent,
];
@@ -542,7 +548,7 @@ class AttendanceController extends Controller
// Hitung total per siswa selama sebulan
$totals = [];
foreach ($students as $student) {
$totals[$student->id] = ['hadir' => 0, 'sakit' => 0, 'izin' => 0, 'alpha' => 0, 'terlambat' => 0];
$totals[$student->id] = ['hadir' => 0, 'sakit' => 0, 'izin' => 0, 'alpha' => 0, 'pkl' => 0, 'terlambat' => 0];
}
foreach ($recap as $row) {
foreach ($row['students'] as $sid => $s) {
@@ -550,6 +556,7 @@ class AttendanceController extends Controller
$totals[$sid]['sakit'] += $s['sakit'];
$totals[$sid]['izin'] += $s['izin'];
$totals[$sid]['alpha'] += $s['alpha'];
$totals[$sid]['pkl'] += $s['pkl'];
$totals[$sid]['terlambat'] += $s['terlambat'];
}
}
@@ -616,7 +623,7 @@ class AttendanceController extends Controller
$title .= ' (' . \Carbon\Carbon::parse($data['start'])->format('d/m/Y') . ' - ' . \Carbon\Carbon::parse($data['end'])->format('d/m/Y') . ')';
$sheet->setCellValue('A1', $title);
$totalCols = 1 + $data['recap']->count() * 4 + 4; // +4 untuk kolom TOTAL
$totalCols = 1 + $data['recap']->count() * 5 + 5; // +5 untuk kolom TOTAL
$sheet->mergeCells('A1:' . $this->getColLetter($totalCols - 1) . '1');
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(14);
@@ -627,15 +634,15 @@ class AttendanceController extends Controller
foreach ($data['recap'] as $row) {
$cell = $this->getColLetter($col) . '2';
$sheet->setCellValue($cell, $row['label'] . ' ' . \Carbon\Carbon::parse($row['date'])->format('d/m'));
$endCell = $this->getColLetter($col + 3) . '2';
$endCell = $this->getColLetter($col + 4) . '2';
$sheet->mergeCells($cell . ':' . $endCell);
$sheet->getStyle($cell)->getFont()->setBold(true);
$col += 4;
$col += 5;
}
// Kolom TOTAL
$totalCell = $this->getColLetter($col) . '2';
$sheet->setCellValue($totalCell, 'TOTAL');
$sheet->mergeCells($totalCell . ':' . $this->getColLetter($col + 3) . '2');
$sheet->mergeCells($totalCell . ':' . $this->getColLetter($col + 4) . '2');
$sheet->getStyle($totalCell)->getFont()->setBold(true);
// Header row 3: H, S, I, A per day + TOTAL
@@ -646,16 +653,19 @@ class AttendanceController extends Controller
$sheet->setCellValue($this->getColLetter($col + 1) . '3', 'S');
$sheet->setCellValue($this->getColLetter($col + 2) . '3', 'I');
$sheet->setCellValue($this->getColLetter($col + 3) . '3', 'A');
foreach (range(0, 3) as $i) {
$sheet->setCellValue($this->getColLetter($col + 4) . '3', 'P');
$sheet->setCellValue($this->getColLetter($col + 4) . '3', 'P');
foreach (range(0, 4) as $i) {
$sheet->getStyle($this->getColLetter($col + $i) . '3')->getFont()->setBold(true);
}
$col += 4;
$col += 5;
}
// Sub-header TOTAL
$sheet->setCellValue($this->getColLetter($col) . '3', 'H');
$sheet->setCellValue($this->getColLetter($col + 1) . '3', 'S');
$sheet->setCellValue($this->getColLetter($col + 2) . '3', 'I');
$sheet->setCellValue($this->getColLetter($col + 3) . '3', 'A');
$sheet->setCellValue($this->getColLetter($col + 4) . '3', 'P');
foreach (range(0, 3) as $i) {
$sheet->getStyle($this->getColLetter($col + $i) . '3')->getFont()->setBold(true);
}
@@ -672,19 +682,21 @@ class AttendanceController extends Controller
$sheet->setCellValue($this->getColLetter($col + 1) . $rowIdx, $s['sakit']);
$sheet->setCellValue($this->getColLetter($col + 2) . $rowIdx, $s['izin']);
$sheet->setCellValue($this->getColLetter($col + 3) . $rowIdx, $s['alpha']);
$sheet->setCellValue($this->getColLetter($col + 4) . $rowIdx, $s['pkl']);
} else {
foreach (range(0, 3) as $i) {
foreach (range(0, 4) as $i) {
$sheet->setCellValue($this->getColLetter($col + $i) . $rowIdx, '-');
}
}
$col += 4;
$col += 5;
}
// TOTAL per siswa
$t = $data['totals'][$student->id] ?? ['hadir' => 0, 'sakit' => 0, 'izin' => 0, 'alpha' => 0];
$t = $data['totals'][$student->id] ?? ['hadir' => 0, 'sakit' => 0, 'izin' => 0, 'alpha' => 0, 'pkl' => 0];
$sheet->setCellValue($this->getColLetter($col) . $rowIdx, $t['hadir']);
$sheet->setCellValue($this->getColLetter($col + 1) . $rowIdx, $t['sakit']);
$sheet->setCellValue($this->getColLetter($col + 2) . $rowIdx, $t['izin']);
$sheet->setCellValue($this->getColLetter($col + 3) . $rowIdx, $t['alpha']);
$sheet->setCellValue($this->getColLetter($col + 4) . $rowIdx, $t['pkl']);
$rowIdx++;
}
@@ -728,7 +740,7 @@ class AttendanceController extends Controller
$title .= ' (' . \Carbon\Carbon::create()->month($data['month'])->format('F') . ' ' . $data['year'] . ')';
$sheet->setCellValue('A1', $title);
$totalCols = 1 + $data['recap']->count() * 4 + 4; // +4 untuk kolom TOTAL
$totalCols = 1 + $data['recap']->count() * 5 + 5; // +5 untuk kolom TOTAL
$sheet->mergeCells('A1:' . $this->getColLetter($totalCols - 1) . '1');
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(14);
@@ -739,15 +751,15 @@ class AttendanceController extends Controller
foreach ($data['recap'] as $row) {
$cell = $this->getColLetter($col) . '2';
$sheet->setCellValue($cell, $row['label'] . ' ' . \Carbon\Carbon::parse($row['start'])->format('d/m') . '-' . \Carbon\Carbon::parse($row['end'])->format('d/m'));
$endCell = $this->getColLetter($col + 3) . '2';
$endCell = $this->getColLetter($col + 4) . '2';
$sheet->mergeCells($cell . ':' . $endCell);
$sheet->getStyle($cell)->getFont()->setBold(true);
$col += 4;
$col += 5;
}
// Kolom TOTAL
$totalCell = $this->getColLetter($col) . '2';
$sheet->setCellValue($totalCell, 'TOTAL');
$sheet->mergeCells($totalCell . ':' . $this->getColLetter($col + 3) . '2');
$sheet->mergeCells($totalCell . ':' . $this->getColLetter($col + 4) . '2');
$sheet->getStyle($totalCell)->getFont()->setBold(true);
// Header row 3: H, S, I, A per week + TOTAL
@@ -758,16 +770,19 @@ class AttendanceController extends Controller
$sheet->setCellValue($this->getColLetter($col + 1) . '3', 'S');
$sheet->setCellValue($this->getColLetter($col + 2) . '3', 'I');
$sheet->setCellValue($this->getColLetter($col + 3) . '3', 'A');
foreach (range(0, 3) as $i) {
$sheet->setCellValue($this->getColLetter($col + 4) . '3', 'P');
$sheet->setCellValue($this->getColLetter($col + 4) . '3', 'P');
foreach (range(0, 4) as $i) {
$sheet->getStyle($this->getColLetter($col + $i) . '3')->getFont()->setBold(true);
}
$col += 4;
$col += 5;
}
// Sub-header TOTAL
$sheet->setCellValue($this->getColLetter($col) . '3', 'H');
$sheet->setCellValue($this->getColLetter($col + 1) . '3', 'S');
$sheet->setCellValue($this->getColLetter($col + 2) . '3', 'I');
$sheet->setCellValue($this->getColLetter($col + 3) . '3', 'A');
$sheet->setCellValue($this->getColLetter($col + 4) . '3', 'P');
foreach (range(0, 3) as $i) {
$sheet->getStyle($this->getColLetter($col + $i) . '3')->getFont()->setBold(true);
}
@@ -784,19 +799,21 @@ class AttendanceController extends Controller
$sheet->setCellValue($this->getColLetter($col + 1) . $rowIdx, $s['sakit']);
$sheet->setCellValue($this->getColLetter($col + 2) . $rowIdx, $s['izin']);
$sheet->setCellValue($this->getColLetter($col + 3) . $rowIdx, $s['alpha']);
$sheet->setCellValue($this->getColLetter($col + 4) . $rowIdx, $s['pkl']);
} else {
foreach (range(0, 3) as $i) {
foreach (range(0, 4) as $i) {
$sheet->setCellValue($this->getColLetter($col + $i) . $rowIdx, '-');
}
}
$col += 4;
$col += 5;
}
// TOTAL per siswa
$t = $data['totals'][$student->id] ?? ['hadir' => 0, 'sakit' => 0, 'izin' => 0, 'alpha' => 0];
$t = $data['totals'][$student->id] ?? ['hadir' => 0, 'sakit' => 0, 'izin' => 0, 'alpha' => 0, 'pkl' => 0];
$sheet->setCellValue($this->getColLetter($col) . $rowIdx, $t['hadir']);
$sheet->setCellValue($this->getColLetter($col + 1) . $rowIdx, $t['sakit']);
$sheet->setCellValue($this->getColLetter($col + 2) . $rowIdx, $t['izin']);
$sheet->setCellValue($this->getColLetter($col + 3) . $rowIdx, $t['alpha']);
$sheet->setCellValue($this->getColLetter($col + 4) . $rowIdx, $t['pkl']);
$rowIdx++;
}