@extends('layouts.pro-logged-in')

@section('content')

    <h2 class="p-3">{{ date('Y-m-d') }}</h2>

    <div class="px-3 text-sm">
        <div class="row mx-0">
            <div class="col-4">
                <h4>Appointments</h4>
                <table class="table table-sm table-striped">
                    <thead>
                        <tr class="bg-white">
                            <th class="border py-1 px-2">Date/Time</th>
                            <th class="border py-1 px-2">Patient</th>
                            <th class="border py-1 px-2">Pro</th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach($appointments as $appointment)
                        <tr>
                            <td class="border py-1 px-2">{{ friendly_date_time($appointment->start_time) }}</td>
                            <td class="border py-1 px-2">{{ $appointment->client->displayName() }}</td>
                            <td class="border py-1 px-2">{{ $appointment->pro->displayName() }}</td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
            <div class="col-4">
                <h4>Open Tickets</h4>
                <table class="table table-sm table-striped">
                    <thead>
                    <tr class="bg-white">
                        <th class="border py-1 px-2">Type</th>
                        <th class="border py-1 px-2">Patient</th>
                        <th class="border py-1 px-2">Pro(s)</th>
                        <th class="border py-1 px-2">Created</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($tickets as $ticket)
                        <tr>
                            <td class="border py-1 px-2 text-nowrap">
                                {{ strtoupper($ticket->category) }}
                                <a class="d-block mt-2" href="/tickets/view/{{$ticket->uid}}/SUB_dashboard">View Ticket</a>
                            </td>
                            <td class="border py-1 px-2 text-nowrap">
                                <a href="/clients/view/{{$ticket->patient->uid}}/SUB_detail">
                                    {{ $ticket->patient->displayName() }}
                                </a>
                            </td>
                            <td class="border py-1 px-2">
                                <div class="text-nowrap">
                                    <span class="text-secondary">As:</span>
                                    <a href="/pros/view/{{$ticket->assignedPro->uid}}/SUB_dashboard">
                                        {{ $ticket->assignedPro->displayName() }}
                                    </a>
                                </div>
                                <div class="text-nowrap">
                                    <span class="text-secondary">Mg:</span>
                                    <a href="/pros/view/{{$ticket->managerPro->uid}}/SUB_dashboard">
                                        {{ $ticket->managerPro->displayName() }}
                                    </a>
                                </div>
                                <div class="text-nowrap">
                                    <span class="text-secondary">Or:</span>
                                    <a href="/pros/view/{{$ticket->orderingPro->uid ?? ''}}/SUB_dashboard">
                                        {{$ticket->orderingPro ? $ticket->orderingPro->displayName() : '' }}
                                    </a>
                                </div>
                                <div class="text-nowrap">
                                    <span class="text-secondary">In:</span>
                                    <a href="/pros/view/{{$ticket->initiatingPro->uid}}/SUB_dashboard">
                                        {{ $ticket->initiatingPro->displayName() }}
                                    </a>
                                </div>
                            </td>
                            <td class="border py-1 px-2 text-nowrap">{{ friendly_date_time($ticket->created_at) }}</td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
            <div class="col-4">
                <h4>Memos</h4>
                <table class="table table-sm table-striped">
                    <thead>
                        <tr class="bg-white">
                            <th class="border py-1 px-2">Date/Time</th>
                            <th class="border py-1 px-2">Patient</th>
                            <th class="border py-1 px-2">Category</th>
                            <th class="border py-1 px-2 w-50">Content</th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach($memos as $memo)
                        <tr>
                            <td class="border py-1 px-2">{{ friendly_date_time($memo->created_at) }}</td>
                            <td class="border py-1 px-2 text-nowrap">{{ $memo->client->displayName() }}</td>
                            <td class="border py-1 px-2">{{ $memo->category }}</td>
                            <td class="border py-1 px-2">{{ $memo->content }}</td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>


@endsection
