@php $role = session('login_role'); $rolePath = $role === 'staff' ? 'staff' : 'student'; $portal = $role === 'staff' ? 'STAFF PORTAL' : 'STUDENT PORTAL'; $rawAvailableDates = $availableDates ?? []; $availableDates = array_keys($availableDates ?? []); $today = now()->format('Y-m-d'); $availableDates = array_values(array_filter($availableDates, function($date) use ($today) { return $date >= $today; })); $monthStart = $monthStart ?? now()->format('Y-m-01'); $prevMonth = $prevMonth ?? date('Y-m', strtotime($monthStart.' -1 month')); $nextMonth = $nextMonth ?? date('Y-m', strtotime($monthStart.' +1 month')); $year = date('Y', strtotime($monthStart)); $month = date('m', strtotime($monthStart)); $monthName = date('F Y', strtotime($monthStart)); $daysInMonth = date('t', strtotime($monthStart)); $firstDay = date('N', strtotime($monthStart)); $patientName = $profile['full_name'] ?? 'Patient'; $type = session('booking_appointment_type') ?? 'Dental Check-Up'; $firstAvailable = ''; foreach ($availableDates as $date) { if (date('Y-m', strtotime($date)) === date('Y-m', strtotime($monthStart))) { $firstAvailable = $date; break; } } if (!$firstAvailable) { $firstAvailable = $availableDates[0] ?? ''; } @endphp Select Date - PKU Dental

Book Appointment — Step 2 of 4

{{ now()->format('D, d M Y') }}

Book an Appointment

Schedule your next dental visit at PKU UPSI

@csrf

{{ $monthName }}

Mo
Tu
We
Th
Fr
Sa
Su
@for($i = 1; $i < $firstDay; $i++)
@endfor @for($day = 1; $day <= $daysInMonth; $day++) @php $dateValue = $year.'-'.$month.'-'.str_pad($day,2,'0',STR_PAD_LEFT); $isPast = $dateValue < $today; $isAvailable = !$isPast && in_array($dateValue, $availableDates); $isFirst = $firstAvailable && $dateValue === $firstAvailable; @endphp @if($isAvailable) @else
{{ $day }}
@endif @endfor
Available
Selected
Unavailable
Appointment note
Wednesday is reserved for walk-in patients only. PKU is closed on Saturday and Sunday.
@if(session('error'))
Unable to continue
{{ session('error') }}
@endif

Booking Summary

Patient {{ $patientName }}
Type {{ $type }}
Date {{ $firstAvailable ? date('l, d M Y', strtotime($firstAvailable)) : '-' }}
@if($firstAvailable)
✓ Date Available
Time slots are available on this date. Please continue to select a time.
@else
No Date Available
Please choose another month or contact PKU Dental.
@endif
← Back