@extends('admin.layouts.app') @section('title', __('appointments.title')) @push('styles') @endpush @section('content')
@php $today = now()->toDateString(); $weekDays = ['Sat', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri']; $calendarCursor = $calendarStart->copy(); $monthFilter = request()->input('month', $calendarDate->format('Y-m')); $prevMonth = $calendarDate->copy()->subMonth()->format('Y-m'); $nextMonth = $calendarDate->copy()->addMonth()->format('Y-m'); $prevMonthQuery = array_merge(request()->except(['month', 'page']), ['month' => $prevMonth]); $nextMonthQuery = array_merge(request()->except(['month', 'page']), ['month' => $nextMonth]); @endphp

{{ __('appointments.title') }}

{{ $calendarDate->format('F Y') }} @can('appointments.create') {{ __('appointments.new') }} @endcan
@if (session('success'))
{{ session('success') }}
@endif @if (session('error'))
{{ session('error') }}
@endif
Reset
@if ($appointments->isEmpty())

{{ __('appointments.empty') }}

@else
@foreach ($weekDays as $weekDay)
{{ $weekDay }}
@endforeach
@while ($calendarCursor->lte($calendarEnd)) @php $dateKey = $calendarCursor->toDateString(); $dayAppointments = $appointmentsByDate->get($dateKey, collect()); $isOutsideMonth = $calendarCursor->month !== $calendarDate->month; $isToday = $dateKey === $today; @endphp
$isOutsideMonth, 'is-today' => $isToday])>
{{ $calendarCursor->format('d') }} @if ($dayAppointments->isNotEmpty()) {{ $dayAppointments->count() }} @endif
@foreach ($dayAppointments as $appointment) @php $currentStatus = $appointment->status?->value ?? $appointment->status; $isConfirmedLocked = $currentStatus === \App\Enums\AppointmentStatus::CONFIRMED->value; $quickStatuses = [ \App\Enums\AppointmentStatus::CONFIRMED, \App\Enums\AppointmentStatus::CHECKED_IN, \App\Enums\AppointmentStatus::NO_SHOW, \App\Enums\AppointmentStatus::COMPLETED, ]; $quickStatusLabels = [ \App\Enums\AppointmentStatus::CONFIRMED->value => ' تم التأكيد', \App\Enums\AppointmentStatus::CHECKED_IN->value => ' تم تسجيل الحضور', \App\Enums\AppointmentStatus::NO_SHOW->value => 'لم يحضر', \App\Enums\AppointmentStatus::COMPLETED->value => ' مكتمل', ]; @endphp
{{ $appointment->start_time ? \Illuminate\Support\Str::substr((string) $appointment->start_time, 0, 5) : '--:--' }}
{{ $appointment->patient?->full_name ?? __('common.not_available') }}
{{ $appointment->doctor?->display_name ?? __('common.not_available') }}
{{ is_object($appointment->status) ? $appointment->status->label() : str_replace('_', ' ', ucfirst((string) $appointment->status)) }}
{{ __('common.view') }} @if ($appointment->patient_id) {{ __('appointments.columns.patient') }} @endif @if ($appointment->visit) Visit @endif
@can('appointments.edit')
@csrf
@if ($isConfirmedLocked)
Confirmed / تم التأكيد - Locked
@endif
@endcan
@endforeach
@php($calendarCursor->addDay()) @endwhile
@endif
@endsection