@if($patient)
@php $appointments = \App\Models\Clinic\Appointment::where('patient_id', $patient->id) ->with(['appointmentUserServices.payment', 'doctor', 'services']) ->orderBy('start', 'desc') ->get(); $groupedAppointments = $appointments->groupBy('status'); $statusLabels = [ 'all' => 'Tümü', 'scheduled' => 'Planlandı', 'completed' => 'Tamamlandı', 'cancelled' => 'İptal Edildi', 'no_show' => 'Gelmedi', 'rescheduled' => 'Yeniden Planlandı', 'offer_was_made' => 'Teklif Yapıldı', 'no_action' => 'İşlem Yapılmadı', 'waiting' => 'Beklemede', ]; @endphp @if ($appointments->isEmpty())

Henüz randevu kaydı bulunmamaktadır.

@else
@foreach($statusLabels as $status => $label)
@php $displayAppointments = $status === 'all' ? $appointments : ($groupedAppointments->get($status) ?? collect()); @endphp @if($displayAppointments->count() > 0) @foreach($displayAppointments as $appointment) @php $statusColor = match($appointment->status) { 'completed' => 'text-green-600', 'scheduled' => 'text-blue-600', 'pending' => 'text-yellow-600', 'cancelled' => 'text-red-600', 'no_show' => 'text-red-600', 'rescheduled' => 'text-orange-600', 'no_action' => 'text-gray-600', default => 'text-gray-600' }; $descriptions = []; if (!empty($appointment->description)) { if (is_string($appointment->description)) { $decoded = json_decode($appointment->description, true); $descriptions = $decoded && is_array($decoded) ? $decoded : []; } elseif (is_array($appointment->description)) { $descriptions = $appointment->description; } } @endphp

{{ $appointment->title }}

Tarih: {{ $appointment->start->format('d.m.Y H:i') }}

@if ($appointment->doctor)

Doktor: {{ $appointment->doctor->name }}

@endif

Durum: {{ $statusLabels[$appointment->status] ?? ucfirst($appointment->status) }}

@if (!empty($descriptions) && count($descriptions) > 0) @foreach($descriptions as $index => $desc) @if(isset($desc['note']) && !empty($desc['note']))
📝 Not #{{ $index + 1 }}
@if(isset($desc['created_at'])) {{ \Carbon\Carbon::parse($desc['created_at'])->format('d.m.Y H:i') }} @endif

{{ $desc['note'] }}

@endif @endforeach @endif
Yeni Not Ekle
@if ($appointment->appointmentUserServices->isNotEmpty())
Alınan Hizmetler:
@foreach($appointment->appointmentUserServices as $index => $service) @if ($service->service) @php $bgColor = $index % 2 == 0 ? 'bg-white dark:bg-gray-800' : 'bg-gray-50 dark:bg-gray-700'; $quantity = $service->quantity ?? 1; $unitPrice = $quantity > 0 ? ($service->total / $quantity) : $service->total; @endphp @endif @endforeach
Hizmet Adı Miktar Birim Fiyat Toplam
{{ $service->service->name }} {{ $quantity }} ₺{{ number_format($unitPrice, 2) }} ₺{{ number_format($service->total, 2) }}
@endif
@endforeach @else
@switch($status) @case('scheduled')

📅 Planlanmış randevu bulunamadı

Henüz planlanmış bir randevu bulunmamaktadır.

@break @case('completed')

✅ Tamamlanmış randevu bulunamadı

Henüz tamamlanmış bir randevu bulunmamaktadır.

@break @default

Bu kategoride randevu bulunamadı

@endswitch
@endif
@endforeach @endif
@else

Danışan bilgileri yüklenemedi.

@endif