<?php
$center  = $center ?? [];
$parents = $parents ?? [];
?>
<div class="enterprise-settings-fields">
    <div class="enterprise-field">
        <label class="enterprise-field-label">Code <span class="text-danger">*</span></label>
        <input type="text" name="code" class="form-control text-uppercase" maxlength="30"
               value="<?= esc(old('code', $center['code'] ?? '')) ?>" required>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Name <span class="text-danger">*</span></label>
        <input type="text" name="name" class="form-control" value="<?= esc(old('name', $center['name'] ?? '')) ?>" required>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Parent</label>
        <select name="parent_id" class="form-select">
            <option value="">— None —</option>
            <?php foreach ($parents as $p): ?>
                <option value="<?= $p['id'] ?>" <?= (string) old('parent_id', $center['parent_id'] ?? '') === (string) $p['id'] ? 'selected' : '' ?>>
                    <?= esc($p['code'] . ' — ' . $p['name']) ?>
                </option>
            <?php endforeach; ?>
        </select>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Status</label>
        <select name="status" class="form-select">
            <?php foreach (['active', 'inactive'] as $s): ?>
                <option value="<?= $s ?>" <?= old('status', $center['status'] ?? 'active') === $s ? 'selected' : '' ?>><?= ucfirst($s) ?></option>
            <?php endforeach; ?>
        </select>
    </div>
    <div class="enterprise-field" style="grid-column: 1 / -1;">
        <label class="enterprise-field-label">Notes</label>
        <textarea name="notes" class="form-control" rows="3"><?= esc(old('notes', $center['notes'] ?? '')) ?></textarea>
    </div>
</div>
