fix: correcion de grafico genero al aplicar el filtro de edades
This commit is contained in:
parent
a236233129
commit
b4a2a7ad8f
|
@ -98,13 +98,18 @@ class Graficos{
|
|||
$params[] = $filtros['id_genero'];
|
||||
$types .= "i";
|
||||
}
|
||||
if (!empty($filtros['id_rango_edad'])) {
|
||||
$sql .= " AND c.id_rango_edad = ?";
|
||||
$params[] = $filtros['id_rango_edad'];
|
||||
$types .= "i";
|
||||
}
|
||||
if (!empty($filtros['fechaInicio']) && !empty($filtros['fechaFin'])) {
|
||||
$sql .= " AND DATE(c.fecha_entrada) BETWEEN ? AND ?";
|
||||
$params[] = $filtros['fechaInicio'];
|
||||
$params[] = $filtros['fechaFin'];
|
||||
$types .= "ss";
|
||||
}
|
||||
$sql .= " GROUP BY g.descripcion ORDER BY g.descripcion";
|
||||
$sql .= " GROUP BY g.id_genero, g.descripcion ORDER BY g.id_genero";
|
||||
|
||||
$query = $this->db->prepare($sql);
|
||||
if ($params) $query->bind_param($types, ...$params);
|
||||
|
|
|
@ -133,21 +133,47 @@ function getFiltroActivo() {
|
|||
}
|
||||
|
||||
async function obtenerDatosGeneros(filtros = {}) {
|
||||
const response = await fetch("../controllers/graficos.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ tipoConsulta: "Generos", ...filtros }),
|
||||
});
|
||||
return await response.json();
|
||||
try {
|
||||
const response = await fetch("../controllers/graficos.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
tipoConsulta: "Generos",
|
||||
...filtros
|
||||
}),
|
||||
});
|
||||
const data = await response.json();
|
||||
if (!Array.isArray(data)) {
|
||||
console.error("La respuesta del backend no es un array:", data);
|
||||
return [];
|
||||
}
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error al obtener datos de géneros:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function obtenerDatosEdades(filtros = {}) {
|
||||
const response = await fetch("../controllers/graficos.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ tipoConsulta: "Edades", ...filtros }),
|
||||
});
|
||||
return await response.json();
|
||||
try {
|
||||
const response = await fetch("../controllers/graficos.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
tipoConsulta: "Edades",
|
||||
...filtros
|
||||
}),
|
||||
});
|
||||
const data = await response.json();
|
||||
if (!Array.isArray(data)) {
|
||||
console.error("La respuesta del backend no es un array:", data);
|
||||
return [];
|
||||
}
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error al obtener datos de edades:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function obtenerDatosEstados(filtros = {}) {
|
||||
|
|
Loading…
Reference in New Issue