datos_usuarios.php 12 KB

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