<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-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\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
    <?php if (isset($component)) { $__componentOriginalcd7d47400374ca1a3c459e4c1c1bfb40 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalcd7d47400374ca1a3c459e4c1c1bfb40 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.manage-filters','data' => ['search' => true,'searchRoute' => route('admin.roles', $role ?? null),'class' => 'flex-row-reverse']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('manage-filters'); ?>
<?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(['search' => true,'search-route' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(route('admin.roles', $role ?? null)),'class' => 'flex-row-reverse']); ?>
        <button type="button" class="btn btn-outline-primary" data-coreui-toggle="modal" data-coreui-target="#addRole">
            <?php echo app('translator')->get('admin.createRole'); ?>
        </button>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalcd7d47400374ca1a3c459e4c1c1bfb40)): ?>
<?php $attributes = $__attributesOriginalcd7d47400374ca1a3c459e4c1c1bfb40; ?>
<?php unset($__attributesOriginalcd7d47400374ca1a3c459e4c1c1bfb40); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalcd7d47400374ca1a3c459e4c1c1bfb40)): ?>
<?php $component = $__componentOriginalcd7d47400374ca1a3c459e4c1c1bfb40; ?>
<?php unset($__componentOriginalcd7d47400374ca1a3c459e4c1c1bfb40); ?>
<?php endif; ?>
    <div class="row">
        <div class="col-md-3">
            <ul class="nav nav-justified nav-pills admin-pill-nav d-block" role="navigation">
                <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $roleData): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li class="nav-item align-items-center<?php echo e($role->id == $roleData->id ? ' selected' : ''); ?>">
                        <a class="name w-100 align-self-center" href="<?php echo e(route('admin.roles', $roleData->id)); ?>">
                            <div>
                                <span class="role-name"><?php echo e($roleData->name); ?></span>
                                <div class="role-desc small text-muted">
                                    <?php echo e($roleData->description); ?>

                                </div>
                            </div>
                        </a>
                        <div class="actions">
                            <div class="btn-group">
                                <button class="btn btn-link dropdown-toggle dropdown-no-caret" type="button"
                                    data-coreui-toggle="dropdown" aria-expanded="false">
                                    <i class="pull-right lni lni-cog"></i>
                                </button>
                                <div class="dropdown-menu">
                                    <a class="dropdown-item edit-role" data-url="<?php echo e(route('admin.roles.edit')); ?>"
                                        data-id="<?php echo e($roleData->id); ?>" data-coreui-toggle="modal"
                                        data-coreui-target="#editRole"><?php echo app('translator')->get('common.edit'); ?></a>
                                    <form action="<?php echo e(route('admin.roles.destroy', $roleData->id)); ?>" method="POST"
                                        class="">
                                        <?php echo method_field('DELETE'); ?>
                                        <?php echo csrf_field(); ?>
                                        <button class="dropdown-item  warning-delete frm-submit" role="button"
                                            title="<?php echo app('translator')->get('common.delete'); ?>"><?php echo app('translator')->get('common.delete'); ?></button>
                                    </form>

                                </div>
                            </div>
                        </div>
                    </li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ul>
        </div>
        <div class="col-md-9">
            <form method="post" action="<?php echo e(route('admin.role.action')); ?>">
                <div class="card mb-3">
                    <div class="card-header">
                        <button type="submit" class="btn btn-primary btn-sm"
                            id="unassignBtn"><?php echo app('translator')->get('admin.unassign'); ?></button>
                        <button type="button" class="btn btn-primary btn-sm get-users" id="assignBtn"
                            data-id="<?php echo e($role->id); ?>" data-url="<?php echo e(route('admin.role.getUsers', $role->id)); ?>"
                            data-coreui-toggle="modal" data-coreui-target="#userList"><?php echo app('translator')->get('admin.assignRole'); ?></button>
                    </div>
                    <div class="card-body p-0">
                        <div class="row">
                            <input type="hidden" name="role_id" value="<?php echo e($role->id); ?>" />
                            <input type="hidden" name="action" value="0" />
                            <?php echo csrf_field(); ?>
                            <div class="col-12">
                                <table class="table table-hover table-artisan mb-0">
                                    <thead>
                                        <tr>
                                            <th scope="col">
                                                <input type="checkbox" class="form-check-input checkbox_all i-checks">
                                            </th>
                                            <th scope="col"><?php echo app('translator')->get('admin.name'); ?></th>
                                            <th scope="col"><?php echo app('translator')->get('admin.email'); ?></th>
                                            <th scope="col"><?php echo app('translator')->get('admin.status'); ?></th>
                                            <th scope="col"><?php echo app('translator')->get('admin.addedDate'); ?></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <tr>
                                                <th scope="row">
                                                    <input type="checkbox" class="form-check-input id_class"
                                                        name="users[]" value="<?php echo e($user->id); ?>">
                                                </th>
                                                <td><?php echo e($user->name); ?></td>
                                                <td><?php echo e($user->email); ?></td>
                                                <td>
                                                    <?php if($user->status == 1): ?>
                                                        <span class="badge me-1 bg-success"><?php echo app('translator')->get('common.active'); ?></span>
                                                    <?php else: ?>
                                                        <span class="badge me-1 bg-danger"><?php echo app('translator')->get('common.inactive'); ?></span>
                                                    <?php endif; ?>
                                                </td>
                                                <td><?php echo e($user->created_at->format(setting('datetime_format', 'd-m-Y H:i:s'))); ?>

                                                </td>
                                            </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <?php if($users->hasPages()): ?>
                        <div class="card-footer">
                            <?php echo e($users->links()); ?>

                        </div>
                    <?php endif; ?>
                </div>
            </form>
        </div>
    </div>
    <?php echo $__env->make('roles.partials.create_role', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('roles.partials.edit_role', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('roles.partials.users_list', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php $__env->startSection('footer_scripts'); ?>
        <script>
            const APP = function() {
                const enableDisableBtn = function() {
                        var lnth = document.querySelectorAll('.id_class:checked').length

                        if (lnth > 0) {
                            document.getElementById("unassignBtn").disabled = false;
                            document.getElementById("assignBtn").disabled = true;
                        } else {
                            document.getElementById("unassignBtn").disabled = true;
                            document.getElementById("assignBtn").disabled = false;
                        }

                    },
                    checkAll = function() {
                        document.querySelectorAll('.i-checks').forEach(element => element.addEventListener('click',
                            event => {
                                var clist = document.getElementsByClassName("id_class");
                                if (element.checked) {
                                    for (var i = 0; i < clist.length; ++i) {
                                        clist[i].checked = "checked";
                                    }
                                } else {
                                    for (var i = 0; i < clist.length; ++i) {
                                        clist[i].checked = "";
                                    }
                                }
                                enableDisableBtn();
                            }));

                        document.querySelectorAll('.id_class').forEach(element => {
                            element.addEventListener('change', event => {
                                enableDisableBtn();
                            })
                        });
                    },
                    assignRoleModal = function() {
                        if (document.querySelectorAll('.get-users').length > 0) {
                            document.querySelector('.get-users').addEventListener('click',
                                event => {
                                    const element = document.querySelector('.get-users')
                                    document.getElementById('userView').innerHTML =
                                        "<h6><?php echo e(__('common.loading')); ?></h6>";
                                    var search = document.getElementById('search-input').value;
                                    var data = element.dataset;
                                    axios.post(data.url, {
                                            id: data.id,
                                            q: search,
                                        })
                                        .then(function(response) {
                                            if (response.data.success == 1) {
                                                document.getElementById('userView').innerHTML = response.data.view;
                                            } else {
                                                document.getElementById('userView').innerHTML =
                                                    "<h4><?php echo e(__('common.somethingWentWrong')); ?></h4>";
                                            }
                                        })
                                        .catch(function(err) {
                                            console.log(err)
                                            document.getElementById('userView').innerHTML =
                                                "<h4><?php echo e(__('common.somethingWentWrong')); ?></h4>";
                                        });
                                });
                        }
                    };
                const editRoleModal = function() {
                    if (document.querySelectorAll('.edit-role').length > 0) {
                        document.querySelectorAll('.edit-role').forEach(element => element.addEventListener('click',
                            event => {
                                event.preventDefault();
                                document.getElementById('edit-modal').innerHTML =
                                    "<h6><?php echo e(__('common.loading')); ?></h6>";
                                var data = element.dataset;
                                axios.post(data.url, {
                                        id: data.id,
                                    })
                                    .then(function(response) {
                                        console.log(response.data)
                                        if (response.data.success == 1) {
                                            document.getElementById('edit-modal').innerHTML = response.data
                                                .view;
                                        } else {
                                            document.getElementById('edit-modal').innerHTML =
                                                "<h4><?php echo e(__('common.somethingWentWrong')); ?></h4>";
                                        }
                                    })
                                    .catch(function(err) {
                                        console.log(err)
                                        document.getElementById('edit-modal').innerHTML =
                                            "<h4><?php echo e(__('common.somethingWentWrong')); ?></h4>";
                                    });

                            }));
                    }
                }
                return {
                    init: function() {
                        enableDisableBtn();
                        assignRoleModal();
                        editRoleModal();
                        checkAll();
                    }
                }
            }();
            document.addEventListener("DOMContentLoaded", function(event) {
                APP.init();
            });
        </script>
    <?php $__env->stopSection(); ?>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH /www/wwwroot/webtoolzone.com/resources/themes/admin/roles/index.blade.php ENDPATH**/ ?>