<?php if (isset($component)) { $__componentOriginalb998c89882eab8e1df2af93927d4d429 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalb998c89882eab8e1df2af93927d4d429 = $attributes; } ?>
<?php $component = App\View\Components\Dashboard\Layout::resolve(['title' => __('dashboard.menus')] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('dashboard.layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\Dashboard\Layout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
    <div class="container-fluid">

        <!-- Page Header -->
        <div class="row">
            <div class="col-12">
                <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                    <h4 class="mb-sm-0 font-size-18"><?php echo e(__('dashboard.menus')); ?></h4>

                    <div class="page-title-right d-flex align-items-center">
                        <div class="btn btn-list">
                            <a href="<?php echo e(route('dashboard.menus.create')); ?>" class="btn ripple btn-primary">
                                <i class="fas fa-plus-circle"></i> <?php echo e(__('dashboard.add')); ?>

                            </a>
                            <button id="btn_active" class="btn ripple btn-dark">
                                <i class="fas fa-eye"></i> <?php echo e(__('dashboard.publish/unpublish')); ?>

                            </button>
                            <button id="btn_delete" class="btn ripple btn-danger">
                                <i class="fas fa-trash"></i> <?php echo e(__('dashboard.delete')); ?>

                            </button>
                        </div>

                        <ol class="breadcrumb m-0">
                            <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard.home')); ?>">Dashboard</a></li>
                            <li class="breadcrumb-item active"><?php echo e(__('dashboard.menus')); ?></li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>
        <!-- End Page Header -->

        <!-- Table -->
        <div class="row">
            <div class="col-12">
                <div class="dashboard-table-container">

                    <div class="card-body">
                        <table id="datatable-buttons" class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th class="text-center" style="width: 50px;">
                                        <input type="checkbox" id="checkAll" class="form-check-input">
                                    </th>
                                    <th><?php echo e(__('dashboard.id')); ?></th>
                                    <th><?php echo e(__('dashboard.name_en')); ?></th>
                                    <th><?php echo e(__('dashboard.name_ar')); ?></th>
                                    <th><?php echo e(__('dashboard.segment')); ?></th>
                                    <th><?php echo e(__('dashboard.parent')); ?></th>
                                    <th><?php echo e(__('dashboard.status')); ?></th>
                                    <th><?php echo e(__('dashboard.actions')); ?></th>
                                </tr>
                            </thead>


                            <tbody>
                                <?php $__currentLoopData = $menus; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $menu): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr id="<?php echo e($menu->id); ?>">
                                        <td class="text-center">
                                            <input type="checkbox" name="checkbox" class="check-inputs form-check-input"
                                                value="<?php echo e($menu->id); ?>">
                                        </td>
                                        <td><a
                                                href="<?php echo e(route('dashboard.menus.edit', $menu->id)); ?>"><?php echo e($menu->id); ?></a>
                                        </td>
                                        <td><a
                                                href="<?php echo e(route('dashboard.menus.edit', $menu->id)); ?>"><?php echo e($menu->getTranslation('name', 'en')); ?></a>
                                        </td>
                                        <td><a
                                                href="<?php echo e(route('dashboard.menus.edit', $menu->id)); ?>"><?php echo e($menu->getTranslation('name', 'ar')); ?></a>
                                        </td>

                                        <td><a
                                                href="<?php echo e(route('dashboard.menus.edit', $menu->id)); ?>"><?php echo e($menu->segment); ?></a>
                                        </td>

                                        <td>
                                            <a href="<?php echo e(route('dashboard.menus.edit', $menu->id)); ?>">
                                                <?php echo e($menu->parent_name); ?>

                                            </a>
                                        </td>
                                        <td>
                                            <?php if($menu->status == 1): ?>
                                                <span class="status-badge active"><?php echo e(__('dashboard.yes')); ?></span>
                                            <?php else: ?>
                                                <span class="status-badge inactive"><?php echo e(__('dashboard.no')); ?></span>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <div class="action-buttons">
                                                <form action="<?php echo e(route('dashboard.menus.toggle-status', $menu->id)); ?>"
                                                    method="POST" class="d-inline">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('PATCH'); ?>
                                                    <button type="submit"
                                                        class="btn-action <?php echo e($menu->status ? 'unpublish' : 'publish'); ?>"
                                                        title="<?php echo e($menu->status ? __('dashboard.unpublish') : __('dashboard.publish')); ?>">
                                                        <i
                                                            class="fas fa-<?php echo e($menu->status ? 'eye-slash' : 'eye'); ?>"></i>
                                                    </button>
                                                </form>
                                                <a href="<?php echo e(route('dashboard.menus.edit', $menu->id)); ?>"
                                                    class="btn-action edit" title="<?php echo e(__('dashboard.edit')); ?>">
                                                    <i class="fas fa-edit"></i>
                                                </a>
                                                <form action="<?php echo e(route('dashboard.menus.destroy', $menu->id)); ?>"
                                                    method="POST" class="d-inline">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('DELETE'); ?>
                                                    <button type="submit" class="btn-action delete"
                                                        title="<?php echo e(__('dashboard.delete')); ?>"
                                                        onclick="return confirm('هل أنت متأكد من الحذف؟')">
                                                        <i class="fas fa-trash"></i>
                                                    </button>
                                                </form>
                                            </div>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <!-- end cardaa -->
            </div> <!-- end col -->
        </div>
        <!-- end row -->
    </div>

    <?php $__env->startPush('scripts'); ?>
        <?php if (isset($component)) { $__componentOriginal8a794b33c692643f62ff347833453dc6 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8a794b33c692643f62ff347833453dc6 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.dashboard.partials.datatable','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('dashboard.partials.datatable'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8a794b33c692643f62ff347833453dc6)): ?>
<?php $attributes = $__attributesOriginal8a794b33c692643f62ff347833453dc6; ?>
<?php unset($__attributesOriginal8a794b33c692643f62ff347833453dc6); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8a794b33c692643f62ff347833453dc6)): ?>
<?php $component = $__componentOriginal8a794b33c692643f62ff347833453dc6; ?>
<?php unset($__componentOriginal8a794b33c692643f62ff347833453dc6); ?>
<?php endif; ?>
        <script>
            $(document).ready(function() {
                // تهيئة الجدول
                var table = initializeDataTable('#datatable-buttons');

                // تهيئة الـ checkboxes المحسنة مع تأخير
                setTimeout(function() {
                    initializeEnhancedCheckboxes();
                }, 1000);

                // إعادة تهيئة الـ checkboxes عند تغيير الجدول
                table.on('draw', function() {
                    setTimeout(function() {
                        initializeEnhancedCheckboxes();
                    }, 100);
                });

                // حل بسيط للـ checkboxes
                $(document).on('click', '.checkbox-enhanced', function(e) {
                    e.preventDefault();
                    var checkbox = $(this).find('input[type="checkbox"]');
                    var isChecked = checkbox.is(':checked');
                    checkbox.prop('checked', !isChecked);

                    if (checkbox.attr('id') === 'checkAll') {
                        $('.check-inputs').prop('checked', !isChecked);
                    } else {
                        var totalCheckboxes = $('.check-inputs').length;
                        var checkedCheckboxes = $('.check-inputs:checked').length;
                        $('#checkAll').prop('checked', totalCheckboxes === checkedCheckboxes);
                    }

                    // تحديث المظهر
                    setTimeout(function() {
                        $('.check-inputs:checked').closest('.checkbox-enhanced').addClass('checked');
                        $('.check-inputs:not(:checked)').closest('.checkbox-enhanced').removeClass(
                            'checked');

                        if ($('#checkAll').is(':checked')) {
                            $('#checkAll').closest('.checkbox-enhanced').addClass('checked');
                        } else {
                            $('#checkAll').closest('.checkbox-enhanced').removeClass('checked');
                        }
                    }, 10);
                });
            });

            // Bulk status change functionality
            $('#btn_active').on('click', function(e) {
                e.preventDefault();

                var selectedCheckboxes = $(".check-inputs:checked");
                var selectedIds = [];

                selectedCheckboxes.each(function() {
                    selectedIds.push($(this).val());
                });

                if (selectedIds.length === 0) {
                    Swal.fire({
                        title: "<?php echo e(__('messages.no_select')); ?>",
                        text: "<?php echo e(__('messages.please select at least one')); ?>",
                        icon: "warning",
                        confirmButtonColor: "#5156be"
                    });
                    return;
                }

                Swal.fire({
                    title: "<?php echo e(__('messages.are you sure')); ?>",
                    text: "<?php echo e(__('messages.change checked status')); ?>",
                    icon: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#3085d6",
                    cancelButtonColor: "#d33",
                    confirmButtonText: "<?php echo e(__('messages.yes, change it')); ?>!"
                }).then((result) => {
                    if (result.isConfirmed) {
                        $.ajaxSetup({
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            }
                        });

                        $.ajax({
                            url: "<?php echo e(route('dashboard.change.status', ['modelname' => 'menus', 'ids' => ':ids'])); ?>"
                                .replace(':ids', selectedIds.join(',')),
                            type: 'POST',
                            data: {
                                selectedIds: selectedIds,
                                modelName: 'menus'
                            },
                            beforeSend: function() {
                                Swal.fire({
                                    title: "<?php echo e(__('messages.processing')); ?>",
                                    text: "<?php echo e(__('messages.please_wait')); ?>",
                                    allowOutsideClick: false,
                                    allowEscapeKey: false,
                                    showConfirmButton: false,
                                    didOpen: () => {
                                        Swal.showLoading();
                                    }
                                });
                            },
                            success: function(response) {
                                if (response.success) {
                                    Swal.fire({
                                        icon: "success",
                                        title: "<?php echo e(__('messages.updated')); ?>",
                                        text: response.message ||
                                            "<?php echo e(__('messages.status_changed_successfully')); ?>",
                                        showConfirmButton: false,
                                        timer: 1500
                                    });

                                    setTimeout(function() {
                                        location.reload();
                                    }, 1500);
                                } else {
                                    Swal.fire({
                                        icon: "error",
                                        title: "<?php echo e(__('messages.error')); ?>",
                                        text: response.message ||
                                            "<?php echo e(__('messages.an_error_occurred')); ?>"
                                    });
                                }
                            },
                            error: function(xhr) {
                                var message = xhr.responseJSON?.message ||
                                    "<?php echo e(__('messages.an_error_occurred')); ?>";
                                Swal.fire({
                                    icon: "error",
                                    title: "<?php echo e(__('messages.error')); ?>",
                                    text: message
                                });
                            }
                        });
                    }
                });
            });
        </script>
        <?php if (isset($component)) { $__componentOriginalf3793465e8b1cf9ff81a31cb3e6f1297 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf3793465e8b1cf9ff81a31cb3e6f1297 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.dashboard.partials.delete-btn','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('dashboard.partials.delete-btn'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf3793465e8b1cf9ff81a31cb3e6f1297)): ?>
