<form action="<?= e(url('configuracion/numeraciones')) ?>" method="post" class="row g-2">
    <?= csrf_field() ?>
    <?php $selectedDocumentType = (string) old('n_tipo_documento', old('tipo_documento', 'factura')); ?>
    <div class="col-md-4">
        <label class="form-label">Tipo documento</label>
        <select class="form-select" name="n_tipo_documento" required>
            <option value="factura" <?= $selectedDocumentType === 'factura' ? 'selected' : '' ?>>Factura</option>
            <option value="nota_credito" <?= $selectedDocumentType === 'nota_credito' ? 'selected' : '' ?>>Nota crédito</option>
            <option value="nota_debito" <?= $selectedDocumentType === 'nota_debito' ? 'selected' : '' ?>>Nota débito</option>
            <option value="remision" <?= $selectedDocumentType === 'remision' ? 'selected' : '' ?>>Remisión</option>
        </select>
    </div>
    <div class="col-md-4">
        <label class="form-label">Sucursal</label>
        <?php $selectedNumberingBranch = (int) old('n_sucursal_id', old('sucursal_id', 0)); ?>
        <select class="form-select" name="n_sucursal_id">
            <option value="0">General (todas)</option>
            <?php foreach ($branches as $branch): ?>
                <option value="<?= e((string) $branch['id']) ?>" <?= $selectedNumberingBranch === (int) $branch['id'] ? 'selected' : '' ?>>
                    <?= e((string) $branch['nombre']) ?>
                </option>
            <?php endforeach; ?>
        </select>
    </div>
    <div class="col-md-4">
        <label class="form-label">Prefijo</label>
        <input class="form-control" name="n_prefijo" maxlength="20" value="<?= e((string) old('n_prefijo', old('prefijo', ''))) ?>">
    </div>
    <div class="col-md-4">
        <label class="form-label">Consecutivo actual</label>
        <input type="number" min="1" class="form-control" name="n_consecutivo_actual" value="<?= e((string) old('n_consecutivo_actual', old('consecutivo_actual', '1'))) ?>" required>
    </div>
    <div class="col-md-4">
        <label class="form-label">Final</label>
        <input type="number" min="1" class="form-control" name="n_consecutivo_final" value="<?= e((string) old('n_consecutivo_final', old('consecutivo_final', ''))) ?>">
    </div>
    <div class="col-md-4">
        <label class="form-label d-block">Activa</label>
        <input type="hidden" name="n_activo" value="0">
        <div class="form-check mt-2">
            <input class="form-check-input" type="checkbox" name="n_activo" value="1" <?= (string) old('n_activo', old('activo', '1')) === '1' ? 'checked' : '' ?>>
        </div>
    </div>
    <div class="col-12 d-flex justify-content-end">
        <button class="btn btn-primary" type="submit">Guardar numeración</button>
    </div>
</form>
<?php /**PATH /Applications/XAMPP/xamppfiles/htdocs/veltrix-v2/resources/views/modules/configuracion/partials/numbering_form.blade.php ENDPATH**/ ?>