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

 <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>Roles<span style="color:red;">*</span></strong>
                       <select name="role_id" class="custom-select form-control" onchange="changeRole(this.value)" style="text-transform:capitalize;" required>
                             <?php $__currentLoopData = $rol; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ro): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                             <?php if($ro->id==$role->id): ?>
                            <option value="<?php echo e($role->id); ?>" selected><?php echo e(substr($role->name, strpos($role->name, '_') + 1)); ?></option>
                             <?php else: ?>
                              <option value="<?php echo e($ro->id); ?>" >
                                 <?php echo e(substr($ro->name, strpos($ro->name, '_') + 1)); ?>

                              </option>
                              <?php endif; ?>
                              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                         </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; height:270px; overflow-y: scroll;">
                <div class="card-body role-permission">
                    <?php $__currentLoopData = $permissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $permission): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                     <div class="col-sm-3 form-check-inline">
                        <?php if(in_array($permission->id, $rolePermissions)): ?>
                       <input class="form-check-input m-1 p-1" type="checkbox" name="permission[]" id="inlineCheckbox1" value="<?php echo e($permission->id); ?>" checked>
                       <?php else: ?>
                        <input class="form-check-input m-1 " type="checkbox" name="permission[]" id="inlineCheckbox1" value="<?php echo e($permission->id); ?>">
                       <?php endif; ?>
                      <label class="form-check-label m-1 p-1" for="inlineCheckbox1" style="text-transform:capitalize;"><?php echo e($permission->name); ?></label>
                     </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
               </div> 
             </div>
             <div class="text-center">
                <button type="submit" class="btn btn-info">Save</button> 
                <a href="<?php echo e(url('/addroles')); ?>" class="btn btn-info" 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)
            {
               
                $('.role-permission').html(response);
            },
            error: function(response) {
            }
        });
        
    }
</script> 
<?php $__env->stopSection(); ?>


<?php echo $__env->make('frontend.layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\CRM\resources\views/frontend/permis.blade.php ENDPATH**/ ?>