<?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(); ?>

 <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

 <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>



<div class="container h-100" style="margin-top:10px;">

      

<h5>Assign Permissions</h5>

<div class="row">

         <form method="POST" action="<?php echo e(route('role.store')); ?>">

            <?php echo e(csrf_field()); ?>


                <div class=" form-outline  mb-3" style="width:300px;">

                     <strong>Role<span style="color:red;">*</span></strong>

                       <select name="role_id" class=" form-control" style="text-transform:capitalize;" readonly>

                            <option value="<?php echo e($role->id); ?>"><?php echo e($role->name); ?></option>

                           

                         </select>

                        <?php $__errorArgs = ['role_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>

                        <div class="alert alert-danger mt-1 mb-1"><?php echo e($message); ?></div>

                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>     

                </div>

               

              <div class="card" style="width:auto;">





                                        <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($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, $rolePermissions)): ?>

                                                                   <input name="permissions[]" class="permissioncheckbox <?php echo e($key); ?>" type="checkbox" value="<?php echo e($permission->id); ?>" checked>

                                                                   &nbsp; <?php echo e(ucfirst($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($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">Save</button> 

                <a href="<?php echo e(url('/addroles')); ?>" class="btns primary-btn" style="color:white;">Back</a> 

             </div>   

         </form>     

</div>

</div>

</main>

<script type="text/javascript">

    function changeRole(argument) {



        $.ajax({

            url: 'onchangerole/'+ argument,

            type: 'Get',

            dataType: 'json',    

            success:function(response)

            {

               console.log($html);

                $('.role-permission').html(response);

            },

            error: function(response) {

            }

        });

        

    }

</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('frontend.layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/vinecork/public_html/webdev/Company/resources/views/frontend/permis.blade.php ENDPATH**/ ?>