Rutas salón
Some checks are pending
Deploy Pruebas / deploy (push) Waiting to run

This commit is contained in:
Your Name
2024-10-08 11:59:02 -06:00
parent fab36e0f9b
commit 2dd40e1bb8

View File

@@ -62,10 +62,8 @@ try {
'salon_reposicion.salon as reposicion_salon', 'salon_reposicion.salon as reposicion_salon',
]; ];
$fecha = ($_GET['fecha'] != 'null') ? ("'{$_GET['fecha']}'" ?: 'CURRENT_DATE') : 'CURRENT_DATE'; $fecha = ($_GET['fecha'] != 'null') ? ("'{$_GET['fecha']}'" ?: 'CURRENT_DATE') : 'CURRENT_DATE';
$data = array_map(
fn($ruta) => array_merge( $horarios_y_reposiciones = $db->query(
[
'horarios' => $db->query(
"SELECT " . implode(', ', $columns) . <<<SQL "SELECT " . implode(', ', $columns) . <<<SQL
, NULL, NULL, 0 AS tipo , NULL, NULL, 0 AS tipo
FROM horario_view FROM horario_view
@@ -80,18 +78,9 @@ try {
WHERE $fecha::DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin WHERE $fecha::DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin
AND horario_dia = EXTRACT(DOW FROM $fecha::DATE) AND horario_dia = EXTRACT(DOW FROM $fecha::DATE)
AND bloque_horario.id = :bloque_horario_id AND bloque_horario.id = :bloque_horario_id
AND salon_view_mat.id_espacio_padre = :id_espacio_sgu AND salon_view_mat.id_espacio_padre IN :id_espacio_sgu
ORDER BY horario_hora, salon_view_mat.salon; SQL . ' UNION ALL ' . 'SELECT ' . implode(', ', $columns) . <<<SQL
SQL, , reposicion_hora + horario_view.duracion as reposicion_fin, registro_fecha_ideal, 1 AS tipo
[
'bloque_horario_id' => $_GET['bloque_horario_id'],
'id_espacio_sgu' => $ruta['id_espacio_sgu'],
]
),
// 'query' => $db->getLastQuery(),
'reposiciones' => $db->query(
'SELECT ' . implode(', ', $columns) . <<<SQL
, reposicion_hora + horario_view.duracion as reposicion_fin, registro_fecha_ideal, 1 AS tipo
FROM horario_view FROM horario_view
inner JOIN periodo using(periodo_id) inner JOIN periodo using(periodo_id)
NATURAL JOIN registro NATURAL JOIN registro
@@ -104,13 +93,25 @@ try {
AND periodo.periodo_fecha_fin AND periodo.periodo_fecha_fin
AND reposicion_fecha = $fecha::DATE AND reposicion_fecha = $fecha::DATE
AND bloque_horario.id = :bloque_horario_id AND bloque_horario.id = :bloque_horario_id
AND salon_reposicion.id_espacio_padre = :id_espacio_sgu AND salon_reposicion.id_espacio_padre IN :id_espacio_sgu
ORDER BY reposicion_hora ORDER BY reposicion_hora
SQL, SQL,
[ [
'bloque_horario_id' => $_GET['bloque_horario_id'], 'bloque_horario_id' => $_GET['bloque_horario_id'],
'id_espacio_sgu' => $ruta['id_espacio_sgu'], 'id_espacio_sgu' => array_column($data, 'id_espacio_sgu'),
] ]
);
$data = array_map(
fn($ruta) => array_merge(
[
'horarios' => array_filter(
$horarios_y_reposiciones,
fn($horario) => $horario['id_espacio_sgu'] === $ruta['id_espacio_sgu'] && $horario['tipo'] === 0
),
// 'query' => $db->getLastQuery(),
'reposiciones' => array_filter(
$horarios_y_reposiciones,
fn($horario) => $horario['id_espacio_sgu'] === $ruta['id_espacio_sgu'] && $horario['tipo'] === 1
), ),
], ],
$ruta, $ruta,