<?php if(isset($menus) && count($menus) > 0): ?>
    <div class="input-session mb-4">
        
        <div id="accordion" class="dd">
            <ol class="dd-list">
                <?php $__currentLoopData = $menus; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li class="dd-item" data-id="<?php echo e($element->id); ?>">
                        <div class="card accordion_card" id="accordion_<?php echo e($element->id); ?>">
                            <div class=" item_header" id="heading_<?php echo e($element->id); ?>">
                                <div class="dd-handle">
                                    <div class="pull-left">
                                        <?php echo e($element->name_en); ?>

                                    </div>
                                </div>
                                <div class="pull-right btn_div">
                                    <?php if(userPermission('element-update')): ?>
                                        <a href="javascript:void(0);"
                                            onclick="updateSession(<?php echo e($element->id); ?>,'<?php echo e(addslashes($element->name_en)); ?>','<?php echo e(addslashes($element->name_ar)); ?>','<?php echo e(addslashes($element->description_en)); ?>','<?php echo e(addslashes($element->description_ar)); ?>','<?php echo e($element->level_id); ?>','<?php echo e($element->track_id); ?>',<?php echo e(json_encode($element->file)); ?>)"
                                            class="primary-btn btn_zindex panel-title">
                                            <?php echo app('translator')->get('common.edit'); ?>
                                            <i class="ti-pencil-alt"></i>
                                        </a>
                                    <?php endif; ?>
                                    <?php if(userPermission('element-update')): ?>
                                        <a href="javascript:void(0);" onclick="" data-toggle="collapse"
                                            data-target="#collapse_<?php echo e($element->id); ?>" aria-expanded="false"
                                            aria-controls="collapse_<?php echo e($element->id); ?>"
                                            class="primary-btn btn_zindex panel-title">
                                            <?php echo app('translator')->get('common.show'); ?>
                                            <i class="ti-angle-down"></i>
                                        </a>
                                    <?php endif; ?>
                                    <?php if(env('APP_SYNC') == true): ?>
                                        <a href="javascript:void(0);" class="primary-btn btn_zindex mb-3"
                                            title="Disable For Demo" data-toggle="tooltip">
                                            <i class="ti-close"></i>
                                        </a>
                                    <?php else: ?>
                                        <?php if(userPermission('delete-element')): ?>
                                            <a href="javascript:void(0);" onclick="elementDelete(<?php echo e($element->id); ?>)"
                                                class="primary-btn btn_zindex mb-3">
                                                <i class="ti-close"></i>
                                            </a>
                                        <?php endif; ?>
                                    <?php endif; ?>
                                </div>
                            </div>
                            <div id="collapse_<?php echo e($element->id); ?>" class="collapse"
                                aria-labelledby="heading_<?php echo e($element->id); ?>"
                                data-parent="#accordion_<?php echo e($element->id); ?>">
                                <div class="card-body">

                                    <div class="col-md-6">
                                        <div class="d-flex align-items-center">
                                            <div class="btnSelect">
                                                <button id="add_btn_session_<?php echo e($element->id); ?>"
                                                    class="circular-btn mx-2" aria-label="Toggle new session form">
                                                    <i class="fas fa-plus" style="color: #fff"></i>
                                                </button>
                                            </div>

                                            <div id="add_session_session_<?php echo e($element->id); ?>" class="input-session"
                                                style="display: none;width:100%">
                                                <button id="add_lesson_modal_btn_<?php echo e($element->id); ?>"
                                                    class="session-btn m-2"
                                                    data-modal-target="#add_lesson_modal_<?php echo e($element->id); ?>">
                                                    <i class="fas fa-plus" style="color: #000000"></i> <?php echo app('translator')->get('academics.add_lesson'); ?>
                                                </button>
                                                <button id="add_quiz_modal_btn_<?php echo e($element->id); ?>"
                                                    class="session-btn m-2"
                                                    data-modal-target="#add_quiz_modal_<?php echo e($element->id); ?>">
                                                    <i class="fas fa-plus" style="color: #000000"></i> <?php echo app('translator')->get('academics.add_quiz'); ?>
                                                </button>
                                                <button id="add_assignment_modal_btn_<?php echo e($element->id); ?>"
                                                    class="session-btn m-2"
                                                    data-modal-target="#add_assignment_modal_<?php echo e($element->id); ?>">
                                                    <i class="fas fa-plus" style="color: #000000"></i> <?php echo app('translator')->get('academics.add_assignment'); ?>
                                                </button>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row mt-4">
                                        <div class="col-lg-12">
                                            <div class="row">
                                                <div class="col">
                                                    <h4><?php echo app('translator')->get('academics.track'); ?>:</h4>
                                                    <p class="text-dark">
                                                        <?php echo e($element->track->track_name_en); ?>

                                                    </p>
                                                </div>
                                                <div class="col">
                                                    <h4><?php echo app('translator')->get('common.level'); ?>:</h4>
                                                    <p class="text-dark">
                                                        <?php echo e($element->level->name_en); ?></p>
                                                </div>
                                                <div class="col">
                                                    <h4><?php echo app('translator')->get('academics.name_en'); ?>:</h4>
                                                    <p class="text-dark">
                                                        <?php echo e($element->name_en); ?></p>
                                                </div>
                                                <div class="col">
                                                    <h4><?php echo app('translator')->get('academics.name_ar'); ?>:</h4>
                                                    <p class="text-dark">
                                                        <?php echo e($element->name_ar); ?></p>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-12">

                                            <?php $__currentLoopData = $lessons->where('session_id', $element->id); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <div class="row align-items-center mt-2">
                                                    <div class="col-md-10 col-9">
                                                        <h5>
                                                            <?php echo e($item->name); ?> [<?php echo e($item->duration); ?>]
                                                            [<?php echo e($item->privacy); ?>] [lesson]

                                                        </h5>
                                                    </div>
                                                    <div class="col-md-2">
                                                        <?php if (isset($component)) { $__componentOriginalf5ee9bc45d6af00850b10ff7521278be = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf5ee9bc45d6af00850b10ff7521278be = $attributes; } ?>
