@extends('home.partial.layout') @php use Carbon\Carbon; // Get the start date of the current month $startDate = Carbon::now()->startOfMonth(); //$start_Date = Carbon::now()->startOfMonth()->subMonth()->setDay(26); // Get the end date of the current month $endDate = Carbon::now()->endOfMonth(); //$end_Date = Carbon::now()->endOfMonth()->setDay(25); $currentDate = Carbon::now(); // $currentDate = Carbon::parse('2023-10-24'); if ($currentDate->day >= 26) { $startDate = $currentDate; //$endDate = $startDate->addMonth()->startOfMonth(); $end_Date = $currentDate->addMonthsNoOverflow(1)->startOfMonth()->setDay(25); //$startDate = $startDate->copy()->setDay(25); $start_Date = $currentDate->copy()->subMonthNoOverflow()->setDay(26); } else { $start_Date = $currentDate->copy()->subMonthNoOverflow()->setDay(26); $end_Date = $currentDate->copy()->setDay(25); } $endday = \Carbon\Carbon::parse($endDate); $day = $endday->day; $dayInt = (int)$day; // Get the start and end dates of the previous month //$prevStartDate = $startDate->copy()->subMonth()->startOfMonth(); //$prevEndDate = $prevStartDate->copy()->endOfMonth(); $prevStartDate = Carbon::parse($startDate)->subMonth()->startOfMonth(); $prevEndDate = $prevStartDate->copy()->endOfMonth(); // Get the start and end dates of the next month $nextStartDate = $endDate->copy()->addDay()->startOfMonth(); $nextEndDate = $nextStartDate->copy()->endOfMonth(); $numDays = $endDate->daysInMonth; @endphp @section('page_css') @endsection @section('content')

Academic Attendance

@if(Auth::user()->hasRole(HR_ROLE))
Add
@endif @if (Session::has('error'))
@endif @if (Session::has('success'))
@endif @if($errors->any())
@endif
{{$start_Date->format('M d')}} - {{$end_Date->format('M d, Y')}}
@php $start_date = Carbon::now()->subMonth()->startOfMonth()->setDay(26); // $end_date = Carbon::now(); $end_date = $end_Date @endphp @foreach($acadmic_employees as $acadmic_employee) @php $loop_date = clone $start_date; @endphp @while($loop_date <= $end_date) @php $checkin = null; $leaveApplication = null; // Filter attendance for the current employee and date if ($acadmic_employee->attendance()) { $checkin = $acadmic_employee->attendance() ->whereDate('check_in', $loop_date->format('Y-m-d')) ->first(); } // Filter leave application for the current employee and date if ($acadmic_employee->leaveApplication) { $leaveApplication = $acadmic_employee->leaveApplication ->where(function ($query) use ($loop_date) { $query->where('date_from', '<=', $loop_date->format('Y-m-d')) ->where('date_to', '>=', $loop_date->format('Y-m-d')); })->where('employee_id',$acadmic_employee->id) ->where('status',6) ->first(); } @endphp @php $loop_date->addDay(); @endphp @endwhile @endforeach

{{ $acadmic_employee->name }} {{ $acadmic_employee->lname }}

format('Y-m-d'))) == 5 || date('N', strtotime($loop_date->format('Y-m-d'))) == 6) style="background-color: grey;" @endif style="z-index:-9999;"> @if($checkin && $leaveApplication) @elseif($checkin) @elseif($leaveApplication) @else @endif
@endsection