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

<div id="mcp-dashboard-notifications">

    <div class="card mb-4">
        <div class="card-header pl-2">
            <strong>
                Appointment Status Changes
            </strong>
        </div>
        <div class="card-body p-0">
            @if(!count($apptsPending['status']))
                <div class="p-2">
                    No new changes
                </div>
            @endif
            @if(count($apptsPending['status']))
                <table class="table table-sm table-striped">
                    <thead>
                    <tr>
                        <th>Patient</th>
                        <th>Time</th>
                        <th>Memo</th>
                        <th>Status</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($apptsPending['status'] as $appt)
                        <tr discardable-container>
                            <td>
                                <a class="d-block"
                                   href="/patients/view/{{$appt->client->uid}}">{{$appt->client->displayName()}}</a>
                            </td>
                            <td>
                                {{friendlier_date_time($appt->start_time)}}
                            </td>
                            <td>
                                @if($appt->status_memo)
                                    <div class="text-secondary text-sm">{{$appt->status_memo}}</div>
                                @endif
                            </td>
                            <td>
                                <span class="font-weight-bold text-secondary">{{$appt->status}}</span>
                            </td>
                            <td>
                                <form url="/api/appointment/acknowledgeStatusAsAppointmentPro" discardable>
                                    <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">Ack.</button>
                                </form>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            @endif
        </div>
    </div>

    <div class="card mb-4">
        <div class="card-header pl-2">
            <strong>
                Appointment Confirmation Changes
            </strong>
        </div>
        <div class="card-body p-0">
            @if(!count($apptsPending['decision']))
                <div class="p-2">
                    No new changes
                </div>
            @endif
            @if(count($apptsPending['decision']))
                <table class="table table-sm table-striped">
                    <thead>
                    <tr>
                        <th>Patient</th>
                        <th>Time</th>
                        <th>Status</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($apptsPending['decision'] as $appt)
                        <tr discardable-container>
                            <td>
                                <a class="d-block"
                                   href="/patients/view/{{$appt->client->uid}}">{{$appt->client->displayName()}}</a>
                            </td>
                            <td>{{friendlier_date_time($appt->start_time)}}</td>
                            <td>{{$appt->latestConfirmationDecision->decision_enum}}</td>
                            <td>
                                <form url="/api/appointment/acknowledgeDecisionAsAppointmentPro" discardable>
                                    <input type="hidden" name="uid" value="{{$appt->uid}}">
                                    <button submit class="bg-transparent border-0 p-0 text-primary">Ack.</button>
                                </form>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            @endif
        </div>
    </div>

</div>
