index.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. error_reporting(E_ALL & ~E_NOTICE);
  3. ini_set("display_errors", 1);
  4. ?>
  5. <!DOCTYPE html>
  6. <head>
  7. <title>Registros checador | Facultad de derecho</title>
  8. <meta charset="utf-8">
  9. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  10. <link rel="stylesheet" href="../css/bootstrap-ulsa.min.css" type="text/css">
  11. <link rel="stylesheet" href="../css/indivisa.css" type="text/css">
  12. <link rel="stylesheet" href="../css/fa_all.css" type="text/css">
  13. <link rel="stylesheet" href="../css/style.css" type="text/css">
  14. </head>
  15. <body style="display: block;">
  16. <?php
  17. include("../include/header.php");
  18. ?>
  19. <main class="container content-margin">
  20. <!--
  21. <div class="row justify-content-md-center" id="login" >
  22. <div class="col-12 col-md-6 box">
  23. <div class="modal-header">
  24. <h4 class="col-12 modal-title text-center">Últimos registros</h4>
  25. </div>
  26. <div class="">
  27. <form method="post" action="#" id="formLogin" onsubmit="return false">
  28. <div class="row">
  29. <div class="col">
  30. <p class="text-center font-weight-bold text-primary">Utiliza tu usuario y contraseña de dominio</p>
  31. </div>
  32. </div>
  33. <div class="form-group row">
  34. <div class="input-group px-4">
  35. <div class="input-group-prepend secondary">
  36. <div class="input-group-text bg-primary text-white"><i class="fas fa-user fa-fw"></i></div>
  37. </div>
  38. <input class="form-control form-control-lg" type="text" autocomplete="username" placeholder="Usuario (ad ó do)" id="username" name="username" value="" autofocus="true" maxlength="10">
  39. </div>
  40. </div>
  41. <div class="form-group row">
  42. <div class="input-group mb-2 px-4">
  43. <div class="input-group-prepend text-secondary">
  44. <div class="input-group-text bg-primary text-white"><i class="fas fa-unlock-alt fa-fw"></i></div>
  45. </div>
  46. <input class="form-control form-control-lg" type="password" autocomplete="current-password" placeholder="Contraseña" id="passwd" name="passwd" value="" maxlength="50">
  47. </div>
  48. </div>
  49. <div class="row d-none" id="errorLogin">
  50. <div class="col-12">
  51. <p class="text-danger text-center font-weight-bold"></p>
  52. </div>
  53. </div>
  54. <div class="row justify-content-md-center">
  55. <div class="col-6">
  56. <button type="submit" class="btn btn-lg btn-block btn-secondary" id="btn-login"><span class="fas fa-check fa-fw"></span> Ingresar</button>
  57. </div>
  58. </div>
  59. </form>
  60. </div>
  61. </div>
  62. </div>-->
  63. <!-- ./login -->
  64. <h2 class="my-4">Últimos registros</h2>
  65. <div class="row justify-content-md-center" id="tabla-accesos">
  66. <!--<div class="col-12">
  67. <p class="text-right"><a href="" class="btn btn-info"><span class="fas fa-power-off"></span> Salir</a></p>
  68. </div>-->
  69. <div class="col-12 col-md-9 table-responsive table-striped">
  70. <table class="table table-sm table-hover mt-2">
  71. <thead class="thead-dark">
  72. <tr>
  73. <th>Fecha</th>
  74. <th>Clave</th>
  75. <th>Profesor</th>
  76. <th>Estatus</th>
  77. </tr>
  78. </thead>
  79. <tbody>
  80. <tbody id="table-result">
  81. <tr class="log-row">
  82. <td class="log-fecha text-monospace"></td>
  83. <td class="log-clave text-monospace text-right"></td>
  84. <td class="log-prof text-uppercase"></td>
  85. <td class="log-status"></td>
  86. </tr>
  87. </tbody>
  88. </tbody>
  89. </table>
  90. </div>
  91. </div>
  92. </main><!-- ./container -->
  93. <?php
  94. include("../include/footer.php");
  95. ?>
  96. <script src="../js/jquery.min.js"></script>
  97. <script src="../js/bootstrap/popper.min.js"></script>
  98. <script src="../js/bootstrap/bootstrap.min.js"></script>
  99. <script>
  100. var _reloadTime = 15; //en segundos
  101. $(document).ready(function() {
  102. actualilzaLog();
  103. timer(_reloadTime);
  104. });
  105. function timer(tiempo = 0) {
  106. if (tiempo > 0) {
  107. setTimeout(actualilzaLog, tiempo * 1000);
  108. }
  109. }
  110. function actualilzaLog() {
  111. $.ajax({
  112. url: 'read_logfile.php',
  113. type: 'POST',
  114. dataType: 'json',
  115. //data: { id: _grupo_id, check: strCheck},
  116. success: function(result) {
  117. if (result["result"] == false) {
  118. alert("Error al guardar el horario.\n" + result["error"]);
  119. } else {
  120. var rows = $("#table-result > tr").length; //limpia tabla actual
  121. if (rows > result["log"].length) { //sobran
  122. //borrar renglones extra (rows - result.length) pero dejar al menos 1
  123. while (rows > result["log"].length && rows > 1) {
  124. $(".log-row:last-child").remove();
  125. rows--;
  126. }
  127. } else { //faltan, clonar
  128. for (var i = rows; i < result["log"].length; i++) {
  129. $(".log-row:first-child").clone(true).appendTo("#table-result");
  130. }
  131. }
  132. if (result["log"].length != 0) { //hay elementos?
  133. $("#table-result").children().each(function(index) {
  134. if (index < result["log"].length) { //llenar info
  135. $(this).find(".log-fecha").html(result["log"][index]["fecha"]);
  136. $(this).find(".log-clave").html(result["log"][index]["clave"]);
  137. $(this).find(".log-prof").html(result["log"][index]["prof"]);
  138. $(this).find(".log-status").html(result["log"][index]["status"]);
  139. $(this).find(".log-status").removeClass("text-success");
  140. $(this).find(".log-status").removeClass("text-primary");
  141. $(this).find(".log-status").removeClass("text-danger");
  142. if (result["log"][index]["status"] == "Registrada") {
  143. $(this).find(".log-status").addClass("text-success");
  144. } else if (result["log"][index]["status"].indexOf("Duplicada") !== -1) {
  145. $(this).find(".log-status").addClass("text-primary");
  146. } else {
  147. $(this).find(".log-status").addClass("text-danger");
  148. }
  149. }
  150. });
  151. }
  152. } //sin error
  153. },
  154. error: function(jqXHR, textStatus, errorThrown) {
  155. $("#errorBox_text").html(errorThrown);
  156. }
  157. }); //ajax
  158. timer(_reloadTime);
  159. }
  160. </script>
  161. </body>
  162. </html>