<?php $component = App\View\Components\DropDown::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('drop-down'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\DropDown::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
                                                            <a class="dropdown-item" data-toggle="modal"
                                                                data-target="#update_lesson_modal_<?php echo e($item->id); ?>"
                                                                href="#"><?php echo app('translator')->get('common.edit'); ?></a>
                                                            <a class="dropdown-item" data-toggle="modal"
                                                                data-target="#deleteAssignmentModal<?php echo e($item->id); ?>"
                                                                href="#"><?php echo app('translator')->get('common.delete'); ?></a>
                                                         <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf5ee9bc45d6af00850b10ff7521278be)): ?>
<?php $attributes = $__attributesOriginalf5ee9bc45d6af00850b10ff7521278be; ?>
<?php unset($__attributesOriginalf5ee9bc45d6af00850b10ff7521278be); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf5ee9bc45d6af00850b10ff7521278be)): ?>
<?php $component = $__componentOriginalf5ee9bc45d6af00850b10ff7521278be; ?>
<?php unset($__componentOriginalf5ee9bc45d6af00850b10ff7521278be); ?>
<?php endif; ?>
                                                    </div>

                                                    <!-- Update Lesson Modal -->
                                                    <?php echo $__env->make('backEnd.academics.sessions.modals.update_lesson_modal', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

                                                    
                                                    <div class="modal fade admin-query"
                                                        id="deleteAssignmentModal<?php echo e($item->id); ?>">
                                                        <div class="modal-dialog modal-dialog-centered">
                                                            <div class="modal-content">
                                                                <div class="modal-header">
                                                                    <h4 class="modal-title"><?php echo app('translator')->get('academics.delete_lesson'); ?></h4>
                                                                    <button type="button" class="close"
                                                                        data-dismiss="modal">&times;</button>
                                                                </div>
                                                                <div class="modal-body">
                                                                    <div class="text-center">
                                                                        <h4><?php echo app('translator')->get('common.are_you_sure_to_delete'); ?></h4>
                                                                    </div>
                                                                    <div class="mt-40 d-flex justify-content-between">
                                                                        <button type="button"
                                                                            class="primary-btn tr-bg"
                                                                            data-dismiss="modal"><?php echo app('translator')->get('common.cancel'); ?></button>
                                                                        <?php echo e(Form::open(['route' => ['track_levels_sessions_lessons_delete', $item->id], 'method' => 'DELETE', 'enctype' => 'multipart/form-data'])); ?>

                                                                        <button class="primary-btn fix-gr-bg"
                                                                            type="submit"><?php echo app('translator')->get('common.delete'); ?></button>
                                                                        <?php echo e(Form::close()); ?>

                                                                    </div>
                                                                </div>

                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                                            <?php $__currentLoopData = $assignments->where('session_id', $element->id); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <div class="row align-items-center mt-2">
                                                    <div class="col-md-10 col-9">
                                                        <h5>
                                                            <?php echo e($item->title); ?> [<?php echo e($item->privacy); ?>] [Assignment]
                                                        </h5>
                                                    </div>
                                                    <div class="col-md-2">
                                                        <?php if (isset($component)) { $__componentOriginalf5ee9bc45d6af00850b10ff7521278be = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf5ee9bc45d6af00850b10ff7521278be = $attributes; } ?>
<?php $component = App\View\Components\DropDown::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('drop-down'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\DropDown::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
                                                            <a class="dropdown-item" data-toggle="modal"
                                                                data-target="#update_assignment_modal_<?php echo e($item->id); ?>"
                                                                href="#"><?php echo app('translator')->get('common.edit'); ?></a>
                                                            <a class="dropdown-item" data-toggle="modal"
                                                                data-target="#deleteAssignmentModal<?php echo e($item->id); ?>"
                                                                href="#"><?php echo app('translator')->get('common.delete'); ?></a>
                                                         <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf5ee9bc45d6af00850b10ff7521278be)): ?>
