<?php $__env->startSection('title', 'Branches'); ?>
<?php $__env->startSection('page_title', 'Branches'); ?>
<?php $__env->startSection('breadcrumbs'); ?>
    <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Home</a></li>
    <li class="breadcrumb-item active">Branches</li>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_actions'); ?>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('create', App\Models\Branch::class)): ?>
        <a href="<?php echo e(route('branches.create')); ?>" class="btn btn-primary"><i class="bi bi-plus-lg me-1"></i>Add Branch</a>
    <?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <div class="card">
        <div class="card-header"><i class="bi bi-buildings me-1"></i>All Branches (<?php echo e($branches->count()); ?>)</div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover align-middle js-datatable">
                    <thead>
                        <tr>
                            <th>Branch</th>
                            <th>Code</th>
                            <th>Principal</th>
                            <th>City</th>
                            <th class="text-center">Users</th>
                            <th class="text-center">Status</th>
                            <th class="text-end">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $branches; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $branch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td>
                                    <div class="d-flex align-items-center gap-2">
                                        <span class="sms-avatar sm" style="background:var(--sms-primary)"><?php echo e($branch->initials); ?></span>
                                        <div>
                                            <a href="<?php echo e(route('branches.show', $branch)); ?>" class="fw-semibold text-decoration-none"><?php echo e($branch->name); ?></a>
                                            <div class="small text-muted"><?php echo e($branch->phone ?: '—'); ?></div>
                                        </div>
                                    </div>
                                </td>
                                <td><span class="badge bg-soft-primary"><?php echo e($branch->code); ?></span></td>
                                <td><?php echo e($branch->principal_name ?: '—'); ?></td>
                                <td><?php echo e($branch->city ?: '—'); ?></td>
                                <td class="text-center"><?php echo e($branch->users_count); ?></td>
                                <td class="text-center">
                                    <?php if($branch->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('update', $branch)): ?>
                                        <a href="<?php echo e(route('branches.edit', $branch)); ?>" class="btn btn-sm btn-light border" title="Edit"><i class="bi bi-pencil"></i></a>
                                    <?php endif; ?>
                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('delete', $branch)): ?>
                                        <form method="POST" action="<?php echo e(route('branches.destroy', $branch)); ?>" class="d-inline" data-confirm="Delete branch “<?php echo e($branch->name); ?>”?">
                                            <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                            <button class="btn btn-sm btn-light border text-danger" title="Delete"><i class="bi bi-trash"></i></button>
                                        </form>
                                    <?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/branches/index.blade.php ENDPATH**/ ?>