
<?php $__env->startSection('title',__('messages.role')); ?>
<?php $__env->startSection('content'); ?>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('role.create')): ?>
        <div class="add-new-button-hidden">
            <button class="btn add_new_btn" data-bs-toggle="modal" data-bs-target="#roleCreateModal"
            ><i class="plus-ico"></i> <?php echo e(__('messages.add_role')); ?>

            </button>
        </div>
    <?php endif; ?>
    <h2 class="ms-2 mb-3 card-title"><?php echo e(__('messages.role_list')); ?></h2>
    <div class="card mt-3 m-lg-2">
        <div class="card-body mt-2 table_card">
            <table id="datatable-buttons" class="table table-bordered dt-responsive w-100"
                   data-table="dataTables">
                <thead>
                <tr>
                    <th width="5%"><?php echo e(__('messages.sl')); ?></th>
                    <th width="10%"><?php echo e(__('messages.name')); ?></th>
                    <th width="60%"><?php echo e(__('messages.permissions')); ?></th>
                    <th width="25%"><?php echo e(__('messages.action')); ?></th>
                </tr>
                </thead>
                <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td><?php echo e(++$key); ?></td>
                        <td class="text-800"><?php echo e(strtoupper($item->name)); ?></td>
                        <td>
                            <?php $__currentLoopData = $item->permissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $perm): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <span
                                    class="badge permission-list-badge"><?php echo e(str_replace('.', ' ', $perm->name)); ?></span>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </td>
                        <td class="center">
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('role.edit')): ?>
                                <a class="btn btn-sm role_edit_btn"
                                   data-url="<?php echo e(route('super-admin.roles.edit',$item->id)); ?>" data-bs-toggle="modal"
                                   data-bs-target="#roleEditModal">
                                    <i class="edit-ico"></i>
                                </a>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('role.delete')): ?>
                                <a href="#" class="btn btn-sm" onclick="deletePost(<?php echo e($item->id); ?>)">
                                    <i class="delete-ico"></i>
                                    <form id="delete-form-<?php echo e($item->id); ?>"
                                          action="<?php echo e(route('super-admin.roles.destroy', $item->id)); ?>"
                                          method="POST" style="display: none;">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                    </form>
                                </a>
                            <?php endif; ?>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
    <div class="modal fade" id="roleCreateModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered modal-xl">
            <div class="modal-content p-5">
                <h4 class="card-title"><?php echo e(__('messages.create_role')); ?></h4>
                <p class="card-title-desc"><?php echo e(__('messages.fill_all_information_below')); ?></p>
                <div class="modal-body p-0 mt-3 roleCreateModal">
                    <div class="modal-spinner d-flex flex-column align-items-center">
                        <div class="spinner-border text-secondary" role="status">
                            <span class="sr-only"></span>
                        </div>
                        <h5 class="mt-1">Loading...</h5>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="roleEditModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered modal-xl">
            <div class="modal-content p-5">
                <h4 class="card-title"><?php echo e(__('messages.edit_role')); ?></h4>
                <p class="card-title-desc"><?php echo e(__('messages.fill_all_information_below')); ?></p>
                <div class="modal-body p-0 mt-3 roleEditModal">
                    <div class="modal-spinner d-flex flex-column align-items-center">
                        <div class="spinner-border text-secondary" role="status">
                            <span class="sr-only"></span>
                        </div>
                        <h5 class="mt-1">Loading...</h5>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('scripts'); ?>
    <script type="text/javascript">
        $(document).on('click', '.role_edit_btn', function () {
            let url = $(this).data('url');
            axios.get(url).then(function (response) {
                $('.roleEditModal').html(response.data);
                $('.modal-spinner').hide();
                $(".modal").on("hidden.bs.modal", function () {
                    $(".roleEditModal").html(` <div class="modal-spinner d-flex flex-column align-items-center">
                        <div class="spinner-border text-secondary" role="status">
                            <span class="sr-only"></span>
                        </div>
                        <h5 class="mt-1">Loading...</h5>
                    </div>`);
                });
            }).catch(function (error) {
                console.log(error)
            })
        })
        $('.add_new_btn').click(function () {
            axios.get("<?php echo e(url('system/roles/create')); ?>").then(function (response) {
                $('.roleCreateModal').html(response.data);
                $('.modal-spinner').hide();
                $(".modal").on("hidden.bs.modal", function () {
                    $(".roleCreateModal").html(` <div class="modal-spinner d-flex flex-column align-items-center">
                        <div class="spinner-border text-secondary" role="status">
                            <span class="sr-only"></span>
                        </div>
                        <h5 class="mt-1">Loading...</h5>
                    </div>`);
                });
                createPageJS();
            }).catch(function (error) {
                console.log(error)
            })
        })

    </script>
<?php $__env->stopPush(); ?>


<?php echo $__env->make('backend.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\laragon\www\hr_and_att\resources\views/backend/user/role/index.blade.php ENDPATH**/ ?>