<!DOCTYPE HTML>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <style type="text/css">
        table {
            page-break-inside: auto
        }

        tr {
            page-break-inside: avoid;
            page-break-after: auto
        }

        thead {
            display: table-header-group
        }

        tfoot {
            display: table-footer-group
        }
    </style>
</head>

<body onload="window.print()" onfocus="window.close()">

    <style>
        @media print {

            thead th {
                font-size: 15px !important;
                border: 1px solid #ddd;
            }

            .searchClient,
            #pop,
            button {
                visibility: hidden;
            }

            table {
                /* width: ; */
            }

            /* table tr th, */
            table,
            tr,
            thead th,
            td {
                font-size: 9px !important;
                padding: 2px !important;
                border: 1px solid #010a02;
                border-collapse: collapse;
            }

        }

        .container {
            width: 940px;
            margin: 0 auto;
            padding: 10px;
        }

        .table {

            border-collapse: collapse;
            width: 100%;
            border: 1px solid #4CAF50;
        }

        h2 {
            text-align: center;
        }

        table {
            border-collapse: collapse;
            width: 100%;
        }

        th,
        td {
            border: 1px solid #bbb;
            padding: 10px;
            text-align: left;
        }

        tr:hover {
            background-color: #e5e5e5
        }
    </style>
    <div class="flex flex-col mt-5" id="bodyBox">
        <div class=" bg-white p-6 rounded-lg">

            <div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
                <div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
                    <div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg">
                        <button type="button" onclick="window.print()">Print
                            <i class="fa fa-print"></i>
                        </button>
                        <div class="block searchClient hidden">
                            <input type="text" name="clientSearch"
                                class="py-2 px-4 m-2 border border-gray-300 float-right" placeholder="Search User">
                        </div>
                        @if(isset($print_url) && !empty($print_url))
                        <a href="{{ route($print_url) }}" target="_blank"><i class="fa fa-print"></i></a>
                        @endif



                        {{-- //razib --}}
                        @if( request()->type !='all')
                        @foreach($poplist as $pop)
                        @if($pop->id == request()->type)
                        <h2 class="text-center bold text-xl font-bold pb-5 mt-5 pop{{$pop->id}}">View Expired Customer
                            Billing
                            Information Of: {{$pop->popname}} ( {{ date('M-Y') }} )</h2>
                        @endif
                        @endforeach
                        <hr>
                        <table id="dataTable" class="min-w-full divide-y divide-gray-200 pt-2 pop{{$pop->id}}">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        ID
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        User name
                                    </th>
                                    <th scope="col"
                                        class="noprint px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Password
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Status
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Expire
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Bill Cycle
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Bill Amount
                                    </th>
                                    {{-- <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        OTC
                                    </th> --}}
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Package
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        POP
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Name
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Address
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Contact
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Created Date
                                    </th>
                                    {{-- <th scope="col"
                                        class="noprint px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                    </th> --}}
                                </tr>
                            </thead>
                            <tbody class="bg-white divide-y divide-gray-200">
                                @foreach ($list as $r)
                                {{-- {{dd($r)}} --}}
                                <tr @if($r->clients_status == 'deactive') class="deactive" @endif>
                                    <td>
                                        @php(printf("CID%04d",$r->id))
                                    </td>
                                    <td>
                                        {{$r->userid}}
                                    </td>
                                    <td class="noprint">
                                        {{$r->password}}
                                    </td>
                                    <td @if($r->clients_status == 'expired') class="deactive" @endif>
                                        @if($r->client_approval == 'pending')
                                        {{ $r->client_approval }}
                                        @else
                                        <x-Custom.Status status="{{ $r->clients_status }}" />
                                        @endif
                                    </td>
                                    <td class="whitespace-nowrap">
                                        {{ date('d-M-Y',strtotime($r->expire_date)) }}
                                    </td>
                                    <td>
                                        {{$r->billing_cycle}}
                                    </td>
                                    <td>
                                        {{$r->package_rate}}
                                    </td>
                                    {{-- <td>
                                        {{$r->otc}}
                                    </td> --}}
                                    <td>
                                        {{$r->package_name}}
                                    </td>
                                    <td>
                                        {{ $r->popname ?? '' }}
                                    </td>
                                    <td>
                                        {{ $r->clients_name ?? ''}}
                                    </td>
                                    <td style="max-width:250px;">
                                        <p style="font-size:12px;">Flat No: {{$r->flat_no ?? ''}} ,
                                            Building Name: {{ $r->building_name ?? ''}} ,<br>
                                            Road No: {{ $r->road_no ?? '' }} ,<br>
                                            Block/Sector: {{ $r->block_sector ?? '' }} ,
                                            Area : {{ $r->area ?? '' }} </p>
                                    </td>
                                    <td>
                                        {{$r->contact_no ?? ''}}
                                    </td>
                                    <td class="whitespace-nowrap">
                                        {{ date('d-M-Y',strtotime($r->created_at)) }}
                                    </td>

                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                        @else
                        @foreach($poplist as $pop)
                        <h2 class="text-center bold text-xl font-bold pb-5 mt-5 pop{{$pop->id}}">View Expired Customer
                            Billing
                            Information Of: {{$pop->popname}} ( {{ date('M-Y') }} )</h2>
                        <hr>
                        <table id="dataTable" class="min-w-full divide-y divide-gray-200 pt-2 pop{{$pop->id}}">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        ID
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        User name
                                    </th>
                                    <th scope="col"
                                        class="noprint px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Password
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Status
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Expire
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Bill Cycle
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Bill Amount
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        OTC
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Package
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        POP
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Name
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Address
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Contact
                                    </th>
                                    <th scope="col"
                                        class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        Created Date
                                    </th>
                                    <th scope="col"
                                        class="noprint px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                    </th>
                                </tr>
                            </thead>
                            <tbody class="bg-white divide-y divide-gray-200">
                                @foreach ($list as $r)
                                @if($r->pop_id == $pop->id)
                                {{-- {{dd($r)}} --}}
                                <tr @if($r->clients_status == 'deactive') class="deactive" @endif>
                                    <td>
                                        @php(printf("CID%04d",$r->id))
                                    </td>
                                    <td>
                                        {{$r->userid}}
                                    </td>
                                    <td class="noprint">
                                        {{$r->password}}
                                    </td>
                                    <td @if($r->clients_status == 'expired') class="deactive" @endif>
                                        @if($r->client_approval == 'pending')
                                        {{ $r->client_approval }}
                                        @else
                                        <x-Custom.Status status="{{ $r->clients_status }}" />
                                        @endif
                                    </td>
                                    <td class="whitespace-nowrap">
                                        {{ date('d-M-Y',strtotime($r->expire_date)) }}
                                    </td>
                                    <td>
                                        {{$r->billing_cycle}}
                                    </td>
                                    <td>
                                        {{$r->package_rate}}
                                    </td>
                                    <td>
                                        {{-- {{$r->otc}} --}}
                                    </td>
                                    <td>
                                        {{$r->package_name}}
                                    </td>
                                    <td>
                                        {{ $r->popname ?? '' }}
                                    </td>
                                    <td>
                                        {{ $r->clients_name ?? ''}}
                                    </td>
                                    <td style="max-width:250px;">
                                        <p style="font-size:12px;">Flat No: {{$r->flat_no ?? ''}} ,
                                            Building Name: {{ $r->building_name ?? ''}} ,<br>
                                            Road No: {{ $r->road_no ?? '' }} ,<br>
                                            Block/Sector: {{ $r->block_sector ?? '' }} ,
                                            Area : {{ $r->area ?? '' }} </p>
                                    </td>
                                    <td>
                                        {{$r->contact_no ?? ''}}
                                    </td>
                                    <td class="whitespace-nowrap">
                                        {{ date('d-M-Y',strtotime($r->created_at)) }}
                                    </td>

                                </tr>
                                @endif
                                @endforeach
                            </tbody>
                        </table>

                        @endforeach
                        @endif

                        <div class="p-5">
                            @if(isset($paginate) && $paginate !== false ))
                            {{  $list->links()  }}
                            @endif
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        window.onload = function() { window.print(); }
        window.onfocus=function(){ window.close(); }
    </script>
</body>

</html>