Actualizar Interfaz/scripts/reporte_ventas.js
This commit is contained in:
parent
37620d21c6
commit
52eedeadd4
Interfaz/scripts
|
@ -1,15 +1,14 @@
|
||||||
document.getElementById('formReporte').addEventListener('submit', function (event) {
|
document.getElementById('formReporte').addEventListener('submit', function (event) {
|
||||||
event.preventDefault(); // Evitar que el formulario se envíe
|
event.preventDefault();
|
||||||
|
|
||||||
const fechaInicio = document.getElementById('fechaInicio').value;
|
const fechaInicio = document.getElementById('fechaInicio').value;
|
||||||
const fechaFin = document.getElementById('fechaFin').value;
|
const fechaFin = document.getElementById('fechaFin').value;
|
||||||
|
|
||||||
// Cargar el reporte de ventas
|
|
||||||
cargarReporte(fechaInicio, fechaFin);
|
cargarReporte(fechaInicio, fechaFin);
|
||||||
});
|
});
|
||||||
|
|
||||||
function cargarReporte(fechaInicio, fechaFin) {
|
function cargarReporte(fechaInicio, fechaFin) {
|
||||||
const url = `reporte_ventas.php?fechaInicio=${encodeURIComponent(fechaInicio)}&fechaFin=${encodeURIComponent(fechaFin)}`;
|
const url = `control/reporte_ventas.php?fechaInicio=${encodeURIComponent(fechaInicio)}&fechaFin=${encodeURIComponent(fechaFin)}`;
|
||||||
|
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
|
@ -19,14 +18,11 @@ function cargarReporte(fechaInicio, fechaFin) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualizar el total de boletos vendidos
|
|
||||||
document.getElementById('totalBoletos').textContent = data.totalBoletos;
|
document.getElementById('totalBoletos').textContent = data.totalBoletos;
|
||||||
|
|
||||||
// Limpiar la tabla
|
|
||||||
const tbody = document.querySelector('#tablaVentas tbody');
|
const tbody = document.querySelector('#tablaVentas tbody');
|
||||||
tbody.innerHTML = '';
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
// Llenar la tabla con los datos de las ventas
|
|
||||||
data.ventas.forEach(venta => {
|
data.ventas.forEach(venta => {
|
||||||
const fila = document.createElement('tr');
|
const fila = document.createElement('tr');
|
||||||
fila.innerHTML = `
|
fila.innerHTML = `
|
||||||
|
@ -40,7 +36,6 @@ function cargarReporte(fechaInicio, fechaFin) {
|
||||||
.catch(error => console.error('Error al cargar el reporte:', error));
|
.catch(error => console.error('Error al cargar el reporte:', error));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualizar el reporte cada 10 segundos
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const fechaInicio = document.getElementById('fechaInicio').value;
|
const fechaInicio = document.getElementById('fechaInicio').value;
|
||||||
const fechaFin = document.getElementById('fechaFin').value;
|
const fechaFin = document.getElementById('fechaFin').value;
|
||||||
|
@ -48,4 +43,4 @@ setInterval(() => {
|
||||||
if (fechaInicio && fechaFin) {
|
if (fechaInicio && fechaFin) {
|
||||||
cargarReporte(fechaInicio, fechaFin);
|
cargarReporte(fechaInicio, fechaFin);
|
||||||
}
|
}
|
||||||
}, 10000); // 10 segundos
|
}, 10000);
|
||||||
|
|
Loading…
Reference in New Issue