<?php ($permissions = userPermissions()); ?>




<?php if(request()->is('admin*')): ?>

    <div class='topSearchbar ' id="search-result">
        <p class='d-fixed bg-inherit text-center border p-1 h5'>Total Search Result : <?php echo e($list->count()); ?> </p>

        <ul style='list-style:none;margin:0;padding:0'>
            <?php $__currentLoopData = $list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <li class="w-100 d-flex flex-column justify-content-between align-items-center border mb-2 py-1">

                    <div class="w-100 d-flex justify-content-between"
                        style="padding-left:6px !important; padding-right:6px !important;">

                        <div class="" style="width: 100% !important" id="userinfo-<?php echo e($data->id); ?>">
                            <p> <strong> User-name : </strong>
                                <span
                                    style="text-transform: capitalize; letter-spacing: 0.025em;"><?php echo e($data->clientsinfo->clients_name); ?></span>
                            </p>

                            <p style="margin-top:-10px;"> <strong>Phone</strong> <span>:</span>
                                <span
                                    style="font-variant-numeric: slashed-zero;"><?php echo e($data->clientsinfo->contact_no); ?></span>
                            </p>
                            <p class='' style="margin-top:-10px;"> <strong class="text-dark">User Id:</strong>
                                <?php echo e($data->userid); ?> </p>

                            <p class='text-danger' style="margin-top:-10px;"> <strong class="text-dark">Due:</strong>
                                <?php if($data->customerAccount): ?>
                                    <?php echo e($data->customerAccount->dueAmount); ?>

                                <?php else: ?>
                                    0
                                <?php endif; ?> Tk
                            </p>
                        </div>

                        <div class="actionContainer d-none flex-column justify-content-between align-items-start shadow-sm border p-1 "
                            style="row-gap: 1.5px; max-height:130px; overflow-y:scroll; width:30% !important; display:none !important; "
                            id="topoverMenu-<?php echo e($data->id); ?>">

                            <?php if(in_array('mac-customer_edit', $permissions)): ?>
                                <a href="<?php echo e(route('clients.edit', $data->id)); ?>" class="btn btn-xs  btn-edit">Edit</a>
                            <?php endif; ?>

                            <?php if(in_array('mac-customer_edit', $permissions)): ?>
                                <a href="<?php echo e(route('clients.show', $data->id)); ?>"
                                    class="btn btn-xs  btn-details">Details</a>
                            <?php endif; ?>


                            <?php if(in_array('changeBillCycle', $permissions)): ?>
                                <button type="button" class="btn btn-xs btn-bill-change clientBillCycleChange"
                                    data-toggle="modal" data-id="<?php echo e($data->id); ?>"
                                    data-curdate=<?php echo e($data->billing_cycle); ?> data-target="#billCycleChange">
                                    B.Change
                                </button>
                            <?php endif; ?>


                            <?php if(in_array('changePackage', $permissions)): ?>
                                <a href="" data-clientid="<?php echo e($data->id); ?>"
                                    class="btn  btn-xs btn-pac-change package_change_action_btn" data-toggle="modal"
                                    data-target="#package_change_modal" role="button">P.Change</a>
                            <?php endif; ?>


                            <?php if($data->clients_status == 'disable'): ?>
                                
                                <?php if(in_array('id-enable', $permissions)): ?>
                                    <a href="#" class="btn  btn-xs btn-dis idEnable"
                                        data-id="<?php echo e($data->id); ?>" id="<?php echo e($data->id); ?>">Enable</a>
                                <?php endif; ?>
                            <?php endif; ?>


                            <?php if($data->clients_status != 'disable'): ?>
                                <?php if(in_array('id-disable', $permissions)): ?>
                                    <a href="#" class="btn  btn-xs btn-dis idDisable confirmDisable"
                                        data-id="<?php echo e($data->id); ?>" id="<?php echo e($data->id); ?>"
                                        role="button">Disable</a>
                                <?php endif; ?>
                            <?php endif; ?>


                            <?php if($data->clients_status != 'deactive'): ?>
                                <?php if(in_array('customer-deactivated', $permissions)): ?>
                                    <a href="#" class="btn  btn-xs btn-dec id_deactive"
                                        data-id="<?php echo e($data->id); ?>" id="deactive<?php echo e($data->id); ?>">Deactive
                                    </a>
                                <?php endif; ?>
                            <?php endif; ?>

                            <?php if($data->clients_status == 'deactive'): ?>
                                <?php if(in_array('customer-reactivate', $permissions)): ?>
                                    <a href="#" data-id="<?php echo e($data->id); ?>" id="reactive<?php echo e($data->id); ?>"
                                        class=" btn  btn-xs btn-dec id_reactive">Reactive
                                    </a>
                                <?php endif; ?>
                            <?php endif; ?>

                            <?php if(in_array('can-close', $permissions)): ?>
                                <?php if(request()->path() != 'admin/pending-customer'): ?>
                                    <?php if($data->deleted_at == null): ?>
                                        <a href="#" class="btn  btn-xs btn-close idClose"
                                            data-id="<?php echo e($data->id); ?>">Close</a>
                                    <?php else: ?>
                                    <?php endif; ?>
                                <?php endif; ?>
                            <?php endif; ?>


                            <?php if(in_array('mac-customer_destroy', $permissions)): ?>
                                <button class="btn  btn-xs btn-dis idDestroy"
                                    data-id="<?php echo e($data->id); ?>">Delete</button>
                            <?php endif; ?>

                        </div>

                    </div>

                    <div class="d-flex justify-content-between align-items-center w-100 border-top px-1"
                        style=" column-gap:3.5px; height:30px;">
                        <a href="<?php echo e(route('getPaymentHistory', ['id' => $data->id])); ?>"
                            class='btn w-100 btn-xs border text-space' style="background: #65a30d; color:#FFFFFF;"> CID
                            <?php echo e($data->id); ?>

                        </a>

                        <?php if(auth()->user()->hasRole('Admin|Billing Man')): ?>
                            
                            <?php if($data->pop->bill_generate == 'yes'): ?>
                                <button data-package_rate="<?php echo e($data->packages->package_rate ?? 0); ?>"
                                    data-billing_type = "<?php echo e(getBillingType()); ?>" data-id="<?php echo e($data->id); ?>" data-userid="<?php echo e($data->userid); ?>"
                                    <?php if($data->customerAccount != null): ?> data-amount="<?php echo e($data->customerAccount->dueAmount > 0 ? $data->customerAccount->dueAmount : 0); ?>" <?php endif; ?>
                                    type="button" class="btn btn-danger ajaxPayment btn-xs btn-block text-nowrap"
                                    data-toggle="modal" data-target="#paymentModal">
                                    Payment
                                </button>
                            <?php else: ?>
                                <?php if(in_array('customer-recharge', $permissions)): ?>
                                    <?php if(checkSettings('reseller-client-dynamic-recharge') == 'enable' && in_array('dynamic-recharge', $permissions)): ?>
                                    <?php else: ?>
                                        <?php if($data->client_approval == 'approved'): ?>
                                            <button data-id="<?php echo e($data->id); ?>" type="button"
                                                class="btn btn-dark ajaxRecharge btn-xs btn-block text-nowrap">
                                                Rechage
                                            </button>
                                        <?php endif; ?>
                                    <?php endif; ?>
                                <?php endif; ?>
                            <?php endif; ?>
                        <?php endif; ?>


                        <a href="<?php echo e(route('send-sms-single', $data->id)); ?>"
                            class='  btn w-100 btn-xs border text-space' style="background: #f3f4f6;">
                            SMS </a>


                            <?php if(in_array('mac-customer_edit', $permissions)): ?>
                            <a href="<?php echo e(route('clients.edit', $data->id)); ?>" class="btn w-100 btn-xs  border text-space bg-primary">Edit</a>
                        <?php endif; ?>

                        <div class="">
                            <a class="btn w-100 btn-xs dropdown-toggle d-none" href="#" role="button"
                                id="overMenuLink-<?php echo e($data->id); ?>" onclick="getActionInfo(<?php echo e($data->id); ?>)"
                                style="background:
                        #15803d; color:#FFFFFF;">
                                Action
                            </a>
                        </div>
                    </div>

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


    </div>
