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


        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
   
                    <div class="table-responsive">
                        <table class="table table-striped mb-0">

                            <thead>
                                <tr>
                                    <th><input class="" type="checkbox" id="selectallcheckboxs"></th>
                                    <th>شماره</th>
                                    <th>نام</th>
                                    <th>حالت</th>
                                    <th>وضعیت</th>
                                    <th>تغییرات</th>
                                </tr>
                            </thead>
                            <tbody>
                                <form action="<?php echo e(route('admin.deletegroupfilds')); ?>" method="post">
                                    <button id="groupdeletebtn" style="margin-bottom: 20px;display: none;" type="submit"
                                        class="btn btn-outline-primary waves-effect waves-light">حذف موارد انتخاب
                                        شده</button>
                                    <?php echo csrf_field(); ?>

                                    <?php $__currentLoopData = $filds; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $fild): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        
                                        <tr>
                                            <th>
                                                <?php if($fild->Status == 3): ?>
                                                    <i class="bx bx-checkbox-square"></i>
                                                <?php else: ?>
                                                    <input class="defaultCheck" name="deletedata[]" type="checkbox"
                                                        value="<?php echo e($fild->id); ?>" id="checkboxs">
                                                <?php endif; ?>
                                            </th>
                                            <th scope="row"><?php echo e($loop->index + 1); ?></th>
                                            <td><?php echo e($fild->Name); ?></td>
                                            <td>
                                                <?php if($fild->Type == 1): ?>
                                                    متن
                                                <?php elseif($fild->Type == 2): ?>
                                                    عدد
                                                <?php endif; ?>
                                            </td>
                                            <td>
                                                <?php if($fild->Status == 1): ?>
                                                    مزایا
                                                <?php elseif($fild->Status == 2): ?>
                                                    کسورات
                                                <?php elseif($fild->Status == 3): ?>
                                                    متفرقه
                                                <?php endif; ?>
                                            </td>
                                            <td>
                                                <a href="" data-toggle="modal"
                                                    data-target=".bs-example-modal-lg<?php echo e($fild->id); ?>">حذف</a>

                                                <!--  Modal content for the above example -->
                                                <div class="modal
                                                fade bs-example-modal-lg<?php echo e($fild->id); ?>"
                                                    tabindex="-1" role="dialog"
                                                    aria-labelledby="myLargeModalLabel<?php echo e($fild->id); ?>"
                                                    aria-hidden="true">
                                                    <div class="modal-dialog modal-lg">
                                                        <div class="modal-content">
                                                            <div class="modal-header">
                                                                <h5 class="modal-title mt-0"
                                                                    id="myLargeModalLabel<?php echo e($fild->id); ?>">شما درحال
                                                                    حذف فیلد <?php echo e($fild->Name); ?> هستید</h5>
                                                                <button type="button" class="close" data-dismiss="modal"
                                                                    aria-label="Close">
                                                                    <span aria-hidden="true">×</span>
                                                                </button>
                                                            </div>
                                                            <?php if($fild->Status == 3): ?>
                                                                <div class="modal-body">
                                                                    <p>آیا از حذف فیلد اطمینان دارید؟</p>
                                                                    <a type="button"
                                                                        class="btn btn-danger waves-effect waves-light"
                                                                        style="color: white">این فیلد امکان حذف ندارد</a>
                                                                </div>
                                                            <?php else: ?>
                                                                <div class="modal-body">
                                                                    <p>آیا از حذف فیلد اطمینان دارید؟</p>
                                                                    <a href="<?php echo e(route('admin.deletefild', ['id' => $fild->id])); ?>"
                                                                        type="button"
                                                                        class="btn btn-danger waves-effect waves-light">حذف
                                                                        فیلد</a>
                                                                </div>
                                                            <?php endif; ?>
                                                        </div>
                                                        <!-- /.modal-content -->
                                                    </div>
                                                    <!-- /.modal-dialog -->
                                                </div>
                                                <!-- /.modal -->
                    </div>
                    </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                    </form>

                    </tbody>
                    </table>

                </div>

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


<?php $__env->startSection('script'); ?>
    <script>
        var ch = [];
        const checkboxes = document.querySelectorAll('#checkboxs');

        checkboxes.forEach(checkbox => {
            checkbox.addEventListener('change', function(event) {
                if (event.target.checked) {
                    // Checkbox is checked
                    ch.push(event.target.value);
                    // console.log(ch);
                    // Perform actions for checked checkbox
                } else {
                    // Checkbox is unchecked
                    ch = ch.filter(item => item !== event.target.value)
                    // console.log(ch);
                    // Perform actions for unchecked checkbox
                }
                if (ch.length > 0) {
                    document.getElementById('groupdeletebtn').style.display = 'block';
                    // console.log(ch);
                } else {
                    document.getElementById('groupdeletebtn').style.display = 'none';
                    // console.log(ch);
                }
            });
        });

        document.getElementById('selectallcheckboxs').addEventListener('change', function(event) {
            if (event.target.checked) {
                checkboxes.forEach((checkbox, index) => {
                    ch.push(checkboxes[index].value);
                    checkboxes[index].checked = true;
                    // console.log((index + 1));
                });
                // console.log('hi');
            } else {
                ch = [];
                checkboxes.forEach((checkbox, index) => {
                    checkboxes[index].checked = false;
                })
            }
            if (ch.length > 0) {
                document.getElementById('groupdeletebtn').style.display = 'block';
                // console.log(ch.length);
            } else {
                document.getElementById('groupdeletebtn').style.display = 'none';
                // console.log(ch.length);
            }
        })
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.sidebar', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Users/ali/pakanbakhtar/pakanbakhtar/resources/views/admin/fildslists.blade.php ENDPATH**/ ?>