123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502 |
- <?php
- require_once("./include/constantes.php");
- require_once("./include/util.php");
- require_once("./include/bd_pdo.php");
- require_once("./include/xTemplate/xtemplate.class.php");
- //define("PAG", "http://200.13.89.48");
- define("PAG", "http://200.13.89.27");
-
- if(isset($_GET["nivel"])){
- $nivel = filter_input(INPUT_GET, "nivel", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- $stmt = $pdo->prepare('Select "Periodo_id", "Periodo_desc" from "Periodo" WHERE "Nivel_id" = :nivel AND "EstadoPeriodo_id" != 2 AND "Periodo_calendario_activo" = true');
- $stmt->bindParam(":nivel", $nivel);
- if(!$stmt->execute()){
- echo "Error al obtener los periodos activos.";
- exit();
- }else{
- $periodo_rs = $stmt->fetch();
- if(!is_array($periodo_rs) || count($periodo_rs) == 0){
- unset($periodo_rs);
- }
- }
- $stmt->closeCursor();
- //Obtiene grupos del periodo
- if(isset($periodo_rs)){
- $stmt = $pdo->prepare('Select * from fs_grupo(NULL, :periodo)');
- $stmt->bindParam(":periodo", $periodo_rs["Periodo_id"]);
- if(!$stmt->execute()){
- echo "Error al obtener los grupos.";
- exit();
- }else{
- $grupos_rs = $stmt->fetchAll();
- }
- $stmt->closeCursor();
- }
- $pendiente = "<em>Pendiente</em>";
-
-
- if(isset($periodo_rs) && isset($_POST["grupo"]) && is_numeric($_POST["grupo"]) && $_POST["grupo"] != ""){
- $filter_grupo = filter_input(INPUT_POST, "grupo", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- if(isset($_POST["filter_fecha"]) && $_POST["filter_fecha"]!= "")
- $filter_fecha = fechaGuion(trim(filter_input(INPUT_POST, "filter_fecha", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto
- $stmt = $pdo->prepare('Select * from fs_grupo(:grupo, :periodo)');
- $stmt->bindParam(":periodo", $periodo_rs["Periodo_id"]);
- $stmt->bindParam(":grupo", $filter_grupo);
- if(!$stmt->execute()){
- $errorDesc = "Ocurrió un error al cargar el grupo.";
- }else{
- $grupo_actual_rs = $stmt->fetch();
- if(!is_array($grupo_actual_rs) || count($grupo_actual_rs) == 0){
- $stmt->closeCursor();
- header("Location: consulta_horario.php");
- exit();
- }
- }
- $stmt->closeCursor();
- //Obtiene horario del grupo
- $stmt = $pdo->prepare('Select * from fs_horariogrupo(:gpo, NULL, false)');
- $stmt->bindParam(":gpo", $filter_grupo);
- if(!$stmt->execute()){
- //header("Location: materias.php?error=2");
- $errorDesc = "Error al cargar el horario del grupo";
- print_r($stmt->errorInfo());
- exit();
- }else{
- $horario_rs = $stmt->fetchAll();
- $horaMin = horaMin($horario_rs);
- $horaMax = horaMax($horario_rs);
- }
- $stmt->closeCursor();
- }
- }else{//no existe nivel
- $stmt = $pdo->prepare('Select * from fs_nivel(NULL)');
- if(!$stmt->execute()){
- echo "Error al obtener los niveles.";
- exit();
- }else{
- $nivel_rs = $stmt->fetchAll();
- }
- $stmt->closeCursor();
- }
-
- ?>
- <!DOCTYPE html>
- <html lang="es" prefix="og: http://ogp.me/ns#">
- <head>
- <title>Horarios - Facultad de Ingeniería</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <link rel="stylesheet" href="<?php echo PAG;?>/css/bootstrap-ulsa.min.css" type="text/css">
- <link rel="stylesheet" href="<?php echo PAG;?>/css/indivisa.css" type="text/css">
- <link rel="stylesheet" href="<?php echo PAG;?>/css/sgi.css" type="text/css">
- <link rel="stylesheet" href="<?php echo PAG;?>/css/fa_all.css" type="text/css">
- <link rel="stylesheet" href="<?php echo PAG;?>/apsa/css/horario_alumnos.css" type="text/css">
- <script src="<?php echo PAG;?>/js/util.js"></script>
- </head>
- <body>
- <div>
- <div class="container content marco">
- <img src="img/horarios.jpg" alt="horarios" class="img-fluid"/>
- <?php if(!isset($_GET["nivel"])){ //no existe el nivel?>
- <!-- Filtro -->
- <div class="row justify-content-md-center my-3" style="height: 50px;">
- <div class="col-12 col-md-8">
- <?php if(isset($nivel_rs)){ ?>
- <form action="consulta_horario.php" method="get">
- <div class="form-box">
- <div class="form-group row">
- <label for="filter_nivel" class="col-3 col-form-label text-right font-weight-bold">Nivel</label>
- <div class="col-6">
- <select id="filter_nivel" name="nivel" class="form-control">
- <option value="">Selecciona un nivel</option>
- <?php foreach($nivel_rs as $nivel) { ?>
- <option value="<?php echo $nivel["Nivel_id"];?>" ><?php echo $nivel["Nivel_desc"];?></option>
- <?php } ?>
- </select>
- </div>
- <div class="col-3">
- <button type="submit" class="btn btn-secondary"><?php echo $ICO["buscar"]; ?> Ver grupos</button>
- </div>
- </div>
- </div>
- </form>
- <?php }else{//fin hay periodos con horario para mostrar ?>
- <h3>No hay horarios para mostrar.</h3>
- <?php } ?>
- </div>
- </div>
- <?php }else { //si existe
- if($nivel == 1) $nivel_nombre = "Licenciatura";
- else $nivel_nombre = "Posgrado";
- ?>
-
- <h1 class="subtitle">Horarios de <?php echo $nivel_nombre;?> <?php if(isset($periodo_rs)){?> <small><span class="fas fa-angle-double-right"></span> <?php echo $periodo_rs["Periodo_desc"];?></small><?php } ?></h1>
- <!-- Filtro -->
- <div class="row justify-content-md-center my-3" style="height: 50px;">
- <div class="col-12 col-md-8">
- <?php if(isset($periodo_rs)){ ?>
- <form action="consulta_horario.php?nivel=<?php echo $nivel?>" method="post">
- <div class="form-box">
- <div class="form-group row">
- <label for="filter_grupo" class="col-3 col-form-label text-right font-weight-bold">Grupo</label>
- <div class="col-6">
- <select id="filter_grupo" name="grupo" class="form-control">
- <option value="">Selecciona un grupo</option>
- <?php foreach($grupos_rs as $grupo) {
- $nombre = "";
- if($nivel == 1)
- $nombre = $grupo["Grupo_desc"]." ".$grupo["Carrera_prefijo"];
- else
- $nombre = $grupo["Grupo_desc"]." - ".$grupo["Carrera_desc"];
- ?>
- <option value="<?php echo $grupo["Grupo_id"];?>" <?php if(isset($filter_grupo) && $filter_grupo == $grupo["Grupo_id"]){echo "selected='selected'";}?> ><?php echo $nombre;?></option>
- <?php } ?>
- </select>
- </div>
- <div class="col-3">
- <button type="submit" class="btn btn-secondary"><?php echo $ICO["buscar"]; ?> Ver horario</button>
- </div>
- </div>
- </div>
- </form>
- <?php }else{//fin hay periodos con horario para mostrar ?>
- <h3>No hay horarios para mostrar.</h3>
- <?php } ?>
- </div>
- </div>
- </div>
- <main class="container-fluid content marco-wide">
- <?php
- if(isset($grupo_actual_rs) && isset($horario_rs)){//Si existe grupo seleccionado carga horario
- ?>
- <?php
- $stmt = $pdo->prepare('Select * from fs_dia(NULL)');
- if(!$stmt->execute()){
- echo "Error al obtener los días";
- print_r($stmt->errorInfo());
- }
- $dias_rs = $stmt->fetchAll();
- $stmt->closeCursor();
-
- $stmt = null;
-
- $horas_dif = intval(date('H', strtotime($horaMax))) - intval(date('H', strtotime($horaMin)));
- $hora_ini = date('H', strtotime($horaMin));
- $hora_fin = date('H', strtotime($horaMax));
- if(intval(date('i', strtotime($horaMax))) != 0)
- $hora_fin++;
- /* Definidas en constantes.php
- HORA_INICIO = 7;
- HORA_FINAL = 22;
- FRACCION_HORA = 4;*/
- ?>
-
- <ul class="nav nav-tabs d-print-none mb-4" id="myTab" role="tablist">
- <li class="nav-item">
- <a class="nav-link active" id="tab1-tab" data-toggle="tab" href="#tab1" role="tab" aria-controls="calendario" aria-selected="true">Horario</a>
- </li>
- <li class="nav-item">
- <a class="nav-link" id="tab2-tab" data-toggle="tab" href="#tab2" role="tab" aria-controls="lista" aria-selected="false">Listado por materia</a>
- </li>
- </ul>
- <div class="tab-content" id="horariosTabContent">
- <div class="tab-pane fade show active" id="tab1" role="tabpanel" aria-labelledby="tab1-tab">
- <?php // ---- Como horario ---- ?>
- <div class="row justify-content-md-center">
- <div class="col-md-auto no-gutters px-0">
- <table class="table table-sm table-responsive table-borderless calendario" id="tabla-horario" data-hora-inicio="<?php echo $hora_ini;?>" data-fracciones = "<?php echo FRACCION_HORA; ?>">
- <thead class="thead-dark">
- <tr>
- <th>Hora</th>
- <?php foreach($dias_rs as $dia){
- echo "<th data='dia_".$dia["Dia_id"]."'>".$dia["Dia_desc"]."</th>";
- } ?>
- </tr>
- </thead>
- <tbody id="calendario-body">
- <?php
- $biccell = false;
- //for($h = HORA_INICIO, $i=0; $h < HORA_FINAL; $h++, $i++){
- for($h = $hora_ini, $i=0; $h < $hora_fin; $h++, $i++){
- ?>
- <tr>
- <td data-hora="<?php echo $h;?>" data-index="<?php echo $i;?>" class="hora" ><?php echo $h;?>:00 </td>
- <?php
- if(!$biccell){
- $biccell = true;
- ?>
- <td colspan='<?php echo count($dias_rs); ?>' rowspan='<?php echo ($hora_fin-$hora_ini)+1; ?>'>
- <div class='area-horario'>
- <table class="table table-borderless ">
- <tbody>
- <?php
- for($h2 = $hora_ini; $h2 < $hora_fin; $h2++){
- for($f = 0; $f < FRACCION_HORA; $f++){
- echo "<tr class='dia'>";
- foreach($dias_rs as $dia){
- echo "<td title='".$h2.":".sprintf("%02d", ($f*(60/FRACCION_HORA)))."' data-dia='".$dia["Dia_id"]."' data-hora='".$h2."' data-fraccion='".($f*(60/FRACCION_HORA))."' class='crea-horario fraccion '></td>";
- }
- echo "</tr>";
- }
- }
- ?>
- </tbody>
- </table>
- <div id="bloque-horarios"></div>
- </div>
- </td>
- <?php
- } ?>
- </tr>
- <?php } ?>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- <div class="tab-pane fade" id="tab2" role="tabpanel" aria-labelledby="tab2-tab">
- <?php
- // --- Como listado ----
- $stmt = $pdo->prepare('Select * from fs_horariogrupo(:gpo, NULL, false) order by "Materia_desc", "Dia_id", "Horario_hora"');
- $stmt->bindParam(":gpo", $filter_grupo);
- if(!$stmt->execute()){
- //header("Location: materias.php?error=2");
- $errorDesc = "Error al cargar el horario del grupo";
- print_r($stmt->errorInfo());
- exit();
- }
- $horario_materia_rs = $stmt->fetchAll();
- $stmt->closeCursor();
- $materia_old = -1;
- $xtpl = new XTemplate('./tpl/horariolista_reporte.tpl.html');
- foreach($horario_materia_rs as $horario){
- if(intval($horario["Materia_id"]) != $materia_old && $materia_old != -1){
- if((isset($filter_fecha) && strtotime($filter_fecha) >= strtotime($horario["fecha_inicial"]) && strtotime($filter_fecha) <= strtotime($horario["fecha_final"]) ) || !isset($filter_fecha)){
- $xtpl->parse("main.table");
- }
- }
- $materia_old = intval($horario["Materia_id"]);
- $xtpl->assign("MATERIA", $horario["Materia_desc"]);
- $xtpl->assign("CLAVE", $horario["Materia_clave"]);
- //----- Carga profesores ----
- if($horario["TipoSubmateria_id"] == 0){
- $stmt = $pdo->prepare('Select * from fs_profesorhorariogrupo(:id)');
- $stmt->bindParam(":id", $horario["HorarioGrupo_id"]);
- if(!$stmt->execute()){
- $t = $stmt->errorInfo();
- $errorDesc = "Ocurrió un error al obtener los datos de los profesores ".$t[2];
- break;
- }
- $profesores_rs = $stmt->fetchAll();
- $stmt->closeCursor();
- $prof_nombre = "";
- if(isset($profesores_rs) && count($profesores_rs) > 0){
- $profesores_all = "";
- foreach($profesores_rs as $profesor){
- $prof_nombre = $profesor["Usuario_apellidos"]." ".$profesor["Usuario_nombre"];
- $profesores_all .= $prof_nombre."<br>";
- }
- }else{
- $profesores_all = $pendiente;
- }
- $xtpl->assign("PROFESOR", $profesores_all);
- }else{//Con submaterias
-
- //----- Carga submaterias ----
- $stmt = $pdo->prepare('Select * from fs_submateriahorariogrupo(:id)');
- $stmt->bindParam(":id", $horario["HorarioGrupo_id"]);
- if(!$stmt->execute()){
- $t = $stmt->errorInfo();
- $errorDesc = "Ocurrió un error al obtener los datos de los profesores ".$t[2];
- break;
- }
- $submaterias_rs = $stmt->fetchAll();
- $stmt->closeCursor();
- $sub_prof_num = 0;
- $profesores_all = "";
- if(count($submaterias_rs) > 0){
- foreach($submaterias_rs as $submateria){
- //---
- $stmt = $pdo->prepare('Select * from fs_submateriahorariogrupoprofesor(:id,:sub)');
- $stmt->bindParam(":id", $horario["HorarioGrupo_id"]);
- $stmt->bindParam(":sub", $submateria["Submateria_id"]);
- if(!$stmt->execute()){
- $t = $stmt->errorInfo();
- $errorDesc = "Ocurrió un error al obtener los datos de los profesores ".$t[2];
- break;
- }
- $profesores_rs = $stmt->fetchAll();
- $stmt->closeCursor();
- $sub_prof_num += count($profesores_rs);
- if(isset($profesores_rs) && count($profesores_rs) > 0){
- foreach($profesores_rs as $profesor){
- $prof_nombre = $profesor["Usuario_apellidos"]." ".$profesor["Usuario_nombre"];
- $profesores_all .= $prof_nombre."<br>";
- }
- //$xtpl->assign("PROFESOR", $profesores_all);
- }/*else{
- $xtpl->assign("PROFESOR", $pendiente);
- }*/
- }
- if($sub_prof_num > 0)
- $xtpl->assign("PROFESOR", $profesores_all);
- else
- $xtpl->assign("PROFESOR", $pendiente);
- }
- unset($profesores_rs);
- }//fin con submaterias
- $xtpl->assign("DIA", ucfirst(diaNombre($horario["Dia_id"])));
- $xtpl->assign("HORAI", date('H:i', strtotime($horario["Horario_hora"])));
- $xtpl->assign("HORAF", date('H:i', strtotime($horario["Horario_hora_final"])));
- if($horario["Salon_desc"]!= ""){
- if($horario["Salon_desc_larga"] != "")
- $xtpl->assign("SALON", $horario["Salon_desc"]." (".$horario["Salon_desc_larga"].")");
- else
- $xtpl->assign("SALON", $horario["Salon_desc"]);
- }else
- $xtpl->assign("SALON", $pendiente);
- $xtpl->parse("main.table.row");
-
- }//for each materias
- if($materia_old != -1){
- if((isset($filter_fecha) && strtotime($filter_fecha) >= strtotime($horario["fecha_inicial"]) && strtotime($filter_fecha) <= strtotime($horario["fecha_final"]) ) || !isset($filter_fecha))
- $xtpl->parse("main.table");
- }
- $xtpl->parse("main");
- $xtpl->out("main");
- ?>
- </div>
- </div><!-- End tabs-->
-
- <div class="row justify-content-md-center mt-4 d-none" id="electivasBlock">
- <div class="col-md-auto">
- <h3>Electivas</h3>
- <table class="table table-sm table-hover table-responsive text-80" id="tabla-horario" data-hora-inicio="<?php echo $hora_ini;?>" data-fracciones = "<?php echo FRACCION_HORA; ?>">
- <thead class="thead-light">
- <tr><th scope="col">Materia</th><th scope="col">Horario</th><th scope="col">Profesores</th><th scope="col">Salón</th></tr>
- </thead>
- <tbody>
- <?php
- foreach($horario_rs as $horario){
- if($horario["TipoSubmateria_id"] != 0){
- //----- Carga submaterias ----
- $stmt = $pdo->prepare('Select * from fs_submateriahorariogrupo(:id)');
- $stmt->bindParam(":id", $horario["HorarioGrupo_id"]);
- if(!$stmt->execute()){
- $t = $stmt->errorInfo();
- $errorDesc = "Ocurrió un error al obtener los datos de los profesores ".$t[2];
- break;
- }
- $submaterias_rs = $stmt->fetchAll();
- $stmt->closeCursor();
- $sub_prof_num = 0;
- $nombre_impreso = false;
- if(count($submaterias_rs) > 0){
- $tiene_submaterias = true;
- foreach($submaterias_rs as $submateria){
- $submateria_text = $submateria["Submateria_desc"];
- $dia_hora_text = ucfirst(diaNombre($horario["Dia_id"]))." ".date('H:i', strtotime($horario["Horario_hora"]));
- $profesores_all = "";
- $salon_text = "";
- //---
- $stmt = $pdo->prepare('Select * from fs_submateriahorariogrupoprofesor(:id,:sub)');
- $stmt->bindParam(":id",$horario["HorarioGrupo_id"]);
- $stmt->bindParam(":sub", $submateria["Submateria_id"]);
- if(!$stmt->execute()){
- $t = $stmt->errorInfo();
- $errorDesc = "Ocurrió un error al obtener los datos de los profesores ".$t[2];
- break;
- }
- $profesores_rs = $stmt->fetchAll();
- $stmt->closeCursor();
- $sub_prof_num += count($profesores_rs);
- if(isset($profesores_rs) && count($profesores_rs) > 0){
- foreach($profesores_rs as $profesor){
- $prof_nombre = '<span class="fas fa-user-graduate fa-fw mx-1"></span> '.$profesor["Usuario_apellidos"]." ".$profesor["Usuario_nombre"];
- $profesores_all .= $prof_nombre."<br>";
- }
- //$xtpl->assign("PROFESOR_SUB", $profesores_all);
- if($submateria["Salon_desc"]){
- $salon_text = $submateria["Salon_desc"];
- }else{
- $salon_text = $pendiente;
- }
- ?>
- <tr>
- <td class="align-middle"><?php echo $submateria_text;?> </td>
- <td class="text-center align-middle"><?php echo $dia_hora_text;?></td>
- <td class="align-middle"><?php echo $profesores_all;?></td>
- <td class="text-center align-middle"><?php echo $salon_text;?></td>
- </tr>
- <?php
- //$xtpl->parse("main.submaterias_block.row");
- }//se pinta sólo si tiene profesor
- }
- }//hay submaterias
- }//fin if
- }
- unset($profesores_rs);
- ?>
- </tbody>
- </table>
- </div>
- </div>
- <?php }//end if existe grupo_actual_rs ?>
-
- <?php }//hay nivel ?>
- </main>
-
- <script src="http://200.13.89.48/js/jquery.min.js"></script>
- <script src="http://200.13.89.48/js/bootstrap/popper.min.js"></script>
- <script src="http://200.13.89.48/js/bootstrap/bootstrap.min.js"></script>
- <?php if(isset($grupo_actual_rs)){ ?>
- <script>
- var _w = 208, _h = 25;//tamaño de bloques
- var _tab_size = 25; //espaciado por cada elemento que colisiona
- var _frac = parseInt($('#tabla-horario').data('fracciones'));
- var _reloadOnClose = false;
- var id_obj = 0; //id de objeto actual
- var _hora_min = parseInt($('#tabla-horario').data('hora-inicio'));
- var clasesObj = [];
- //al imprimir pone horarios lado a lado, sólo soporta 2
- function imprime(){
- _tab_size = _w/2;
- loadHorario();
- setTimeout(function() {
- window.print()
- }, 250);
- setTimeout(function() {
- _tab_size = 25;
- loadHorario();
- }, 500);
- //window.print();
- }
- </script>
- <script src="http://200.13.89.48/apsa/js/horario.js"></script>
- <script src="./js/consulta_horario.js?v=1.1"></script>
- <?php } ?>
- </body>
- </html>
|