diff --git a/action/action_auditoria_detalle.php b/action/action_auditoria_detalle.php index 824237b..6b7cd0d 100644 --- a/action/action_auditoria_detalle.php +++ b/action/action_auditoria_detalle.php @@ -20,13 +20,57 @@ $user = unserialize($_SESSION['user']); try { if ($_SERVER['REQUEST_METHOD'] === 'GET') { - $data = $db - ->where('registro_fecha_ideal', $_GET['registro_fecha_ideal']) - ->where('horario_id', $_GET['horario_id']) - ->where('profesor_id', $_GET['profesor_id']) - ->getOne('auditoria_mat'); + $data = $db->querySingle( + "SELECT + :registro_fecha_ideal as registro_fecha_ideal, + horario_hora, + horario_fin, + profesor_nombre, + profesor_correo, + profesor_clave, + horario.facultad_id, + materia_nombre as materia, + facultad_nombre as facultad, + carrera_nombre as carrera, + registro_fecha, + estado_color, + estado_supervisor.estado_supervisor_id, + estado_supervisor.nombre, + estado_icon, + usuario_nombre, + horario_grupo, + registro_retardo, + justificada, + justificacion, + comentario, + CASE + WHEN registro.registro_retardo THEN 'warning' + ELSE 'primary' + END AS color + FROM horario + NATURAL JOIN facultad + NATURAL JOIN materia + NATURAL JOIN carrera + NATURAL JOIN horario_profesor + NATURAL JOIN profesor + LEFT JOIN registro ON + REGISTRO.HORARIO_ID = HORARIO.HORARIO_ID AND + REGISTRO.PROFESOR_ID = HORARIO_PROFESOR.PROFESOR_ID AND + REGISTRO.REGISTRO_FECHA_IDEAL = :registro_fecha_ideal + + LEFT JOIN estado_supervisor ON estado_supervisor.estado_supervisor_id = COALESCE(registro.estado_supervisor_id, 0) + LEFT JOIN usuario ON usuario_id = supervisor_id + + WHERE horario.horario_id = :horario_id + AND profesor.profesor_id = :profesor_id", + $_GET + ); + /* ->where('registro_fecha_ideal', $_GET['registro_fecha_ideal']) + ->where('horario_id', $_GET['horario_id']) + ->where('profesor_id', $_GET['profesor_id']) + ->getOne('auditoria_mat'); */ // Print the JSON file - echo json_encode(array_merge($data, ['query' => $db->getLastQuery(), 'get' => $_GET])); + echo json_encode($data); } else { http_response_code(405); echo json_encode(['error' => 'method not allowed']);