<?php
// get_gasto_items.php
session_start();
require_once __DIR__ . '/../cotizaciones/api/_node.php';

$idGasto = isset($_GET['id']) ? intval($_GET['id']) : 0;

header('Content-Type: application/json; charset=utf-8');
if ($idGasto <= 0) {
  echo json_encode([]);
  exit;
}

$token = cpn_node_token_or_fail();
$base = cpn_node_api_base();
$resp = cpn_node_request('GET', $base . '/api/gastos/items?id=' . urlencode((string)$idGasto), $token, null);
if (!($resp['ok'] ?? false)) {
  echo json_encode([]);
  exit;
}

echo json_encode($resp['data'] ?? []);
