All
This commit is contained in:
@@ -81,29 +81,42 @@ try {
|
||||
'horario_view',
|
||||
columns: $columns
|
||||
),
|
||||
'query' => $db->getLastQuery(),
|
||||
'reposiciones' => $db
|
||||
->join('periodo', 'periodo.periodo_id = horario_view.periodo_id')
|
||||
->join('registro', 'registro.horario_id = horario_view.horario_id')
|
||||
->join('reposicion', 'registro.reposicion_id = reposicion.reposicion_id')
|
||||
->join('bloque_horario', '(bloque_horario.hora_inicio, bloque_horario.hora_fin) OVERLAPS (reposicion_hora, reposicion_hora + horario_view.duracion)')
|
||||
->join('profesor', 'profesor.profesor_id = registro.profesor_id')
|
||||
->join('salon_view', 'salon_view.salon_id = reposicion.salon_id', 'LEFT')
|
||||
->join('salon as salon_reposicion', 'salon_reposicion.salon_id = horario_view.salon_id', 'LEFT')
|
||||
->where("CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin")
|
||||
->where("reposicion_fecha = CURRENT_DATE")
|
||||
->where('bloque_horario.id', $_GET['bloque_horario_id'])
|
||||
->where('salon_view.id_espacio_padre', $ruta['id_espacio_sgu'])
|
||||
->get(
|
||||
'horario_view',
|
||||
columns: $columns
|
||||
// 'query' => $db->getLastQuery(),
|
||||
'reposiciones' => $db->query(
|
||||
'SELECT ' . implode(', ', $columns) . <<<SQL
|
||||
, reposicion_hora + horario_view.duracion as reposicion_fin
|
||||
FROM horario_view
|
||||
JOIN periodo USING (periodo_id)
|
||||
JOIN registro USING (horario_id)
|
||||
JOIN reposicion USING (reposicion_id)
|
||||
JOIN bloque_horario ON (bloque_horario.hora_inicio, bloque_horario.hora_fin) OVERLAPS (reposicion_hora, reposicion_hora + horario_view.duracion)
|
||||
JOIN profesor USING (profesor_id)
|
||||
JOIN salon_view as salon_reposicion ON (salon_reposicion.salon_id = reposicion.salon_id)
|
||||
WHERE
|
||||
CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio
|
||||
AND periodo.periodo_fecha_fin
|
||||
AND reposicion_fecha = CURRENT_DATE
|
||||
AND bloque_horario.id = :bloque_horario_id
|
||||
AND salon_reposicion.id_espacio_padre = :id_espacio_sgu
|
||||
ORDER BY reposicion_hora
|
||||
SQL,
|
||||
[
|
||||
'bloque_horario_id' => $_GET['bloque_horario_id'],
|
||||
'id_espacio_sgu' => $ruta['id_espacio_sgu'],
|
||||
]
|
||||
),
|
||||
],
|
||||
$ruta,
|
||||
),
|
||||
$data
|
||||
);
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
|
||||
$data = array_filter(
|
||||
$data,
|
||||
fn($ruta) => count($ruta['horarios']) > 0 || count($ruta['reposiciones']) > 0
|
||||
);
|
||||
|
||||
echo json_encode(array_values($data), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
http_response_code(405);
|
||||
echo json_encode(['error' => 'method not allowed']);
|
||||
|
||||
Reference in New Issue
Block a user