<?php $__env->startSection('title', $branch->exists ? 'Editar filial' : 'Nova filial'); ?>
<?php $__env->startSection('content'); ?>
    <div class="page-heading"><div><span class="eyebrow">ADMINISTRAÇÃO · FILIAIS</span><h1><?php echo e($branch->exists ? 'Editar '.$branch->name : 'Registar nova filial'); ?></h1><p>Todos os campos poderão ser actualizados por administradores autorizados.</p></div><a class="secondary-link" href="<?php echo e(route('admin.branches.index')); ?>">← Voltar</a></div>
    <?php if($errors->any()): ?><div class="alert danger"><?php echo e($errors->first()); ?></div><?php endif; ?>
    <form class="panel management-form" method="POST" action="<?php echo e($branch->exists ? route('admin.branches.update', $branch) : route('admin.branches.store')); ?>"><?php echo csrf_field(); ?> <?php if($branch->exists): ?><?php echo method_field('PUT'); ?><?php endif; ?>
        <div class="form-section"><div><span class="eyebrow">IDENTIFICAÇÃO</span><h2>Dados da unidade</h2></div><div class="form-grid">
            <label class="field"><span>Organização</span><select name="organization_id" required><?php $__currentLoopData = $organizations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $organization): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($organization->id); ?>" <?php if(old('organization_id', $branch->organization_id ?: $organizations->first()?->id) == $organization->id): echo 'selected'; endif; ?>><?php echo e($organization->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></label>
            <label class="field"><span>Código único</span><input name="code" value="<?php echo e(old('code', $branch->code)); ?>" maxlength="30" required placeholder="EX.: BIE-KTO"></label>
            <label class="field span-2"><span>Nome oficial da unidade</span><input name="name" value="<?php echo e(old('name', $branch->name)); ?>" required></label>
            <label class="field"><span>Tipo</span><select name="type"><option value="filial" <?php if(old('type', $branch->type ?: 'filial') === 'filial'): echo 'selected'; endif; ?>>Filial</option><option value="sede" <?php if(old('type', $branch->type) === 'sede'): echo 'selected'; endif; ?>>Sede</option></select></label>
            <label class="field"><span>Unidade superior</span><select name="parent_id"><option value="">Sem unidade superior</option><?php $__currentLoopData = $parents; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $parent): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($parent->id); ?>" <?php if(old('parent_id', $branch->parent_id) == $parent->id): echo 'selected'; endif; ?>><?php echo e($parent->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></label>
        </div></div>
        <div class="form-section"><div><span class="eyebrow">LOCALIZAÇÃO</span><h2>Endereço e contactos</h2></div><div class="form-grid">
            <label class="field"><span>Província</span><input name="province" value="<?php echo e(old('province', $branch->province)); ?>" required></label><label class="field"><span>Município</span><input name="municipality" value="<?php echo e(old('municipality', $branch->municipality)); ?>"></label>
            <label class="field span-2"><span>Endereço</span><input name="address" value="<?php echo e(old('address', $branch->address)); ?>"></label><label class="field"><span>Telefone</span><input name="phone" value="<?php echo e(old('phone', $branch->phone)); ?>"></label><label class="field"><span>Email</span><input type="email" name="email" value="<?php echo e(old('email', $branch->email)); ?>"></label>
        </div></div>
        <div class="form-options"><label><input type="checkbox" name="is_headquarters" value="1" <?php if(old('is_headquarters', $branch->is_headquarters)): echo 'checked'; endif; ?>> Esta unidade é a sede principal</label><label><input type="checkbox" name="is_active" value="1" <?php if(old('is_active', $branch->exists ? $branch->is_active : true)): echo 'checked'; endif; ?>> Unidade activa</label></div>
        <div class="form-actions"><a class="secondary-link" href="<?php echo e(route('admin.branches.index')); ?>">Cancelar</a><button class="primary-button compact" type="submit">Guardar filial</button></div>
    </form>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\Joe B\.codex\.chatgpt-projects\g-p-6a6ce038586481919be04257dc687fef\nestab-ops\resources\views/admin/branches/form.blade.php ENDPATH**/ ?>