<?php else: ?>
    <div></div>

<?php endif; ?>


<style>
    #search-result::-webkit-scrollbar {
        width: 6px;

    }


    #search-result::-webkit-scrollbar-track {
        background: #f1f1f1;

    }

    #search-result::-webkit-scrollbar-thumb {
        background: #888;

        border-radius: 2.5px;

    }

    #search-result::-webkit-scrollbar-thumb:hover {
        background: #555;

    }

    #search-result::-webkit-scrollbar {
        width: 6px;

    }

    .actionContainer::-webkit-scrollbar {
        width: 2px;

    }


    .actionContainer::-webkit-scrollbar-track {
        background: #f1f1f1;

    }

    .actionContainer::-webkit-scrollbar-thumb {
        background: #888;

        border-radius: 4.5px;

    }

    .actionContainer::-webkit-scrollbar-thumb:hover {
        background: #555;

    }

    .actionContainer::-webkit-scrollbar {
        width: 2px;

    }

    .actionContainer {
        overflow-x: hidden;
    }

    .actionContainer>a,
    .actionContainer>button {
        width: 100% !important;
        border: 0.75px solid gray;
        letter-spacing: 0.1em;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        color: #FFFFFF;
    }

    .btn-edit {
        background-color: rgb(21 128 61 / 0.8);
    }

    .btn-bill-change {
        background-color: rgb(126 34 206 / 0.8);
    }

    .btn-pac-change {
        background-color: rgb(77 124 15 / 0.8);
    }

    .btn-dis {
        background-color: rgb(190 18 60 / 0.8);
    }

    .btn-dec {
        background-color: rgb(2 6 23 / 0.8);
    }

    .btn-dec:hover {
        background-color: rgb(2 6 23 / 0.8);
        color: #FFFFFF;
    }

    .btn-del {
        background-color: rgb(185 28 28 / 0.8);
    }

    .btn-close {
        background-color: rgb(76 5 25 / 0.8);

    }

    .btn-details {
        background-color: rgb(76 15 25 / 0.8);
    }

    .btn-close:hover {
        background-color: rgb(76 5 25 / 0.8);
        color: #FFFFFF;
    }
</style>

<script>
    function getActionInfo(id) {
        const userInfo = document.getElementById(`userinfo-${id}`);
        const actionMenu = document.getElementById(`topoverMenu-${id}`);
        userInfo.style.width = "70%";
        actionMenu.style.display = "block";

    }

    window.addEventListener('click', function(event) {
        let searchResultDiv = document.getElementById('search-result');
        if (event.target !== searchResultDiv && !searchResultDiv.contains(event.target)) {
            searchResultDiv.style.display = 'none';

        }

    });
</script>
<?php /**PATH /var/www/html/pbn/radius-circle/resources/views/clients/topSearchResult.blade.php ENDPATH**/ ?>