@extends('layouts.app') @section('header_title', 'Laporan Kehadiran Matrix') @section('content')

Laporan Rekapitulasi Kehadiran (Matrix)

Tampilan matriks kehadiran seluruh karyawan per tanggal secara horizontal beserta tautan foto absensi.

Reset
@php $period = \Carbon\CarbonPeriod::create($startDate, $endDate); $dates = []; foreach ($period as $date) { $dates[] = $date->toDateString(); } $matrixData = []; foreach ($attendances as $item) { $matrixData[$item->employee_id][$item->date] = $item; } @endphp
@foreach($dates as $d) @php $isSunday = \Carbon\Carbon::parse($d)->isSunday(); @endphp @endforeach @forelse($employees as $emp) @php $empAtt = $matrixData[$emp->id] ?? []; // Parse roster rules if available $rosterRules = []; if ($emp->rosterSchedule && !empty($emp->rosterSchedule->schedule_rules)) { $rosterRules = is_string($emp->rosterSchedule->schedule_rules) ? json_decode($emp->rosterSchedule->schedule_rules, true) : $emp->rosterSchedule->schedule_rules; } $rosterMap = []; if (is_array($rosterRules)) { foreach ($rosterRules as $rRule) { if (isset($rRule['date'])) { $rosterMap[$rRule['date']] = $rRule; } } } // Parse regular rules if available $regularRules = []; if ($emp->regularSchedule && !empty($emp->regularSchedule->schedule_rules)) { $regularRules = is_string($emp->regularSchedule->schedule_rules) ? json_decode($emp->regularSchedule->schedule_rules, true) : $emp->regularSchedule->schedule_rules; } $regularMap = []; $regularTolerance = $emp->regularSchedule->late_tolerance_minutes ?? 15; if (is_array($regularRules)) { foreach ($regularRules as $regRule) { if (isset($regRule['day'])) { $regularMap[strtolower($regRule['day'])] = $regRule; } } } @endphp @foreach($dates as $d) @php $att = $empAtt[$d] ?? null; $isSunday = \Carbon\Carbon::parse($d)->isSunday(); $photoInUrl = ($att && !empty($att->photo_in_path)) ? asset('storage/' . $att->photo_in_path) : null; // Cek Keterlambatan melebihi late_tolerance_minutes $isLate = false; if ($att && $att->clock_in) { $currDateObj = \Carbon\Carbon::parse($d); $dayNameLower = strtolower($currDateObj->format('l')); $schedClockIn = null; $toleranceMins = 15; // Prioritas 1: Roster schedule per tanggal if (isset($rosterMap[$d])) { $schedClockIn = $rosterMap[$d]['clock_in'] ?? null; $toleranceMins = $rosterMap[$d]['late_tolerance_minutes'] ?? 15; } // Prioritas 2: Regular schedule per hari elseif (isset($regularMap[$dayNameLower])) { $regConfig = $regularMap[$dayNameLower]; if (!empty($regConfig['is_active'])) { $schedClockIn = $regConfig['clock_in'] ?? null; $toleranceMins = $regularTolerance; } } if ($schedClockIn) { $limitTime = \Carbon\Carbon::parse($d . ' ' . $schedClockIn)->addMinutes($toleranceMins); $actualClockIn = \Carbon\Carbon::parse($d . ' ' . $att->clock_in); if ($actualClockIn->greaterThan($limitTime)) { $isLate = true; } } } @endphp @endforeach @foreach($dates as $d) @php $att = $empAtt[$d] ?? null; $isSunday = \Carbon\Carbon::parse($d)->isSunday(); $photoBreakOutUrl = ($att && !empty($att->break_out_photo_path)) ? asset('storage/' . $att->break_out_photo_path) : null; @endphp @endforeach @foreach($dates as $d) @php $att = $empAtt[$d] ?? null; $isSunday = \Carbon\Carbon::parse($d)->isSunday(); $photoBreakInUrl = ($att && !empty($att->break_in_photo_path)) ? asset('storage/' . $att->break_in_photo_path) : null; // Cek Keterlambatan Masuk Setelah Istirahat melebihi late_checkout_minutes $isBreakLate = false; if ($att && $att->break_in) { $currDateObj = \Carbon\Carbon::parse($d); $dayNameLower = strtolower($currDateObj->format('l')); $schedBreakEnd = null; $breakToleranceMins = 15; // Prioritas 1: Roster schedule per tanggal if (isset($rosterMap[$d])) { $schedBreakEnd = $rosterMap[$d]['break_end'] ?? null; $breakToleranceMins = $rosterMap[$d]['late_checkout_minutes'] ?? ($emp->regularSchedule->late_checkout_minutes ?? 15); } // Prioritas 2: Regular schedule per hari elseif (isset($regularMap[$dayNameLower])) { $regConfig = $regularMap[$dayNameLower]; if (!empty($regConfig['is_active'])) { $schedBreakEnd = $regConfig['break_end'] ?? null; $breakToleranceMins = $regConfig['late_checkout_minutes'] ?? ($emp->regularSchedule->late_checkout_minutes ?? 15); } } if ($schedBreakEnd) { $limitBreakTime = \Carbon\Carbon::parse($d . ' ' . $schedBreakEnd)->addMinutes($breakToleranceMins); $actualBreakIn = \Carbon\Carbon::parse($d . ' ' . $att->break_in); if ($actualBreakIn->greaterThan($limitBreakTime)) { $isBreakLate = true; } } } @endphp @endforeach @foreach($dates as $d) @php $att = $empAtt[$d] ?? null; $isSunday = \Carbon\Carbon::parse($d)->isSunday(); $photoOutUrl = ($att && !empty($att->photo_out_path)) ? asset('storage/' . $att->photo_out_path) : null; @endphp @endforeach @empty @endforelse
Nama Karyawan & Perusahaan {{ \Carbon\Carbon::parse($d)->format('m/d/Y') }}
{{ $emp->name }} NIP: {{ $emp->nip ?? '-' }} @if(isset($emp->companyGroup) && $emp->companyGroup) {{ $emp->companyGroup->name }} @endif @if($att && $att->clock_in)
{{ $att->clock_in }} @if($photoInUrl) @else No Photo @endif
@else - @endif
@if($att && $att->break_out)
{{ $att->break_out }} @if($photoBreakOutUrl) @else No Photo @endif
@else - @endif
@if($att && $att->break_in)
{{ $att->break_in }} @if($photoBreakInUrl) @else No Photo @endif
@else - @endif
@if($att && $att->clock_out)
{{ $att->clock_out }} @if($photoOutUrl) @else No Photo @endif
@else - @endif

Tidak ada data absensi pada rentang tanggal tersebut.

{{ $employees->links() }}
@endsection @push('scripts') @endpush