Initial state
This commit is contained in:
35
action/action_horario.php
Normal file
35
action/action_horario.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$ruta = "../";
|
||||
require_once("../include/bd_pdo.php");
|
||||
|
||||
extract($_POST);
|
||||
|
||||
$dias = array("domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado");
|
||||
$horarios = $db
|
||||
->get("fs_horario($periodo, $carrera, '$grupo', true)");
|
||||
|
||||
// get each id from $horarios (might be duplicate)
|
||||
|
||||
try {
|
||||
$horarios = array_map(function ($horario) use ($dias, $db) {
|
||||
$horario['profesores'] = array_map(
|
||||
fn ($profesor) =>
|
||||
$db->where("id", $profesor)->getOne("fs_profesor"),
|
||||
explode(",", substr($horario['profesores'], 1, -1))
|
||||
);
|
||||
$horario['dia'] = $dias[$horario['dia']];
|
||||
return $horario;
|
||||
}, $horarios);
|
||||
} catch (Exception $e) {
|
||||
die(json_encode([
|
||||
"status" => "error",
|
||||
"message" => $e->getMessage(),
|
||||
]));
|
||||
}
|
||||
?>
|
||||
<?= json_encode([
|
||||
"status" => "success",
|
||||
"horario" => $horarios,
|
||||
]) ?>
|
||||
Reference in New Issue
Block a user