reporte_asistenciasprofesordetalle.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. require_once("../include/util.php");
  7. $menu = 7;
  8. $submenu = 72;
  9. //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
  10. $objSesion = new ValidaSesion($pdo, $submenu, APSA);
  11. if(!$objSesion->tieneAcceso()){
  12. $objSesion->terminaSesion();
  13. }
  14. $objSesion->validaPeriodoUsuario();//si no tiene periodo manda a main
  15. if(!isset($_POST["clave"])){
  16. header("location: reporte_asistenciasprofesor.php");
  17. exit();
  18. }
  19. $filter_clave = filter_input(INPUT_POST, "clave", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  20. ?>
  21. <!DOCTYPE html>
  22. <html lang="es" prefix="og: http://ogp.me/ns#">
  23. <head>
  24. <title>APSA - Facultad de Ingeniería</title>
  25. <meta charset="utf-8">
  26. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  27. <link rel="icon" type="image/png" href="../img/favicon.png" />
  28. <link rel="stylesheet" href="../css/bootstrap-ulsa.min.css" type="text/css">
  29. <link rel="stylesheet" href="../css/indivisa.css" type="text/css">
  30. <link rel="stylesheet" href="../css/sgi.css?rand=<?php echo rand();?>" type="text/css">
  31. <link rel="stylesheet" href="../css/fa_all.css" type="text/css">
  32. <link rel="stylesheet" href="../css/jquery-ui.css" type="text/css">
  33. <link rel="stylesheet" href="../css/clockpicker.css" type="text/css">
  34. <link rel="stylesheet" href="../css/calendar.css" type="text/css">
  35. <script src="../js/util.js"></script>
  36. </head>
  37. <body>
  38. <div>
  39. <?php
  40. //--- Objeto que pinta menu
  41. $menuObj = new MainMenu($_SESSION["usuario_id"], $menu, $pdo, APSA, "Asistencias de profesores");//usr, menu, pdo, sist
  42. $menuObj->printMenu();
  43. /*if(isset($_POST["periodo"]))
  44. $filter_periodo = filter_input(INPUT_POST, "periodo", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  45. else*/
  46. $filter_periodo = $_SESSION["periodo_id"];
  47. //Area
  48. $stmt = $pdo->prepare('Select * from fs_areaacademica(NULL, :nivel)');
  49. $stmt->bindParam(":nivel", $_SESSION["nivel_id"]);
  50. if(!$stmt->execute()){
  51. $errorDesc = "Ocurrió un error al cargar las áreas académicas";
  52. }else{
  53. $area_rs = $stmt->fetchAll();
  54. }
  55. $stmt->closeCursor();
  56. //Periodo
  57. $stmt = $pdo->prepare('Select * from fs_periodo(:id, NULL, NULL, true)');
  58. $stmt->bindParam(":id", $filter_periodo);
  59. if(!$stmt->execute()){
  60. $errorDesc = "Ocurrió un error al cargar el periodo";
  61. }else{
  62. $periodo_rs = $stmt->fetch();
  63. }
  64. $stmt->closeCursor();
  65. if(isset($_POST["area"]) && $_POST["area"]!=""){
  66. $filter_area = trim(filter_input(INPUT_POST, "area", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  67. }
  68. $filter_fini = trim(filter_input(INPUT_POST, "fecha_inicial", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  69. $filter_ffin = trim(filter_input(INPUT_POST, "fecha_final", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  70. $filter_hini = trim(filter_input(INPUT_POST, "hora_inicial", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  71. $filter_hfin = trim(filter_input(INPUT_POST, "hora_final", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  72. $hoy_fecha = date("Y-m-d");
  73. if(isset($filter_fini)) $fecha_ini = fechaGuion($filter_fini); else $fecha_ini = $periodo_rs["Periodo_fecha_inicial"];
  74. if(isset($filter_ffin)){
  75. $fecha_fin = fechaGuion($filter_ffin);
  76. }else{
  77. if($periodo_rs["Periodo_fecha_final"] < $hoy_fecha){
  78. $fecha_fin = $periodo_rs["Periodo_fecha_final"];
  79. }else{
  80. $fecha_fin = $hoy_fecha;
  81. }
  82. }
  83. //echo $filter_periodo." ".$fecha_ini." ".$fecha_fin." ".$filter_hini." ".$filter_hfin." ".$filter_clave."<br>";exit();
  84. if(isset($filter_area)){
  85. $stmt = $pdo->prepare('Select * from fs_asistenciaprofesores(:per, :fini, :ffin, :hini, :hfin, NULL, :clave, :area, 0, NULL)');//sólo activos
  86. $stmt->bindParam(":area", $filter_area);
  87. }else{
  88. $stmt = $pdo->prepare('Select * from fs_asistenciaprofesores(:per, :fini, :ffin, :hini, :hfin, NULL, :clave, NULL, 0, NULL)');//sólo activos
  89. }
  90. $stmt->bindParam(":per", $filter_periodo);
  91. $stmt->bindParam(":fini", $fecha_ini);
  92. $stmt->bindParam(":ffin", $fecha_fin);
  93. $stmt->bindParam(":hini", $filter_hini);
  94. $stmt->bindParam(":hfin", $filter_hfin);
  95. $stmt->bindParam(":clave", $filter_clave);
  96. if(!$stmt->execute()){
  97. $errorDesc = "Ocurrió un error al cargar los profesores";
  98. print_r($stmt->errorInfo());
  99. }else{
  100. $profesores_rs = $stmt->fetchAll();
  101. }
  102. $stmt->closeCursor();
  103. ?>
  104. <main class="container-fluid content marco">
  105. <?php include_once("../include/errorMessage.php"); ?>
  106. <p><button class="btn btn-outline-secondary btn-regresar"><span class="ing-flecha ing-rotate-180"></span> Regresar</button></p>
  107. <?php
  108. if(isset($periodo_rs)){
  109. ?>
  110. <!-- Filtro -->
  111. <div class="row">
  112. <div class="col-12">
  113. <form action="reporte_asistenciasprofesordetalle.php" method="post" id="form_filter">
  114. <input type="hidden" name="clave" value="<?php echo $filter_clave;?>">
  115. <input type="hidden" name="area" value="<?php echo $filter_area;?>">
  116. <div class="form-box">
  117. <div class="form-group row">
  118. <label for="fecha_inicial" class="col-4 col-form-label">Fecha inicial *</label>
  119. <div class="col-8 col-sm-4">
  120. <input id="fecha_inicial" name="fecha_inicial" type="text" class="form-control date-picker" placeholder="dd/mm/aaaa" maxlength="10" required="required" readonly="readonly" value="<?php echo fechaSlash($fecha_ini);?>">
  121. </div>
  122. </div>
  123. <div class="form-group row">
  124. <label for="fecha_final" class="col-4 col-form-label">Fecha final *</label>
  125. <div class="col-8 col-sm-4">
  126. <input id="fecha_final" name="fecha_final" type="text" class="form-control date-picker" placeholder="dd/mm/aaaa" maxlength="10" required="required" readonly="readonly" value="<?php echo fechaSlash($fecha_fin); ?>">
  127. </div>
  128. </div>
  129. <div class="form-group row">
  130. <label for="hora_inicial" class="col-4 col-form-label">Hora inicial *</label>
  131. <div class="col-8 col-sm-4">
  132. <input id="hora_inicial" name="hora_inicial" type="text" class="form-control clock" data-autoclose="true" placeholder="hh:mm" maxlength="5" required="required" readonly="readonly" value="<?php echo $filter_hini;?>">
  133. </div>
  134. </div>
  135. <div class="form-group row">
  136. <label for="hora_final" class="col-4 col-form-label">Hora final *</label>
  137. <div class="col-8 col-sm-4">
  138. <input id="hora_final" name="hora_final" type="text" class="form-control clock" data-autoclose="true" placeholder="hh:mm" maxlength="10" required="required" readonly="readonly" value="<?php echo $filter_hfin ?>">
  139. </div>
  140. </div>
  141. </div>
  142. <div class="form-group row">
  143. <div class="col-12 text-center">
  144. <button type="submit" class="btn btn-outline-primary"><?php echo $ICO["buscar"]; ?> Filtrar</button>
  145. </div>
  146. </div>
  147. </form>
  148. </div>
  149. </div>
  150. <?php //if($filter_periodo != ""){ //hay periodo seleccionado?>
  151. <form action="./export/xls_asistenciasprofesor.php" target="_blank" method="post" id="formEnviar">
  152. <input type="hidden" name="clave" value="<?php if(isset($filter_clave)){ echo $filter_clave; }?>">
  153. <input type="hidden" name="fecha_inicial" value="<?php echo $fecha_ini;?>">
  154. <input type="hidden" name="fecha_final" value="<?php echo $fecha_fin;?>">
  155. <input type="hidden" name="hora_inicial" value="<?php echo $filter_hini;?>">
  156. <input type="hidden" name="hora_final" value="<?php echo $filter_hfin;?>">
  157. <input type="hidden" name="area" value="<?php if(isset($filter_area)){ echo $filter_area; }?>">
  158. <p class="text-right"><button type="submit" class="btn btn-outline-secondary"><?php echo $ICO["descargar"];?> Generar xls</button></p>
  159. </form>
  160. <div class="row justify-content-md-center">
  161. <div class="col-12 table-responsive">
  162. <table class="table table-sm table-striped table-white">
  163. <thead class="thead-dark">
  164. <tr >
  165. <th>Clave</th>
  166. <th>Profesor</th>
  167. <th>Grupo</th>
  168. <th>Materia</th>
  169. <th>Fecha</th>
  170. <th>Hora de clase</th>
  171. <th>Checador</th>
  172. <th>Estatus</th>
  173. </tr>
  174. </thead>
  175. <tbody>
  176. <?php
  177. foreach($profesores_rs as $profesor){
  178. ?>
  179. <tr data-id="<?php echo $profesor["Usuario_id"]; ?>">
  180. <td class="text-center font-weight-bold"><?php echo $profesor["Usuario_claveULSA"]; ?></td>
  181. <td><?php echo $profesor["Usuario_apellidos"]." ".$profesor["Usuario_nombre"]; ?></td>
  182. <td><?php
  183. //if($_SESSION["nivel_id"] == 1)
  184. echo $profesor["Grupo_desc"]." ".$profesor["Carrera_prefijo"];
  185. //else
  186. //echo $profesor["Grupo_desc"];?></td>
  187. <td><?php echo $profesor["Materia_desc"];?><br>
  188. <small><span style="color:<?php echo $profesor["Area_color"];?>"><?php echo $ICO["circulo"];?></span> <?php echo $profesor["Area_desc"];?></small>
  189. </td>
  190. <td class="text-center text-nowrap"><?php echo fechaSlash($profesor["Fecha"]);?></td>
  191. <td class="text-center"><?php echo date('H:i', strtotime($profesor["Horario_hora"]));?></td>
  192. <td class="text-center"><?php
  193. if(isset($profesor["Asistencia_checador_inicial"]) && $profesor["Asistencia_checador_inicial"] != "")
  194. echo date('H:i', strtotime($profesor["Asistencia_checador_inicial"]));
  195. ?>
  196. </td>
  197. <?php
  198. $colorStatus = '';
  199. $status = '';
  200. if(isset($profesor["Asistencia_isRetardo"]) && $profesor["Asistencia_isRetardo"] !== ""){
  201. if($profesor["Asistencia_isRetardo"]){
  202. $status = "Retardo";
  203. $colorStatus = 'text-warning';
  204. }else{
  205. if($profesor["Asistencia_isJustificada"]){
  206. $status = "Justificada";
  207. $colorStatus = 'text-primary';
  208. }else{
  209. $status = "Asistencia";
  210. $colorStatus = 'text-success';
  211. }
  212. }
  213. }else{
  214. $status = "Sin registro";
  215. $colorStatus = 'text-danger';
  216. }
  217. if($profesor["Asistencia_isReposicion"]) $status.="<br><small>Reposición<small>";
  218. ?>
  219. <td class="text-center <?php echo $colorStatus;?>">
  220. <?php echo $status;?>
  221. </td>
  222. </tr>
  223. <?php
  224. }//foreach prof
  225. ?>
  226. </tbody>
  227. </table>
  228. </div>
  229. </div>
  230. <p><button class="btn btn-outline-secondary btn-regresar mt-3"><span class="ing-flecha ing-rotate-180"></span> Regresar</button></p>
  231. <?php } //fin hay periodo seleccionado?>
  232. <?php //} ?>
  233. </main>
  234. <!--- FOOTER--->
  235. <?php require_once("../include/footer.php"); ?>
  236. </div>
  237. <script src="../js/jquery.min.js"></script>
  238. <script src="../js/jquery-ui.js"></script>
  239. <script src="../js/datepicker-es.js"></script>
  240. <script src="../js/clockpicker.js"></script>
  241. <script src="../js/bootstrap/popper.min.js"></script>
  242. <script src="../js/bootstrap/bootstrap.min.js"></script>
  243. <script src="../js/sidebarmenu.js"></script>
  244. <script src="../js/datalist.js"></script>
  245. <script>
  246. var _periodo_fecha_inicial = "<?php echo fechaSlash($periodo_rs["Periodo_fecha_inicial"]); ?>";
  247. var _periodo_fecha_final = "<?php if($periodo_rs["Periodo_fecha_final"] > $hoy_fecha ) echo fechaSlash($hoy_fecha); else echo fechaSlash($periodo_rs["Periodo_fecha_final"]); ?>";
  248. var datepickerOptions = { dateFormat: "dd/mm/yy", minDate:_periodo_fecha_inicial, maxDate:_periodo_fecha_final };
  249. $(document).on( "click", ".btn-reset", function(event){
  250. var forma = $(this).parents("form");
  251. forma.find("input[type=text]").val("");
  252. forma.find("select").prop("selectedIndex",0);
  253. $("#fecha_inicial").val(_periodo_fecha_inicial);
  254. $("#fecha_final").val(_periodo_fecha_final);
  255. forma.submit();
  256. });
  257. $(document).on( "click", ".btn-regresar", function(event){
  258. $("#formEnviar").attr("action", "reporte_asistenciasprofesor.php");
  259. $("#formEnviar").attr("target", "_self");
  260. $("#formEnviar").submit();
  261. });
  262. $(document).ready(function(){
  263. setDatalist("#periodo", <?php echo $_SESSION["periodo_id"]; ?>);
  264. $(document).on('click', '#dlPeriodo ul li' ,function(){
  265. $("#formaPeriodo").submit();
  266. });
  267. $(".date-picker" ).datepicker(datepickerOptions);
  268. $(".date-picker" ).datepicker( $.datepicker.regional[ "es" ] );
  269. $('.clock').clockpicker();
  270. });
  271. </script>
  272. </body>
  273. </html>