@extends('layouts.dashboard.superadminapp') @section('title', 'Daily Attendance & Productivity Report') @section('styles') @endsection @section('content')

UEPL | Daily Attendance & Productivity Report

day, 00 month 0000
@if(session('success')) @endif @if(session('error')) @endif
Filter Options
@php // Calculate summary statistics $totalEmployees = $employees->count(); $presentCount = 0; $absentCount = 0; $onLeaveCount = 0; $totalOtMinutes = 0; $totalShortageMinutes = 0; $totalWorkMinutes = 0; $standardWorkHours = 9; foreach($employees as $emp) { $attendance = $attendanceData->where('employee_id', $emp->employee_id)->first(); $leave = $leaveData->where('employee_id', $emp->id)->first(); if($attendance) { $presentCount++; // Calculate working hours if($attendance->check_in && $attendance->check_out) { $checkIn = \Carbon\Carbon::parse($attendance->check_in); $checkOut = \Carbon\Carbon::parse($attendance->check_out); $breakOut = $attendance->break_out ? \Carbon\Carbon::parse($attendance->break_out) : null; $breakIn = $attendance->break_in ? \Carbon\Carbon::parse($attendance->break_in) : null; $totalMins = $checkIn->diffInMinutes($checkOut); $breakMins = ($breakOut && $breakIn) ? $breakOut->diffInMinutes($breakIn) : 0; $workMins = max(0, $totalMins - $breakMins); $totalWorkMinutes += $workMins; $workHours = $workMins / 60; if($workHours > $standardWorkHours) { $totalOtMinutes += ($workHours - $standardWorkHours) * 60; } else { $totalShortageMinutes += ($standardWorkHours - $workHours) * 60; } } } elseif($leave) { $onLeaveCount++; } else { $absentCount++; } } $avgWorkHours = $presentCount > 0 ? round($totalWorkMinutes / $presentCount / 60, 2) : 0; $productivityRate = $totalEmployees > 0 ? round(($presentCount / $totalEmployees) * 100, 1) : 0; @endphp
{{ $totalEmployees }}
Total Employees
{{ $presentCount }}
Present
{{ $onLeaveCount }}
On Leave
{{ $absentCount }}
Absent
{{ sprintf('%02d:%02d', intdiv($totalOtMinutes, 60), $totalOtMinutes % 60) }}
Total OT
{{ $productivityRate }}%
Attendance Rate
Daily Report for {{ \Carbon\Carbon::parse(request('date', date('Y-m-d')))->format('d M Y') }}
Avg Work: {{ $avgWorkHours }} hrs
@foreach($employees as $emp) @php $attendance = $attendanceData->where('employee_id', $emp->employee_id)->first(); $leave = $leaveData->where('employee_id', $emp->id)->first(); $workDuration = null; $workHours = 0; $ot = 0; $shortage = 0; $productivityScore = 0; if($attendance && $attendance->check_in && $attendance->check_out) { $checkIn = \Carbon\Carbon::parse($attendance->check_in); $checkOut = \Carbon\Carbon::parse($attendance->check_out); $breakOut = $attendance->break_out ? \Carbon\Carbon::parse($attendance->break_out) : null; $breakIn = $attendance->break_in ? \Carbon\Carbon::parse($attendance->break_in) : null; $totalMins = $checkIn->diffInMinutes($checkOut); $breakMins = ($breakOut && $breakIn) ? $breakOut->diffInMinutes($breakIn) : 0; $workMins = max(0, $totalMins - $breakMins); $workHours = round($workMins / 60, 2); $workDuration = sprintf('%02d:%02d', intdiv($workMins, 60), $workMins % 60); $ot = $workHours > $standardWorkHours ? round($workHours - $standardWorkHours, 2) : 0; $shortage = $workHours < $standardWorkHours ? round($standardWorkHours - $workHours, 2) : 0; // Productivity score: 100% for 9 hrs, +10% per OT hour, -10% per shortage hour $productivityScore = min(150, max(0, 100 + ($ot * 10) - ($shortage * 10))); } $rowClass = ''; if($attendance) { $rowClass = 'row-present'; } elseif($leave) { $rowClass = 'row-leave'; } else { $rowClass = 'row-absent'; } @endphp @endforeach
Employee ID Name Department Status Check In Break Out Break In Check Out Work Hours OT Shortage Leave Type Leave Status Productivity
{{ $emp->employee_id }} {{ $emp->name }} {{ $emp->department ?? '-' }} @if($attendance) Present @elseif($leave) On Leave @else Absent @endif {{ $attendance->check_in ?? '-' }} {{ $attendance->break_out ?? '-' }} {{ $attendance->break_in ?? '-' }} {{ $attendance->check_out ?? '-' }} @if($workDuration) {{ $workDuration }} @else - @endif @if($ot > 0) +{{ sprintf('%02d:%02d', floor($ot), ($ot - floor($ot)) * 60) }} @else - @endif @if($shortage > 0) -{{ sprintf('%02d:%02d', floor($shortage), ($shortage - floor($shortage)) * 60) }} @else - @endif @if($leave) @switch($leave->leave_type) @case('CL') CL @break @case('SL') SL @break @case('PL') PL @break @case('LOP') LOP @break @default {{ $leave->leave_type }} @endswitch @else - @endif @if($leave) @if(strtolower($leave->status) == 'approved') Approved @elseif(strtolower($leave->status) == 'pending') Pending @else {{ $leave->status }} @endif @else - @endif @if($attendance) @if($productivityScore >= 100) {{ $productivityScore }}% @elseif($productivityScore >= 80) {{ $productivityScore }}% @else {{ $productivityScore }}% @endif @elseif($leave) On Leave @else N/A @endif
Top Performers (OT Hours)
@php $topPerformers = collect(); foreach($employees as $emp) { $attendance = $attendanceData->where('employee_id', $emp->employee_id)->first(); if($attendance && $attendance->check_in && $attendance->check_out) { $checkIn = \Carbon\Carbon::parse($attendance->check_in); $checkOut = \Carbon\Carbon::parse($attendance->check_out); $breakOut = $attendance->break_out ? \Carbon\Carbon::parse($attendance->break_out) : null; $breakIn = $attendance->break_in ? \Carbon\Carbon::parse($attendance->break_in) : null; $totalMins = $checkIn->diffInMinutes($checkOut); $breakMins = ($breakOut && $breakIn) ? $breakOut->diffInMinutes($breakIn) : 0; $workMins = max(0, $totalMins - $breakMins); $workHours = $workMins / 60; if($workHours > $standardWorkHours) { $topPerformers->push([ 'name' => $emp->name, 'department' => $emp->department, 'ot' => round($workHours - $standardWorkHours, 2) ]); } } } $topPerformers = $topPerformers->sortByDesc('ot')->take(5); @endphp @forelse($topPerformers as $performer) @empty @endforelse
Employee Department OT Hours
{{ $performer['name'] }} {{ $performer['department'] ?? '-' }} +{{ sprintf('%02d:%02d', floor($performer['ot']), ($performer['ot'] - floor($performer['ot'])) * 60) }}
No OT recorded today
Needs Attention (Shortage)
@php $needsAttention = collect(); foreach($employees as $emp) { $attendance = $attendanceData->where('employee_id', $emp->employee_id)->first(); if($attendance && $attendance->check_in && $attendance->check_out) { $checkIn = \Carbon\Carbon::parse($attendance->check_in); $checkOut = \Carbon\Carbon::parse($attendance->check_out); $breakOut = $attendance->break_out ? \Carbon\Carbon::parse($attendance->break_out) : null; $breakIn = $attendance->break_in ? \Carbon\Carbon::parse($attendance->break_in) : null; $totalMins = $checkIn->diffInMinutes($checkOut); $breakMins = ($breakOut && $breakIn) ? $breakOut->diffInMinutes($breakIn) : 0; $workMins = max(0, $totalMins - $breakMins); $workHours = $workMins / 60; if($workHours < $standardWorkHours) { $needsAttention->push([ 'name' => $emp->name, 'department' => $emp->department, 'shortage' => round($standardWorkHours - $workHours, 2) ]); } } } $needsAttention = $needsAttention->sortByDesc('shortage')->take(5); @endphp @forelse($needsAttention as $emp) @empty @endforelse
Employee Department Shortage
{{ $emp['name'] }} {{ $emp['department'] ?? '-' }} -{{ sprintf('%02d:%02d', floor($emp['shortage']), ($emp['shortage'] - floor($emp['shortage'])) * 60) }}
All employees met target hours
@endsection @section('scripts') @endsection