<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Mock get parameters
$_GET['sucursal_id'] = 0;

ob_start();
require_once 'c:/wamp64/www/rey/pedidos/api/get_admin_orders.php';
$output = ob_get_clean();

$json = json_decode($output, true);

if ($json === null) {
    echo "ERROR: El output no es JSON valido. Output:\n";
    echo substr($output, 0, 500) . "\n";
} else {
    echo "API Response Summary:\n";
    echo "Success: " . ($json['success'] ? 'SI' : 'NO') . "\n";
    if (isset($json['view_mode'])) {
        echo "View Mode: " . $json['view_mode'] . "\n";
    }
    if (isset($json['data'])) {
        echo "Total Productos: " . count($json['data']) . "\n";
        if (count($json['data']) > 0) {
            echo "Ejemplo de producto:\n";
            print_r(array_slice($json['data'], 0, 1));
        }
    }
    if (isset($json['error'])) {
        echo "Error detail: " . $json['error'] . "\n";
    }
}
