@extends('layouts.user_type.auth') @section('content')
| Employee | @for ($i = 1; $i <= $daysInMonth; $i++) @php $date = \Carbon\Carbon::parse("$month-$i"); @endphp
{{ $date->format('M d') }} {{ $date->format('D') }} |
@endfor
|---|---|
| {{ $employee->name ?? ($employee->first_name . ($employee->middle_name ? ' ' . $employee->middle_name : '') . ' ' . $employee->last_name) }} | @for ($i = 1; $i <= $daysInMonth; $i++) @php $date = \Carbon\Carbon::parse("$month-$i"); $formattedDate = $date->format('Y-m-d'); $isSunday = $date->isSunday(); $isFutureDate = $date->greaterThan(\Carbon\Carbon::today()); $isHoliday = in_array($formattedDate, $holidays); // Check if employee is on leave $leave = $employee->leaves->first(function ($leave) use ($date) { return $date->between( \Carbon\Carbon::parse($leave->start_date)->startOfDay(), \Carbon\Carbon::parse($leave->end_date)->endOfDay() ); }); $attendancesForDay = $employee->attendances ->filter(function ($att) use ($formattedDate) { return \Carbon\Carbon::parse($att->check_in)->format('Y-m-d') === $formattedDate; }); $firstCheckIn = $attendancesForDay->min('check_in'); $lastCheckOut = $attendancesForDay->max('check_out'); $hasAttendance = $firstCheckIn !== null; if ($isHoliday) { $status = 'H'; } elseif ($leave) { // Check if it is a half-day leave if ($leave->half_day) { $status = 'HD'; } else { $status = $leave->leaveType->name ?? 'L'; } } elseif ($isSunday) { $status = 'W'; } elseif ($isFutureDate) { $status = '-'; } else { $status = $attendancesForDay->isNotEmpty() ? 'P' : 'A'; } @endphp
@if ($status === 'P' && $hasAttendance)
{{ $status }}
In: {{ \Carbon\Carbon::parse($firstCheckIn)->setTimezone('Asia/Kolkata')->format('h:i A') }}
Out: {{ $lastCheckOut ? \Carbon\Carbon::parse($lastCheckOut)->setTimezone('Asia/Kolkata')->format('h:i A') : '-' }} @else @php // Check for Regularization (only if status was A) if ($status === 'A') { $regularized = $employee->regularizations->first(function ($reg) use ($formattedDate) { return $reg->date === $formattedDate && $reg->status === 'Pending'; }); if ($regularized) { $status = 'RRC'; } } @endphp {{ $status == 'Maternity Leave' ? 'ML' : $status }} @endif |
@endfor