logs.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. </tr>
  43. </thead>
  44. <tbody>
  45. <?
  46. global $db;
  47. $registros = $db
  48. ->where('momento::DATE = CURRENT_DATE')
  49. ->orderBy('momento', 'desc')
  50. ->get('log_registro');
  51. foreach ($registros as $log) {
  52. ?>
  53. <tr class="<?= $log['success'] ? '' : 'table-danger' ?>" data-id="<?= $log['log_id'] ?>">
  54. <td class="text-center align-middle px-2">
  55. <?= substr($log['momento'], 0, 10) ?>
  56. </td>
  57. <td class="text-center align-middle px-2">
  58. <?= substr($log['momento'], 11, 8) ?>
  59. </td>
  60. <td class="text-center align-middle px-2">
  61. <?= $log['clave'] ?>
  62. </td>
  63. <td class="text-center align-middle px-2">
  64. <?= $log['profesor'] ?>
  65. </td>
  66. <td class="text-center align-middle px-2">
  67. <?
  68. if ($log['horarios'] == null) {
  69. echo "N/A";
  70. } else {
  71. ?>
  72. <button type="button" class="btn btn-info" data-toggle="modal" data-target="#horarioModal"
  73. data-horario='<?= json_encode($log['horarios'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>'>
  74. Horario
  75. </button>
  76. <?
  77. }
  78. ?>
  79. </td>
  80. <td class="text-center align-middle px-2">
  81. <?= $log['ip'] ?>
  82. </td>
  83. <td class="text-center align-middle px-2">
  84. <?= $log['navegador'] ?>
  85. </td>
  86. <td class="text-center align-middle px-2">
  87. <?= $log['informacion'] ?>
  88. </td>
  89. <td class="text-center align-middle px-2">
  90. <?= $log['detalle'] ?>
  91. </td>
  92. </tr>
  93. <?
  94. }
  95. ?>
  96. </tbody>
  97. </table>
  98. </div>
  99. </main>
  100. <!-- Horario Modal -->
  101. <div class="modal fade" id="horarioModal" tabindex="-1" role="dialog" aria-labelledby="horarioModalLabel"
  102. aria-hidden="true">
  103. <div class="modal-dialog modal-lg">
  104. <div class="modal-content">
  105. <div class="modal-header">
  106. <h5 class="modal-title" id="horarioModalLabel">Horario</h5>
  107. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  108. <span aria-hidden="true">&times;</span>
  109. </button>
  110. </div>
  111. <div class="modal-body">
  112. <pre id="jsonOutput"></pre>
  113. </div>
  114. <div class="modal-footer">
  115. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. <?
  121. include "import/html_footer.php";
  122. ?>
  123. </body>
  124. <script src="js/jquery.min.js"></script>
  125. <script src="js/bootstrap/bootstrap.min.js"></script>
  126. <script src="https://unpkg.com/petite-vue"></script>
  127. <script>
  128. $(document).ready(function () {
  129. $('#horarioModal').on('show.bs.modal', function (event) {
  130. const button = $(event.relatedTarget);
  131. const horario = button.data('horario');
  132. const modal = $(this);
  133. // Ensure horario is an object
  134. let parsedHorario;
  135. if (typeof horario === 'string') {
  136. parsedHorario = JSON.parse(JSON.parse(horario, (key, value) => {
  137. if (typeof value === 'string') {
  138. return value.replace(/\\n/g, '\n');
  139. }
  140. return value;
  141. }));
  142. } else {
  143. parsedHorario = horario;
  144. }
  145. const formattedHorario = formatJson(parsedHorario);
  146. modal.find('#jsonOutput').html(formattedHorario);
  147. });
  148. });
  149. function formatJson(jsonObject) {
  150. let formatted = '';
  151. if (Array.isArray(jsonObject)) {
  152. formatted += '<ol>';
  153. for (let i = 0; i < jsonObject.length; i++) {
  154. formatted += '<li>';
  155. formatted += formatJson(jsonObject[i]);
  156. formatted += '</li>';
  157. }
  158. formatted += '</ol>';
  159. } else if (typeof jsonObject === 'object') {
  160. formatted += '<ol>';
  161. for (let key in jsonObject) {
  162. formatted += '<li><strong>' + key + ':</strong> ';
  163. formatted += formatJson(jsonObject[key]);
  164. formatted += '</li>';
  165. }
  166. formatted += '</ol>';
  167. } else {
  168. formatted += jsonObject;
  169. }
  170. return formatted;
  171. }
  172. </script>
  173. </html>