<?php $attributes = $__attributesOriginalf5ee9bc45d6af00850b10ff7521278be; ?>
<?php unset($__attributesOriginalf5ee9bc45d6af00850b10ff7521278be); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf5ee9bc45d6af00850b10ff7521278be)): ?>
<?php $component = $__componentOriginalf5ee9bc45d6af00850b10ff7521278be; ?>
<?php unset($__componentOriginalf5ee9bc45d6af00850b10ff7521278be); ?>
<?php endif; ?>
                                                    </div>

                                                    <!-- Update assignment Modal -->
                                                    <?php echo $__env->make('backEnd.academics.sessions.modals.update_assignment_modal', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

                                                    
                                                    <div class="modal fade admin-query"
                                                        id="deleteAssignmentModal<?php echo e($item->id); ?>">
                                                        <div class="modal-dialog modal-dialog-centered">
                                                            <div class="modal-content">
                                                                <div class="modal-header">
                                                                    <h4 class="modal-title"><?php echo app('translator')->get('academics.delete_assignment'); ?></h4>
                                                                    <button type="button" class="close"
                                                                        data-dismiss="modal">&times;</button>
                                                                </div>
                                                                <div class="modal-body">
                                                                    <div class="text-center">
                                                                        <h4><?php echo app('translator')->get('common.are_you_sure_to_delete'); ?></h4>
                                                                    </div>
                                                                    <div class="mt-40 d-flex justify-content-between">
                                                                        <button type="button"
                                                                            class="primary-btn tr-bg"
                                                                            data-dismiss="modal"><?php echo app('translator')->get('common.cancel'); ?></button>
                                                                        <?php echo e(Form::open(['route' => ['track_levels_sessions_assignment_delete', $item->id], 'method' => 'DELETE', 'enctype' => 'multipart/form-data'])); ?>

                                                                        <button class="primary-btn fix-gr-bg"
                                                                            type="submit"><?php echo app('translator')->get('common.delete'); ?></button>
                                                                        <?php echo e(Form::close()); ?>

                                                                    </div>
                                                                </div>

                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                            <?php $__currentLoopData = $quiz->where('session_id', $element->id); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <div class="row align-items-center mt-2">
                                                    <div class="col-md-10 col-9">
                                                        <h5>
                                                            <?php echo e($item->title); ?> [<?php echo e($item->privacy); ?>] [Quiz]
                                                        </h5>
                                                    </div>
                                                    <div class="col-md-2">
                                                        <?php if (isset($component)) { $__componentOriginalf5ee9bc45d6af00850b10ff7521278be = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf5ee9bc45d6af00850b10ff7521278be = $attributes; } ?>
<?php $component = App\View\Components\DropDown::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('drop-down'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\DropDown::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
                                                            <a class="dropdown-item" data-toggle="modal"
                                                                data-target="#update_quiz_modal_<?php echo e($item->id); ?>"
                                                                href="#"><?php echo app('translator')->get('common.edit'); ?></a>
                                                            <a class="dropdown-item" data-toggle="modal"
                                                                data-target="#deleteQuizModal<?php echo e($item->id); ?>"
                                                                href="#"><?php echo app('translator')->get('common.delete'); ?></a>
                                                         <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf5ee9bc45d6af00850b10ff7521278be)): ?>
