<?php $__env->startSection('content'); ?>

    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->denies('specific_management_services')): ?>
        <div class="card">
            <div class="card-body">
                <form action="<?php echo e(route('allClientDownloadExcel')); ?>" method="POST" id="search">
                    <?php echo csrf_field(); ?>

                    <div class="row">
                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    Manager Name
                                </label>
                                <select name="reseller" id="reseller" class="form-control select2 form-control-sm">
                                    <option value="all">ALL Manager</option>
                                    <?php $__currentLoopData = userResellers(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($r->id); ?>"><?php echo e($r->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    POP Name
                                </label>
                                <select name="pop" id="pop" class="form-control select2 form-control-sm" required>
                                    <option value="all"> ALL POP</option>

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

                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    Select Area
                                </label>
                                
                                <select name="area" id="poparea" class="form-control select2 form-control-sm">

                                </select>
                            </div>
                        </div>
                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    Billing Cycle
                                </label>
                                <select name="billing_cycle" id="billing_cycle" class="select2 form-control form-control-sm">
                                    <option value="all">ALL Billing Cycle</option>
                                    <?php $__currentLoopData = explode(',', $confday); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $conf): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($conf); ?>"><?php echo e($conf); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                                    
                                </select>

                            </div>
                        </div>
                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    User State
                                </label>
                                <select name="user_state" class="form-control form-control-sm">
                                    <option value="">ALL Customer Status</option>
                                    <option value="active">Active</option>
                                    <option value="disable">Disable</option>
                                    <option value="deactive">Deactive</option>
                                    <option value="expired">Expired</option>

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

                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    Cable Type
                                </label>
                                <select name="cable_type" id="cable_type" class="form-control select2 form-control-sm">
                                    <option value="">Select Cable Type</option>
                                    <option value="cat5">Cat 5</option>
                                    <option value="cat6">Cat 6</option>
                                    <option value="fiber_optic">Fiber Optic</option>
                                </select>

                            </div>
                        </div>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('search-by-package-name')): ?>
                            <div class="col-md-2 col-sm-3 col-xs-6">
                                <div class="form-group">
                                    <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                        Select Packages
                                    </label>
                                    <select name="mother_package" class="select2 form-control  form-control-sm" >
                                        <option value="">Select Package</option>
                                        <?php $__currentLoopData = $packages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $package): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($package->id); ?>"><?php echo e($package->package_name); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>

                                </div>
                            </div>
                        <?php endif; ?>
                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    Search By CID
                                </label>
                                <input class="form-control form-control-sm" name="user_id" type="text" placeholder="CID">
                            </div>
                        </div>
                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    Search By Username
                                </label>
                                <input class="form-control form-control-sm" name="value" type="text" placeholder="Username">
                            </div>
                        </div>
                        <?php if(checkSettings('customer_code') == 'enable'): ?>
                            <div class="col-md-2 col-sm-3 col-xs-6">
                                <div class="form-group">
                                    <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="code">
                                        Search By Code</label>
                                    <input class="form-control form-control-sm" name="code" type="text" placeholder="Code">
                                </div>
                            </div>
                        <?php endif; ?>
                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="name">Search By Name</label>
                                <input class="form-control form-control-sm" name="name" type="text" placeholder="Name">
                            </div>
                        </div>
                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    Search By Contact
                                </label>
                                <input class="form-control form-control-sm" name="contact" type="text" placeholder="01234567891">
                            </div>
                        </div>
                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    Search By Box
                                </label>
                                <input class="form-control form-control-sm" name="box" type="text" placeholder="">
                            </div>
                        </div>
                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    Search By Expire Date
                                </label>
                                <div class="input-group date" id="searchFrom" data-target-input="nearest">
                                    <input type="text" name="expire_date"
                                        class="form-control form-control-sm datetimepicker-input input-group-append"
                                        data-toggle="datetimepicker" data-target="#searchFrom" autocomplete="off">

                                </div>
                            </div>
                        </div>
                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    Static IP
                                </label>
                                <input class="form-control form-control-sm" name="static_ip" type="text" placeholder="">
                            </div>
                        </div>
                        <div class="col-md-2 col-sm-3 col-xs-6 mt-4">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="from_date">
                                    All Static IP User
                                </label>
                                <input class="" name="check_ip" type="checkbox" placeholder="">
                            </div>
                        </div>

                        <div class="col-md-2 col-sm-3 col-xs-6">
                            <div class="form-group">
                                <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="finance">
                                    Accounts Status
                                </label>
                                <select name="finance" class="select2 form-control  form-control-sm" >
                                    <option value="">Select One</option>
                                    <option value="withDue">With Due</option>
                                    <option value="withoutDue">Without Due</option>
                                </select>
                            </div>
                        </div>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('vip-client-search')): ?>
                            <div class="col-md-2 col-sm-3 col-xs-6">
                                <div class="form-group">
                                    <label class="flex-1 block text-gray-700 text-sm font-bold mb-2" for="experity_check">VIP</label>
                                    <select name="experity_check" class="select2 form-control form-control-sm">
                                        <option value="">Select One</option>
                                        <option value="vip">VIP</option>
                                    </select>
                                </div>
                            </div>
                        <?php endif; ?>
                        




                    </div>
                    <div class="form-group float-right">
                        <input type="hidden" name="changeType" value="packageChange">

                        <button @click="search" class="btn btn-primary" type="submit" id="searchBtn"><i
                                class="fa fa-search"></i> Search</button>
                        <button class="btn btn-info" type="reset" id="reset">Reset</button>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('allClientDownloadExcel')): ?>
                            <button type="submit" class="noprint btn btn-primary" >
                                <i class="fa fa-download"></i> Download Client
                            </button>
                        <?php endif; ?>
                    </div>

                </form>

            </div>
        </div>

        <div class="card">
            <div class="card-body">
                <div id="result">
                    
                </div>
            </div>
        </div>
    <?php endif; ?>







