BOLETC/php/reporte_ventas.php

29 lines
810 B
PHP

<?php
include 'conexion.php';
$fechaInicio = $_GET['fechaInicio'] ?? null;
$fechaFin = $_GET['fechaFin'] ?? null;
if (!$fechaInicio || !$fechaFin) {
die(json_encode(["error" => "Debe seleccionar un período de fechas."]));
}
$sql = "SELECT b.id, c.nombre AS concierto, c.fecha, c.hora, z.nombre AS zona, a.numero AS asiento, b.precio, b.fecha_venta
FROM boletos b
JOIN asientos a ON b.asiento_id = a.id
JOIN zonas z ON a.zona_id = z.id
JOIN conciertos c ON z.concierto_id = c.id
WHERE DATE(b.fecha_venta) BETWEEN ? AND ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ss", $fechaInicio, $fechaFin);
$stmt->execute();
$result = $stmt->get_result();
$ventas = [];
while ($row = $result->fetch_assoc()) {
$ventas[] = $row;
}
echo json_encode($ventas);
?>