@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 HCP</th>
                                <th class="border-0">Company Pro</th>
                                <th class="border-0">Company<br>Pro Payer</th>
                                <th class="border-0">Company<br>Location</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($rows as $row)
                                <tr>
                                    <td>{{ friendly_date_time($row->effective_dateest, true) }}</td>
                                    <td>
                                        <a native target="_blank" href="/patients/view/{{ $row->client->uid }}/notes/view/{{$row->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>{{ $row->hcpPro ? $row->hcpPro->displayName() : '-' }}</td>
                                    <td>

                                        <b>{{$row->hcpCompanyPro && $row->hcpCompanyPro->company ? $row->hcpCompanyPro->company->name : '-'}}</b>
                                        @if($row->hcpCompanyPro && $row->hcpCompanyPro->company)
                                            <div moe class="ml-1">
                                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
                                                <form url="/api/note/wipeHcpCompanyPro">
                                                    <input type="hidden" name="uid" value="{{$row->uid}}">
                                                    <p>Wipe company pro from this note?</p>
                                                    <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>
                                        @else
                                            <div moe class="ml-1">
                                                <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
                                                <form url="/api/note/putHcpCompanyPro">
                                                    <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>
                                                            @if($row->hcpPro)
                                                                @foreach($row->hcpPro->companyPros as $companyPro)
                                                                    <option value="{{$companyPro->uid}}">{{$companyPro->pro->displayName() . ' / ' . $companyPro->company->name}}</option>
                                                                @endforeach
                                                            @endif
                                                        </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>
                                        @endif

                                    </td>
                                    <td>
                                        @if($row->hcpCompanyPro && $row->hcpCompanyPro->company)

                                            <div class="d-flex align-items-baseline mb-1">
                                                <div class="">
                                                    <b>{{$row->hcpCompanyProPayer && $row->hcpCompanyProPayer->payer ? $row->hcpCompanyProPayer->payer->name : '-'}}</b>
                                                    @if($row->hcpCompanyProPayer && $row->hcpCompanyProPayer->payer)
                                                        <div moe class="ml-1">
                                                            <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
                                                            <form url="/api/note/wipeHcpCompanyProPayer">
                                                                <input type="hidden" name="uid" value="{{$row->uid}}">
                                                                <p>Wipe payer from this note?</p>
                                                                <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>
                                                    @else
                                                        <div moe class="ml-1">
                                                            <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
                                                            <form url="/api/note/putHcpCompanyProPayer">
                                                                <input type="hidden" name="uid" value="{{$row->uid}}">
                                                                <div class="mb-2">
                                                                    <select name="hcpCompanyProPayerUid" class="form-control form-control-sm">
                                                                        <option value="">-- select --</option>
                                                                        @foreach($row->hcpCompanyPro->companyProPayers as $companyProPayer)
                                                                            <option value="{{$companyProPayer->uid}}">{{$companyProPayer->payer->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>
                                                    @endif
                                                </div>
                                            </div>

                                        @endif
                                    </td>
                                    <td>
                                        @if($row->hcpCompanyPro && $row->hcpCompanyPro->company)


                                            <div class="d-flex align-items-baseline mb-1">
                                                <div class="">
                                                    <b>{{$row->hcpCompanyLocation ? $row->hcpCompanyLocation->line1 . ', ' . $row->hcpCompanyLocation->city : '-'}}</b>
                                                    @if($row->hcpCompanyLocation)
                                                        <div moe class="ml-1">
                                                            <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
                                                            <form url="/api/note/wipeHcpCompanyLocation">
                                                                <input type="hidden" name="uid" value="{{$row->uid}}">
                                                                <p>Wipe location from this note?</p>
                                                                <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>
                                                    @else
                                                        <div moe class="ml-1">
                                                            <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
                                                            <form url="/api/note/putHcpCompanyLocation">
                                                                <input type="hidden" name="uid" value="{{$row->uid}}">
                                                                <div class="mb-2">
                                                                    <select name="hcpCompanyLocationUid" class="form-control form-control-sm">
                                                                        <option value="">-- select --</option>
                                                                        @if($row->hcpCompany && $row->hcpCompany->locations)
                                                                            @foreach($row->hcpCompany->locations as $location)
                                                                                <option value="{{$location->uid}}">{{$location->line1 . ', ' . $location->city}}</option>
                                                                            @endforeach
                                                                        @endif
                                                                    </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>
                                                    @endif
                                                </div>
                                            </div>
                                        @endif
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        <div class="pt-3 px-3">
                            {{ $rows->links() }}
                        </div>
                    </div>
                </div>

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