<?php $__env->startSection('title', 'Users'); ?>
<?php $__env->startSection('page_title', 'Users'); ?>
<?php $__env->startSection('breadcrumbs'); ?>
    <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Home</a></li>
    <li class="breadcrumb-item active">Users</li>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('page_actions'); ?>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('users.create')): ?>
        <a href="<?php echo e(route('users.create')); ?>" class="btn btn-primary"><i class="bi bi-plus-lg me-1"></i>Add User</a>
    <?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <div class="card">
        <div class="card-header"><i class="bi bi-person-badge me-1"></i>All Users (<?php echo e($users->count()); ?>)</div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover align-middle js-datatable">
                    <thead>
                        <tr>
                            <th>Name</th><th>Role</th><th>Branch</th><th>Employee #</th>
                            <th class="text-center">Status</th><th class="text-end">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td>
                                    <div class="d-flex align-items-center gap-2">
                                        <span class="sms-avatar sm"><?php echo e($u->initials); ?></span>
                                        <div>
                                            <div class="fw-semibold"><?php echo e($u->name); ?></div>
                                            <div class="small text-muted"><?php echo e($u->email); ?></div>
                                        </div>
                                    </div>
                                </td>
                                <td><span class="badge bg-soft-info"><?php echo e($u->role_label); ?></span></td>
                                <td><?php echo e($u->branch?->name ?? '—'); ?></td>
                                <td><?php echo e($u->employee_code ?? '—'); ?></td>
                                <td class="text-center">
                                    <?php if($u->is_active): ?><span class="badge bg-soft-success">Active</span>
                                    <?php else: ?><span class="badge bg-soft-danger">Inactive</span><?php endif; ?>
                                </td>
                                <td class="text-end">
                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('users.update')): ?>
                                        <a href="<?php echo e(route('users.edit', $u)); ?>" class="btn btn-sm btn-light border"><i class="bi bi-pencil"></i></a>
                                    <?php endif; ?>
                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('users.delete')): ?>
                                        <?php if($u->id !== auth()->id() && !$u->isSuperAdmin()): ?>
                                            <form method="POST" action="<?php echo e(route('users.destroy', $u)); ?>" class="d-inline" data-confirm="Delete user “<?php echo e($u->name); ?>”?">
                                                <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                                <button class="btn btn-sm btn-light border text-danger"><i class="bi bi-trash"></i></button>
                                            </form>
                                        <?php endif; ?>
                                    <?php endif; ?>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/u385418287/domains/itartificer.com/public_html/sms-erp/resources/views/users/index.blade.php ENDPATH**/ ?>