<form
    action="<?php if(!empty($packages)): ?> <?php echo e(route('batchUserPackageChange')); ?> <?php else: ?> <?php echo e(route('batchUserBillingCycleChange')); ?> <?php endif; ?>"
    method="POST" class="flex flex-wrap" id="batchUserPackageChange">
    <?php echo csrf_field(); ?>
    
    <input type="hidden" name="client_ids[]" id="client_ids">
    <input type="hidden" id="uuid" name="uuid" value="<?php echo e(createUUID()); ?>">
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead style="background: #78716C;color:white;">
                <tr>
                    <th class="text-center">
                        <input type="checkbox" id="allSelect">
                    </th>
                    <th scope="col" class="">
                        ID
                    </th>

                    <th scope="col" class="">
                        User name
                    </th>

                    <th scope="col" class="">
                        Expire Date
                    </th>

                    <th scope="col" class="">
                        Bill Cycle
                    </th>

                    <?php if(!auth()->check() || ! auth()->user()->hasRole('Sub Reseller')): ?>
                        <th scope="col" class="">
                            Package
                        </th>
                    <?php endif; ?>
                    <th scope="col" class="">
                        Sub Package
                    </th>

                    <th scope="col" class="">
                        Contact No
                    </th>


                </tr>
            </thead>
            <tbody class="">
                
                <?php $__empty_1 = true; $__currentLoopData = $r; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td class="text-center">
                            <input type="checkbox" class="checkbox new_class_for_client_id_of_pending" name="id[]"
                                value="<?php echo e($row->id); ?>">
                        </td>
                        <td>
                            
                            <?php echo e($row->id); ?>

                        </td>
                        <td>
                            <?php echo e($row->userid); ?>

                        </td>

                        <td class="whitespace-nowrap">
                            <?php echo e(date('d-M-Y', strtotime($row->expire_date))); ?>

                        </td>


                        <td>
                            <?php echo e($row->billing_cycle); ?>

                        </td>
                        <?php if(!auth()->check() || ! auth()->user()->hasRole('Sub Reseller')): ?>
                            <td>
                                <?php echo e($row->packages->package_name); ?>

                            </td>
                        <?php endif; ?>

                        <td>
                            <?php if($row->subpack): ?>
                                <?php echo e($row->subpack->name); ?>

                            <?php endif; ?>
                        </td>

                        <td>
                            <?php echo e($row->clientsinfo->contact_no ?? ''); ?>

                        </td>
                        
                    </tr>

                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <?php endif; ?>

                <?php if(!empty($packages)): ?>
                    <tr>
                        <td colspan="8">
                            <div class="row">
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('batch-package-change-without-cost')): ?>
                                    <div class="col-sm-2">
                                        <label class="flex-1 block text-gray-700 text-sm font-bold mb-2"
                                            for="change_pack_without_cost">
                                            Change Package Without Cost
                                        </label>
                                    </div>
                                    <div class="col-sm-2">
                                        <select name="change_pack_without_cost" id="change_pack_without_cost"
                                            class="form-control">
                                            <option value="no">No</option>
                                            <option value="yes">Yes</option>
                                        </select>
                                    </div>
                                <?php endif; ?>
                                <div class="col-sm-4"></div>
                                <div class="col-sm-2">

                                    <?php if($row->pop->subreseller == 'yes'): ?>

                                        <select name="package_id" class="form-control" required>
                                            <option value="">Select</option>
                                            <?php $__currentLoopData = $packages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($p->id); ?>">
                                                    (<?php echo e($p->id); ?>)
                                                    - <?php echo e($p->name); ?> <?php if(globalPermission('package-change-price-show')): ?>
                                                        (<?php echo e($p->rate); ?> TK) (s)
                                                    <?php endif; ?>
                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                        </select>
                                    <?php else: ?>
                                        <select name="package_id" class="form-control" required>
                                            <option value="">Select</option>
                                            <?php $__currentLoopData = $packages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($p->id); ?>">
                                                    (<?php echo e($p->id); ?>)
                                                    - <?php echo e($p->package_name); ?>

                                                    <?php if(globalPermission('package-change-price-show')): ?>
                                                        (<?php echo e($p->package_rate); ?> TK)
                                                    <?php endif; ?>
                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                        </select>

                                    <?php endif; ?>

                                </div>

                                <div class="col-sm-2">
                                    
                                    <button class="btn btn-primary" id="changePack">Change Package</button>
                                </div>
                            </div>


                        </td>
                    </tr>
                <?php else: ?>
                    <tr>
                        <td colspan="8">

                            <div class="container-fluid " style="background: #d8b4fe;">
                                <div class="row border  p-2">
                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('change-billing-cycle-without-cost')): ?>
                                        <div class="col-sm-2">
                                            <label class="flex-1 block text-gray-700 text-sm font-bold mb-2"
                                                for="change_without_cost">
                                                Change Without Cost
                                            </label>
                                        </div>
                                        <div class="col-sm-2">
                                            <select name="change_without_cost" id="change_without_cost"
                                                class="form-control">
                                                <option value="no">No</option>
                                                <option value="yes">Yes</option>
                                            </select>
                                        </div>
                                    <?php endif; ?>
                                    <div class="col-sm-4"></div>
                                    <div class="col-sm-2 border " id="billCycle">
                                        <select name="billCycle" class="form-control" required>
                                            <option value="">Select Cycle</option>
                                            <?php $__currentLoopData = explode(',', $confday); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($item); ?>">
                                                    <?php echo e($item); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                    <div class="col-sm-2" id="expireDate" style="display: none">
                                        <input type="date" class="form-control" name="expire_date">
                                    </div>

                                    <div class="col-sm-2">
                                        
                                        <button class="btn btn-primary" id="changePack">Billing Cycle Change</button>
                                    </div>
                                </div>
                            </div>

                        </td>
                    </tr>

                <?php endif; ?>

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

<script>
    $(function() {
        $('#allSelect').on('click', function() {
            if (this.checked) {
                $('.new_class_for_client_id_of_pending').each(function() {
                    $(this).prop('checked', true); //check
                });
            } else {
                $('.new_class_for_client_id_of_pending').each(function() {
                    $(this).prop('checked', false); //uncheck
                });
            }
        });

        $('#changePack').on('click', function(e) {
            $('#changePack').prop('disabled', true);
            e.preventDefault();
            var ids = [];
            $('.new_class_for_client_id_of_pending').each(function() {
                id = $(this).filter(':checked').val();
                if (id != null) {
                    ids.push(id);
                }
            });
            $('#client_ids').val(ids);
            $('#batchUserPackageChange').submit();
        });

        $('#change_without_cost').on('change', function() {

            let type_val = $('#change_without_cost').val();

            if (type_val == 'yes') {
                $('#billCycle').hide();
                $('#expireDate').show();
            } else {
                $('#billCycle').show();
                $('#expireDate').hide();
            }
        });

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