@extends ('layouts/template')

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

        <div class="card-header px-2 py-1 d-flex align-items-center">
            <strong class="mr-4">
                <i class="fas fa-file-invoice-dollar"></i>
                Reports Pending Signature
            </strong>
        </div>

        <div class="card-body p-0">
            <div class="p-3">
                @include('app.mcp.reports_filters')
            </div>
            <table class="table table-sm table-striped border-top p-0 m-0">
                <thead class="bg-light">
                    <tr>
                        <th class="border-0">Patient</th>
                        <th class="border-0">Title</th>
                        <th class="border-0">Category</th>
                        <th class="border-0">Report Date</th>
                        <th class="border-0">Sign</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($reports as $report)
                    <tr class="{{$report->is_entry_error ? 'entry-error' : ''}}">
                        <td class="border-bottom-0">{{$report->client->displayName()}}</td>
                        <td>
                            <a native target="_blank" href="{{route('patients.view.incoming-reports', ['patient' => $report->client, 'currentReport' => $report])}}" class="{{@$currentReport->uid === $report->uid ? 'font-weight-bold' : ''}}">
                                {{ $report->title ? $report->title : '(not set)' }}
                            </a>
                        </td>
                        <td>{{ $report->category }}{{ $report->subcategory ? ' / ' . $report->subcategory : '' }}</td>
                        <td>{{ friendly_date_time($report->report_date, false) }}</td>
                        <td>
                            @if(!$report->has_hcp_pro_signed)
                            -
                            @else
                            <div class="text-success mb-1">
                                <i class="fa fa-check"></i>
                                Signed
                            </div>
                            @if($report->hcp)
                            <div class="text-secondary">
                                <div class="text-sm font-weight-bold">{{$report->hcp->displayName()}}</div>
                                <div class="text-sm">{{friendlier_date_time($report->hcp_pro_signed_at)}}</div>
                            </div>
                            @endif
                            @endif
                        </td>
                    </tr>
                    @endforeach

                    @if(count($reports) === 0)
                    <tr>
                        <td colspan="5">No records found!</td>
                    </tr>
                    @endif
                </tbody>

            </table>

        </div>
    </div>
    <div class="mt-3">
        {{ $reports->appends(request()->input())->links() }}
    </div>
</div>
@endsection