fix: correcion del grafico estados al aplicar el filtro de edades
This commit is contained in:
parent
b4a2a7ad8f
commit
4a0e01f7ad
|
@ -179,13 +179,18 @@ class Graficos{
|
|||
$params[] = $filtros['id_rango_edad'];
|
||||
$types .= "i";
|
||||
}
|
||||
if (!empty($filtros['id_examen'])) {
|
||||
$sql .= " AND c.id_examen = ?";
|
||||
$params[] = $filtros['id_examen'];
|
||||
$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 e.nombre ORDER BY e.nombre";
|
||||
$sql .= " GROUP BY e.id, e.nombre ORDER BY e.nombre";
|
||||
|
||||
$query = $this->db->prepare($sql);
|
||||
if ($params) $query->bind_param($types, ...$params);
|
||||
|
|
|
@ -177,12 +177,25 @@ async function obtenerDatosEdades(filtros = {}) {
|
|||
}
|
||||
|
||||
async function obtenerDatosEstados(filtros = {}) {
|
||||
const response = await fetch("../controllers/graficos.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ tipoConsulta: "Estados", ...filtros }),
|
||||
});
|
||||
return await response.json();
|
||||
try {
|
||||
const response = await fetch("../controllers/graficos.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
tipoConsulta: "Estados",
|
||||
...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 estados:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function obtenerDatosExamenes(filtros = {}) {
|
||||
|
|
Loading…
Reference in New Issue