<?php $__env->startSection('title',$role->exists?'Edit Role':'New Role'); ?> <?php $__env->startSection('page_title',$role->exists?'Edit Role':'New Role'); ?>
<?php $__env->startSection('content'); ?><div class="page-header"><div><h1><?php echo e($role->exists?'Role Permissions':'Create Role'); ?></h1><p class="muted">Permissions are action-specific. Branch access remains controlled by the user profile.</p></div><a class="btn btn-secondary" href="<?php echo e(route('users.index')); ?>">Back</a></div>
<form method="post" action="<?php echo e($role->exists?route('roles.update',$role):route('roles.store')); ?>"><?php echo csrf_field(); ?> <?php if($role->exists): ?><?php echo method_field('put'); ?><?php endif; ?><div class="card"><div class="card-body"><div class="form-grid"><div class="field"><label>Role Name *</label><input class="control" name="name" value="<?php echo e(old('name',$role->name)); ?>" required></div><div class="field"><label>Role Slug *</label><input class="control" name="slug" value="<?php echo e(old('slug',$role->slug)); ?>" <?php if($role->is_system): echo 'readonly'; endif; ?> required></div></div></div></div>
<?php ($selected=old('permission_ids',$role->exists?$role->permissions->pluck('id')->all():[])); ?>
<div class="card" style="margin-top:20px"><div class="card-header"><h3>Permission Matrix</h3><label class="checkbox"><input type="checkbox" data-check-all> Select all</label></div><div class="table-wrap"><table><thead><tr><th>Module</th><th>Allowed actions</th></tr></thead><tbody><?php $__currentLoopData = $permissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $module=>$items): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><tr><td><strong><?php echo e(ucwords(str_replace('_',' ',$module))); ?></strong></td><td><div class="permission-row"><?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $permission): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><label class="checkbox"><input type="checkbox" name="permission_ids[]" value="<?php echo e($permission->id); ?>" <?php if(in_array($permission->id,$selected)): echo 'checked'; endif; ?>> <?php echo e(ucwords(str_replace('_',' ',$permission->action))); ?></label><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></div></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></tbody></table></div><div class="card-footer"><button class="btn btn-primary">Save Role</button><?php if($role->exists&&!$role->is_system&&auth()->user()->hasPermission('roles.delete_draft')): ?><button type="submit" form="delete-role" class="btn btn-danger" onclick="return confirm('Delete this role?')">Delete</button><?php endif; ?></div></div></form><?php if($role->exists): ?><form id="delete-role" method="post" action="<?php echo e(route('roles.destroy',$role)); ?>"><?php echo csrf_field(); ?> <?php echo method_field('delete'); ?></form><?php endif; ?>
<?php $__env->startPush('scripts'); ?><script>document.querySelector('[data-check-all]')?.addEventListener('change',e=>document.querySelectorAll('input[name="permission_ids[]"]').forEach(x=>x.checked=e.target.checked));</script><?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/cbo/public_html/resources/views/admin/roles/form.blade.php ENDPATH**/ ?>