44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
document.getElementById("generarReporte").addEventListener("click", function() {
|
|
let fechaInicio = document.getElementById("fechaInicio").value;
|
|
let fechaFin = document.getElementById("fechaFin").value;
|
|
|
|
if (!fechaInicio || !fechaFin) {
|
|
alert("Por favor, selecciona un período de fechas.");
|
|
return;
|
|
}
|
|
|
|
fetch(`../php/reporte_ventas.php?fechaInicio=${fechaInicio}&fechaFin=${fechaFin}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
let tabla = document.getElementById("tablaReporte");
|
|
tabla.innerHTML = ""; // Limpiar datos previos
|
|
|
|
data.forEach(venta => {
|
|
let row = `<tr>
|
|
<td>${venta.id}</td>
|
|
<td>${venta.concierto}</td>
|
|
<td>${venta.fecha}</td>
|
|
<td>${venta.hora}</td>
|
|
<td>${venta.zona}</td>
|
|
<td>${venta.asiento}</td>
|
|
<td>$${parseFloat(venta.precio).toFixed(2)}</td>
|
|
<td>${venta.fecha_venta}</td>
|
|
</tr>`;
|
|
tabla.innerHTML += row;
|
|
});
|
|
})
|
|
.catch(error => console.error("Error cargando el reporte:", error));
|
|
});
|
|
|
|
document.getElementById("exportarCSV").addEventListener("click", function() {
|
|
let fechaInicio = document.getElementById("fechaInicio").value;
|
|
let fechaFin = document.getElementById("fechaFin").value;
|
|
|
|
if (!fechaInicio || !fechaFin) {
|
|
alert("Por favor, selecciona un período de fechas.");
|
|
return;
|
|
}
|
|
|
|
window.location.href = `../php/exportar_csv.php?fechaInicio=${fechaInicio}&fechaFin=${fechaFin}`;
|
|
});
|