@extends('home.partial.layout') @php // Get the current date $currentDate = Carbon::now(); // Check if the current day is greater than or equal to 26th of the month if ($currentDate->day >= 26) { // Set the start date as the current date $startDate = $currentDate; // Set the end date as the 25th day of the next month $end_Date = $currentDate->copy()->addMonthsNoOverflow(1)->startOfWeek(Carbon::SUNDAY)->endOfWeek(Carbon::SATURDAY); // Set the start date as the 26th of the previous month $start_Date = $currentDate->copy()->subMonthNoOverflow()->setDay(26)->startOfWeek(Carbon::SUNDAY); } else { // Set the start and end dates for the current period $start_Date = $currentDate->copy()->subMonthNoOverflow()->setDay(26)->startOfWeek(Carbon::SUNDAY); $end_Date = $currentDate->copy()->setDay(25)->endOfWeek(Carbon::SATURDAY); } // Get the end date of the current week $endday = \Carbon\Carbon::parse($end_Date); $day = $endday->day; $dayInt = (int)$day; // Get the start and end dates of the previous week $prevStartDate = Carbon::parse($startDate)->subWeek()->startOfWeek(Carbon::SUNDAY); $prevEndDate = $prevStartDate->copy()->endOfWeek(Carbon::SATURDAY); // Get the start and end dates of the next week $nextStartDate = $end_Date->copy()->addDay()->startOfWeek(Carbon::SUNDAY); $nextEndDate = $nextStartDate->copy()->endOfWeek(Carbon::SATURDAY); // Get the number of days in the current week (7 days) $numDays = 7; @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 @php $start_date = Carbon::now()->startOfWeek(Carbon::SUNDAY); // $end_date = Carbon::now(); $end_date = $start_date->copy()->addDays(6); @endphp
{{$start_date->format('M d')}} - {{$end_date->format('M d, Y')}}
@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