<div class="mt-0 pb-1">
    <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
        <h6 class="my-0 font-weight-bold text-secondary">Appointments</h6>
        <span class="mx-2 text-secondary">|</span>
        <a href="/patients/view/{{$patient->uid}}/calendar">Calendar</a>
    </div>
    <table class="table table-sm border-0 m-0">
        <tbody>
        @foreach($patient->appointmentsFromLastWeek as $appointment)
            <tr>
                <td class="text-black p-0 border-0 pb-1">
                    <div class="pb-0 d-flex align-items-center flex-wrap">
                        <a class="on-hover-opaque mr-1"
                           href="/patients/view/{{$patient->uid}}/calendar/{{$appointment->uid}}"
                           title="Update">
                            <i class="font-size-11 fa fa-edit text-primary"></i>
                        </a>
                        <span class="mr-1 text-nowrap">{{ friendly_date_time($appointment->raw_date, false) }}</span>
                        @if($appointment->raw_start_time)
                            <span class="mr-1 text-nowrap">{{ friendly_time($appointment->raw_start_time, false) }}</span>
                        @endif
                        @if($appointment->timezone)
                            <span class="text-secondary text-sm mr-1 text-nowrap">({{ str_replace("_", " ", $appointment->timezone) }})</span>
                        @endif
                        <span class="mr-1">/</span>
                        <span class="font-weight-bold mr-1 text-nowrap">{{$appointment->pro->displayName()}}</span>
                        <div moe>
                            <a href="#" start show class="text-sm">({{ $appointment->status }})</a>
                            <form url="/api/appointment/updateStatus">
                                <input type="hidden" name="uid" value="{{ $appointment->uid }}">
                                <div class="mb-2">
                                    <select class="form-control form-control-sm bg-light" name="status" required>
                                        <option value="">-- select --</option>
                                        <option {{ $appointment->status === 'CREATED' ? 'selected' : '' }} value="CREATED">CREATED</option>
                                        <option {{ $appointment->status === 'CONFIRMED' ? 'selected' : '' }} value="CONFIRMED">CONFIRMED</option>
                                        <option {{ $appointment->status === 'CANCELLED' ? 'selected' : '' }} value="CANCELLED">CANCELLED</option>
                                        <option {{ $appointment->status === 'COMPLETED' ? 'selected' : '' }} value="COMPLETED">COMPLETED</option>
                                        <option {{ $appointment->status === 'ABANDONED' ? 'selected' : '' }} value="ABANDONED">ABANDONED</option>
                                    </select>
                                </div>
                                <div>
                                    <button submit class="btn btn-sm btn-primary mr-1">Update</button>
                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
                                </div>
                            </form>
                        </div>
                        @if($appointment->status === 'CREATED')
                            <div moe class="ml-2">
                                <a href="#" start show class="text-sm font-weight-bold">Req. Conf.</a>
                                <form url="/api/appointment/sendConfirmationRequestViaSms">
                                    <input type="hidden" name="uid" value="{{ $appointment->uid }}">
                                    <div class="mb-2">
                                        <label for="" class="text-sm text-secondary mb-1">Cell Number</label>
                                        <input type="text" class="form-control form-control-sm" name="toSmsNumber" value="{{$patient->cell_number}}" required>
                                    </div>
                                    <div>
                                        <button submit class="btn btn-sm btn-primary mr-1">Send</button>
                                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
                                    </div>
                                </form>
                            </div>
                        @endif
                        <span class="text-sm ml-2">{{ $appointment->title ? $appointment->title : '' }}</span>
                        {{--@if($appointment->title && $appointment->description)<span class="text-secondary mx-1">/</span>@endif--}}
                        {{--<span class="text-sm">{{ $appointment->description ? $appointment->description : '' }}</span>--}}
                    </div>
                </td>
            </tr>
        @endforeach
        @if(!$patient->appointmentsFromLastWeek || count($patient->appointmentsFromLastWeek) === 0)
            <tr>
                <td class="text-secondary p-0 border-0">
                    No recent appointments
                </td>
            </tr>
        @endif
        <tr>
            <td class="text-secondary pt-2 px-0 border-0">
                <a href="/patients/view/{{$patient->uid}}/appointments/all/all">See all appointments</a>
            </td>
        </tr>
        </tbody>
    </table>
</div>

