reporte_syllabus.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <?php
  2. require_once("../include/constantes.php");
  3. require_once("../include/bd_pdo.php");
  4. require_once("../classes/ValidaSesion.php");
  5. require_once("../classes/MainMenu.php");
  6. $menu = 7;
  7. $submenu = 74;
  8. //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
  9. $objSesion = new ValidaSesion($pdo, $submenu, APSA);
  10. if(!$objSesion->tieneAcceso()){
  11. $objSesion->terminaSesion();
  12. }
  13. $objSesion->validaPeriodoUsuario();//si no tiene periodo manda a main
  14. //Obtiene áreas académicas
  15. if(!$_SESSION["jefe_carrera"] || $_SESSION["sgi_administrador"]){
  16. $stmt = $pdo->prepare("Select * from fs_areaacademica(NULL, :nivel)");
  17. }else{
  18. if(!$_SESSION["jefe_carrera"]){
  19. header("Location: ../index.php?error=3");
  20. exit();
  21. }
  22. $stmt = $pdo->prepare("Select * from fs_areausuario(:usr, :nivel)");
  23. $stmt->bindParam(":usr", $_SESSION["usuario_id"]);
  24. }
  25. $stmt->bindParam(":nivel", $_SESSION["nivel_id"]);
  26. if(!$stmt->execute()){
  27. $errorDesc = "Ocurrió un error al cargar las áreas académicas.";
  28. }else{
  29. $areas_rs = $stmt->fetchAll();
  30. }
  31. $stmt->closeCursor();
  32. ?>
  33. <!DOCTYPE html>
  34. <html lang="es" prefix="og: http://ogp.me/ns#">
  35. <head>
  36. <title>APSA - Facultad de Ingeniería</title>
  37. <meta charset="utf-8">
  38. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  39. <link rel="icon" type="image/png" href="../img/favicon.png" />
  40. <link rel="stylesheet" href="../css/bootstrap-ulsa.min.css" type="text/css">
  41. <link rel="stylesheet" href="../css/indivisa.css" type="text/css">
  42. <link rel="stylesheet" href="../css/sgi.css?rand=<?php echo rand();?>" type="text/css">
  43. <link rel="stylesheet" href="../css/fa_all.css" type="text/css">
  44. <link rel="stylesheet" href="../css/jquery-ui.css" type="text/css">
  45. <link rel="stylesheet" href="../css/calendar.css" type="text/css">
  46. <script src="../js/util.js"></script>
  47. </head>
  48. <body>
  49. <div>
  50. <?php
  51. //--- Objeto que pinta menu
  52. $menuObj = new MainMenu($_SESSION["usuario_id"], $menu, $pdo, APSA, "Reporte de Syllabus y Plande cátedra");//usr, menu, pdo, sist
  53. $menuObj->printMenu();
  54. //Obtiene datos
  55. $query = "";
  56. if(count($areas_rs)>1){
  57. if(isset($_POST["area"]) && is_numeric($_POST["area"])){
  58. $query .= ":area";
  59. $filter_area = filter_input(INPUT_POST, "area", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  60. }else{
  61. $query .= "NULL";
  62. }
  63. }else{
  64. $query .= ":area";
  65. $filter_area = $areas_rs[0]["Area_id"];
  66. }
  67. $stmt = $pdo->prepare('Select * from fs_reporte_syllabus_plan(:periodo, '.$query.')');
  68. $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
  69. if(isset($filter_area)) $stmt->bindParam(":area", $filter_area);
  70. if(!$stmt->execute()){
  71. $errorDesc = "Ocurrió un error al cargar los datos";
  72. }else{
  73. $reporte_rs = $stmt->fetchAll();
  74. }
  75. $stmt->closeCursor();
  76. //--Manejo de errores y mensajes de exito
  77. if(isset($_GET["error"]) && is_numeric($_GET["error"])){
  78. switch ($_GET["error"]){
  79. case 0: $errorDesc = "No se reciberon los datos del grupo."; break;
  80. case 1: $errorDesc = "Ocurrió un error al insertar los datos del grupo."; break;
  81. case 2: $errorDesc = "Ocurrió un error al actualizar los datos del grupo."; break;
  82. case 3: $errorDesc = "No tienes permisos para realizar esa acción."; break;
  83. case 4: $errorDesc = "Ocurrió un error al cargar los datos grupos."; break;
  84. case 5: $errorDesc = "No existen grupos para el periodo. Primero debes crear grupos en esta sección."; break;
  85. case 6: $errorDesc = "El grupo que buscas no existe. Consulta la lista de grupos disponibles en esta sección."; break;
  86. }
  87. }
  88. if(isset($_GET["ok"]) && is_numeric($_GET["ok"])){
  89. switch ($_GET["ok"]){
  90. case 0: $successDesc = "El grupo se guardó correctamente."; break;
  91. case 1: $successDesc = "El grupo se actualizó correctamente."; break;
  92. }
  93. }
  94. ?>
  95. <main class="container-fluid content marco">
  96. <?php include_once("../include/errorMessage.php");?>
  97. <?php include("../include/periodoCambio.php");?>
  98. <?php
  99. if(isset($reporte_rs)){
  100. ?>
  101. <!-- Filtro -->
  102. <?php if(count($areas_rs)>1){ ?>
  103. <div class="row">
  104. <div class="col-12">
  105. <form action="reporte_syllabus.php" method="post">
  106. <div class="form-box form-box-info">
  107. <div class="form-group row">
  108. <label for="filter_area" class="col-4 col-form-label">Área académica</label>
  109. <div class="col-8 col-sm-4">
  110. <div class="datalist datalist-select mb-1 w-100">
  111. <div class="datalist-input">Mostrar todas</div>
  112. <span class="ing-buscar icono"></span>
  113. <ul style="display:none">
  114. <li data-id="">Mostrar todas</li>
  115. <?php foreach($areas_rs as $area) {?>
  116. <li data-id="<?php echo $area["Area_id"];?>" <?php if(isset($filter_area) && $filter_area == $area["Area_id"]){echo "class='selected'";}?> ><?php echo $area["Area_desc"];?></li>
  117. <?php }?>
  118. </ul>
  119. <input type="hidden" id="filter_area" name="area" value="">
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="form-group row">
  125. <div class="col-12 text-center">
  126. <button type="submit" class="btn btn-outline-primary"><?php echo $ICO["buscar"]; ?> Filtrar</button>
  127. <button type="button" class="btn btn-outline-danger btn-reset"><?php echo $ICO["borrar"]?> Limpiar</button>
  128. </div>
  129. </div>
  130. </form>
  131. </div>
  132. </div>
  133. <?php } else if(count($areas_rs)==1){
  134. echo "<h3 class='text-center mb-4'>Área: ".$areas_rs[0]["Area_desc"]."</h3>";
  135. }?>
  136. <?php if(count($reporte_rs)>0){ ?>
  137. <div class="row ">
  138. <div class="col-12 table-responsive">
  139. <ul>
  140. <li><b>Syllabus</b>: Cantidad de campos llenos, el total de posibles campos es 13.</li>
  141. <li><b>Plan de Cátedra</b>: Cantidad de sesiones llenas considerando 16 semanas.</li>
  142. </ul>
  143. <div class="text-right my-4">
  144. <form action="./export/xls_syllabus.php" target="_blank" method="post" id="formaReporte" >
  145. <input type="hidden" value="<?php echo isset($filter_area)?$filter_area:'';?>" name="area">
  146. <button type="submit" class="btn btn-outline-secondary btn-reporte" data-target="./export/pdf_syllabus_all.php">
  147. <?php echo $ICO["descargar"];?> Todos los Syllabus
  148. </button>
  149. <button type="submit" class="btn btn-outline-secondary btn-reporte" data-target="./export/pdf_plancatedra_all.php">
  150. <?php echo $ICO["descargar"];?> Todos los Planes de Cátedra
  151. </button>
  152. <button type="submit" class="btn btn-outline-secondary btn-reporte" data-target="./export/xls_syllabus.php">
  153. <?php echo $ICO["descargar"];?> Reporte general
  154. </button>
  155. </form>
  156. </div>
  157. <table class="table table-sm table-striped table-white">
  158. <thead class="thead-dark">
  159. <tr >
  160. <th>Clave</th>
  161. <th>Nombre</th>
  162. <th>Materia</th>
  163. <th>Grupo</th>
  164. <th>Área</th>
  165. <th>Syllabus</th>
  166. <th>Plan</th>
  167. </tr>
  168. </thead>
  169. <tbody>
  170. <?php
  171. foreach($reporte_rs as $rep){
  172. $limite = 50;
  173. ?>
  174. <tr data-prof="<?php echo $rep["Usuario_id"];?>" data-mat="<?php echo $rep["Materia_id"];?>" data-gpo="<?php echo $rep["Grupo_id"];?>" data-gpo_nom="<?php echo $rep["Grupo_desc"];?>" data-sub="<?php echo $rep["Submateria_id"];?>">
  175. <td class="text-center"><?php echo $rep["Usuario_claveULSA"];?></td>
  176. <td><?php echo $rep["Usuario_apellidos"]." ".$rep["Usuario_nombre"]; ?></td>
  177. <td><?php echo $rep["Materia_desc"];
  178. if($rep["electiva"]) echo '<span class="badge badge-info ml-3 px-2 py-1" style="font-size: 60%;">ELECTIVA</span>';?></td>
  179. <td><?php echo $rep["Grupo_desc"].$rep["Carrera_prefijo"];?></td>
  180. <td class="text-center"><?php echo $rep["Area_desc"]; ?></td>
  181. <td class="text-center text-nowrap <?php echo (round($rep["total_campos_llenos"]/13*100,1) < $limite)?"table-danger":"" ?>">
  182. <span class="ver-syllabus pointer"><?php echo $ICO["ver"];?>
  183. <?php echo round($rep["total_campos_llenos"]/13*100,1);?>%</span>
  184. </td>
  185. <td class="text-center text-nowrap <?php echo (round($rep["promedio_sesiones_semana"]*100,1) < $limite)?"table-danger":"" ?>">
  186. <span class="ver-plan pointer"><?php echo $ICO["ver"];?>
  187. <?php echo round($rep["promedio_sesiones_semana"]*100,1);?>%</span>
  188. </td>
  189. </tr>
  190. <?php } ?>
  191. </tbody>
  192. </table>
  193. <form action="./export/pdf_plancatedra.php" target="_blank" method="post" id="formaSubmit">
  194. <input type="hidden" name="mat" value="" id="mat">
  195. <input type="hidden" name="gpo" value="" id="gpo">
  196. <input type="hidden" name="gpo_nom" value="" id="gpo_nom">
  197. <input type="hidden" name="sub" value="" id="sub">
  198. <input type="hidden" name="prof" value="" id="prof">
  199. </form>
  200. </div>
  201. </div>
  202. <?php }else{ ?>
  203. <h2 class="text-center text-danger">No se encontraron registros</h2>
  204. <?php } ?>
  205. <?php } ?>
  206. </main>
  207. <!--- FOOTER--->
  208. <?php require_once("../include/footer.php"); ?>
  209. </div>
  210. <script src="../js/jquery.min.js"></script>
  211. <script src="../js/jquery-ui.js"></script>
  212. <script src="../js/datepicker-es.js"></script>
  213. <script src="../js/bootstrap/popper.min.js"></script>
  214. <script src="../js/bootstrap/bootstrap.min.js"></script>
  215. <script src="../js/fechas.js"></script>
  216. <script src="../js/sidebarmenu.js"></script>
  217. <script src="../js/datalist.js"></script>
  218. <script>
  219. //Cambia el reporte de acuerdo al botón
  220. $(document).on( "click", ".btn-reporte", function(event){
  221. var newAction = $(this).data('target');
  222. $('#formaReporte').attr('action', newAction);
  223. });
  224. $(document).on( "click", ".ver-syllabus", function(event){
  225. $("#mat").val( $(this).parents("tr").data("mat") );
  226. $("#gpo").val( $(this).parents("tr").data("gpo") );
  227. $("#gpo_nom").val( $(this).parents("tr").data("gpo_nom") );
  228. $("#prof").val( $(this).parents("tr").data("prof") );
  229. $("#sub").val( $(this).parents("tr").data("sub") );
  230. $("#formaSubmit").attr("action", "./export/pdf_syllabus.php");
  231. $("#formaSubmit").submit();
  232. });
  233. $(document).on( "click", ".ver-plan", function(event){
  234. $("#mat").val( $(this).parents("tr").data("mat") );
  235. $("#gpo").val( $(this).parents("tr").data("gpo") );
  236. $("#gpo_nom").val( $(this).parents("tr").data("gpo_nom") );
  237. $("#prof").val( $(this).parents("tr").data("prof") );
  238. $("#sub").val( $(this).parents("tr").data("sub") );
  239. $("#formaSubmit").attr("action", "./export/pdf_plancatedra.php");
  240. $("#formaSubmit").submit();
  241. });
  242. $(document).on( "click", ".btn-reset", function(event){
  243. var forma = $(this).parents("form");
  244. forma.find("input[type=text]").val("");
  245. //forma.find("select").prop("selectedIndex",0);
  246. setDatalistFirst("#filter_carrera");
  247. setDatalistFirst("#filter_sem");
  248. forma.submit();
  249. });
  250. setDatalist("#periodo", <?php echo $_SESSION["periodo_id"]; ?>);
  251. $(document).on('click', '#dlPeriodo ul li' ,function(){
  252. $("#formaPeriodo").submit();
  253. });
  254. </script>
  255. </body>
  256. </html>