@php
$months = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'];
$selectedDate = now()->parse($date);
@endphp
@if($view === 'month')
{{ $months[(int)now()->parse($date)->format('n') - 1] }} {{ now()->parse($date)->format('Y') }}
@elseif($view === 'year')
@else
@php
$monthIndex = (int)now()->parse($date)->format('n') - 1;
$weekNumber = $selectedDate->week;
@endphp
{{ $months[$monthIndex] }} {{ now()->parse($date)->format('Y') }} · Semaine {{ $weekNumber }}
@php
$startOfWeek = $selectedDate->copy()->startOfWeek();
$daysOfWeek = ['L', 'M', 'M', 'J', 'V', 'S', 'D'];
@endphp
@if($view === 'day' && $selectedDate->format('Y-m-d') !== now()->format('Y-m-d'))
@endif
@endif
@if($view === 'day')
@php
$daysLong = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
$dayOfWeek = $daysLong[$selectedDate->dayOfWeek];
$monthIndex = (int)$selectedDate->format('n') - 1;
@endphp
{{ $dayOfWeek }}, {{ $selectedDate->format('d') }} {{ $months[$monthIndex] }} {{ $selectedDate->format('Y') }}
@php
// Compter directement depuis la base pour le jour sélectionné
$provider = auth()->user()->provider;
$startOfDay = $selectedDate->copy()->startOfDay();
$endOfDay = $selectedDate->copy()->endOfDay();
$totalCount = $provider->appointments()
->whereBetween('start_time', [$startOfDay, $endOfDay])
->count();
$scheduledCount = $provider->appointments()
->whereBetween('start_time', [$startOfDay, $endOfDay])
->where('status', 'scheduled')
->count();
$completeCount = $provider->appointments()
->whereBetween('start_time', [$startOfDay, $endOfDay])
->where('status', 'complete')
->count();
$cancelledCount = $provider->appointments()
->whereBetween('start_time', [$startOfDay, $endOfDay])
->where('status', 'cancelled')
->count();
@endphp
Tous ({{ $totalCount }})
Programmé ({{ $scheduledCount }})
Terminé ({{ $completeCount }})
Annulé ({{ $cancelledCount }})
@endif
@if($view === 'year')
@for($m = 1; $m <= 12; $m++)
@php
$monthDate = now()->parse($date)->month($m)->startOfMonth();
$monthEnd = $monthDate->copy()->endOfMonth();
$monthAppts = $appointments->filter(function($apt) use ($monthDate, $monthEnd) {
return $apt->start_time->between($monthDate, $monthEnd);
});
$total = $monthAppts->count();
@endphp
{{ $months[$m - 1] }}
{{ $total }} RDV
@endfor
@elseif($view === 'month')
@php
$currentMonth = now()->parse($date);
$startOfMonth = $currentMonth->copy()->startOfMonth();
$endOfMonth = $currentMonth->copy()->endOfMonth();
$startDate = $startOfMonth->copy()->startOfWeek();
$endDate = $endOfMonth->copy()->endOfWeek();
@endphp
@foreach(['Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim'] as $day)
{{ $day }}
@endforeach
@php
$currentDay = $startDate->copy();
@endphp
@while($currentDay->lte($endDate))
@php
$dayStr = $currentDay->format('Y-m-d');
$isCurrentMonth = $currentDay->month === $currentMonth->month && $currentDay->year === $currentMonth->year;
$isToday = $currentDay->isToday();
$dayAppts = $appointments->filter(fn($apt) => $apt->start_time->format('Y-m-d') === $dayStr);
@endphp
{{ $currentDay->format('d') }}
@if($dayAppts->count() > 0)
{{ $dayAppts->count() }} RDV
@endif
@php
$currentDay->addDay();
@endphp
@endwhile
@else
@for($hour = 6; $hour <= 20; $hour++)
@endfor
Clic droit (ou long clic) pour changer le statut
@endif