@extends('layouts.invoice-center')
@section('inner-content')
    <div class="d-flex mb-2 pb-2 align-items-center border-bottom">
        <div class="font-size-14 font-weight-bold">Companies</div>
    </div>
    @if(count($records))
        <table class="table table-sm table-bordered table-striped">
            <thead>
            <tr>
                <th class="border-bottom-0"></th>
                <th class="border-bottom-0 width-300px">Name</th>
                <th class="border-bottom-0">State</th>
                <th class="border-bottom-0">Customers</th>
                <th class="border-bottom-0">Vouchers</th>
                <th class="border-bottom-0">Created</th>
            </tr>
            </thead>
            <tbody>
            <?php $i = 1; ?>
            @foreach($records as $record)
                <tr>
                    <td>{{ $i++ }}</td>
                    <td>{{ $record->name }}</td>
                    <td>{{ $record->state }}</td>
                    <td>
                        <a href="{{route('invoice-center.customers')}}?companyUid={{$record->uid}}"
                           class="mr-2"
                           open-in-stag-popup
                           update-parent
                           title="{{$record->name}}: Customers"
                           popup-style="stag-popup-med overflow-visible"
                           mc-initer="invoice-center">{{count($record->customers)}} customer{{count($record->customers) === 1 ? '' : 's'}}</a>
                    </td>
                    <td>
                        <a href="{{route('invoice-center.giftCards')}}?companyUid={{$record->uid}}"
                           class="mr-2"
                           open-in-stag-popup
                           update-parent
                           title="{{$record->name}}: Vouchers"
                           popup-style="stag-popup-med overflow-visible"
                           mc-initer="invoice-center">{{count($record->giftCards)}} voucher{{count($record->giftCards) === 1 ? '' : 's'}}</a>
                    </td>
                    <td>{{ friendly_date($record->created_at) }}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
        {{$records->withQueryString()->links()}}
    @else
        <div class="text-secondary">No companies yet!</div>
    @endif
@endsection