<?php $__env->startSection('title', $department->exists ? 'Editar departamento' : 'Novo departamento'); ?>
<?php $__env->startSection('content'); ?>
    <div class="page-heading"><div><span class="eyebrow">ADMINISTRAÇÃO · DEPARTAMENTOS</span><h1><?php echo e($department->exists ? 'Editar '.$department->name : 'Criar departamento'); ?></h1><p>A estrutura pode evoluir sem perder o histórico anterior.</p></div><a class="secondary-link" href="<?php echo e(route('admin.departments.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 narrow" method="POST" action="<?php echo e($department->exists ? route('admin.departments.update', $department) : route('admin.departments.store')); ?>"><?php echo csrf_field(); ?> <?php if($department->exists): ?><?php echo method_field('PUT'); ?><?php endif; ?>
        <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', $department->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', $department->code)); ?>" required></label><label class="field span-2"><span>Nome</span><input name="name" value="<?php echo e(old('name', $department->name)); ?>" required></label><label class="field span-2"><span>Descrição</span><textarea name="description" rows="5"><?php echo e(old('description', $department->description)); ?></textarea></label></div>
        <div class="form-options"><label><input type="checkbox" name="is_active" value="1" <?php if(old('is_active', $department->exists ? $department->is_active : true)): echo 'checked'; endif; ?>> Departamento activo</label></div><div class="form-actions"><a class="secondary-link" href="<?php echo e(route('admin.departments.index')); ?>">Cancelar</a><button class="primary-button compact" type="submit">Guardar departamento</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/departments/form.blade.php ENDPATH**/ ?>