<?php $type = $type ?? []; ?>
<div class="enterprise-settings-fields enterprise-settings-fields--single">
    <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', $type['name'] ?? '')) ?>" required placeholder="e.g. Passport, Work Permit">
    </div>
    <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="15" value="<?= esc(old('code', $type['code'] ?? '')) ?>" required>
    </div>
    <div class="enterprise-field">
        <div class="form-check">
            <input class="form-check-input" type="checkbox" name="requires_expiry" value="1" id="requires_expiry"
                <?= old('requires_expiry', $type['requires_expiry'] ?? 0) ? 'checked' : '' ?>>
            <label class="form-check-label" for="requires_expiry">Requires expiry date</label>
        </div>
    </div>
    <div class="enterprise-field">
        <div class="form-check">
            <input class="form-check-input" type="checkbox" name="requires_number" value="1" id="requires_number"
                <?= old('requires_number', $type['requires_number'] ?? 0) ? 'checked' : '' ?>>
            <label class="form-check-label" for="requires_number">Requires document number</label>
        </div>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Description</label>
        <textarea name="description" class="form-control" rows="3"><?= esc(old('description', $type['description'] ?? '')) ?></textarea>
    </div>
    <?php if (! empty($type)): ?>
    <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', $type['status'] ?? 'active') === $s ? 'selected' : '' ?>><?= ucfirst($s) ?></option>
            <?php endforeach; ?>
        </select>
    </div>
    <?php endif; ?>
</div>
