<?php
header('Content-Type: application/json; charset=utf-8');
$cid=$_GET['cliente_id']??'';
$file='/var/www/0000/database/pedidos_horizon.json';
$all=json_decode(@file_get_contents($file),true)?:[];
$all=array_reverse($all);
foreach($all as $p){ if(($p['cliente_id']??'')==$cid){ echo json_encode($p); exit; } }
echo json_encode(['estado'=>'SIN_PEDIDOS']);
