123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352 |
- <?php
- require_once("../include/constantes.php");
- require_once("../include/util.php");
- require_once("../include/bd_pdo.php");
- require_once("../classes/ValidaSesion.php");
- require_once("../classes/MainMenu.php");
- $menu = 8;
- $submenu = 83;
- //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
- $objSesion = new ValidaSesion($pdo, $submenu, APSA);
- if(!$objSesion->tieneAcceso()){
- $objSesion->terminaSesion();
- }
- $objSesion->validaPeriodoUsuario();//si no tiene periodo manda a main
- /*if(!$objSesion->puedeEditar()){
- $errorDesc = "No puedes generar nombramientos.";
- }*/
-
- //Obtiene grupos del periodo
- $stmt = $pdo->prepare('Select * from fs_grupo(NULL, :periodo)');
- $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
- if(!$stmt->execute()){
- header("Location: grupos.php?error=4");
- exit();
- }else{
- $grupos_rs = $stmt->fetchAll();
- }
- $stmt->closeCursor();
- if(!is_array($grupos_rs) || count($grupos_rs) == 0){
- header("Location: grupos.php?error=5");
- exit();
- }
- ?>
- <!DOCTYPE html>
- <html lang="es" prefix="og: http://ogp.me/ns#">
- <head>
- <title>APSA - 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="icon" type="image/png" href="../img/favicon.png" />
- <link rel="stylesheet" href="../css/bootstrap-ulsa.min.css" type="text/css">
- <link rel="stylesheet" href="../css/indivisa.css" type="text/css">
- <link rel="stylesheet" href="../css/sgi.css?rand=<?php echo rand();?>" type="text/css">
- <link rel="stylesheet" href="../css/fa_all.css" type="text/css">
- <link rel="stylesheet" href="../css/jquery-ui.css" type="text/css">
- <link rel="stylesheet" href="../css/clockpicker.css" type="text/css">
- <link rel="stylesheet" href="../css/calendar.css" type="text/css">
- <script src="../js/util.js"></script>
- </head>
- <body>
- <div>
- <?php
- //--- Objeto que pinta menu
- $menuObj = new MainMenu($_SESSION["usuario_id"], $menu, $pdo, APSA, "Justificar faltas");//usr, menu, pdo, sist
- $menuObj->printMenu();
-
-
- //Obtiene fechas de periodo
- $stmt = $pdo->prepare('Select * from fs_periodo(:periodo, NULL, NULL, true)');
- $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
- if(!$stmt->execute()){
- $errorDesc = "Ocurrió un error al cargar las fechas del periodo";
- }else{
- $periodo_rs = $stmt->fetch();
- }
- $stmt->closeCursor();
- $stmt = null;
-
- if(isset($_POST["hora_inicial"]) && $_POST["hora_inicial"]!=""){
- $filter_hini = trim(filter_input(INPUT_POST, "hora_inicial", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
- }else{
- $filter_hini = HORA_INICIO.':00';
- }
- if(isset($_POST["hora_final"]) && $_POST["hora_final"]!=""){
- $filter_hfin = trim(filter_input(INPUT_POST, "hora_final", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
- }else{
- $filter_hfin = HORA_FINAL.':00';
- }
- if(isset($_POST["hora_final"]) && $_POST["hora_final"]!=""){
- $filter_nombre = trim(filter_input(INPUT_POST, "nombre", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
- }else{
- $filter_nombre = "";
- }
-
-
- if(isset($_POST["fecha"])){
- $fecha = fechaGuion($_POST["fecha"]);
- $stmt = $pdo->prepare('Select * from fs_profesoresfecha(:nom, :periodo, :fecha, :h_ini, :h_fin)');
- $stmt->bindParam(":nom", $filter_nombre);
- $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
- $stmt->bindParam(":fecha", $fecha);
- $stmt->bindParam(":h_ini", $filter_hini);
- $stmt->bindParam(":h_fin", $filter_hfin);
-
- if(!$stmt->execute()){
- $errorDesc = "Ocurrió un error al cargar los profesores de la fecha";
- }else{
- $profesores_rs = $stmt->fetchAll();
- }
- $stmt->closeCursor();
- $stmt = null;
- }
-
- //--Manejo de errores y mensajes de exito
- if(isset($_GET["error"]) && is_numeric($_GET["error"])){
- switch ($_GET["error"]){
- case 0: $errorDesc = "No se reciberon los datos para justificar la falta."; break;
- case 1: $errorDesc = "Ocurrió un error al gruardar la justificación."; break;
- case 2: $errorDesc = "No tienes permisos para realizar esa acción."; break;
- }
- }
- if(isset($_GET["ok"]) && is_numeric($_GET["ok"])){
- switch ($_GET["ok"]){
- case 0: $successDesc = "Las justificaciones se guardaron correctamente."; break;
- }
- }
- ?>
- <main class="container-fluid content marco">
-
- <?php include_once("../include/errorMessage.php");?>
-
- <?php include("../include/periodoCambio.php");?>
-
- <?php if(isset($periodo_rs)){ ?>
-
-
- <p>Selecciona la fecha que deseas justificar.</p>
-
- <div class="row">
- <div class="col-12">
- <form action="" method="post" id="form_filter" onsubmit="return submitForm()">
- <div class="form-box form-box-info">
- <div class="form-group row">
- <label for="fecha" class="col-4 col-form-label">Fecha *</label>
- <div class="col-8 col-sm-4">
- <input id="fecha" name="fecha" type="text" class="form-control date-picker" placeholder="dd/mm/aaaa" maxlength="10" required="required" readonly="readonly" value="<?php if(isset($fecha)){echo fechaSlash($fecha);}else{echo date("d/m/Y");} ?>">
- <div class="invalid-feedback">Debes escribir una fecha.</div>
- </div>
- </div>
- <div class="form-group row">
- <label for="hora_inicial" class="col-4 col-form-label">Hora inicial *</label>
- <div class="col-8 col-sm-4">
- <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;?>">
- </div>
- </div>
- <div class="form-group row">
- <label for="hora_final" class="col-4 col-form-label">Hora final *</label>
- <div class="col-8 col-sm-4">
- <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 ?>">
- </div>
- </div>
- <div class="form-group row">
- <label for="hora_inicial" class="col-4 col-form-label">Nombre</label>
- <div class="col-8 col-sm-4">
- <input id="nombre" name="nombre" type="text" class="form-control" value="<?php echo $filter_nombre;?>">
- </div>
- </div>
- </div>
- <div class="form-group row">
- <div class="col-12 text-center">
- <button type="submit" class="btn btn-outline-primary"><?php echo $ICO["buscar"]; ?> Buscar profesores</button>
- </div>
- </div>
- </form>
- </div>
- </div>
-
-
- <div class="row">
- <div class="col-12 ">
-
- <?php if(isset($profesores_rs) && count($profesores_rs) > 0){ ?>
- <form action="./action/justifica_insert.php" method="post" onsubmit="return validaAsistencia()">
- <input type="hidden" name="fecha" value="<?php echo $fecha; ?>" >
- <div class="row">
- <div class="col-12">
- <p>Selecciona los horarios de los profesores en los que se justificará la falta.</p>
- </div>
- </div>
- <div class="row">
- <div class="col-12 table-responsive">
- <table class="table table-sm table-striped table-white">
- <thead class="thead-dark">
- <tr >
- <th style="width:30px;" class="">
- <div class="custom-control custom-checkbox">
- <input type="checkbox" class="custom-control-input" id="selectAll">
- <label class="custom-control-label" for="selectAll"></label>
- </div>
- </th>
- <th>Clave</th>
- <th>Profesor</th>
- <th>Hora</th>
- <th>Materia</th>
- <th>Grupo</th>
- </tr>
- </thead>
- <tbody id="profesor_list">
- <?php
- $i = 0;
- foreach($profesores_rs as $profesor){ ?>
- <tr class="">
- <td class="center">
- <div class="custom-control custom-checkbox">
- <?php $id_val = "";
- if(intval($profesor["Reposicion_id"]) == -1){
- $id_val = "0_".$profesor["HorarioGrupo_id"];
- }else{
- $id_val = "1_".$profesor["Reposicion_id"];
- }
- ?>
- <input type="checkbox" class="custom-control-input select_profesor" name="asistenciaArr[]" id="customCheck<?php echo $i;?>" value="<?php echo $profesor["Usuario_id"]."_".$profesor["Horario_hora"]."_".$id_val;?>">
- <label class="custom-control-label" for="customCheck<?php echo $i;?>"></label>
- </div>
- </td>
- <td class="text-center font-weight-bold"><?php echo $profesor["Usuario_claveULSA"];?></td>
- <td><?php echo $profesor["Usuario_apellidos"]." ".$profesor["Usuario_nombre"];?></td>
- <td class="text-center"><?php echo date('H:i', strtotime($profesor["Horario_hora"])); if($profesor["Reposicion_id"]!= -1){ echo " [REP]";}?></td>
- <td><?php echo $profesor["Materia_desc"];?></td>
- <td class="text-center text-nowrap"><?php
- //if($_SESSION["nivel_id"] == 1)
- echo $profesor["Grupo_desc"]." ".$profesor["Carrera_prefijo"];
- //else
- //echo $profesor["Grupo_desc"];
- ?></td>
- </tr>
- <?php
- $i++;
- } ?>
- </tbody>
- </table>
- </div>
- </div>
- <div class="row justify-content-md-center">
- <div class="col text-center">
- <button type="submit" class="btn btn-outline-primary" id="btn_justificar"><?php echo $ICO["aceptar"];?> Justificar faltas</button>
- </div>
- </div>
- </form>
- <?php } ?>
- </div>
- </div>
-
- <?php } ?>
- </main>
- <!--- FOOTER--->
- <?php require_once("../include/footer.php"); ?>
-
- </div>
-
- <script src="../js/jquery.min.js"></script>
- <script src="../js/jquery-ui.js"></script>
- <script src="../js/datepicker-es.js"></script>
- <script src="../js/bootstrap/popper.min.js"></script>
- <script src="../js/bootstrap/bootstrap.min.js"></script>
- <script src="../js/clockpicker.js"></script>
- <script src="../js/fechas.js"></script>
- <script src="../js/sidebarmenu.js"></script>
- <script src="../js/datalist.js"></script>
- <script>
-
- setDatalist("#periodo", <?php echo $_SESSION["periodo_id"]; ?>);
- $(document).on('click', '#dlPeriodo ul li' ,function(){
- $("#formaPeriodo").submit();
- });
-
- <?php
- if(strtotime(date("Y-m-d")) < strtotime($periodo_rs["Periodo_fecha_final"]))
- $limite = date("d/m/Y");
- else
- $limite = fechaSlash($periodo_rs["Periodo_fecha_final"]);
- ?>
- var _periodo_fecha_inicial = "<?php echo fechaSlash($periodo_rs["Periodo_fecha_inicial"]); ?>";
- var _periodo_fecha_final = "<?php echo $limite; ?>";
- var datepickerOptions = { dateFormat: "dd/mm/yy", minDate:_periodo_fecha_inicial, maxDate:_periodo_fecha_final };
- function submitForm(){
- if(!validaFecha($('#fecha').val()) ){
- $('#fecha').addClass("is-invalid");
- return false;
- }
- return true;
- }
- function validaAsistencia(){
-
- var numberOfChecked = $('#profesor_list input:checkbox:checked').length;
- //var totalCheckboxes = $('#profesores_block input:checkbox').length;
- //var numberNotChecked = totalCheckboxes - numberOfChecked;
- if(numberOfChecked == 0){
- $("#errorBox").collapse('show');
- $("#errorBox_text").html("Debes seleccionar al menos un horario para justificar");
- $('#messageBox')[0].scrollIntoView({ block: "end" });
- return false;
- }
- return true;
- }
-
- $(document).ready(function(){
- $(".date-picker" ).datepicker(datepickerOptions);
- $(".date-picker" ).datepicker( $.datepicker.regional[ "es" ] );
- $(".date-picker").blur(function(){
- var fechaObj = fechaObjeto($(this).val());
- if( fechaObj !== false ){
- if(Date.parse(fechaObj) < Date.parse(fechaObjeto(_periodo_fecha_inicial))){
- $(this).val(_periodo_fecha_inicial);
- }else if(Date.parse(fechaObj) > Date.parse(fechaObjeto(_periodo_fecha_final))){
- $(this).val(_periodo_fecha_final);
- }
- }
- });
-
- $('.clock').clockpicker();
-
- $("#btn-profesores").click(function(){
- $("#profesores_block").removeClass("d-none");
- });
-
- $("#btn_justificar").prop("disabled", true);
-
- $("#selectAll").change(function(){
- var check = $(this).prop("checked");
- $(".select_profesor").prop("checked", check);
-
- $("#btn_justificar").prop("disabled", !check);
- });
- $(".select_profesor").change(function(event){
- event.stopPropagation();
- //var check = $(this).prop("checked");
- var numberOfChecked = $('.select_profesor:checked').length;
- var totalCheckboxes = $('.select_profesor').length;
- if(numberOfChecked == totalCheckboxes){
- $("#selectAll").prop("checked", true);
- }else{
- $("#selectAll").prop("checked", false);
- }
- if(numberOfChecked > 0){
- $("#btn_justificar").prop("disabled", false);
- }else{
- $("#btn_justificar").prop("disabled", true);
- }
- });
-
- });
- </script>
- </body>
- </html>
|