123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- <?php
- require_once("../include/constantes.php");
- require_once("../include/bd_pdo.php");
- require_once("../classes/ValidaSesion.php");
- require_once("../classes/MainMenu.php");
- require_once("../include/util.php");
- require_once("./include/charts_util.php");
- $menu = 12;
- $submenu = 121;
- //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
- $objSesion = new ValidaSesion($pdo, $submenu, GEMA);
- if(!$objSesion->tieneAcceso()){
- $objSesion->terminaSesion();
- }
- $objSesion->validaPeriodoUsuario();//si no tiene periodo manda a main
-
- ?>
- <!DOCTYPE html>
- <html lang="es" prefix="og: http://ogp.me/ns#">
- <head>
- <title>GEMA - 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/calendar.css" type="text/css">
- <style>
- .text-donut{position: absolute; top:50%; margin-top: 6px; z-index:1; padding-bottom:0; left:50%; transform: translateX(-50%); -ms-transform: translateX(-50%);-webkit-transform:translateX(-50%); font-size:45px; line-height:55px}
- </style>
- </head>
- <body>
- <div>
- <?php
- //--- Objeto que pinta menu
- $menuObj = new MainMenu($_SESSION["usuario_id"], $menu, $pdo, GEMA, "Cambios de estado de alumnos");//usr, menu, pdo, sist
- $menuObj->printMenu();
-
- if($_SESSION["periodo_id"] != ""){
- //Plan de estudios
- $stmt = $pdo->prepare('Select * from fs_planestudio_alumnos(:nivel, NULL, true)');
- $stmt->bindParam(":nivel", $_SESSION["nivel_id"]);
- if(!$stmt->execute()){
- $errorDesc = "Ocurrió un error al cargar los planes de estudio";
- }else{
- $plan_rs = $stmt->fetchAll();
- }
- $stmt->closeCursor();
- $filter_periodo = $_SESSION["periodo_id"];
- $query = "";
- if(isset($_POST["plan"]) && $_POST["plan"] != 0 && $_POST["plan"] != ""){
- //$filter_plan = $_POST["plan"];
- $filter_plan = filter_input(INPUT_POST, "plan", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- $query = ":plan, ";
- }else
- $query = "NULL, ";
-
- $prefijo = "";
- $nivel = "";
- foreach($plan_rs as $plan){
- if($nivel == "")
- $nivel = $plan["Nivel_desc"];
- if(isset($filter_plan) && $plan["PlanEstudio_id"] == $filter_plan)
- $prefijo = $plan["Carrera_prefijo"];
- break;
- }
- //busca datos del periodo
- $stmt = $pdo->prepare('Select * from fs_periodo(:periodo, NULL, NULL, NULL)');
- $stmt->bindParam(":periodo", $filter_periodo);
- if(!$stmt->execute()){
- $errorDesc = "Ocurrió un error al obtener las fechas del periodo";
- //print_r($stmt->errorInfo());
- }else{
- $periodo_rs = $stmt->fetch();
-
- //Obtiene total de cambios de estado
- if(isset($_POST["fecha_inicial"]) && $_POST["fecha_inicial"]!=""){
- $filter_fini = fechaGuion(trim(filter_input(INPUT_POST, "fecha_inicial", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto
- }else{
- $filter_fini = $periodo_rs["Periodo_fecha_inicial"];
- }
- $query.= ':fini, ';
- if(isset($_POST["fecha_final"]) && $_POST["fecha_final"]!=""){
- $filter_ffin = fechaGuion(trim(filter_input(INPUT_POST, "fecha_final", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto
- }else{
- $filter_ffin = $periodo_rs["Periodo_fecha_final"];
- }
- $query.= ':ffin, ';
-
- if(isset($_POST["revalida"]) && $_POST["revalida"] == 1){
- $filter_revalida = 1;
- $query .= "true";
- }else{
- $filter_revalida = 0;
- $query .= "false";
- }
-
- $stmt = $pdo->prepare('Select * from fs_estadoalumno_cambios(:nivel, '.$query.')');//sólo no revalidadas
- $stmt->bindParam(":nivel", $_SESSION["nivel_id"]);
- $stmt->bindParam(":fini", $filter_fini);
- $stmt->bindParam(":ffin", $filter_ffin);
- if(isset($filter_plan)) $stmt->bindParam(":plan", $filter_plan);
- if(!$stmt->execute()){
- $errorDesc = "Ocurrió un error al cargar el total de estados.";
- //print_r($stmt->errorInfo());
- }else{
- $estado_rs = $stmt->fetchAll();
- $estadoArr = array();
- $estado_last = -1;
- $subestadoArr = array();
- $e = 0;
- $total = 0;
- foreach($estado_rs as $estado){
- if($estado_last != $estado["EstadoAlumno_id"]){
- if($estado_last != -1){
- $estadoArr[$e]["subestadoArr"]=$subestadoArr;
- $estadoArr[$e]["total"] = $total;
- $e++;
- $total = 0;
- }
- $estado_last = $estado["EstadoAlumno_id"];
- $subestadoArr = array();
- }
- $estadoArr[$e] = array("id" => $estado["EstadoAlumno_id"], "desc" =>$estado["EstadoAlumno_desc"], "color"=>$estado["EstadoAlumno_color"], "total"=>0, "subestadoArr"=>array());
- $subestadoArr[] = array("id" => $estado["SubEstadoAlumno_id"], "desc" =>$estado["SubEstadoAlumno_desc"], "color"=>$estado["SubEstadoAlumno_color"], "total"=>$estado["SubEstadoAlumno_total"]);
- $total+= $estado["SubEstadoAlumno_total"];
- }
- if($estado_last != -1){
- $estadoArr[$e]["subestadoArr"]=$subestadoArr;
- $estadoArr[$e]["total"] = $total;
- }
- unset($e);
- }
- $stmt->closeCursor();
- }
- }//hay periodo seleccionado
- ?>
- <main class="container-fluid content marco">
- <?php include_once("../include/errorMessage.php"); ?>
-
- <?php include("../include/periodoCambio.php");?>
-
- <?php if($_SESSION["periodo_id"] != ""){ ?>
- <!-- Filtro -->
- <div class="row">
- <div class="col-12">
- <form action="#" method="post">
- <div class="form-box form-box-info">
- <div class="form-group row">
- <label for="plan-nueva" class="col-4 col-form-label">Programa académico</label>
- <div class="col-8 col-sm-4">
- <div class="datalist datalist-select mb-1 w-100">
- <div class="datalist-input">Todos en <?php echo $nivel;?></div>
- <span class="ing-buscar icono"></span>
- <ul style="display:none">
- <li data-id="0">Todos en <?php echo $nivel;?></li>
- <?php foreach($plan_rs as $plan) { ?>
- <li data-id="<?php echo $plan["PlanEstudio_id"];?>" <?php if(isset($filter_plan) && $filter_plan==$plan["PlanEstudio_id"]){ echo 'class="selected"'; }?>><?php echo $plan["Carrera_desc"]." ".$plan["PlanEstudio_desc"];?></li>
- <?php }?>
- </ul>
- <input type="hidden" id="plan-nueva" name="plan" value="">
- </div>
- </div>
- </div>
- <div class="form-group row">
- <label for="fecha_inicial" class="col-4 col-form-label">Fecha Inicial de cambio</label>
- <div class="col-8 col-sm-4">
- <input id="fecha_inicial" name="fecha_inicial" type="text" class="form-control date-picker" placeholder="dd/mm/aaaa" maxlength="10" readonly="readonly" required="required" value="<?php if(isset($filter_fini)){ echo fechaSlash($filter_fini);}?>">
- <div class="invalid-feedback">No es una fecha válida.</div>
- </div>
- </div>
- <div class="form-group row">
- <label for="fecha_final" class="col-4 col-form-label">Fecha Final de cambio</label>
- <div class="col-8 col-sm-4">
- <input id="fecha_final" name="fecha_final" type="text" class="form-control date-picker" placeholder="dd/mm/aaaa" maxlength="10" readonly="readonly" required="required" value="<?php if(isset($filter_ffin)){ echo fechaSlash($filter_ffin);}?>">
- <div class="invalid-feedback">No es una fecha válida.</div>
- </div>
- </div>
- <div class="form-group row align-items-center">
- <label class="col-4 col-form-label">¿Incluir con revalidación?</label>
- <div class="col-8 col-sm-4">
- <div class="row">
- <div class="col-6 col-sm-4 text-center">
- <div class="form-check form-check-inline">
- <input class="form-check-input radio-lg revalida" type="radio" id="revalida_no" name="revalida" value="0" <?php if(!isset($filter_revalida) || (isset($filter_revalida) && intval($filter_revalida) == 0) ){ echo 'checked="checked"'; }?>>
- <label for="revalida_no" class="col-form-label">No</label>
- </div>
- </div>
- <div class="col-6 col-sm-4 text-center">
- <div class="form-check form-check-inline">
- <input class="form-check-input radio-lg revalida" type="radio" id="revalida_si" name="revalida" value="1" <?php if(isset($filter_revalida) && intval($filter_revalida) == 1 ){ echo 'checked="checked"'; }?>>
- <label for="revalida_si" class="col-form-label">Sí</label>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="form-group row mt-4">
- <div class="col-12 text-center">
- <button type="submit" class="btn btn-outline-primary"><?php echo $ICO["buscar"]; ?> Filtrar</button>
- <!--<button type="button" class="btn btn-outline-danger btn-reset"><?php echo $ICO["borrar"]?> Limpiar</button>!-->
- </div>
- </div>
- </form>
- </div>
- </div>
- <!-- end Filtro -->
- <?php } ?>
-
- <?php if(count($estadoArr) > 0){ ?>
- <form action="./export/xls_estados.php" target="_blank" method="post">
- <input type="hidden" name="plan" value="<?php echo isset($filter_plan)?$filter_plan:0;?>">
- <input type="hidden" name="fini" value="<?php echo $filter_fini;?>">
- <input type="hidden" name="ffin" value="<?php echo $filter_ffin;?>">
- <input type="hidden" name="prefijo" value="<?php echo ($prefijo!="")?$prefijo:$nivel;?>">
- <input type="hidden" name="revalida" value="<?php echo $filter_revalida;?>">
- <p class="pb-4"><button type="submit" class="btn btn-outline-secondary float-right"><?php echo $ICO["descargar"];?> Descargar datos</button></p>
- </form>
-
- <!-- Graficas -->
- <div class="row justify-content-center">
- <?php foreach($estadoArr as $estado){?>
- <div class="col-6 mb-5">
- <div class="card">
- <div class="card-header font-weight-bold" style="color:<?php echo $estado["color"];?>">
- <?php echo $ICO_LG["circulo"]; ?> <?php echo $estado["desc"];?>
- </div>
- <div class="card-body">
- <div>
- <canvas id="graficaEstado<?php echo $estado["id"];?>" height="500"></canvas>
- </div>
- <span class="text-donut">0</span>
- </div>
- </div>
- </div>
- <?php }//foreach ?>
- </div>
- <?php }else{ ?>
- <p class="text-center text-danger">No hay alumnos para el programa y/o periodo especificados.</p>
- <?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/sidebarmenu.js"></script>
- <script src="../js/chart.min.js"></script>
- <script src="../js/chartjs-plugin-datalabels.min.js"></script>
- <script src="../js/datalist.js"></script>
-
- <script>
- <?php if(count($estadoArr) > 0){ ?>
- var options = {
- tooltips: false,
- cutoutPercentage:25,
- maintainAspectRatio: false,
- padding: 64,
- plugins: {
- datalabels: {
- color: 'white',
- anchor: 'center',
- }
- },
- };
-
- function draw_grafica(){
- <?php foreach($estadoArr as $estado){?>
- new Chart($("#graficaEstado<?php echo $estado["id"];?>"), {
- type: 'doughnut',
- data: {
- labels: [
- <?php
- foreach($estado["subestadoArr"] as $subedo){
- echo '"'.$subedo["desc"].'", ';
- }?>
- ],
- datasets: [{
- data: [
- <?php
- foreach($estado["subestadoArr"] as $subedo){
- $data = $subedo["total"];
- echo $data.", ";
- }
- ?>
- ],
- backgroundColor: [<?php
- foreach($estado["subestadoArr"] as $subedo){
- echo '"'.$subedo["color"].'", ';
- }?>
- ],
- borderColor: "white",
- borderWidth: 2,
- datalabels: {
- labels: {
- name: {
- align: 'top',
- borderWidth: 0,
- font: {size: 12},
- formatter: function(value, ctx) {
- let datasets = ctx.chart.data.datasets;
- if (datasets.indexOf(ctx.dataset) === datasets.length - 1) {
- let sum = datasets[0].data.reduce((a, b) => a + b, 0);
- let percentage = Math.round((value / sum) * 100) + '%';
- return percentage;
- } else {
- return percentage;
- }
- },
- offset:0
- },
- value: {
- align: 'bottom',
- backgroundColor: 'white',
- borderColor: 'white',
- borderWidth: 2,
- borderRadius: 4,
- font: {size: 14, weight: 'bold'},
- /*color: function(ctx) {
- return ctx.dataset.backgroundColor;
- },*/
- color: "black",
- padding:{left: 6,right: 6,top: 2,bottom: 2},
- offset:0
- }
- }
- }
- }]//datasets
- },
- options: options
- });
- $("#graficaEstado<?php echo $estado["id"];?>").parents('.card-body').find('.text-donut').html("<?php echo $estado["total"];?>");
- <?php }//multiples graficas ?>
- }
- <?php }?>
-
-
- $(document).ready(function(){
- <?php if(count($estadoArr) > 0){ ?>
- draw_grafica();
- <?php } ?>
- setDatalist("#periodo", <?php echo $_SESSION["periodo_id"]; ?>);
- $(document).on('click', '#dlPeriodo ul li' ,function(){
- $("#formaPeriodo").submit();
- });
- $(".date-picker" ).datepicker({ dateFormat: "dd/mm/yy", changeMonth: true, changeYear: true});
- $(".date-picker" ).datepicker( $.datepicker.regional[ "es" ] );
- });
- </script>
- </body>
- </html>
|