fix: Correcion de filtro de examenes

This commit is contained in:
Hectorgh24 2025-06-15 23:27:01 -06:00
parent 26031d2c4d
commit cc47523717
2 changed files with 20 additions and 7 deletions

View File

@ -220,7 +220,7 @@ class Graficos{
$params[] = $filtros['fechaFin']; $params[] = $filtros['fechaFin'];
$types .= "ss"; $types .= "ss";
} }
$sql .= " GROUP BY ex.nombre_examen ORDER BY ex.nombre_examen"; $sql .= " GROUP BY ex.id_examen, ex.nombre_examen ORDER BY ex.id_examen";
$query = $this->db->prepare($sql); $query = $this->db->prepare($sql);
if ($params) $query->bind_param($types, ...$params); if ($params) $query->bind_param($types, ...$params);

View File

@ -160,12 +160,25 @@ async function obtenerDatosEstados(filtros = {}) {
} }
async function obtenerDatosExamenes(filtros = {}) { async function obtenerDatosExamenes(filtros = {}) {
const response = await fetch("../controllers/graficos.php", { try {
method: "POST", const response = await fetch("../controllers/graficos.php", {
headers: { "Content-Type": "application/json" }, method: "POST",
body: JSON.stringify({ tipoConsulta: "Examenes", ...filtros }), headers: { "Content-Type": "application/json" },
}); body: JSON.stringify({
return await response.json(); tipoConsulta: "Examenes",
...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 exámenes:", error);
return [];
}
} }
async function obtenerDatosFechas(filtros = {}) { async function obtenerDatosFechas(filtros = {}) {