<?php

session_start();    
require('../../conexion.php');

$usuario = $_SESSION['cveUsuario'];
$i=0;
$result = query("SELECT nv.ntv_no_mesa, nv.id, nv.ntv_no_nota, ntv_fecha_creacion, 
uss_nombre, pdn_comensal, ntv_hora_edt, DATE_FORMAT(nv.created_at, '%H:%i:%s') hora_creacion
FROM productos_nota AS pdn 
INNER JOIN productos AS pd ON pd.id = pdn.id_producto
INNER JOIN notas_venta AS nv ON nv.id = pdn.id_nota_venta
INNER JOIN usuarios as us ON us.id = nv.id_usuario
WHERE pdn.pdn_estatus IN('activo') AND DATE(pdn.created_at) = CURRENT_DATE() 
AND pro_clasificaciones NOT IN('BAR') GROUP BY nv.id ORDER BY ntv_hora_ini DESC;");

while($row = mysqli_fetch_assoc($result)){
    $rowdata[$i] = $row;
    $i++;
}

if ($i>0){
    $res =  json_encode($rowdata,JSON_UNESCAPED_UNICODE);
} else {
    $res =  '[{"id":"0"}]';	
}
echo $res;
?>