<?php $attributes = $__attributesOriginalf3793465e8b1cf9ff81a31cb3e6f1297; ?>
<?php unset($__attributesOriginalf3793465e8b1cf9ff81a31cb3e6f1297); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf3793465e8b1cf9ff81a31cb3e6f1297)): ?>
<?php $component = $__componentOriginalf3793465e8b1cf9ff81a31cb3e6f1297; ?>
<?php unset($__componentOriginalf3793465e8b1cf9ff81a31cb3e6f1297); ?>
<?php endif; ?>
    <?php $__env->stopPush(); ?>

    <?php $__env->startSection('script'); ?>
    <?php $__env->stopSection(); ?>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalb998c89882eab8e1df2af93927d4d429)): ?>
<?php $attributes = $__attributesOriginalb998c89882eab8e1df2af93927d4d429; ?>
<?php unset($__attributesOriginalb998c89882eab8e1df2af93927d4d429); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalb998c89882eab8e1df2af93927d4d429)): ?>
<?php $component = $__componentOriginalb998c89882eab8e1df2af93927d4d429; ?>
<?php unset($__componentOriginalb998c89882eab8e1df2af93927d4d429); ?>
<?php endif; ?>
<?php /**PATH /home/egypetoo/public_html/resources/views/Dashboard/Menus/index.blade.php ENDPATH**/ ?>