@extends('layouts.app') @section('title', 'Appointment '.$appointment->reference) @php $a = $appointment; $user = auth()->user(); $canManage = $user->can('manage-appointment', $a); $desk = $user->hasRole('admin', 'security'); @endphp @section('content')

{{ $a->reference }}

{{ $a->type_label }} Created {{ $a->created_at->format('d M Y, h:i A') }} by {{ $a->creator?->name ?? 'system' }}
@if ($desk && $a->canCheckIn()) Check in @endif @if ($desk && $a->canCheckOut())
@csrf
@endif @if ($canManage && $a->canResendOtp())
@csrf
@endif @if ($canManage && $a->isEditable() && $a->type === 'scheduled') Edit @endif @if ($canManage && $a->canBeCancelled())
@csrf
@endif Back
@if ($user->can('decide-walkin', $a))
This walk-in visitor is waiting for your decision
@include('walkins._decision', ['a' => $a])
@elseif ($a->status === 'pending')
Waiting for {{ $a->host->name }} to approve this walk-in. @if ($desk)(This page refreshes automatically.)@endif
@endif @if ($a->status === 'rejected')
Rejected by {{ $a->approver?->name }}.@if($a->rejection_reason) Reason: {{ $a->rejection_reason }}@endif
@endif
Visitor

{{ $a->visitor->name }}

{{ $a->visitor->company ?: 'Individual' }}
Phone
{{ $a->visitor->phone }}
Email
{{ $a->visitor->email ?: '—' }}
ID
{{ $a->visitor->id_type ? $a->visitor->id_type.' · '.$a->visitor->id_number : '—' }}
Address
{{ $a->visitor->address ?: '—' }}
Host

{{ $a->host->name }}

{{ $a->host->designation }}@if($a->host->department) · {{ $a->host->department }}@endif
Phone
{{ $a->host->phone ?: '—' }}
Email
{{ $a->host->email }}
Visit
Purpose
{{ $a->purpose }}
Scheduled
{{ $a->scheduled_at->format('l, d M Y · h:i A') }}
Duration
{{ $a->duration_minutes ? $a->duration_minutes.' min' : '—' }}
Vehicle
{{ $a->vehicle_number ?: '—' }}
Badge
{{ $a->badge_number ?: '—' }}
Time inside
{{ $a->checked_in_at ? $a->checked_in_at->diffForHumans($a->checked_out_at ?? now(), true) : '—' }}
@if ($a->notes)
Notes
{{ $a->notes }}
@endif

{{-- The OTP is shown only to the staff member who created the appointment (see 'view-otp' gate). --}} @can('view-otp', $a) @if ($a->isOtpActive() && $a->otp_code)
Visitor OTP (sent to {{ $a->visitor->phone }}{{ $a->visitor->email ? ' / '.$a->visitor->email : '' }})
{{ $a->otp_code }}
@push('scripts') @endpush @elseif ($a->isOtpActive())
This OTP was issued before OTP display was enabled. Click Resend OTP to generate one you can see here.
@elseif ($a->otp_used_at)
OTP was used at check-in and is no longer valid.
@elseif ($a->canResendOtp())
OTP has expired. Click Resend OTP to send a new one.
@endif @endcan
OTP sent
{{ $a->otp_sent_at?->format('d M, h:i A') ?? 'Not issued' }}
OTP valid till
{{ $a->otp_expires_at?->format('d M, h:i A') ?? '—' }}
OTP used
{{ $a->otp_used_at?->format('d M, h:i A') ?? 'Not used' }}
Timeline
  • Created by {{ $a->creator?->name ?? 'system' }} — {{ $a->created_at->format('d M Y, h:i A') }}
  • @if ($a->approved_at)
  • Approved by {{ $a->approver?->name }} — {{ $a->approved_at->format('d M Y, h:i A') }}
  • @endif @if ($a->otp_used_at)
  • OTP verified — {{ $a->otp_used_at->format('d M Y, h:i A') }}
  • @endif @if ($a->checked_in_at)
  • Checked in by {{ $a->checkedInBy?->name }} — {{ $a->checked_in_at->format('d M Y, h:i A') }}
  • @endif @if ($a->checked_out_at)
  • Checked out by {{ $a->checkedOutBy?->name }} — {{ $a->checked_out_at->format('d M Y, h:i A') }}
  • @endif @if ($a->cancelled_at)
  • Cancelled — {{ $a->cancelled_at->format('d M Y, h:i A') }}
  • @endif
{{-- Message logs may contain the OTP, so the front desk does not see them. --}} @if (! $user->isSecurity() && $a->notificationLogs->isNotEmpty())
Messages sent
@if($user->isAdmin())@endif @foreach ($a->notificationLogs as $log) @if ($user->isAdmin())@endif @endforeach
WhenChannelToStatusMessage
{{ $log->created_at->format('d M, h:i A') }} {{ strtoupper($log->channel) }} {{ $log->recipient }} {{ ucfirst($log->status) }}{{ $user->can('view-otp', $a) ? $log->message : $log->masked_message }}
@endif @if ($history->isNotEmpty()) @endif
@endsection