<?php $__env->startSection('content'); ?>
    <div class="card">

        <div class="card-body">
            <form action="<?php echo e(route('reseller.permissionUpdate', $reseller->id)); ?>" method="POST" id="package_assign_from">
                <?php echo method_field('PUT'); ?>
                <?php echo csrf_field(); ?>

                <input type="hidden" name="reseller_id" value="<?php echo e($reseller->id); ?>">



                <h2 class="font-bold text-center bg-gray-100 border-gray-100 text-3xl">Manager Name :
                    <?php echo e($reseller->name); ?></h2>

                <table class="table mt-5" id="custom_data_table">
                    <thead>

                        <tr class="bg-blue-300 text-center">
                            <th></th>
                            
                            <th>ID</th>
                            <th>Package Name</th>
                            <th>Package Rate</th>
                            <th><?php if(checkAPI()): ?> Profile Name <?php else: ?> Pool Name <?php endif; ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('specific_management_services')): ?>
                            <?php $__currentLoopData = $packages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php if(in_array($p->id, explode(',', $reseller->package_list)) == true): ?>
                                    <tr>

                                        <td>


                                            <input class="checkbox" id="package_<?php echo e($p->id); ?>" name="package_id[]"
                                                type="checkbox" value="<?php echo e($p->id); ?>"
                                                <?php if(in_array($p->id, explode(',', $reseller->package_list)) == true): ?> checked <?php endif; ?>>

                                        </td>
                                        <td><?php echo e($p->id); ?> </td>
                                        <td><?php echo e($p->package_name); ?> </td>
                                        <td class="text-center"><?php echo e($p->package_rate); ?> </td>
                                        <td class="text-center"><?php if(checkAPI()): ?> <?php echo e($p->profile_name); ?> <?php else: ?> <?php echo e($p->pool_name); ?> <?php endif; ?></td>

                                    </tr>
                                <?php endif; ?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php else: ?>
                            <?php $__currentLoopData = $packages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>

                                    <td>


                                        <input class="checkbox" id="package_<?php echo e($p->id); ?>" name="package_id[]"
                                            type="checkbox" value="<?php echo e($p->id); ?>"
                                            <?php if(in_array($p->id, explode(',', $reseller->package_list)) == true): ?> checked <?php endif; ?>>

                                    </td>
                                    <td><?php echo e($p->id); ?> </td>
                                    <td><?php echo e($p->package_name); ?> </td>
                                    <td class="text-center"><?php echo e($p->package_rate); ?> </td>
                                    <td class="text-center"><?php echo e($p->pool_name); ?> </td>

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



                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->denies('specific_management_services')): ?>
                    <div class="flex justify-between mt-5 bg-gray-200 p-2">
                        <a href="<?php echo e(route('resellers.index')); ?>" class="btn btn-default float-left"><i
                                class="fa fa-arrow-left"></i> Back</a>
                        
                        <input type="submit" class="btn btn-primary float-right" id="assign_package_btn"
                            value="Assign Package">
                    </div>
                <?php endif; ?>



                <div class="p-5 text-right">
                </div>

            </form>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('ajax'); ?>
    <script>
        $(function() {
            $('#select_all').on('click', function() {

                if (this.checked) {
                    $('.checkbox').each(function() { //loop through each checkbox
                        $(this).prop('checked', true); //check
                    });
                } else {
                    $('.checkbox').each(function() { //loop through each checkbox
                        $(this).prop('checked', false); //uncheck
                    });
                }

            });



            $('#custom_data_table').DataTable({
                responsive: true,
                "bProcessing": true,
                "iDisplayLength": 100000,
                'order': [
                    [0, "desc"]
                ]
            });

            var l = $('#custom_data_table_filter').find('input');
            l.keyup(function() {
                var value = $(this).val();
                if (value.length > 0) {
                    $('#select_all').prop('checked', false);
                }

            });

            $('#assign_package_btn').click(function(e) {
                e.preventDefault();
                $('#processing').show();

                $('#custom_data_table_filter').find('input').val('');
                $('#custom_data_table').DataTable().search('').draw();
                $('#package_assign_from').submit();
            });
        });
    </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/spacewalker/radius-circle/resources/views/reseller/package.blade.php ENDPATH**/ ?>