@extends ('layouts/empty')

@section('content')
    <div class="mcp-theme-1">
        <div class="card-body">

            <div class="mcp-theme-1">

                <div class="card">
                    <div class="card-body p-0">

                        <table class="table table-sm table-striped p-0 m-0">
                            <thead class="bg-light">
                            <tr>
                                <th class="border-0">Date</th>
                                <th class="border-0">Patient</th>
                                <th class="border-0">Insurance</th>
                                <th class="border-0">State</th>
                                <th class="border-0">Note</th>
                                <th class="border-0">HCP</th>
                                <th class="border-0">Company Pro</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($rows as $row)
                                <?php $note = \App\Models\Note::where('id', $row->note_id)->first(); ?>
                                <tr>
                                    <td>{{ friendly_date_time($row->created_at, true) }}</td>
                                    <td>
                                        <a native target="_blank" href="/patients/view/{{ $row->client->uid }}">{{ $row->client->displayName() }}</a>
                                    </td>
                                    <td>
                                        <?php $_cpc = $row->client->getPrimaryCoverage();?>
                                        @if($_cpc && $row->client->getPrimaryCoverageStatus() === 'YES')
                                            {{$_cpc->insuranceDisplayPayerName()}}
                                        @else
                                            No
                                        @endif
                                    </td>
                                    <td>
                                        {{$row->client->mailing_address_state}}
                                    </td>
                                    <td>
                                        <a native target="_blank" href="/patients/view/{{ $row->client->uid }}/notes/view/{{$note->uid}}">{{ $note->effective_dateest }}</a>
                                    </td>
                                    <td>{{ $note->hcpPro ? $note->hcpPro->displayName() : '-' }}</td>
                                    <td>
                                        <b>{{$row->hcpCompanyPro && $row->hcpCompanyPro->company ? $row->hcpCompanyPro->company->name : '-'}}</b>
                                        <div moe class="ml-1">
                                            <a class="text-primary" href="" show start>Edit</a>
                                            <form url="/api/bill/swapHcpCompanyPro">
                                                <input type="hidden" name="uid" value="{{$row->uid}}">
                                                <div class="mb-2">
                                                    <select name="hcpCompanyProUid" class="form-control form-control-sm">
                                                        <option value="">-- select --</option>
                                                        @foreach($row->hcp->companyPros as $companyPro)
                                                            <option value="{{$companyPro->uid}}">{{$companyPro->company->name}}</option>
                                                        @endforeach
                                                    </select>
                                                </div>
                                                <div class="mb-0">
                                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                                </div>
                                            </form>
                                        </div>
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        <div class="pt-3 px-3">
                            {{ $rows->links() }}
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
@endsection