logs.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Consultar horario |
  5. <?= $user->facultad['facultad'] ?? 'General' ?>
  6. </title>
  7. <meta charset="utf-8">
  8. <meta http-equiv="content-type" content="text/plain; charset=UTF-8" />
  9. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  10. <?php include_once "import/html_css_files.php"; ?>
  11. </head>
  12. <style>
  13. #jsonOutput {
  14. background-color: #f4f4f4;
  15. padding: 10px;
  16. border-radius: 4px;
  17. overflow-x: auto;
  18. }
  19. </style>
  20. <!-- -->
  21. <body style="display: block;">
  22. <?php
  23. include('include/constantes.php');
  24. include("import/html_header.php");
  25. html_header("Logs");
  26. ?>
  27. <?= "<!-- $user -->" ?>
  28. <main class="container content content-margin" id="local-app">
  29. <div class="table-responsive">
  30. <table class="table table-hover table-striped table-bordered table-sm">
  31. <thead class="thead-dark">
  32. <tr>
  33. <th scope="col" class="text-center align-middle px-2">Fecha</th>
  34. <th scope="col" class="text-center align-middle px-2" width="10%">Hora</th>
  35. <th scope="col" class="text-center align-middle px-2">Clave</th>
  36. <th scope="col" class="text-center align-middle px-2">Profesor</th>
  37. <th scope="col" class="text-center align-middle px-2" width="7%">Horario</th>
  38. <th scope="col" class="text-center align-middle px-2">IP</th>
  39. <th scope="col" class="text-center align-middle px-2">Navegador</th>
  40. <th scope="col" class="text-center align-middle px-2">Información</th>
  41. <th scope="col" class="text-center align-middle px-2">Detalle</th>
  42. <th scope="col" class="text-center align-middle px-2">Horario web</th>
  43. </tr>
  44. </thead>
  45. <tbody>
  46. <?
  47. global $db;
  48. $registros = $db
  49. ->where('momento::DATE = ' . (isset($_GET['fecha']) ? "'{$_GET['fecha']}'" : 'CURRENT_DATE'))
  50. ->orderBy('momento', 'desc')
  51. ->get('log_registro');
  52. foreach ($registros as $log) {
  53. ?>
  54. <tr class="<?= $log['success'] ? '' : 'table-danger' ?>" data-id="<?= $log['log_id'] ?>">
  55. <td class="text-center align-middle px-2">
  56. <?= substr($log['momento'], 0, 10) ?>
  57. </td>
  58. <td class="text-center align-middle px-2">
  59. <?= substr($log['momento'], 11, 8) ?>
  60. </td>
  61. <td class="text-center align-middle px-2">
  62. <?= $log['clave'] ?>
  63. </td>
  64. <td class="text-center align-middle px-2">
  65. <?= $log['profesor'] ?>
  66. </td>
  67. <td class="text-center align-middle px-2">
  68. <?
  69. if ($log['horarios'] == null) {
  70. echo "N/A";
  71. } else {
  72. ?>
  73. <button type="button" class="btn btn-info" data-toggle="modal" data-target="#horarioModal"
  74. data-horario='<?= json_encode($log['horarios'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>'>
  75. Horario
  76. </button>
  77. <?
  78. }
  79. ?>
  80. </td>
  81. <td class="text-center align-middle px-2">
  82. <?= $log['ip'] ?>
  83. </td>
  84. <td class="text-center align-middle px-2">
  85. <?= $log['navegador'] ?>
  86. </td>
  87. <td class="text-center align-middle px-2">
  88. <?= $log['informacion'] ?>
  89. </td>
  90. <td class="text-center align-middle px-2">
  91. <?= $log['detalle'] ?>
  92. </td>
  93. <td class="text-center align-middle px-2">
  94. <?
  95. if ($log['horario_web'] == null) {
  96. echo "N/A";
  97. } else {
  98. ?>
  99. <button type="button" class="btn btn-info" data-toggle="modal" data-target="#horarioModal"
  100. data-horario='<?= json_encode($log['horario_web'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>'>
  101. Horario
  102. </button>
  103. <?
  104. }
  105. ?>
  106. </td>
  107. </tr>
  108. <?
  109. }
  110. ?>
  111. </tbody>
  112. </table>
  113. </div>
  114. </main>
  115. <!-- Horario Modal -->
  116. <div class="modal fade" id="horarioModal" tabindex="-1" role="dialog" aria-labelledby="horarioModalLabel"
  117. aria-hidden="true">
  118. <div class="modal-dialog modal-lg">
  119. <div class="modal-content">
  120. <div class="modal-header">
  121. <h5 class="modal-title" id="horarioModalLabel">Horario</h5>
  122. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  123. <span aria-hidden="true">&times;</span>
  124. </button>
  125. </div>
  126. <div class="modal-body">
  127. <pre id="jsonOutput"></pre>
  128. </div>
  129. <div class="modal-footer">
  130. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. <?
  136. include "import/html_footer.php";
  137. ?>
  138. </body>
  139. <script src="js/jquery.min.js"></script>
  140. <script src="js/bootstrap/bootstrap.min.js"></script>
  141. <script src="https://unpkg.com/petite-vue"></script>
  142. <script>
  143. $(document).ready(function () {
  144. $('#horarioModal').on('show.bs.modal', function (event) {
  145. const button = $(event.relatedTarget);
  146. const horario = button.data('horario');
  147. const modal = $(this);
  148. // Ensure horario is an object
  149. let parsedHorario;
  150. if (typeof horario === 'string') {
  151. parsedHorario = JSON.parse(JSON.parse(horario, (key, value) => {
  152. if (typeof value === 'string') {
  153. return value.replace(/\\n/g, '\n');
  154. }
  155. return value;
  156. }));
  157. } else {
  158. parsedHorario = horario;
  159. }
  160. const formattedHorario = formatJson(parsedHorario);
  161. modal.find('#jsonOutput').html(formattedHorario);
  162. });
  163. });
  164. function formatJson(jsonObject) {
  165. let formatted = '';
  166. if (Array.isArray(jsonObject)) {
  167. formatted += '<ol>';
  168. for (let i = 0; i < jsonObject.length; i++) {
  169. formatted += '<li>';
  170. formatted += formatJson(jsonObject[i]);
  171. formatted += '</li>';
  172. }
  173. formatted += '</ol>';
  174. } else if (typeof jsonObject === 'object') {
  175. formatted += '<ol>';
  176. for (let key in jsonObject) {
  177. formatted += '<li><strong>' + key + ':</strong> ';
  178. formatted += formatJson(jsonObject[key]);
  179. formatted += '</li>';
  180. }
  181. formatted += '</ol>';
  182. } else {
  183. formatted += jsonObject;
  184. }
  185. return formatted;
  186. }
  187. </script>
  188. </html>