@extends ('layouts.company-client-layout')
@section('company-client-content')
<div class="mb-1 bg-light">
    <div class="row">
        <div class="col-md-12">
            <div>
                <div class="d-flex align-items-end pb-3">
                    <h4 class="font-weight-bold m-0">
                        Customer Records ({{ $customers->total()}})
                    </h4>
                    <span class="mx-2 text-secondary">|</span>
                    @include('app.patient.company-client.partials.create-company-client-customer-form')
                    <span class="mx-2 text-secondary">|</span>
                    @include('app.patient.company-client.partials.create-company-client-form')
                </div>
            </div>

        </div>
    </div>
</div>

<div>
    <div class="">
        <table class="table table-striped table-sm table-bordered mb-0">
            <thead class="bg-light">
                <tr>
                    <th class="border-0 text-secondary">Company</th>
                    <th class="border-0 text-secondary text-nowrap">Customer Balance</th>
                    <th class="border-0 text-secondary text-nowrap">Pending Invoices Balance</th>
                    <th class="border-0 text-secondary">Created At</th>
                    <th class="border-0 text-secondary">Portal</th>
                    <th class="border-0 text-secondary delete-column">&nbsp;</th>
                </tr>
            </thead>
            <tbody>
                @foreach($customers as $customer)
                    <tr>
                        <td>{{ $customer->company ? $customer->company->name : '--' }}</td>
                        <td>${{ friendly_money($customer->customer_balance) }}</td>
                        <td>${{ friendly_money($customer->pending_invoices_balance_total) }}</td>
                        <td>{{ friendly_date($customer->created_at) }}</td>
                        <td>
                        <!-- <a href="#" data-uid="{{$customer->uid}}" class="generate-and-visit-ic-portal" native target="_blank">Visit</a> -->
                        <a href="#" data-uid="{{$customer->uid}}" class="generate-and-copy-ic-portal-url ml-1" native target="_blank">Copy Url</a>
                        </td>
                        <td>
                            <div class="d-flex align-items-center">
                                @include('app.patient.company-client.partials.deactivate-reactivate-customer', ['record' => $customer])
                                <a href="{{ route('patients.view.customer', ['patient' => $patient, 'slug' => $customer->slug]) }}" class="ml-2">View</a>
                            </div>
                        </td>
                    </tr>
                @endforeach
                @if(!count($customers))
                    <tr>
                        <td colspan="6">
                            @include('app.patient.company-client.partials.create-company-client-customer-form', ['button' => 'btn btn-primary text-white'])
                        </td>
                    </tr>
                @endif
            </tbody>
        </table>
    </div>
</div>
@endsection