@php
use Illuminate\Support\Carbon;
$selectedDate = Carbon::parse($date ?? ($week ?? $month))->settings(['formatFunction' => 'translatedFormat']);
$showUserDetail = !$month || $week || $date; // is week or day filter
$isPerDayFilter = isset($date);
$datesWithoutWeekend = '';
@endphp
Absensi | {{ $date ?? ($week ?? $month) }}
Data Absensi
@if ($division)
| Divisi |
: |
{{ $division ? App\Models\Division::find($division)->name : '-' }} |
@endif
@if ($jobTitle)
| Jabatan |
: |
{{ $jobTitle ? App\Models\JobTitle::find($jobTitle)->name : '-' }} |
@endif
@if ($month)
Bulan: {{ $selectedDate->format('F Y') }}
@elseif ($week)
Tanggal: {{ $start->format('l, d/m/Y') }} - {{ $end->format('l, d/m/Y') }}
@elseif ($date)
Tanggal: {{ $selectedDate->format('d/m/Y') }}
@endif
|
No.
|
{{ $showUserDetail ? __('Name') : __('Name') . '/' . __('Date') }}
|
@if ($showUserDetail)
{{ __('NIP') }}
|
{{ __('Division') }}
|
{{ __('Job Title') }}
|
@if ($isPerDayFilter)
{{ __('Shift') }}
|
@endif
@endif
@foreach ($dates as $date)
@if ($isPerDayFilter)
Status
@elseif (!$month)
{{ $date->format('d/m') }}
@else
{{ $date->format('d') }}
@endif
|
@endforeach
@if (!$isPerDayFilter)
@foreach (['H', 'T', 'I', 'S', 'A'] as $_st)
{{ $_st }}
|
@endforeach
@endif
@foreach ($employees as $employee)
@php
$attendances = $employee->attendances;
$attendance = $employee->attendances->isEmpty() ? null : $employee->attendances->first();
@endphp
|
{{ $loop->iteration }}
|
{{ $employee->name }}
|
@if ($showUserDetail)
{{ $employee->nip }}
|
{{ $employee->division?->name ?? '-' }}
|
{{ $employee->jobTitle?->name ?? '-' }}
|
@if ($isPerDayFilter)
{{ $attendance['shift'] ?? '-' }}
|
@endif
@endif
@php
$presentCount = 0;
$lateCount = 0;
$excusedCount = 0;
$sickCount = 0;
$absentCount = 0;
@endphp
@foreach ($dates as $date)
@php
$isWeekend = $date->isWeekend();
$status = ($attendances->firstWhere(fn($v, $k) => $v['date'] === $date->format('Y-m-d')) ?? [
'status' => $isWeekend || !$date->isPast() ? '-' : 'absent',
])['status'];
switch ($status) {
case 'present':
$shortStatus = 'H';
$presentCount++;
break;
case 'late':
$shortStatus = 'T';
$lateCount++;
break;
case 'excused':
$shortStatus = 'I';
$excusedCount++;
break;
case 'sick':
$shortStatus = 'S';
$sickCount++;
break;
case 'absent':
$shortStatus = 'A';
$absentCount++;
break;
default:
$shortStatus = '-';
break;
}
@endphp
{{ $isPerDayFilter ? __($status) : $shortStatus }}
|
@endforeach
@if (!$isPerDayFilter)
@foreach ([$presentCount, $lateCount, $excusedCount, $sickCount, $absentCount] as $statusCount)
{{ $statusCount }}
|
@endforeach
@endif
@endforeach
@if ($employees->isEmpty())
Tidak ada data
@endif