<button id="downloadCsv" class=" btn btn-primary" >
    Download CSV
</button>
<?php if(checkAPI()): ?>
    <h5>Total Online: <?php echo e($count); ?></h5>
    <div class="table-responsive">

        <table id="dataTable" class="table table-bordered table-striped">
            <thead class="custom-table-head">
                <tr>
                    <th scope="col"> User ID </th>
                    <th scope="col">Name</th>
                    <th scope="col"> Client IP </th>
                    <th scope="col"> NAS IP </th>
                    <th scope="col"> MAC Address </th>
                    <th scope="col"> Uptime </th>
                    <th scope="col"></th>
                </tr>
            </thead>
            <tbody class="bg-white divide-y divide-gray-200">
                <?php
                    $clientCount = 0;
                ?>
                <?php $__currentLoopData = $allMikrotikAndActiveUsers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mikrotikAndActiveUsers): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php $__currentLoopData = $mikrotikAndActiveUsers['activeUsers']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $client): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td>
                                <?php echo e($client['name']); ?>

                            </td>
                            <td><?php echo e($client['client_name']); ?></td>
                            <td>
                                <?php echo e($client['address']); ?>

                            </td>

                            <td>
                                <?php echo e($mikrotikAndActiveUsers['nasIp']); ?>

                            </td>

                            <td>
                                <?php echo e($client['caller-id']); ?>

                            </td>

                            <td>
                                
                                <?php echo e(formatUptime($client['uptime'])); ?>


                                
                            </td>

                            <td class="px-6 text-center text-sm font-medium">
                                <a href="<?php echo e(route('clients.show', $clients[$client['name']])); ?>"
                                    class="noprint btn btn-primary btn-xs btn-block mb-1">View live Traffice</a>
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('onlineUserDisconnection')): ?>
                                    <a href="<?php echo e(route('userDisconnect', $client['name'])); ?>"
                                        class="btn btn-danger">Disconnect</a>
                                <?php endif; ?>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>





                <!-- More items... -->
            </tbody>
        </table>

        <div class="p-5">
            
        </div>
    </div>
<?php else: ?>
    <h5>Total Online: <?php echo e($list->count()); ?></h5>
    
    <div class="table-responsive">
        <table id="dataTable" class="table table-bordered">
            <thead class="bg-gray-50">
                <tr>
                    <th scope="col"> User ID </th>
                    <?php if(checkSettings('client_name_in_online_list') == 'enable'): ?>
                        <th scope="col">Name</th>
                    <?php endif; ?>
                    <th scope="col"> Client IP </th>
                    <th scope="col"> NAS IP </th>
                    <th scope="col"> MAC Address </th>
                    <th scope="col"> Last Update </th>
                    <th scope="col"> Uptime </th>
                    <th>Date</th>
                    <th scope="col">Action</th>
                </tr>
            </thead>
            <tbody class="bg-white divide-y divide-gray-200">


                <?php $__currentLoopData = $list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td> <?php echo e($r->username); ?> </td>
                        <?php if(checkSettings('client_name_in_online_list') == 'enable'): ?>
                            <td> <?php echo e($r->clients_name ?? ''); ?> </td>
                        <?php endif; ?>
                        <td> <?php echo e($r->framedipaddress); ?> </td>
                        <td> <?php echo e($r->nasipaddress); ?> </td>
                        <td> <?php echo e($r->callingstationid); ?> </td>
                        <td> <?php echo e($r->acctupdatetime); ?></td>
                        <td> <?php echo e(\Carbon\Carbon::parse($r->acctstarttime)->diffForHumans()); ?> </td>
                        <td> <?php echo e($r->acctstarttime); ?> </td>

                        <td class="px-6 text-center text-sm font-medium">
                            <?php if(checkSettings('show-traffice') == 'enable'): ?>
                                <a href="<?php echo e(route('clients-with-userName', $r->username)); ?>"
                                    class="noprint btn btn-primary btn-xs btn-block  mb-1">View live Traffice</a>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('onlineUserDisconnection')): ?>
                                <a href="<?php echo e(route('onlineUserDisconnect')); ?>?id=<?php echo e($r->username); ?>"
                                    class="btn btn-danger">Disconnect</a>
                            <?php endif; ?>


                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                <!-- More items... -->
            </tbody>
        </table>

        <div class="p-5">
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('discount-online-all')): ?>
                <?php if($list->count() > 0): ?>
                    <a onclick="return confirm('Are you sure you want disconnect ?');" href="<?php echo e(route('disconnectAll')); ?>"
                        class="btn btn-danger float-right">Disconnect All</a>
                <?php endif; ?>
            <?php endif; ?>
            
        </div>
    </div>
<?php endif; ?>
<?php /**PATH /var/www/html/netlink/radius-circle/resources/views/clients/onlineofline/onlinesearch.blade.php ENDPATH**/ ?>