@extends('layouts.app') @section('title', 'Connect - Team Leave Calendar') @section('content') @php $startOfMonth = sprintf('%04d-%02d-01', $year, $month); $daysInMonth = date('t', strtotime($startOfMonth)); $firstDayOfWeek = date('w', strtotime($startOfMonth)); $monthName = date('F', strtotime($startOfMonth)); @endphp
  Approved Leaves Timeline

{{ $monthName }} {{ $year }}

@php $dayCount = 1; @endphp @for($i = 0; $i < $firstDayOfWeek; $i++) @endfor @for($day = 1; $day <= $daysInMonth; $day++) @php $currentDateStr = sprintf('%04d-%02d-%02d', $year, $month, $day); $currentDate = new \DateTime($currentDateStr); // Find leaves active on this day $activeLeaves = $leaves->filter(function($l) use ($currentDate) { return $currentDate >= $l->start_date && $currentDate <= $l->end_date; }); $isToday = $currentDateStr === date('Y-m-d'); @endphp @if(($day + $firstDayOfWeek) % 7 == 0 && $day < $daysInMonth) @endif @endfor @php $remainingCells = 7 - (($daysInMonth + $firstDayOfWeek) % 7); @endphp @if($remainingCells < 7) @for($i = 0; $i < $remainingCells; $i++) @endfor @endif
Sun Mon Tue Wed Thu Fri Sat
{{ $day }} @if($isToday) TODAY @endif
@foreach($activeLeaves as $leave)
{{ $leave->employee->first_name }}
@endforeach

Active & Upcoming Leaves

@if($leaves->isEmpty())

No approved leaves logged for this month.

@else @foreach($leaves as $leave)
{{ $leave->employee->fullName }}
{{ $leave->start_date->format('d M') }} - {{ $leave->end_date->format('d M Y') }}
{{ $leave->leaveType->code }}
{{ (float)$leave->total_days }} days
@endforeach @endif
@endsection