@extends ('layouts/template')

@section('content')
<div class="p-3 mcp-theme-1" id="patients-list">
    <div class="card">

        <div class="card-header px-3 py-2 d-flex align-items-center">
            <strong class="mr-4">
                <i class="fas fa-calendar-alt"></i>
                Appointments
            </strong>
        </div>

        <div class="card-body p-0">
            <div class="p-3">
                @include('app.mcp.appointments_filters')
            </div>
            <table class="table table-sm table-striped p-0 m-0">
                <thead class="bg-light border-top">
                    <tr>
                        <th class="border-0">Date & Time</th>
                        <th class="border-0">Patient</th>
                        <th class="border-0">Title</th>
                        <th class="border-0">Description</th>
                        <th class="border-0">Status</th>
                        <th class="border-0">Confirmation</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($appointments as $appointment)
                    <tr>
                        <td>
                            <a href="/patients/view/{{$appointment->client->uid}}/calendar/{{$appointment->uid}}">
                                {{friendly_date($appointment->raw_date) . ' ' . friendly_time($appointment->raw_start_time)}}                            
                            </a>
                        </td>
                        <td>{{ $appointment->client->displayName() }}</pre>
                        </td>
                        <td>{{ $appointment->title }}</td>
                        <td>{{ $appointment->description }}</td>
                        <td>
                            {{ $appointment->status }}
                            @if($appointment->status_memo)
                            <hr>
                            {{$appointment->status_memo}}
                            @endif
                        </td>
                        <td>
                            @include('app.patient.partials.appointment-confirmation',['patient' => $appointment->client])
                        </td>
                    </tr>
                    @endforeach

                    @if(count($appointments) === 0)
                    <tr>
                        <td colspan="6">No records found!</td>
                    </tr>
                    @endif
                </tbody>
            </table>
            @if($appointments->hasPages())
            <div class="ml-2 mt-2">
                {{ $appointments->appends(request()->input())->links() }}
            </div>
            @endif
        </div>
    </div>
</div>
@endsection
