<?php
    
    $apptsPending = [
        'status' => $pro->getAppointmentsPendingStatusChangeAckAsDna(),
        'decision' => $pro->getAppointmentsPendingDecisionAckAsDna(),
        // 'time' => $pro->getAppointmentsPendingTimeChangeAck()
    ];

?>
@if(!count($apptsPending['status']) && !count($apptsPending['decision'])/* && !count($apptsPending['time'])*/)
    No appointment changes
@endif
@if(count($apptsPending['status']))
    <b class="text-secondary my-2 d-block">Appointment Status Changes</b>
    @foreach($apptsPending['status'] as $appt)
        <div class="d-flex mb-1">
            <div>
                <a href="/patients/view/{{$appt->client->uid}}"><b>{{$appt->client->displayName()}}</b></a>
                <span class="ml-2">{{friendlier_date_time($appt->start_time)}}</span>
                <span class="ml-2">{{$appt->status}}</span>
                @if($appt->status_memo)
                    <div class="text-secondary text-sm">{{$appt->status_memo}} This is a status memo</div>
                @endif
            </div>
            @if($appt->pro_id == $pro->id)
            <div moe relative class="ml-auto">
                <form show url="/api/appointment/acknowledgeStatusAsAppointmentPro">
                    <input type="hidden" name="uid" value="{{$appt->uid}}">
                    <input type="hidden" name="currentStatus" value="{{$appt->status}}">
                    @if($appt->status_memo !== null)
                    <input type="hidden" name="currentStatusMemo" value="{{$appt->status_memo}}">
                    @endif
                    <input type="hidden" name="currentRawDate" value="{{$appt->raw_date}}">
                    <input type="hidden" name="currentRawStartTime" value="{{$appt->raw_start_time}}">
                    <input type="hidden" name="currentRawEndTime" value="{{$appt->raw_end_time}}">
                    <input type="hidden" name="currentTimezone" value="{{$appt->timezone}}">
                    <button submit class="bg-transparent border-0 p-0 text-primary">Acknowledge</button>
                </form>
            </div>
            @endif
        </div>
    @endforeach
@endif
@if(count($apptsPending['decision']))
    <b class="text-secondary my-2 d-block">Appointment Confirmation Changes</b>
    @foreach($apptsPending['decision'] as $appt)
        <div class="d-flex mb-1">
            <a href="/patients/view/{{$appt->client->uid}}"><b>{{$appt->client->displayName()}}</b></a>
            <span class="ml-2">{{friendlier_date_time($appt->start_time)}}</span>
            <span class="ml-2">{{$appt->latestConfirmationDecision->decision_enum}}</span>
            @if($appt->pro_id == $pro->id)
                <div moe relative class="ml-auto">
                    <form show url="/api/appointment/acknowledgeDecisionAsAppointmentPro">
                        <input type="hidden" name="uid" value="{{$appt->uid}}">
                        <button submit class="bg-transparent border-0 p-0 text-primary">Acknowledge</button>
                    </form>
                </div>
            @endif
        </div>
    @endforeach
@endif
