<?php $__env->startSection('title','Users & Roles'); ?>
<?php $__env->startSection('content'); ?>
<div class="page-shell">
<div class="page-head"><div><h1 class="page-title">Multi-user / Role Permission</h1><div class="page-subtitle">Create manager, accountant, cashier and custom role users</div></div></div>
<form method="POST" action="<?php echo e(route('admin.users.store')); ?>" class="card panel-tight grid-3"><?php echo csrf_field(); ?>
<div><label>Name</label><input type="text" name="name" required></div><div><label>Email</label><input type="text" name="email" required></div><div><label>Password</label><input type="text" name="password" required></div>
<div><label>Role</label><select name="role"><option>Super Admin</option><option>Manager</option><option>Accountant</option><option>Cashier</option><option>Custom</option></select></div>
<div><label>Status</label><select name="status"><option>Active</option><option>Inactive</option></select></div><div><label>Branch ID</label><input type="number" name="branch_id"></div>
<div style="grid-column:1/-1"><label>Custom Permissions</label><div class="row"><?php $__currentLoopData = $permissionMap; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $perm): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><label style="display:flex;align-items:center;gap:6px"><input type="checkbox" name="permissions[]" value="<?php echo e($perm); ?>"> <?php echo e(ucfirst($perm)); ?></label><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></div></div>
<div class="form-actions" style="grid-column:1/-1"><button class="btn primary">Create User</button></div>
</form>
<div class="card panel-tight table-wrap">
<table class="table">
<thead><tr><th>Name</th><th>Email</th><th>Role</th><th>Status</th><th>Branch</th><th>Permissions</th><th>Action</th></tr></thead>
<tbody>
<?php $__currentLoopData = $admins; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $admin): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<tr>
    <td><?php echo e($admin->name); ?></td><td><?php echo e($admin->email); ?></td><td><?php echo e($admin->role); ?></td><td><?php echo e($admin->status); ?></td><td><?php echo e($admin->branch_id ?: '—'); ?></td><td><?php echo e(implode(', ', $admin->permissionsList())); ?></td>
    <td>
        <details>
            <summary class="btn">Edit</summary>
            <form method="POST" action="<?php echo e(route('admin.users.update',$admin)); ?>" class="grid-2" style="margin-top:10px"><?php echo csrf_field(); ?> <?php echo method_field('PUT'); ?>
                <div><label>Name</label><input type="text" name="name" value="<?php echo e($admin->name); ?>"></div>
                <div><label>Email</label><input type="text" name="email" value="<?php echo e($admin->email); ?>"></div>
                <div><label>New Password</label><input type="text" name="password"></div>
                <div><label>Role</label><select name="role"><?php $__currentLoopData = ['Super Admin','Manager','Accountant','Cashier','Custom']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($role); ?>" <?php if($admin->role==$role): echo 'selected'; endif; ?>><?php echo e($role); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div>
                <div><label>Status</label><select name="status"><option value="Active" <?php if($admin->status=='Active'): echo 'selected'; endif; ?>>Active</option><option value="Inactive" <?php if($admin->status=='Inactive'): echo 'selected'; endif; ?>>Inactive</option></select></div><div><label>Branch ID</label><input type="number" name="branch_id" value="<?php echo e($admin->branch_id); ?>"></div>
                <div style="grid-column:1/-1"><label>Permissions</label><div class="row"><?php $__currentLoopData = $permissionMap; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $perm): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><label style="display:flex;align-items:center;gap:6px"><input type="checkbox" name="permissions[]" value="<?php echo e($perm); ?>" <?php if(in_array($perm,$admin->permissionsList())): echo 'checked'; endif; ?>> <?php echo e(ucfirst($perm)); ?></label><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></div></div>
                <div class="form-actions" style="grid-column:1/-1"><button class="btn primary">Update</button></div>
            </form>
            <form method="POST" action="<?php echo e(route('admin.users.destroy',$admin)); ?>" style="margin-top:10px"><?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?><button class="btn btn-danger" onclick="return confirm('Delete this user?')">Delete</button></form>
        </details>
    </td>
</tr>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</tbody></table></div></div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH J:\xampp\htdocs\pos\resources\views/admin/users/index.blade.php ENDPATH**/ ?>