<?php $attributes = $__attributesOriginalf5ee9bc45d6af00850b10ff7521278be; ?>
<?php unset($__attributesOriginalf5ee9bc45d6af00850b10ff7521278be); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf5ee9bc45d6af00850b10ff7521278be)): ?>
<?php $component = $__componentOriginalf5ee9bc45d6af00850b10ff7521278be; ?>
<?php unset($__componentOriginalf5ee9bc45d6af00850b10ff7521278be); ?>
<?php endif; ?>
                                                    </div>


                                                    <!-- Update quiz Modal -->
                                                    <?php echo $__env->make('backEnd.academics.sessions.modals.update_quiz_modal', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

                                                    
                                                    <div class="modal fade admin-query"
                                                        id="deleteQuizModal<?php echo e($item->id); ?>">
                                                        <div class="modal-dialog modal-dialog-centered">
                                                            <div class="modal-content">
                                                                <div class="modal-header">
                                                                    <h4 class="modal-title"><?php echo app('translator')->get('academics.delete_quiz'); ?></h4>
                                                                    <button type="button" class="close"
                                                                        data-dismiss="modal">&times;</button>
                                                                </div>
                                                                <div class="modal-body">
                                                                    <div class="text-center">
                                                                        <h4><?php echo app('translator')->get('common.are_you_sure_to_delete'); ?></h4>
                                                                    </div>
                                                                    <div class="mt-40 d-flex justify-content-between">
                                                                        <button type="button"
                                                                            class="primary-btn tr-bg"
                                                                            data-dismiss="modal"><?php echo app('translator')->get('common.cancel'); ?></button>
                                                                        <?php echo e(Form::open(['route' => ['track_levels_sessions_quiz_delete', $item->id], 'method' => 'DELETE', 'enctype' => 'multipart/form-data'])); ?>

                                                                        <button class="primary-btn fix-gr-bg"
                                                                            type="submit"><?php echo app('translator')->get('common.delete'); ?></button>
                                                                        <?php echo e(Form::close()); ?>

                                                                    </div>
                                                                </div>

                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>




                    <!-- Add Lesson Modal -->
                    <?php echo $__env->make('backEnd.academics.sessions.modals.add_lesson_modal', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

                    <!-- Add Quiz Modal -->
                    <?php echo $__env->make('backEnd.academics.sessions.modals.add_quiz_modal', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

                    <!-- Add Assignment Modal -->
                    <?php echo $__env->make('backEnd.academics.sessions.modals.add_assignment_modal', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ol>
        </div>
    </div>
<?php else: ?>
    <div>
        <div class="text-center">
            <h4>
                <?php echo app('translator')->get('common.no_sessions'); ?>
            </h4>
        </div>

    </div>
<?php endif; ?>













<style>
    .item_header {
        background: #415094;

    }

    .item_header .pull-left {
        color: #fff;
    }

    .item_header .primary-btn {
        color: #fff;

    }

    .item_header .collapge_arrow_normal {
        color: #fff;

    }
</style>
<?php $__env->startPush('script'); ?>
    <script>
        $(document).ready(function() {



            $(document).on('click', '[id^="add_btn_session_"]', function(event) {
                event.preventDefault();
                event.stopPropagation();

                var elementId = $(this).attr('id').split('_')[
                    3];

                $('#add_session_session_' + elementId).toggle();
                if ($('#add_session_session_' + elementId).is(':visible')) {
                    $(this).html('<i class="fas fa-times" style="color: #fff"></i>');
                } else {
                    $(this).html('<i class="fas fa-plus" style="color: #fff"></i>');
                }
            });





            $(document).on('click',
                '[id^="add_lesson_modal_btn_"], [id^="add_quiz_modal_btn_"], [id^="add_assignment_modal_btn_"]',
                function(event) {
                    event.preventDefault();
                    var modalTarget = $(this).data('modal-target');
                    $(modalTarget).modal('show');
                });

            $(document).on('click', function(event) {
                if (!$(event.target).closest('[id^="add_session_session_"]').length && !$(event.target)
                    .closest('[id^="add_btn_session_"]').length) {
                    $('[id^="add_session_session_"]').hide();
                    $('[id^="add_btn_session_"]').html('<i class="fas fa-plus" style="color: #fff"></i>');
                }
            });

        });



        function updateSession(id, name_en, name_ar, description_en, description_ar, level_id, track_id, files) {
            $('#update_session_id').val(id);
            $('#update_name_en').val(name_en);
            $('#update_name_ar').val(name_ar);
            $('#update_description_en').val(description_en);
            $('#update_description_ar').val(description_ar);
            $('#update_level_id').val(level_id);
            $('#update_track_id').val(track_id);

            $('#existing_files').empty();
            if (typeof files === 'string') {
                try {
                    files = JSON.parse(files);
                } catch (error) {
                    console.error('Error parsing files:', error);
                    files = [];
                }
            }

            if (files && files.length > 0) {
                files.forEach((file, index) => {
                    $('#existing_files').append(`
                <div class="file-item">
                <a target="_blank" href="/${file}"><i class="fa fa-eye"></i> <?php echo app('translator')->get('common.view_material'); ?> ${index +1}</a>             
                </div>
            `);
                });
            }
            $('#ModalUpdateSession').modal('show');
        }
    </script>
<?php $__env->stopPush(); ?>
<?php /**PATH D:\tailors-dev\upedia\resources\views/backEnd/academics/sessions/collapse.blade.php ENDPATH**/ ?>