<?php
// api/marca_options.php — marcas activas para combos
declare(strict_types=1);
header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, OPTIONS');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(204); exit; }

session_start();
require_once __DIR__ . '/../conex.php';
mysqli_set_charset($conn,'utf8mb4');

$res = mysqli_query($conn,"SELECT id_marca, nombre FROM tb_inv_marca WHERE IFNULL(condicion,1)=1 ORDER BY nombre ASC");
$data = [];
while ($row = mysqli_fetch_assoc($res)) $data[] = $row;
echo json_encode(['success'=>true,'data'=>$data]);
