<div class="d-flex align-items-end mb-3">
    <b class="large">Incoming Reports not signed</b>
</div>
<table class="table table-striped table-sm table-bordered mb-0">
    <thead>
    <tr>
        <th class="px-2 text-secondary">Created</th>
        <th class="px-2 text-secondary">Patient</th>
        <th class="px-2 text-secondary">Report</th>
        <th class="px-2 text-secondary">Sign</th>
        <th class="px-2 text-secondary">Title</th>
        <th class="px-2 text-secondary">Category</th>
        <th class="px-2 text-secondary">Memo</th>
    </tr>
    </thead>
    <tbody>
    @foreach($incomingReports as $document)
        <tr class="{{$document->is_entry_error ? 'entry-error' : ''}}">
            <td class="px-2 text-nowrap">
                <a href="/patients/view/{{$document->patient->uid}}/incoming-reports/{{$document->uid}}">
                    <i class="fa fa-arrow-right"></i>
                    {{friendlier_date_time($document->created_at)}}
                </a>
            </td>
            <td class="px-2 text-nowrap">
                <a href="/patients/view/{{$document->patient->uid}}/tickets/erx">
                    {{$document->patient->displayName()}}
                </a>
            </td>
            <td class="px-2">
                <div class="d-flex align-items-center">
                    <a class="pdf-viewer-trigger" native target="_blank"
                       href="/api/incomingReport/download/{{ $document->uid }}"
                       title="View">View</a>
                    @if($document->is_entry_error)
                        <span class="ml-auto text-danger on-hover-opaque" title="Entry Error">
                                    <i class="fa fa-exclamation-triangle"></i>
                                </span>
                    @endif
                </div>
            </td>
            <td class="px-2">
                @if(!$document->has_hcp_pro_signed)
                    @if($document->hcp_pro_id === $pro->id)
                        <div moe relative class="mr-2">
                            <a start show class="">Sign</a>
                            <form url="/api/incomingReport/signAsHcp" right>
                                <input type="hidden" name="uid" value="{{ $document->uid }}">
                                <p class="small">Are you sure you want to sign this report as HCP?</p>
                                <div class="d-flex align-items-center">
                                    <button class="btn btn-sm btn-success mr-2" submit>Sign</button>
                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                </div>
                            </form>
                        </div>
                    @else
                        -
                    @endif
                @else
                    <div class="text-success mb-1">
                        <i class="fa fa-check"></i>
                        Signed
                    </div>
                    @if($document->hcp)
                        <div class="text-secondary">
                            <div class="text-sm font-weight-bold">{{$document->hcp->displayName()}}</div>
                            <div class="text-sm">{{friendlier_date_time($document->hcp_pro_signed_at)}}</div>
                        </div>
                    @endif
                @endif
            </td>
            <td class="px-2">{{ $document->title }}</td>
            <td class="px-2">{{ $document->category }}{{ $document->subcategory ? ' / ' . $document->subcategory : '' }}</td>
            <td class="px-2">{{ $document->memo }}</td>
        </tr>
    @endforeach
    </tbody>
</table>