datos_usuarios.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?php
  2. require_once("./include/constantes.php");
  3. require_once("./include/bd_pdo.php");
  4. require_once("./classes/MainMenu.php");
  5. session_start();
  6. //--- Valida que el usuaro tenga permisos de superadministrador
  7. if(!isset($_SESSION) || !$_SESSION["sgi_administrador"]){
  8. header("Location: main.php");
  9. exit();
  10. }
  11. $session_life = 1*60*60;//convertido a segundos
  12. if (isset($_SESSION["timeout"])) {
  13. // calculate the session's "time to live"
  14. $sessionTTL = time() - $_SESSION["timeout"];
  15. if ($sessionTTL > $session_life) {
  16. $_SESSION = array();
  17. session_destroy();
  18. $pag = $_SERVER['SERVER_NAME']."/salir.php?expired=1";
  19. header("Location: http://".$pag);
  20. exit();
  21. }
  22. }else{
  23. $_SESSION = array();
  24. session_destroy();
  25. $pag = $_SERVER['SERVER_NAME']."/salir.php?expired=1";
  26. header("Location: http://".$pag);
  27. exit();
  28. }
  29. $_SESSION["timeout"] = time();
  30. ?>
  31. <!DOCTYPE html>
  32. <html lang="es" prefix="og: http://ogp.me/ns#">
  33. <head>
  34. <title>.: Facultad de Ingeniería :.</title>
  35. <meta charset="utf-8">
  36. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  37. <link rel="icon" type="image/png" href="img/favicon.png" />
  38. <link rel="stylesheet" href="./css/bootstrap-ulsa.min.css" type="text/css">
  39. <link rel="stylesheet" href="./css/indivisa.css" type="text/css">
  40. <link rel="stylesheet" href="./css/sgi.css?rand=<?php echo rand();?>" type="text/css">
  41. <link rel="stylesheet" href="./css/fa_all.css" type="text/css">
  42. <style>
  43. .badge{padding:4px 8px; margin-left:10px;}
  44. </style>
  45. </head>
  46. <body>
  47. <div>
  48. <?php
  49. //--- Objeto que pinta menu
  50. $menuObj = new MainMenu($_SESSION["usuario_id"], NULL, $pdo, NULL, "Datos de usuarios");//usr, menu, pdo, sist
  51. require_once("./include/main_menus.php");
  52. if(isset($_MAIN_MENU)){
  53. foreach($_MAIN_MENU as $menu){
  54. $menuObj->agregaMenu($menu["nombre"], $menu["pag"], $menu["ico"]);
  55. }
  56. $menuObj->printMenu();
  57. }
  58. //Obtiene datos de alumnos
  59. $stmt = $pdo->prepare('Select * from fs_checkusuario(1, 0, '.(MAX_ROWS*2).')');
  60. if(!$stmt->execute()){
  61. $errorDesc = "Ocurrió un error al cargar los datos";
  62. }else
  63. $datos_rs = $stmt->fetchAll();
  64. $stmt->closeCursor();
  65. $stmt = null;
  66. //Obtiene datos de alumnos
  67. $stmt = $pdo->prepare('Select COUNT(*) as total from fs_checkusuario(1, 0, NULL)');
  68. if(!$stmt->execute()){
  69. $errorDesc = "Ocurrió un error al cargar los datos";
  70. }else
  71. $datosTotal_rs = $stmt->fetch();
  72. $stmt->closeCursor();
  73. $stmt = null;
  74. //--Manejo de errores y mensajes de exito
  75. if(isset($_GET["error"]) && is_numeric($_GET["error"])){
  76. switch ($_GET["error"]){
  77. case 0: $errorDesc = "No se reciberon los datos correctamente."; break;
  78. case 1: $errorDesc = "Ocurrió un error al actualizar los datos de los usuarios."; break;
  79. }
  80. if(isset($_GET["lista"])){
  81. $errorDesc .= "IDs: ".$_GET["lista"];
  82. }
  83. }
  84. if(isset($_GET["ok"]) && is_numeric($_GET["ok"])){
  85. switch ($_GET["ok"]){
  86. case 0: $successDesc = "Los datos se actualizaron correctamente."; break;
  87. }
  88. }
  89. ?>
  90. <div class="container marco mt-4">
  91. <?php include_once("./include/errorMessage.php"); ?>
  92. <?php
  93. if(isset($datos_rs) && count($datos_rs) > 0){
  94. ?>
  95. <div class="row">
  96. <div class="col-6">
  97. <p>Se muestran los primeros <?php echo MAX_ROWS*2;?> registros de <?php echo $datosTotal_rs["total"];?></p>
  98. </div>
  99. <div class="col-6 text-right">
  100. <a href="datos_usuarios_export.php" class="btn btn-outline-secondary"><?php echo $ICO["descargar"];?> Descargar xls</a>
  101. </div>
  102. </div>
  103. <?php } ?>
  104. </div>
  105. <main class="container-fluid content">
  106. <?php
  107. if(isset($datos_rs) && count($datos_rs) > 0){
  108. ?>
  109. <div class="row justify-content-center">
  110. <div class="col-12 col-lg-10 table-responsive">
  111. <table class="table table-sm table-striped table-white">
  112. <thead class="thead-dark">
  113. <tr >
  114. <th>Corregido</th>
  115. <th>Nombre</th>
  116. <th>CURP</th>
  117. <th>Contacto</th>
  118. <th>
  119. <div class="custom-control custom-checkbox">
  120. <input type="checkbox" class="custom-control-input selectAll" id="selectAll0">
  121. <label class="custom-control-label" for="selectAll0">Modificar</label>
  122. </div>
  123. </th>
  124. </tr>
  125. </thead>
  126. <tbody>
  127. <?php
  128. foreach($datos_rs as $dato){
  129. ?>
  130. <tr data-id="<?php echo $dato["Usuario_id"]; ?>" id="id<?php echo $dato["Usuario_id"]; ?>" class="data-row">
  131. <td style="vertical-align:middle" class="text-center">
  132. <?php if ($dato["CheckUsuario_cambio"]){ echo "<span class='text-success'>".$ICO["aceptar"]."</span>"; }
  133. else{ echo "<span class='text-info'>".$ICO["menos"]."</span>"; }
  134. ?>
  135. <br><small><?php echo date("d/m/Y h:i",strtotime($dato["CheckUsuario_fecha_revision"]));?></small>
  136. </td>
  137. <td style="vertical-align:middle">
  138. <?php echo $dato["Usuario_grado_new"]." ".$dato["Usuario_apellidos_new"]." ".$dato["Usuario_nombre_new"]; ?> <span class="badge badge-secondary">Nuevo</span><br>
  139. <span class="text-info"><?php echo $dato["Usuario_grado_new"]." ".$dato["Usuario_apellidos_old"]." ".$dato["Usuario_nombre_old"]; ?></span> <span class="badge badge-info">Actual</span>
  140. </td>
  141. <td style="vertical-align:middle" class="text-center">
  142. <?php echo $dato["Usuario_curp_new"]; ?> <span class="badge badge-secondary">Nuevo</span><br>
  143. <span class="text-info"><?php echo $dato["Usuario_curp_old"]; ?></span> <span class="badge badge-info">Actual</span>
  144. </td>
  145. <td style="vertical-align:middle; font-size:80%" ><?php
  146. $stmt = $pdo->prepare('Select * from fs_checkusuario_contacto(:usr)');
  147. $stmt->bindParam(":usr", $dato["Usuario_id"]);
  148. if(!$stmt->execute()){
  149. $errorDesc = "Ocurrió un error al cargar los datos";
  150. }else{
  151. //$datosContacto_rs = $stmt->fetchAll();
  152. foreach($stmt->fetchAll() as $contacto){
  153. echo "<b>".$contacto["TipoContacto_desc"]." ".$contacto["SubtipoContacto_desc"]."</b>: ".$contacto["CheckContacto_valor"]."<br>";
  154. }
  155. }
  156. $stmt->closeCursor();
  157. ?>
  158. </td>
  159. <td style="vertical-align:middle" class="text-center icono-acciones">
  160. <div class="form-check form-check-inline">
  161. <input class="form-check-input radio-lg radio-accept" type="radio" id="check1_<?php echo $dato["Usuario_id"]; ?>" name="checkgroup_<?php echo $dato["Usuario_id"]; ?>" value="2">
  162. <label for="check1_<?php echo $dato["Usuario_id"]; ?>" class="col-form-label text-success"><?php echo $ICO["aceptar"];?></label>
  163. </div>
  164. <div class="form-check form-check-inline">
  165. <input class="form-check-input radio-lg" type="radio" id="check2_<?php echo $dato["Usuario_id"]; ?>" name="checkgroup_<?php echo $dato["Usuario_id"]; ?>" value="3">
  166. <label for="check2_<?php echo $dato["Usuario_id"]; ?>" class="col-form-label text-danger"><?php echo $ICO["cancelar"];?></label>
  167. </div>
  168. <span class="text-info clear pointer"><?php echo $ICO["borrar"];?></span> </span>
  169. </td>
  170. </tr>
  171. <?php } ?>
  172. </tbody>
  173. </table>
  174. </div>
  175. </div>
  176. <div class="row">
  177. <div class="col-12 text-center">
  178. <button type="button" class="btn btn-primary" id="btn-guardar"><?php echo $ICO["aceptar"];?> Actualizar</button>
  179. </div>
  180. </div>
  181. <form id="formHidden" method="post" action="./action/datos_autoriza.php">
  182. <input type="hidden" name="data" id="users_data" value="">
  183. </form>
  184. <?php } else { ?>
  185. <h4 class="text-center">No hay datos para actualizar</h4>
  186. <?php } ?>
  187. </main>
  188. <!--- FOOTER--->
  189. <?php require_once("./include/footer.php"); ?>
  190. </div>
  191. <script src="./js/jquery.min.js"></script>
  192. <script src="./js/bootstrap/popper.min.js"></script>
  193. <script src="./js/bootstrap/bootstrap.min.js"></script>
  194. <script src="./js/sidebarmenu.js"></script>
  195. <script>
  196. function changeAllChecks(activo){
  197. $(".selectAll").prop("checked", activo);//deselecciona general
  198. $(".select_materia").prop("checked", activo);//deselecciona cada uno
  199. $("#btn_lote").prop("disabled", !activo);//bloquea boton
  200. }
  201. $('body').on('change', '.selectAll', function() {
  202. var check = $(this).prop("checked");
  203. $(this).parents(".table").find(".radio-accept").prop("checked", check);
  204. });
  205. $(document).ready(function(){
  206. $(".btn-menus").click(function(){
  207. var sist = $(this).parents("tr").data("id");
  208. $("#sist").val(sist);
  209. //$("#formHidden").attr("action", "menus.php").submit();
  210. $("#formHidden").submit();
  211. });
  212. $(".clear").click(function(){
  213. var sist = $(this).parent().find(":radio").prop("checked", false);
  214. });
  215. $("#btn-guardar").click(function(){
  216. var objClase = [];
  217. $.each($('.data-row input[type="radio"]:checked'), function(){
  218. objClase.push({id:$(this).parents('.data-row').data('id'), value: parseInt($(this).val())});
  219. });
  220. //console.log(JSON.stringify(objClase));
  221. $("#users_data").val(JSON.stringify(objClase));
  222. $("#formHidden").submit();
  223. });
  224. });
  225. </script>
  226. </body>
  227. </html>