reporte_asistenciasprofesor.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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. ?>
  16. <!DOCTYPE html>
  17. <html lang="es" prefix="og: http://ogp.me/ns#">
  18. <head>
  19. <title>APSA - Facultad de Ingeniería</title>
  20. <meta charset="utf-8">
  21. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  22. <link rel="icon" type="image/png" href="../img/favicon.png" />
  23. <link rel="stylesheet" href="../css/bootstrap-ulsa.min.css" type="text/css">
  24. <link rel="stylesheet" href="../css/indivisa.css" type="text/css">
  25. <link rel="stylesheet" href="../css/sgi.css?rand=<?php echo rand();?>" type="text/css">
  26. <link rel="stylesheet" href="../css/fa_all.css" type="text/css">
  27. <link rel="stylesheet" href="../css/jquery-ui.css" type="text/css">
  28. <link rel="stylesheet" href="../css/clockpicker.css" type="text/css">
  29. <link rel="stylesheet" href="../css/calendar.css" type="text/css">
  30. <script src="../js/util.js"></script>
  31. </head>
  32. <body>
  33. <div>
  34. <?php
  35. //--- Objeto que pinta menu
  36. $menuObj = new MainMenu($_SESSION["usuario_id"], $menu, $pdo, APSA, "Asistencias de profesores");//usr, menu, pdo, sist
  37. $menuObj->printMenu();
  38. /*if(isset($_POST["periodo"]))
  39. $filter_periodo = filter_input(INPUT_POST, "periodo", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  40. else*/
  41. $filter_periodo = $_SESSION["periodo_id"];
  42. //Area
  43. $stmt = $pdo->prepare('Select * from fs_areaacademica(NULL, :nivel)');
  44. $stmt->bindParam(":nivel", $_SESSION["nivel_id"]);
  45. if(!$stmt->execute()){
  46. $errorDesc = "Ocurrió un error al cargar las áreas académicas";
  47. }else{
  48. $area_rs = $stmt->fetchAll();
  49. }
  50. $stmt->closeCursor();
  51. //Periodo
  52. $stmt = $pdo->prepare('Select * from fs_periodo(:id, NULL, NULL, true)');
  53. $stmt->bindParam(":id", $filter_periodo);
  54. if(!$stmt->execute()){
  55. $errorDesc = "Ocurrió un error al cargar el periodo";
  56. }else{
  57. $periodo_rs = $stmt->fetch();
  58. }
  59. $stmt->closeCursor();
  60. if(isset($_POST["fecha_inicial"]) && $_POST["fecha_inicial"]!=""){
  61. $filter_fini = trim(filter_input(INPUT_POST, "fecha_inicial", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  62. }
  63. if(isset($_POST["fecha_final"]) && $_POST["fecha_final"]!=""){
  64. $filter_ffin = trim(filter_input(INPUT_POST, "fecha_final", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  65. }
  66. if(isset($_POST["hora_inicial"]) && $_POST["hora_inicial"]!=""){
  67. $filter_hini = trim(filter_input(INPUT_POST, "hora_inicial", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  68. }else{
  69. $filter_hini = '00:00';
  70. }
  71. if(isset($_POST["hora_final"]) && $_POST["hora_final"]!=""){
  72. $filter_hfin = trim(filter_input(INPUT_POST, "hora_final", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  73. }else{
  74. $filter_hfin = '23:59';
  75. }
  76. $query = "";
  77. if(isset($_POST["desc"]) && $_POST["desc"] != ""){
  78. $query .= ":desc,";
  79. $filter_desc = trim(filter_input(INPUT_POST, "desc", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  80. }else{
  81. $query .= "NULL,";
  82. }
  83. if(isset($_POST["clave"]) && $_POST["clave"] != ""){
  84. $query .= ":clave,";
  85. $filter_clave = filter_input(INPUT_POST, "clave", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  86. }else{
  87. $query .= "NULL,";
  88. }
  89. if(isset($_POST["area"]) && is_numeric($_POST["area"]) && trim($_POST["area"]) != ""){
  90. $query .= ":area,";
  91. $filter_area = filter_input(INPUT_POST, "area", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  92. }else{
  93. $query .= "NULL,";
  94. }
  95. $hoy_fecha = date("Y-m-d");
  96. if(isset($filter_fini)) $fecha_ini = fechaGuion($filter_fini); else $fecha_ini = $periodo_rs["Periodo_fecha_inicial"];
  97. if(isset($filter_ffin)){
  98. $fecha_fin = fechaGuion($filter_ffin);
  99. }else{
  100. if($periodo_rs["Periodo_fecha_final"] < $hoy_fecha){
  101. $fecha_fin = $periodo_rs["Periodo_fecha_final"];
  102. }else{
  103. $fecha_fin = $hoy_fecha;
  104. }
  105. }
  106. $stmt = $pdo->prepare('Select * from fs_asistenciaprofesores_all(:per, :fini, :ffin, :hini, :hfin, '.$query.' 0, NULL)');//sólo activos
  107. $stmt->bindParam(":per", $filter_periodo);
  108. $stmt->bindParam(":fini", $fecha_ini);
  109. $stmt->bindParam(":ffin", $fecha_fin);
  110. $stmt->bindParam(":hini", $filter_hini);
  111. $stmt->bindParam(":hfin", $filter_hfin);
  112. if(isset($filter_desc)) $stmt->bindParam(":desc", $filter_desc);
  113. if(isset($filter_clave)) $stmt->bindParam(":clave", $filter_clave);
  114. if(isset($filter_area)) $stmt->bindParam(":area", $filter_area);
  115. if(!$stmt->execute()){
  116. $errorDesc = "Ocurrió un error al cargar los profesores";
  117. print_r($stmt->errorInfo());
  118. }else{
  119. $profesoresAll_rs = $stmt->fetchAll();
  120. }
  121. $stmt->closeCursor();
  122. ?>
  123. <main class="container-fluid content marco">
  124. <?php include_once("../include/errorMessage.php"); ?>
  125. <?php include("../include/periodoCambio.php");?>
  126. <?php
  127. if(isset($area_rs) && isset($periodo_rs)){
  128. ?>
  129. <!-- Filtro -->
  130. <div class="row">
  131. <div class="col-12">
  132. <form action="" method="post" id="form_filter">
  133. <div class="form-box form-box-info">
  134. <div class="form-group row">
  135. <label for="filter_desc" class="col-4 col-form-label">Nombre profesor</label>
  136. <div class="col-8 col-sm-4">
  137. <input id="filter_desc" name="desc" type="text" class="form-control" <?php if(isset($filter_desc) ){echo 'value="'.$filter_desc.'"';}?>>
  138. </div>
  139. </div>
  140. <div class="form-group row">
  141. <label for="filter_clave" class="col-4 col-form-label">Clave</label>
  142. <div class="col-8 col-sm-4">
  143. <input id="filter_clave" name="clave" type="text" class="form-control" <?php if(isset($filter_clave) ){echo 'value="'.$filter_clave.'"';}?>>
  144. </div>
  145. </div>
  146. <?php if(count($area_rs) > 1){ ?>
  147. <div class="form-group row">
  148. <label for="filter_area" class="col-4 col-form-label">Área</label>
  149. <div class="col-8 col-sm-4">
  150. <select id="filter_area" name="area" class="form-control">
  151. <option value="">Mostrar todas</option>
  152. <?php foreach($area_rs as $area) {?>
  153. <option value="<?php echo $area["Area_id"];?>" <?php if(isset($filter_area) && $filter_area == $area["Area_id"]){echo "selected='selected'";}?> ><?php echo $area["Area_desc"];?></option>
  154. <?php } ?>
  155. </select>
  156. </div>
  157. </div>
  158. <?php } ?>
  159. <div class="bg-info pt-3 pb-2 mt-3">
  160. <p class="text-center font-weight-bold alert-heading">
  161. <a class="d-block collapsed" data-toggle="collapse" href="#avanzadoBox" role="button" aria-expanded="false" aria-controls="collapseExample">
  162. Filtrar por fecha/hora <i class="ing-caret ing-fw ml-5"></i></a>
  163. </p>
  164. <div class="col-12 collapse" id="avanzadoBox">
  165. <div class="form-box">
  166. <div class="form-group row">
  167. <label for="fecha_inicial" class="col-4 col-form-label">Fecha inicial *</label>
  168. <div class="col-8 col-sm-4">
  169. <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);?>">
  170. </div>
  171. </div>
  172. <div class="form-group row">
  173. <label for="fecha_final" class="col-4 col-form-label">Fecha final *</label>
  174. <div class="col-8 col-sm-4">
  175. <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); ?>">
  176. </div>
  177. </div>
  178. <div class="form-group row">
  179. <label for="hora_inicial" class="col-4 col-form-label">Hora inicial *</label>
  180. <div class="col-8 col-sm-4">
  181. <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;?>">
  182. </div>
  183. </div>
  184. <div class="form-group row">
  185. <label for="hora_final" class="col-4 col-form-label">Hora final *</label>
  186. <div class="col-8 col-sm-4">
  187. <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 ?>">
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. <div class="form-group row">
  195. <div class="col-12 text-center">
  196. <button type="submit" class="btn btn-outline-primary"><?php echo $ICO["buscar"]; ?> Filtrar</button>
  197. <button type="button" class="btn btn-outline-danger btn-reset"><?php echo $ICO["borrar"]?> Limpiar</button>
  198. </div>
  199. </div>
  200. </form>
  201. </div>
  202. </div>
  203. <?php //if($filter_periodo != ""){ //hay periodo seleccionado?>
  204. <?php if(isset($profesoresAll_rs)){ ?>
  205. <form action="./export/xls_asistenciasprofesor_all.php" target="_blank" method="post">
  206. <input type="hidden" name="periodo" value="<?php if(isset($filter_periodo)){ echo $filter_periodo; }?>">
  207. <input type="hidden" name="area" value="<?php if(isset($filter_area)){ echo $filter_area; }?>">
  208. <input type="hidden" name="desc" value="<?php if(isset($filter_desc)){ echo $filter_desc; }?>">
  209. <input type="hidden" name="clave" value="<?php if(isset($filter_clave)){ echo $filter_clave; }?>">
  210. <input type="hidden" name="fecha_inicial" value="<?php echo $fecha_ini;?>">
  211. <input type="hidden" name="fecha_final" value="<?php echo $fecha_fin;?>">
  212. <input type="hidden" name="hora_inicial" value="<?php echo $filter_hini;?>">
  213. <input type="hidden" name="hora_final" value="<?php echo $filter_hfin;?>">
  214. <p class="text-right"><button type="submit" class="btn btn-outline-secondary"><?php echo $ICO["descargar"];?> Generar xls</button></p>
  215. </form>
  216. <form action="reporte_asistenciasprofesordetalle.php" id="detalleForm" method="post">
  217. <input type="hidden" name="area" value="<?php if(isset($filter_area)){ echo $filter_area; }?>">
  218. <input type="hidden" name="clave" value="" id="clave_prof">
  219. <input type="hidden" name="fecha_inicial" value="<?php echo $fecha_ini;?>">
  220. <input type="hidden" name="fecha_final" value="<?php echo $fecha_fin;?>">
  221. <input type="hidden" name="hora_inicial" value="<?php echo $filter_hini;?>">
  222. <input type="hidden" name="hora_final" value="<?php echo $filter_hfin;?>">
  223. </form>
  224. <div class="row justify-content-md-center">
  225. <div class="col-12 table-responsive">
  226. <table class="table table-sm table-striped table-white">
  227. <thead class="thead-dark">
  228. <tr>
  229. <th >Clave</th>
  230. <th >Profesor</th>
  231. <th >Clases</th>
  232. <th style="width:350px" >Asistencia</th>
  233. <th >&nbsp;</th>
  234. </tr>
  235. </thead>
  236. <tbody>
  237. <?php
  238. foreach($profesoresAll_rs as $profesor){
  239. ?>
  240. <tr data-id="<?php echo $profesor["Usuario_claveULSA"]; ?>">
  241. <td class="text-center font-weight-bold"><?php echo $profesor["Usuario_claveULSA"]; ?></td>
  242. <td class=""><span class="pointer detalle"><?php echo $profesor["Usuario_apellidos"]." ".$profesor["Usuario_nombre"]; ?></span></td>
  243. <td class="text-center">
  244. <?php echo $profesor["Clases_total"];?>
  245. </td>
  246. <td class="">
  247. <div class="progress" style="height: 24px;">
  248. <?php if( ($profesor["Asistencias"]+$profesor["Retardos"]+$profesor["Reposiciones"]) > 0){ ?>
  249. <div class="progress-bar bg-success" role="progressbar" title="Asistencias <?php echo ($profesor["Asistencias"]+$profesor["Reposiciones"])?>" style="width: <?php echo ($profesor["Asistencias"]+$profesor["Reposiciones"])*100/$profesor["Clases_total"]; ?>%" aria-valuenow="<?php echo ($profesor["Asistencias"]+$profesor["Reposiciones"])*100/$profesor["Clases_total"]; ?>" aria-valuemin="0" aria-valuemax="100"></div>
  250. <div class="progress-bar bg-warning" role="progressbar" title="Retardos <?php echo $profesor["Retardos"]?>" style="width: <?php echo $profesor["Retardos"]*100/$profesor["Clases_total"]; ?>%" aria-valuenow="<?php echo $profesor["Retardos"]*100/$profesor["Clases_total"]; ?>" aria-valuemin="0" aria-valuemax="100"></div>
  251. <div class="progress-bar bg-info" role="progressbar" title="Faltas <?php echo $profesor["Faltas"]?>" style="width: <?php echo $profesor["Faltas"]*100/$profesor["Clases_total"]; ?>%" aria-valuenow="<?php echo $profesor["Faltas"]*100/$profesor["Clases_total"]; ?>" aria-valuemin="0" aria-valuemax="100"></div>
  252. <?php } else {?>
  253. <div class="progress-bar bg-info" role="progressbar" title="Faltas <?php echo $profesor["Clases_total"]?>" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"><span class="text-primary">Sin asistencias</span></div>
  254. <?php } ?>
  255. </div>
  256. <p class="mb-0"><small>Asistencias: <?php echo ($profesor["Asistencias"]+$profesor["Reposiciones"])?> Retardos: <?php echo $profesor["Retardos"]?> Faltas: <?php echo $profesor["Faltas"]?></small></p>
  257. </td>
  258. <td class="text-center">
  259. <span class="pointer detalle" title="Ver detalle" ><span class="ing-ver"></span></span>
  260. </td>
  261. </tr>
  262. <?php } ?>
  263. </tbody>
  264. </table>
  265. </div>
  266. </div>
  267. <?php } ?>
  268. <?php } //fin hay periodo seleccionado?>
  269. <?php //} ?>
  270. </main>
  271. <!--- FOOTER--->
  272. <?php require_once("../include/footer.php"); ?>
  273. </div>
  274. <script src="../js/jquery.min.js"></script>
  275. <script src="../js/jquery-ui.js"></script>
  276. <script src="../js/datepicker-es.js"></script>
  277. <script src="../js/clockpicker.js"></script>
  278. <script src="../js/bootstrap/popper.min.js"></script>
  279. <script src="../js/bootstrap/bootstrap.min.js"></script>
  280. <script src="../js/sidebarmenu.js"></script>
  281. <script src="../js/datalist.js"></script>
  282. <script>
  283. var _periodo_fecha_inicial = "<?php echo fechaSlash($periodo_rs["Periodo_fecha_inicial"]); ?>";
  284. 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"]); ?>";
  285. var datepickerOptions = { dateFormat: "dd/mm/yy", minDate:_periodo_fecha_inicial, maxDate:_periodo_fecha_final };
  286. $(document).on( "click", ".btn-reset", function(event){
  287. var forma = $(this).parents("form");
  288. forma.find("input[type=text]").val("");
  289. forma.find("select").prop("selectedIndex",0);
  290. $("#fecha_inicial").val(_periodo_fecha_inicial);
  291. $("#fecha_final").val(_periodo_fecha_final);
  292. forma.submit();
  293. });
  294. $(document).on( "click", ".detalle", function(event){
  295. var forma = $("#detalleForm");
  296. var id = $(this).parents("tr").data("id");
  297. console.log(id);
  298. $("#clave_prof").val(id);
  299. forma.submit();
  300. });
  301. $(document).ready(function(){
  302. setDatalist("#periodo", <?php echo $_SESSION["periodo_id"]; ?>);
  303. $(document).on('click', '#dlPeriodo ul li' ,function(){
  304. $("#formaPeriodo").submit();
  305. });
  306. $(".date-picker" ).datepicker(datepickerOptions);
  307. $(".date-picker" ).datepicker( $.datepicker.regional[ "es" ] );
  308. $('.clock').clockpicker();
  309. });
  310. </script>
  311. </body>
  312. </html>