participantes.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <?php
  2. require_once("../include/constantes.php");
  3. require_once("../include/bd_pdo.php");
  4. session_start();
  5. if(!isset($_SESSION["n_usuario_id"])){
  6. session_destroy();
  7. $pag = "salir.php?expired=1";
  8. header("Location: ".$pag);
  9. exit();
  10. }
  11. $session_life = 1*60*60;//convertido a segundos
  12. if (isset($_SESSION["n_timeout"])) {
  13. // calculate the session's "time to live"
  14. $sessionTTL = time() - $_SESSION["n_timeout"];
  15. if ($sessionTTL > $session_life) {
  16. $_SESSION = array();
  17. session_destroy();
  18. $pag = $_SERVER['SERVER_NAME']."/navidad/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']."/navidad/salir.php?expired=1";
  26. header("Location: http://".$pag);
  27. exit();
  28. }
  29. $_SESSION["n_timeout"] = time();
  30. if(!isset($_SESSION["n_sgi_administrador"]) || !$_SESSION["n_sgi_administrador"]){
  31. header("Location: main.php?error=0");
  32. exit();
  33. }
  34. //obtiene navidad
  35. $stmt = $pdo->prepare('Select * from fs_navidad()');
  36. if(!$stmt->execute()){
  37. header("Location: ../index.php?error=5");
  38. exit();
  39. }
  40. $navidad_rs = $stmt->fetch();//$navidad_rs["Navidad_activa"] || $navidad_rs["Navidad_id"]
  41. $stmt->closeCursor();
  42. $stmt = $pdo->prepare('Select * from fs_navidadusuario(:nav, NULL, NULL)');
  43. $stmt->bindParam(":nav", $navidad_rs["Navidad_id"]);
  44. if(!$stmt->execute()){
  45. //print_r($stmt->errorInfo());
  46. $errorDesc = "Ocurrió un errror al leer los datos de usuario";
  47. }else{
  48. $usr_rs = $stmt->fetchAll();
  49. if(count($usr_rs) > 0){
  50. $stmt = $pdo->prepare('Select * from fs_navidadtarjeta(:nav, NULL)');
  51. $stmt->bindParam(":nav", $navidad_rs["Navidad_id"]);
  52. if(!$stmt->execute()){
  53. print_r($stmt->errorInfo());
  54. $errorDesc = "Ocurrió un errror al leer los datos de usuario";
  55. }else{
  56. $tarjeta_rs = $stmt->fetchAll();
  57. }
  58. }
  59. }
  60. $stmt->closeCursor();
  61. //--Manejo de errores y mensajes de exito
  62. if(isset($_GET["error"]) && is_numeric($_GET["error"])){
  63. switch ($_GET["error"]){
  64. case 0: $errorDesc = "Ocurrió un error al asignar las parejas."; break;
  65. case 1: $errorDesc = "Ocurrió un error al cambiar el estado de los usuarios."; break;
  66. case 2: $errorDesc = "Ocurrió un error al insertr el usuario externo."; break;
  67. case 3: $errorDesc = "No se recibieron los datos completos."; break;
  68. }
  69. }
  70. if(isset($_GET["ok"]) && is_numeric($_GET["ok"])){
  71. switch ($_GET["ok"]){
  72. case 0: $successDesc = "Las parejas se asignaron correctamente."; break;
  73. case 1: $successDesc = "Se actualizó correctamente el estado de los usuarios."; break;
  74. case 2: $successDesc = "El usuario externo se insertó correctamente."; break;
  75. }
  76. }
  77. ?>
  78. <!DOCTYPE html>
  79. <html lang="es" prefix="og: http://ogp.me/ns#">
  80. <head>
  81. <title>.: Navidad 2020 :.</title>
  82. <meta charset="utf-8">
  83. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  84. <link rel="icon" type="image/png" href="../img/favicon.png" />
  85. <link rel="stylesheet" href="../css/bootstrap-ulsa.min.css" type="text/css">
  86. <link rel="stylesheet" href="../css/indivisa.css" type="text/css">
  87. <link rel="stylesheet" href="../css/sgi.css?rand=<?php echo rand();?>" type="text/css">
  88. <link rel="stylesheet" href="../css/fa_all.css" type="text/css">
  89. <link rel="stylesheet" href="../css/toggle.css" type="text/css">
  90. <link rel="stylesheet" href="./css/navidad.css?rand=<?php echo rand();?>" type="text/css">
  91. </head>
  92. <body style="display: block;">
  93. <header class="sticky-top bg-white bg-head">
  94. <div class="menu d-flex align-items-center" style="visibility: visible;">
  95. <div class="logotipo"><a href="https://lasalle.mx/" target="_blank"><img id="logo" src="../img/logo_lasalle.png" border="0" class="img-fluid" ></a></div>
  96. <div class="flex-grow-1 d-flex justify-content-end">
  97. <div class="d-flex mainMenu justify-content-center align-items-center">
  98. <div class="max-h iconSesion">
  99. <a href="salir.php" class="iconOff max-h pl-3 d-flex justify-content-start align-items-center"><i class="ing-salir"></i></a>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </header>
  105. <div class="row bg-info mx-0 barra-gris">
  106. <div class="marco">
  107. <div class="col-12 py-3">
  108. <h4 class="text-info"><?php echo $_SESSION["n_usuario_apellidos"]." ".$_SESSION["n_usuario_nombre"];?></h4>
  109. <h1 class="text-uppercase text-center cursiva mb-0">Participantes</h1>
  110. </div>
  111. </div>
  112. </div>
  113. <div class="fondo-interno">
  114. <main class="container-fluid content marco mb-4">
  115. <?php include_once("../include/errorMessage.php");?>
  116. <h4 class="mb-5">
  117. <span style="font-weight: bold;text-shadow: -2px 2px 0 #fff, 2px 2px 0 #fff, 2px -2px 0 #fff, -2px -2px 0 #fff;">Navidad <?php echo $navidad_rs["Navidad_id"];?></span>
  118. <input type="checkbox" data-toggle="toggle" data-onstyle="success" data-offstyle="info" data-on="Activa" data-off="Inactiva" id="navidad_activa" value="1" <?php if($navidad_rs["Navidad_activa"]){echo 'checked="checked"';}?>>
  119. </h4>
  120. <ul class="nav nav-tabs d-print-none my-4" id="myTab" role="tablist">
  121. <li class="nav-item">
  122. <a class="nav-link active" id="tabActivo-tab" data-toggle="tab" href="#tabActivo" role="tab" aria-selected="true">Participantes activos</a>
  123. </li>
  124. <li class="nav-item">
  125. <a class="nav-link" id="tabAsignado-tab" data-toggle="tab" href="#tabAsignado" role="tab" aria-selected="false">Asignación</a>
  126. </li>
  127. </ul>
  128. <div class="tab-content" id="cardexTabContent">
  129. <div class="tab-pane fade show active" id="tabActivo" role="tabpanel" aria-labelledby="tabActivo-tab">
  130. <p class="text-right"><a href="#" class="btn btn-outline-primary" data-toggle="modal" data-target="#modal"><?php echo $ICO["mas"];?> Usuario externo</a></p>
  131. <h4 class="mb-4">Hay <?php echo count($usr_rs);?> participantes.</h4>
  132. <?php if(isset($usr_rs)){?>
  133. <form action="./action/participantes_estado.php" method="post">
  134. <div class="row">
  135. <div class="col-12 table-responsive">
  136. <table class="table table-sm table-striped table-white">
  137. <thead class="thead-dark">
  138. <tr >
  139. <th style="width:20px"></th>
  140. <th>Apellidos</th>
  141. <th>Nombre</th>
  142. <th style="width:60px">Intercambio</th>
  143. </tr>
  144. </thead>
  145. <tbody>
  146. <?php
  147. $i = 1;
  148. foreach($usr_rs as $usuario){
  149. ?>
  150. <tr>
  151. <td class="text-center font-weight-bold"><?php echo $i++;?></td>
  152. <td><?php echo $usuario["Usuario_apellidos"]; ?></td>
  153. <td><?php echo $usuario["Usuario_nombre"]; ?></td>
  154. <td class="pl-2 text-center">
  155. <div class="custom-control custom-checkbox">
  156. <input type="checkbox" class="custom-control-input select_alumno" id="al<?php echo $usuario["NavidadUsuario_id"]; ?>" name="activos[]" value="<?php echo $usuario["NavidadUsuario_id"];?>" <?php if($usuario["NavidadUsuario_activo"]){ echo 'checked="checked"'; }?>>
  157. <label class="custom-control-label" for="al<?php echo $usuario["NavidadUsuario_id"]; ?>"></label>
  158. </div>
  159. </td>
  160. </tr>
  161. <?php } ?>
  162. </tbody>
  163. </table>
  164. </div>
  165. </div>
  166. <p class="text-right"><button type="submit" class="btn btn-sm btn-primary mt-1"><?php echo $ICO["aceptar"];?> Actualizar</button></p>
  167. </form>
  168. <?php } ?>
  169. </div>
  170. <!-- --------- -->
  171. <div class="tab-pane fade" id="tabAsignado" role="tabpanel" aria-labelledby="tabAsignado-tab">
  172. <h4 class="mb-4">A quién van a escribir los participantes.</h4>
  173. <?php if(isset($tarjeta_rs) && count($tarjeta_rs) > 0){?>
  174. <div class="row">
  175. <div class="col-12 table-responsive">
  176. <table class="table table-sm table-striped table-white">
  177. <thead class="thead-dark">
  178. <tr >
  179. <th style="width:20px"></th>
  180. <th colspan="2">De</th>
  181. <th colspan="2">Para</th>
  182. <th>Escribió</th>
  183. </tr>
  184. </thead>
  185. <tbody>
  186. <?php
  187. $i = 1;
  188. $escrito = 0;
  189. foreach($tarjeta_rs as $usuario){
  190. ?>
  191. <tr>
  192. <td class="text-center font-weight-bold"><?php echo $i++;?></td>
  193. <td><?php echo $usuario["Usuario_de_apellidos"]; ?></td>
  194. <td><?php echo $usuario["Usuario_de_nombre"]; ?></td>
  195. <td><?php echo $usuario["Usuario_para_apellidos"]; ?></td>
  196. <td><?php echo $usuario["Usuario_para_nombre"]; ?></td>
  197. <td class="text-center"><?php if($usuario["NavidadTarjeta_desc"]==""){ echo $ICO["menos"];}else{echo $ICO["aceptar"];$escrito++;} ?></td>
  198. </tr>
  199. <?php } ?>
  200. </tbody>
  201. </table>
  202. <p class="text-info text-right"><?php echo "Faltan de escribir: ".($i-1-$escrito);?></p>
  203. </div>
  204. </div>
  205. <?php } else{ ?>
  206. <h4 class="text-center text-danger">No hay parejas asignadas.</h4>
  207. <?php } ?>
  208. <p class="text-center">
  209. <a href="./action/participantes_asigna.php" class="btn btn-outline-primary"><span class="ing-cambiar ing-fw"></span> Asignar parejas</a>
  210. </p>
  211. </div>
  212. </div>
  213. <p class="text-center"><a href="main.php" class="btn btn-outline-danger mt-4"><?php echo $ICO["cancelar"];?> Regresar</a></p>
  214. </main>
  215. </div>
  216. <div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="modal" aria-hidden="true">
  217. <div class="modal-dialog modal-dialog-centered" role="document">
  218. <div class="modal-content">
  219. <div class="modal-body">
  220. <form action="./action/participantes_externo.php" method="post">
  221. <div class="form-box form-box-info">
  222. <div class="form-group row">
  223. <label for="apellidos" class="col-4 col-form-label">Apellidos *</label>
  224. <div class="col-8">
  225. <input id="apellidos" name="apellidos" type="text" class="form-control" required="required" maxlength="40">
  226. </div>
  227. </div>
  228. <div class="form-group row">
  229. <label for="nombre" class="col-4 col-form-label">Nombre *</label>
  230. <div class="col-8">
  231. <input id="nombre" name="nombre" type="text" class="form-control" required="required" maxlength="30">
  232. </div>
  233. </div>
  234. <div class="form-group row">
  235. <label for="usr" class="col-4 col-form-label">Usuario *</label>
  236. <div class="col-8">
  237. <input id="usr" name="usr" type="text" class="form-control" required="required" maxlength="15">
  238. </div>
  239. </div>
  240. <div class="form-group row">
  241. <label for="pass" class="col-4 col-form-label">Contraseña *</label>
  242. <div class="col-8">
  243. <input id="pass" name="pass" type="text" class="form-control" required="required" maxlength="25">
  244. </div>
  245. </div>
  246. </div>
  247. <div class="form-group row mt-3">
  248. <div class="offset-4 col-8">
  249. <button type="submit" class="btn btn-outline-primary" id="submitBtn"><?php echo $ICO["aceptar"];?> Guardar</button>
  250. <button type="button" class="btn btn-outline-danger" data-dismiss="modal" aria-label="Close"><?php echo $ICO["cancelar"];?> Cancelar</button>
  251. </div>
  252. </div>
  253. </form>
  254. </div>
  255. </div>
  256. </div>
  257. </div>
  258. <!--- FOOTER--->
  259. <?php require_once("../include/footer.php"); ?>
  260. <script src="../js/jquery.min.js"></script>
  261. <script src="../js/bootstrap/popper.min.js"></script>
  262. <script src="../js/bootstrap/bootstrap.min.js"></script>
  263. <script src="../js/toggle.js"></script>
  264. <script>
  265. $(document).ready(function(){
  266. $('#navidad_activa').change(function(){
  267. $.ajax({
  268. url: './action/navidad_update.php',
  269. type: 'POST',
  270. dataType: 'json',
  271. data: { edo: $('#navidad_activa').prop("checked")},
  272. success: function(result) {
  273. if(result["error"]!= "" && result["error"] !== undefined){
  274. $("#errorBox").collapse('show');
  275. $("#errorBox_text").html(result["error"]);
  276. $('#messageBox')[0].scrollIntoView({ block: "end" });
  277. $('#navidad_activa').prop("checked") = !$('#navidad_activa').prop("checked");
  278. }
  279. },
  280. error: function(jqXHR, textStatus, errorThrown ){
  281. $("#errorBox").collapse('show');
  282. $("#errorBox_text").html(errorThrown);
  283. $('#navidad_activa').prop("checked") = !$('#navidad_activa').prop("checked");
  284. }
  285. });//ajax
  286. });
  287. $('#modal').on('show.bs.modal', function (event) {
  288. $("#modal").find("input[type=text]").val("");
  289. });
  290. });
  291. </script>
  292. </body>
  293. </html>