<?php $__env->startSection('title', 'Branches'); ?>
<?php $__env->startSection('page-title', 'Branch Management'); ?>

<?php $__env->startSection('content'); ?>
<div class="row g-4">
    <div class="col-lg-4">
        <div class="card border-0 shadow-sm"><div class="card-body">
            <h2 class="h5">New branch</h2>
            <form method="POST" action="<?php echo e(route('tenant.branches.store')); ?>" class="vstack gap-2">
                <?php echo csrf_field(); ?>
                <input name="name" class="form-control" placeholder="Branch name" required>
                <input name="code" class="form-control" placeholder="Code" required>
                <select name="manager_id" class="form-select"><option value="">No manager</option><?php $__currentLoopData = $managers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $manager): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($manager->id); ?>"><?php echo e($manager->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select>
                <input name="phone" class="form-control" placeholder="Phone">
                <textarea name="address" class="form-control" placeholder="Address"></textarea>
                <input type="hidden" name="is_active" value="1">
                <button class="btn btn-primary">Create branch</button>
            </form>
        </div></div>
    </div>
    <div class="col-lg-8">
        <div class="card border-0 shadow-sm">
            <div class="table-responsive">
                <table class="table mb-0"><thead><tr><th>Name</th><th>Code</th><th>Manager</th><th>Active</th><th></th></tr></thead><tbody>
                <?php $__currentLoopData = $branches; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $branch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <form method="POST" action="<?php echo e(route('tenant.branches.update', $branch)); ?>">
                            <?php echo csrf_field(); ?> <?php echo method_field('PATCH'); ?>
                            <td><input name="name" value="<?php echo e($branch->name); ?>" class="form-control form-control-sm"></td>
                            <td><input name="code" value="<?php echo e($branch->code); ?>" class="form-control form-control-sm"></td>
                            <td><select name="manager_id" class="form-select form-select-sm"><option value="">None</option><?php $__currentLoopData = $managers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $manager): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($manager->id); ?>" <?php if($branch->manager_id===$manager->id): echo 'selected'; endif; ?>><?php echo e($manager->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></td>
                            <td><input type="hidden" name="is_active" value="0"><input type="checkbox" name="is_active" value="1" <?php if($branch->is_active): echo 'checked'; endif; ?>></td>
                            <td class="text-end"><input type="hidden" name="phone" value="<?php echo e($branch->phone); ?>"><input type="hidden" name="address" value="<?php echo e($branch->address); ?>"><button class="btn btn-sm btn-outline-primary">Save</button>
                        </form>
                            <form method="POST" action="<?php echo e(route('tenant.branches.destroy', $branch)); ?>" class="d-inline"><?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?><button class="btn btn-sm btn-outline-danger">Disable</button></form>
                            </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody></table>
            </div>
            <div class="card-body"><?php echo e($branches->links()); ?></div>
        </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 C:\Users\Polite hp\Documents\Codex\2026-05-08\build-a-complete-production-ready-saas\microfinance-saas\resources\views\tenant\branches\index.blade.php ENDPATH**/ ?>