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

<main id="main" class="main">
<?php echo $__env->make('cdn', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <div class="content-body">

        <div class="row page-titles mx-0">

        <div class="col-sm-6 p-md-0">

            <div class="breadcrumb-range-picker">

                 <h4>Manage Permission</h4>

            </div>

        </div>

        <div class="col-sm-6 p-md-0 justify-content-sm-end mb-2 mt-sm-0 d-flex">

            <a href="<?php echo e(route('company.roles')); ?>">

                <button type="button" class="btns success-btn btn-sm">

                    <i class="fas fa-arrow-left"></i> Back

                </button>

            </a>

        </div>

    </div>

        <div class="container-fluid">

            <?php echo $__env->make('flash_msg', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

            <div class="row">

                <div class="">

                    <div class="card">

                        <div class="card-body">

                             <form action="<?php echo e(route('seller.assign.permission')); ?>" method="POST" id="vendor_register">
                                <?php echo csrf_field(); ?>

                                <div class="form-group row">
                                    <div class="col-lg-6">
                                        <label>Role<span class="text-danger">*</span></label>

                                        <select class="form-control select2" name="role_id" required onchange="changeRole(this.value)">
                                            <option value="">Select Role</option>
                                            <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($role->id); ?>" <?php echo e($role_id==$role->id ? 'selected': ''); ?>><?php echo e(str_replace('_','',str_replace(Auth::user()->company_id,'',$role->name))); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                </div>
                                <div class="row mt-4 ">
                                    <table class="permissionTable table">
                                        <th>
                                            <?php echo e(__('Section')); ?>

                                        </th>
                            
                                        <th>
                                            <label>
                                                <?php echo e(__('Select All')); ?>

                                            </label>
                                        </th>
                            
                                        <th>
                                            <?php echo e(__("Available permissions")); ?>

                                        </th>
                            
                            
                                       
                                        <tbody class="role-permission">
                                           <?php $__currentLoopData = $custom_permission; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $group): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <tr>
                                                <td>
                                                    <b><?php echo e(ucfirst(str_replace('_','',str_replace(Auth::user()->company_id,'',$key)))); ?></b>
                                                </td>
                                                <td width="30%">
                                                    <label>
                                                        <input class="selectall" onclick="selectAll(this.value)" value="<?php echo e($key); ?>" type="checkbox">
                                                        <?php echo e(__('Select All')); ?>

                                                    </label>
                                                </td>
                                                <td>
                                                    
                                                    <?php $__empty_1 = true; $__currentLoopData = $group; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $permission): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                                        
                                                       <label>
                                                            <?php if(in_array($permission->id, $permissionIds)): ?>
                                                               <input name="permissions[]" class="permissioncheckbox <?php echo e($key); ?>" type="checkbox" checked value="<?php echo e($permission->id); ?>">
                                                               &nbsp; <?php echo e(ucfirst(str_replace('_','',str_replace(Auth::user()->company_id,'',$permission->name)))); ?> &nbsp;&nbsp;
                                                            <?php else: ?>
                                                                <input name="permissions[]" class="permissioncheckbox <?php echo e($key); ?>" type="checkbox" value="<?php echo e($permission->id); ?>">
                                                               &nbsp; <?php echo e(ucfirst(str_replace('_','',str_replace(Auth::user()->company_id,'',$permission->name)))); ?> &nbsp;&nbsp;
                                                            <?php endif; ?>
                                                       </label>
                            
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                                        <?php echo e(__("No permission in this group !")); ?>

                                                    <?php endif; ?>
                            
                                                </td>
                            
                                            </tr>
                                           <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="text-center">
                                    <button type="submit" class="btns primary-btn btn-sm">Update</button>
                                </div>

                            </form>

                        </div>

                    </div>

                </div>

            </div>

        </div>

    </div>

</main>
<script type="text/javascript">
    function changeRole(argument) {
        
    }
</script> 

<script>
    function selectAll(argument) {
       
        var cls = "."+argument;

        if($(cls).prop('checked')==true){
           
            $(cls).prop('checked', false);
        } else {
           
            $(cls).prop('checked', true); 
        }
        
    }
</script>

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

<?php echo $__env->make('backend.company.layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/vinecork/public_html/webdev/dailyCRM/resources/views/backend/company/roles/permissions.blade.php ENDPATH**/ ?>