

<?php $__env->startSection('content'); ?>
<!-- page start-->
 <!-- Content Header (Page header) -->
 <section class="content-header">
  <div class="container-fluid">
    <div class="row mb-2">
      <div class="col-sm-6">
        <h1><?php echo e(__('Create Role')); ?></h1>
      </div>
      <div class="col-sm-6">
        <ol class="breadcrumb float-sm-right">
          <li class="breadcrumb-item"><a href="#"><?php echo e(__('Home')); ?></a></li>
          <li class="breadcrumb-item active"><?php echo e(__('Update Role')); ?></li>
        </ol>
      </div>
    </div>
  </div><!-- /.container-fluid -->
</section>
<!-- Main content -->
<!-- Main content -->
<section class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                  <h3 class="card-title"><?php echo e(__('Update Roles')); ?></h3>                  
                  <span class="tools" style="float:right">
                    <a href="<?php echo e(route('role.index')); ?>" title="Back" class="btn btn-primary btn-sm"><i class="fa fa-reply"></i></a>
                  </span>
                </div>
                <!-- /.card-header -->
                <div class="card-body"> 
                    <form class="form-horizontal" autocomplete="off" role="form" method="POST" action="<?php echo e(route('role.update', $roleInfo->id)); ?>">
                        <?php echo csrf_field(); ?>
                        <?php echo e(method_field('PUT')); ?>   
                       <div class="form-group <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> has-error <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                           <label for="name" class="col-lg-4 col-sm-4 control-label">Role Name <span class="text-danger">*</span></label>
                           <div class="col-lg-8">
                               <input type="text" class="form-control" name="name" value="<?php echo e($roleInfo->name); ?>" id="name" placeholder="role Name" required>
                                <?php if($errors->has('name')): ?>
                                   <p class="help-block"><?php echo e($errors->first('name')); ?></p>
                                <?php endif; ?>
                           </div>
                       </div>
                       <div class="col-md-12">
                           <div class="form-group">
                               <div class="col-md-3 custom-control custom-checkbox">           
                               <?php echo e(Form::checkbox('select_all',null,null, array('id'=>'select_all','class'=>'class="select_all"  custom-control-input'))); ?>

                               <?php echo e(Form::label('select_all','Select All',['class'=>'custom-control-label'])); ?><br>
                               </div>
                           </div>
                       </div>
                       <div class="form-group">
                           <?php
                               $modules=['dashboard','customer','merchant','driver','order'];
                           ?>
                            <table border=1>
                               <thead>
                                   <tr>
                                       <th>Module Name</th>
                                       <th>Permissions</th>
                                   </tr>
                               </thead>
                           <tbody>
                             <?php $__currentLoopData = $menus; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $module): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                             <?php $i++; print_r($module); ?>
                             <tr>
                                
                                 <td class="col-sm-2 col-lg-2"> <?php echo e(Form::label('module',ucfirst($module))); ?> </td>
                                 <td class="col-sm-10 col-lg-10">
                                   <div class="row" id="sel_permissions_<?php echo e($i); ?>">
                                        <?php if(in_array('manage '.strtolower($module),(array) $permissions)): ?>
                                            <?php if($key = array_search('manage '.strtolower($module),$permissions)): ?>
                                                <div class="col-lg-2 col-sm-2 custom-control custom-checkbox">
                                                <?php echo e(Form::checkbox('permissions[]','manage '.strtolower($module),in_array('list '.strtolower($module),$assignedPermission), ['class'=>'checkbox custom-control-input','id' =>'permission'.$key])); ?>

                                                <?php echo e(Form::label('permission'.$key,'Manage',['class'=>'custom-control-label'])); ?><br>
                                                </div>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                       <?php if(in_array('list '.strtolower($module),(array) $permissions)): ?>
                                        <?php if($key = array_search('list '.strtolower($module),$permissions)): ?>
                                            <div class="col-lg-2 col-sm-2 custom-control custom-checkbox">
                                            <?php echo e(Form::checkbox('permissions[]','list '.strtolower($module),in_array('list '.strtolower($module),$assignedPermission), ['class'=>'checkbox custom-control-input','id' =>'permission'.$key])); ?>

                                            <?php echo e(Form::label('permission'.$key,'List',['class'=>'custom-control-label'])); ?><br>
                                            </div>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                   <?php if(in_array('create '.strtolower($module),(array) $permissions)): ?>
                                       <?php if($key = array_search('create '.strtolower($module),$permissions)): ?>
                                           <div class="col-lg-2 col-sm-2 custom-control custom-checkbox">
                                               <?php echo e(Form::checkbox('permissions[]','create '.strtolower($module),in_array('create '.strtolower($module),$assignedPermission), ['class'=>'checkbox custom-control-input','id' =>'permission'.$key])); ?>

                                               <?php echo e(Form::label('permission'.$key,'Create',['class'=>'custom-control-label'])); ?><br>
                                           </div>
                                       <?php endif; ?>
                                   <?php endif; ?>
                                   <?php if(in_array('edit '.strtolower($module),(array) $permissions)): ?>
                                       <?php if($key = array_search('edit '.strtolower($module),$permissions)): ?>
                                           <div class="col-lg-2 col-sm-2 custom-control custom-checkbox">
                                               <?php echo e(Form::checkbox('permissions[]','edit '.strtolower($module),in_array('edit '.strtolower($module),$assignedPermission), ['class'=>'checkbox custom-control-input','id' =>'permission'.$key])); ?>

                                               <?php echo e(Form::label('permission'.$key,'Edit',['class'=>'custom-control-label'])); ?><br>
                                           </div>
                                       <?php endif; ?>
                                   <?php endif; ?>    
                                   <?php if(in_array('delete '.strtolower($module),(array) $permissions)): ?>
                                       <?php if($key = array_search('delete '.strtolower($module),$permissions)): ?>
                                           <div class="col-lg-2 col-sm-2 custom-control custom-checkbox">
                                               <?php echo e(Form::checkbox('permissions[]','delete '.strtolower($module),in_array('delete '.strtolower($module),$assignedPermission), ['class'=>'checkbox custom-control-input','id' =>'permission'.$key])); ?>

                                               <?php echo e(Form::label('permission'.$key,'Delete',['class'=>'custom-control-label'])); ?><br>
                                           </div>
                                       <?php endif; ?>
                                   <?php endif; ?>   
                                   <?php if(in_array('view '.strtolower($module),(array) $permissions)): ?>
                                       <?php if($key = array_search('view '.strtolower($module),$permissions)): ?>
                                           <div class="col-lg-2 col-sm-2 custom-control custom-checkbox">
                                               <?php echo e(Form::checkbox('permissions[]','view '.strtolower($module),in_array('delete '.strtolower($module),$assignedPermission), ['class'=>'checkbox custom-control-input','id' =>'permission'.$key])); ?>

                                               <?php echo e(Form::label('permission'.$key,'View',['class'=>'custom-control-label'])); ?><br>
                                           </div>
                                       <?php endif; ?>
                                   <?php endif; ?>                      
                                   </div>
                                   </td>
                                 </tr>
                                 <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                                </table> 
       
                       </div>
                       <div class="form-group">
                           <div class="col-lg-offset-4 col-lg-8">
                               <button type="submit" class="btn btn-primary">Update Role</button>
                               <a href="<?php echo e(route('role.index')); ?>" class="btn btn-warning">Cancel</a>
                           </div>
                       </div>
                   </form>
                </div>
            </div>
        </div>
      </div>
    </div>
</section>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
<script>
   $('#select_all').on('change', function() {     
                $('.checkbox').prop('checked', $(this).prop("checked"));        
        });
        $('.checkbox').change(function(){ //".checkbox" change 
            if($('.checkbox:checked').length == $('.checkbox').length){
                   $('#select_all').prop('checked',true);
            }else{
                   $('#select_all').prop('checked',false);
            }
        });
         $(document).ready(function() {
         if($('.checkbox:checked').length == $('.checkbox').length){
                   $('#select_all').prop('checked',true);
            }else{
                   $('#select_all').prop('checked',false);
            }
        });
</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.layout-admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\extranet\resources\views/pages/admin/role/edit.blade.php ENDPATH**/ ?>