<?php
/**
 * API: Listar Ventas en Espera
 */
header('Content-Type: application/json; charset=utf-8');
require_once '../../db_connection.php';

try {
    $stmt = $pdo->query("SELECT id, codigo_espera, cliente_nombre, total, created_at FROM ventas_espera ORDER BY id DESC");
    $ventas = $stmt->fetchAll(PDO::FETCH_ASSOC);

    echo json_encode([
        'success' => true,
        'data' => $ventas
    ]);

} catch (Exception $e) {
    http_response_code(500);
    echo json_encode([
        'success' => false,
        'error' => $e->getMessage()
    ]);
}