<?php $__env->stopSection(); ?>




<?php $__env->startSection('ajax'); ?>
    <script>
        $(window).on('hashchange', function() {
            if (window.location.hash) {
                var page = window.location.hash.replace('#', '');
                if (page == Number.NaN || page <= 0) {
                    return false;
                } else {
                    getPosts(page);
                }
            }
        });
        $(document).ready(function() {
            $(document).on('click', '.pagination a', function(e) {
                getPosts($(this).attr('href').split('page=')[1]);
                e.preventDefault();
            });
        });

        function getPosts(page) {
            $.ajax({
                url: 'clientSearchReport?page=' + page,
                dataType: 'html',
            }).done(function(data) {
                $('#result').html(data);
                location.hash = page;
            }).fail(function() {
                alert('Could not be loaded.');
            });
        }
    </script>


    <script type="text/javascript">
        function status(id, status) {
            if (confirm("Are you sure to change status?")) {
                url = "<?php echo e(url('/admin/')); ?>" + "/" + status + "/" + id;
                window.location.href = url;
            }

        }




        $(function() {

            $('#reset').click(function() {
                $('#result').html('');
                $('#pop').html('<option value="all">ALL POP</option>');
            });

            $('#searchBtn').on('click', function(e) {
                e.preventDefault();

                $('body').prepend('<div id="loading">Loading.....</div>');
                $.ajax({
                    type: 'get',
                    url: '<?php echo e(route('clientSearchReport')); ?>',
                    data: $('#search').serialize(),
                    dataType: "html",
                    success: function(result) {
                        $('#result').html(result);
                        $('#dataTable').DataTable({
                            'destroy': true,
                        });
                        $('#loading').remove();
                    }
                });
            });


            $('#reseller').on('change', function(e) {
                e.preventDefault();
                $('body').append('<div class="hidden" id="loading">Loading.....</div>');

                $.ajax({
                    type: 'get',
                    url: '<?php echo e(route('getResellerPopList')); ?>',
                    data: {
                        id: $(this).val()
                    },
                    success: function(result) {
                        $('#pop').html(result);
                        $('#loading').remove();

                    }
                });

                $.ajax({
                    type: 'get',
                    url: '<?php echo e(route('getResellerWiseArea')); ?>',
                    data: {
                        id: $(this).val()
                    },
                    success: function(result) {
                        $('#poparea').html(result);
                        $('#loading').remove();

                    }
                });
            });



            $('#pop').on('change', function(e) {
                // console.log('come here');
                e.preventDefault();
                $('body').append('<div class="hidden" id="loading">Loading.....</div>');

                $.ajax({
                    type: 'get',
                    url: '<?php echo e(route('getPopWiseAreaList')); ?>',
                    data: {
                        id: $(this).val()
                    },
                    success: function(result) {
                        // console.log(result);
                        $('#poparea').html(result);
                        $('#loading').remove();

                    }
                });

            });

            // $('#poparea').on('change', function(e) {
            //     console.log('come here');
            //     e.preventDefault();
            //     $('body').append('<div class="hidden" id="loading">Loading.....</div>');
            //     $('#pop').html('<option value="all">ALL POP</option>');
            //     $('#reseller').html('<option value="all">ALL Reseller</option>');
            // });



        });

        /*auto deactive date change start*/
        // const autoDeactiveDateApply = function(cid) {
        //     const cidOfClient = document.getElementById(`autoDeactiveId-${cid}`);
        //     const autoDeactiveDate = cidOfClient.getAttribute('data-autodeactive');
        //     const deactiveModalPropertiesCid = document.getElementById("deactive_client_id");
        //     const deactiveModalPropertiesAutoDate = document.getElementById("deactiveDate");

        //     if (autoDeactiveDate !== '01-Jan-1970') {
        //         deactiveModalPropertiesAutoDate.setAttribute("value", autoDeactiveDate);
        //     }
        //     deactiveModalPropertiesCid.setAttribute("value", cid);

        // }
        /*auto deactive date chnage end*/
        $(document).on('click', '.changeTemporaryExtend', function() {
            var id = $(this).attr('data-id');
            var extendedDay = $(this).attr('data-tmpExtend');
            $('#extend').val(extendedDay);
            $('#client_id').val(id);
        });
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layout.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/ers/radius-circle/resources/views/clients/clientSearch.blade.php ENDPATH**/ ?>