@extends('app-new') @push('head-script') @endpush @push('content-header')
@endpush @section('content')
| Month of {{ \Carbon\Carbon::createFromDate($year, $month)->format('F Y') }} | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Employee Name | Designation | Location | @php // Safely fetch the days in the month $firstEmployeeAttendance = $attendanceSummary->first(); $daysInMonth = $firstEmployeeAttendance && $firstEmployeeAttendance->first() ? $firstEmployeeAttendance->first()->daysInMonth : 0; @endphp @for($day = 1; $day <= $daysInMonth; $day++){{ $day }} | @endforPresent Days | Absent Days | Week Offs | Paid Days | |||||||||||||||||||||||||||||
| {{ $employee->name ?? '-' }} | {{ $employee->designation->name ?? '-' }} | {{ $employee->locations->first()->name ?? '-' }} | @php $statuses = []; @endphp @for($day = 1; $day <= $daysInMonth; $day++) @php $date = \Carbon\Carbon::createFromDate($year, $month, $day)->toDateString(); $attendance = $employeeAttendances->where('attendance_date', $date)->first(); @endphp@php if ($attendance) { if ( !empty($attendance->in_time) || !empty($attendance->out_time) ) { $status = 'P'; // Present } elseif ($attendance->attendance_type === 'week-off') { $status = 'W'; // Week-off } elseif ($attendance->attendance_type === 'holiday') { $status = 'H'; // Holiday } else { $status = 'A'; // Absent } } else { $status = '-'; // No data } $statuses[] = $status; @endphp {{ $status }} | @endfor @php // Calculate present and absent days $presentDays = collect($statuses)->filter(fn($status) => $status === 'P')->count(); $absentDays = collect($statuses)->filter(fn($status) => $status === 'A')->count(); $weekOffs = collect($statuses)->filter(fn($status) => $status === 'W')->count(); $paidDays = $presentDays + $weekOffs; @endphp{{ $presentDays }} | {{ $absentDays }} | {{ $weekOffs }} | {{ $paidDays }} | |||||||||||||||||||||||||||||