

<?php $__env->startSection('title', '| Permissions'); ?>


<?php $__env->startSection('badcome'); ?>

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


<?php $__env->startSection('content'); ?>
<div class="container">
    <div class="row container_layout justify-content-center">
       <div class="col-lg-12" id="accordion">
        <h4><i class="fa fa-key"></i>Available Permissions
     <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view_users')): ?>
        <a href="<?php echo e(route('users.index')); ?>" class="btn btn-default btn-sm pull-right">Users</a>
     <?php endif; ?> 
     <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view_roles')): ?>
        <a href="<?php echo e(route('roles.index')); ?>" class="btn btn-default btn-sm pull-right">Roles</a>
     <?php endif; ?> 
    
     <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('add_permissions')): ?>
        <a href="<?php echo e(URL::to('user_management/permissions/create')); ?>" class="btn btn-success btn-sm pull-right">Add Permission</a>
     <?php endif; ?> 
        </h4>
        <hr>

      <?php $__currentLoopData = $modules; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $module): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="card mb5 collapse_div" >
            <div class="card-header text-white blue-gradient" role="tab" id="<?php echo e($module->module_code); ?>">

                <a data-toggle="collapse" class="other" href="#dd-<?php echo e($module->module_code); ?>" aria-expanded="<?php echo e('true'); ?>">
                       <?php echo e($module->module_code); ?>: <?php echo e($module->module_name); ?>

                </a>

            </div>

                <div id="dd-<?php echo e($module->module_code); ?>" data-parent="#accordion" class="panel-collapse collapse <?php echo e('hide'); ?> "  aria-labelledby="<?php echo e($module->module_code); ?>">
                    <div class="panel-body pl15 pr15">
                        <div class="row">


                            <div class="table-responsive accordian_div">
                                <table class="table table-bordered table-striped mb0">

                                    <thead>
                                        <tr>
                                            <th>Permissions</th>
                                            <th>Status</th>
                                            <th>Operation</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $__currentLoopData = $permissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $permission): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php if($permission->module==$module->module_code): ?>
                                                <tr>
                                                    <td><?php echo e($permission->name); ?></td> 
                                                    <td><?php echo (($permission->is_active)?'<span class="badge badge-pill green">Active</span>':'<span class="badge badge-pill red">Deactive</span>') ?></td> 
                                                    <td>
                                                  <?php if(($permission->name!="edit_permissions") && ($permission->name!="view_permissions")): ?>
                                                     <?php if(auth()->check() && auth()->user()->hasRole('Admin')): ?>
                                                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('edit_permissions')): ?>
                                                               <a href="<?php echo e(URL::to('user_management/permissions/'.$permission->id.'/edit')); ?>" class="btn btn-info btn-sm pull-left" style="margin-right: 3px;">Edit</a>
                                                        <?php endif; ?>
                                                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('delete_permissions')): ?>
                                                            <?php echo Form::open(['method' => 'DELETE','class' =>'delete_data inline_form mtm6', 'route' => ['permissions.destroy', $permission->id] ]); ?>

                                                            <?php echo Form::submit('Delete', ['class' => 'btn btn-danger btn-sm mt0 mb0 delete_data']); ?>

                                                            <?php echo Form::close(); ?>

                                                        <?php endif; ?>
                                                     <?php endif; ?>   
                                                        
                                                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('edit_permissions')): ?>
                                                            <?php echo e(Form::model($permission, array('route' => array('permissions.update', $permission->id), 'method' => 'PUT','class' =>'inline_form mtm6'))); ?>


                                                            <?php if($permission->is_active==0): ?>
                                                               <?php echo e(Form::hidden('is_active', 1, array('class' => 'form-control'))); ?>

                                                               <?php echo e(Form::submit('Activate', array('class' => 'btn btn-success btn-sm'))); ?>

                                                            <?php else: ?>
                                                               <?php echo e(Form::hidden('is_active', 0, array('class' => 'form-control'))); ?>

                                                               <?php echo e(Form::submit('Deactivate', array('class' => 'btn btn-danger btn-sm'))); ?>

                                                            <?php endif; ?>
                                                            <?php echo e(Form::close()); ?>

                                                        <?php endif; ?>
                                                            </td>
                                                        </tr>
                                                 <?php endif; ?>
                                           <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </tbody>
                                </table>
                            </div> 
                        </div>
                    </div>
                </div>
        </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    

</div>
    </div>
</div>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app2', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>