This commit is contained in:
2023-09-18 19:08:35 +00:00
parent d6bc6dde37
commit 76fe06b0df
28 changed files with 1259 additions and 1064 deletions

View File

@@ -68,6 +68,7 @@ try {
comentario,
registro_fecha_justificacion,
profesor.profesor_id, profesor_nombre, profesor_clave, profesor_correo,
horario_id,
materia, carrera, horarios.facultad_id, facultad, nivel, horario_hora, horario_fin, horario_grupo, horarios.salon,
fechas.registro_fecha_ideal,
estado_supervisor.estado_supervisor_id as estado_supervisor_id,

View File

@@ -7,7 +7,16 @@ $ruta = "../";
require_once "../class/c_login.php";
// check if the session is started
$user = Login::get_user();
if (!isset($_SESSION['user']))
die('No se ha iniciado sesión');
$user = unserialize($_SESSION['user']);
//$user->access();
$duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//1 Repo , 0 Cambio
$bloque = filter_input(INPUT_POST, "bloque", FILTER_SANITIZE_NUMBER_INT);//1 Repo , 0 Cambio
$ciclo = filter_input(INPUT_POST, "ciclo", FILTER_SANITIZE_NUMBER_INT);//1 Repo , 0 Cambio
$fecha_falta = trim(htmlspecialchars($_POST["fecha_falta"], ENT_QUOTES, "UTF-8"));//limpia texto
$fecha_falta = trim(htmlspecialchars($_POST["fecha_falta"], ENT_QUOTES, "UTF-8"));//limpia texto
$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//limpia texto
$fecha_cambio = trim(htmlspecialchars($_POST["fecha_cambio"], ENT_QUOTES, "UTF-8"));//limpia texto
@@ -26,19 +35,21 @@ else
//$salon = trim(filter_input(INPUT_POST, "salon", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]);
$duracion_tiempo = $duracion_rs["duracion_interval"];
//-- Obtiene datos de horario regular de clase
$horario_rs = $db->querySingle('SELECT * from fs_horario_basic where id = :hor',
$horario_rs = $db->querySingle('SELECT * from horario_view where horario_id = :hor',
[':hor' => $hor]
);
$materia = $horario_rs["materia_id"];
$gpo = $horario_rs["grupo"];
$duracion = $horario_rs["duracion_total"];
$dia = $horario_rs["dia"];
$dia = $horario_rs["horario_dia"];
$hora = $hora_ini.":".$min_ini.":00";
$fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$hora;
$fecha_fin_new = date("Y-m-d H:i:00", strtotime($fecha_new.' + '.$duracion.' minute'));
$fecha_fin_new = date("Y-m-d", strtotime($fecha_new))." ".$duracion_tiempo;
$dia_new = date('w', strtotime($fecha_new));
if($tipo == 1){//Reposición
@@ -52,8 +63,10 @@ if($tipo == 1){//Reposición
//Valida que tenga clase en la fecha de falta
if(intval($dia) != intval($dia_falta)){
//header("Location:".$pag."?error=11");
echo intval($dia)." != ".intval($dia_falta);
header("Location:".$pag."?error=11");
/*print_r($_POST);
echo 'SELECT * from horario_view where horario_id = '.$hor;
echo intval($dia)." != ".intval($dia_falta);*/
exit();
}
@@ -66,24 +79,28 @@ if($tipo == 1){//Reposición
exit();
}
*/
//Valida que profesor no este en 2 reposiciones al mismo tiempo
//Valida que profesor no este en 2 reposiciones al mismo tiempo en la fecha nueva
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur)',
[':prof' => $prof, ':fecha'=>$fecha_falta, ':hora'=>$hora, ':dur'=>$duracion]
[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo]
)["traslape_profesor_reposicion"];
if($traslape){
//print_r($_POST);
//echo "SELECT * from traslape_profesor_reposicion($prof,'".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."' , '$hora', $duracion)";
header("Location:".$pag."?error=9");
exit();
}
try{
$db->query('SELECT * from fi_reposicion(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, true, :aula, :duracion)',
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo)',
[':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, ':hor' => $hor,
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_id, ':usr'=>$user->user["id"],
':bloque' => $bloque, ':ciclo' => $ciclo
]
);
}catch(Exception $e){
header("Location: ".$pag."?error=1");
echo $e->getMessage();
//header("Location: ".$pag."?error=1");
exit();
}
@@ -96,9 +113,10 @@ if($tipo == 1){//Reposición
}else{//Cambio salón / hora
try{
$db->query('SELECT * from fi_reposicion(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, true, :aula, :duracion)',
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo)',
[':f_falta' => $fecha_falta, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor,
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_id, ':usr'=>$user->user["id"],
':bloque' => $bloque, ':ciclo' => $ciclo
]
);
}catch(Exception $e){

View File

@@ -33,7 +33,8 @@ $user = unserialize($_SESSION['user']);
foreach($rs as $m){
$mat_arr[] = array("horario_id"=>$m["horario_id"], "horario_dia"=>$m["horario_dia"],
"horario_hora"=>substr($m["horario_hora"], 0, 2), "horario_min"=>substr($m["horario_hora"], 3, 2),
"materia_nombre"=>$m["materia_nombre"].' - '.$m["horario_dia_nombre"]." ".substr($m["horario_hora"], 0, -3)
"materia_nombre"=>$m["materia_nombre"].' - '.$m["horario_dia_nombre"]." ".substr($m["horario_hora"], 0, -3),
"grupo"=>$m["horario_grupo"], "duracion" => $m["duracion"]
);
}

View File

@@ -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']);