@extends('home.partial.layout') @section('content') @php use App\Models\Leave\LeaveApplication; use Carbon\Carbon; @endphp

Employees Monthly Attendance Report

@csrf
@for ($day = 1; $day <= Carbon::now()->daysInMonth; $day++) @endfor @for ($day = 1; $day <= Carbon::now()->daysInMonth; $day++) @if (in_array(Carbon::create(null, $currentMonth, $day)->dayOfWeek, [Carbon::FRIDAY, Carbon::SATURDAY])) @else @endif @endfor @foreach($employees as $emp) @for ($day = 1; $day <= Carbon::now()->daysInMonth; $day++) @php $check = null; if($emp->attendance_data->isNotEmpty()){ foreach($emp->attendance_data as $att){ if('check-in' == $att->status){ if($day==Carbon::parse($att->check_in)->day) $check['in'][] = Carbon::parse($att->check_in); }else{ if($day==Carbon::parse($att->check_out)->day) $check['out'][] = Carbon::parse($att->check_out); } } } $leaveRecords = LeaveApplication::where('employee_id', $emp->id) ->whereMonth('date_from', $currentMonth) ->whereDay('date_from', '<=', $day) ->whereMonth('date_to', $currentMonth) ->whereDay('date_to', '>=', $day) ->where('status', $leave_approval_status['approved']) ->get(); $leave = $leaveRecords->isNotEmpty() ? $leaveRecords->first() : null; $empno = $emp->employee_id; $date = Carbon::create(null, $currentMonth, $day)->format('Y-m-d'); $time = get_check_shift_time($empno,$date); $timeDifference = 0; @endphp @if (in_array(Carbon::create(null, $currentMonth, $day)->dayOfWeek, [Carbon::FRIDAY, Carbon::SATURDAY])) @else @endif @endfor @endforeach

Employees Monthly Attendance Report [{{Carbon::create()->month($currentMonth)->format('F')}}]

{{ Carbon::create(null, $currentMonth, $day)->format('j-M-y') }}
Id # Name Weekend Check-In Check-Out
{{$emp->employee_no}} {{$emp->name}}   {{$emp->lname}} @if ($leave != null) @if($leave->leave_type==6) @if(null!=$check && isset($check['in'])) @foreach($check['in'] as $checkin) {{ $checkin->format('H:i') }}
@endforeach @endif @else A @endif @elseif(null!=$check && isset($check['in'])) @foreach($check['in'] as $checkin) {{ $checkin->format('H:i') }}
@endforeach @else - @endif
@if ($leave != null) @if($leave->leave_type==6) @if(null!=$check && isset($check['out'])) @foreach($check['out'] as $checkout) {{ $checkout->format('H:i') }}
@endforeach @endif @else A @endif @elseif(null!=$check && isset($check['out'])) @foreach($check['out'] as $checkout) {{ $checkout->format('H:i') }}
@endforeach @else - @endif
@endsection