Avances bitácoras

This commit is contained in:
2025-06-27 07:57:15 -06:00
parent 3da996350c
commit 5a9b77a624
7 changed files with 197 additions and 66 deletions

View File

@@ -33,6 +33,48 @@
</style>
</head>
<body>
<div class="content">
<h4 class="mb-4">🏪 Registro de Agencias</h4>
<div class="card p-3 shadow-sm">
<div class="table-responsive">
<table class="table table-striped" id="tabla-registros-agencias">
<thead>
<tr>
<th>ID</th>
<th>Nombre</th>
<th>Acción</th>
<th>Registrada por</th>
<th>Fecha</th>
</tr>
</thead>
<tbody>
<?php foreach ($registros as $r): ?>
<tr>
<td><?= htmlspecialchars($r['id_agencia'] ?? '') ?></td>
<td><?= htmlspecialchars(decrypt($r['nombre'] ?? '')) ?></td>
<td><?= htmlspecialchars($r['accion'] ?? '') ?></td>
<td><?= htmlspecialchars(decrypt($r['realizado_por'] ?? '')) ?></td>
<td><?= htmlspecialchars($r['fecha'] ? $r['fecha']->format('Y-m-d H:i:s') : '') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('#tabla-registros-agencias').DataTable({
order: [],
language: {
url: 'https://cdn.datatables.net/plug-ins/1.13.4/i18n/es-ES.json'
}
});
});
</script>
</body>
</html>

View File

@@ -52,17 +52,17 @@
</tr>
</thead>
<tbody>
<?php foreach ($bitacoras as $b): ?>
<?php foreach ($registros as $r): ?>
<tr>
<td><?= htmlspecialchars($b['id_usuario']) ?></td>
<td><?= htmlspecialchars($b['nombre']) ?></td>
<td><?= htmlspecialchars($b['email']) ?></td>
<td><?= htmlspecialchars($b['ip']) ?></td>
<td><?= $b['fecha']->format('Y-m-d H:i:s') ?></td>
<td><?= htmlspecialchars($r['id_usuario'] ?? '') ?></td>
<td><?= htmlspecialchars(decrypt($r['nombre'] ?? '')) ?></td>
<td><?= htmlspecialchars($r['email'] ?? '') ?></td>
<td><?= htmlspecialchars($r['ip'] ?? '') ?></td>
<td><?= $r['fecha']->format('Y-m-d H:i:s') ?></td>
<td>
<?= $b['exito'] == 1 ? 'Éxito' : 'Fallido' ?>
<?= $r['exito'] == 1 ? 'Éxito' : 'Fallido' ?>
</td>
<td><?= htmlspecialchars($b['detalle']) ?></td>
<td><?= htmlspecialchars($r['detalle']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
@@ -74,6 +74,7 @@
<script>
$(document).ready(function () {
$('#tabla-logins').DataTable({
order: [],
language: {
url: 'https://cdn.datatables.net/plug-ins/1.13.4/i18n/es-ES.json'
}

View File

@@ -8,6 +8,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
<style>
body { font-family: 'Segoe UI', sans-serif; background-color: #f4f6f9; }
.sidebar { width: 220px; height: 100vh; background-color: #343a40; position: fixed; top: 0; left: 0; padding-top: 56px; z-index: 1040; }
@@ -31,32 +34,47 @@
</head>
<body>
<div class="content px-4 pt-5 mt-4">
<h4>🛠️ Bitácora de Cambios de Usuario</h4>
<div class="content">
<h4 class="mb-4">🛠️ Cambios de Usuario</h4>
<table class="table table-hover mt-3 align-middle">
<thead class="table-dark">
<tr>
<th>#</th>
<th>ID Usuario</th>
<th>Acción</th>
<th>Descripción</th>
<th>Fecha</th>
</tr>
</thead>
<tbody>
<?php foreach ($registros as $r): ?>
<tr>
<td><?= $r['id_bitacora'] ?></td>
<td><?= $r['usuario_id'] ?></td>
<td><strong><?= htmlspecialchars($r['accion']) ?></strong></td>
<td><?= nl2br(htmlspecialchars($r['descripcion'])) ?></td>
<td><?= $r['fecha'] instanceof DateTime ? $r['fecha']->format('Y-m-d H:i') : htmlspecialchars($r['fecha']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="card p-3 shadow-sm">
<div class="table-responsive">
<table class="table table-striped align-middle" id="tabla-bitacora-usuarios">
<thead class="table-dark">
<tr>
<th>#</th>
<th>ID Usuario</th>
<th>Acción</th>
<th>Descripción</th>
<th>Fecha</th>
</tr>
</thead>
<tbody>
<?php foreach ($registros as $r): ?>
<tr>
<td><?= $r['id_bitacora'] ?></td>
<td><?= $r['usuario_id'] ?></td>
<td><strong><?= htmlspecialchars($r['accion']) ?></strong></td>
<td><?= nl2br(htmlspecialchars($r['descripcion'])) ?></td>
<td><?= $r['fecha'] instanceof DateTime ? $r['fecha']->format('Y-m-d H:i') : htmlspecialchars($r['fecha']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('#tabla-bitacora-usuarios').DataTable({
order: [],
language: {
url: 'https://cdn.datatables.net/plug-ins/1.13.4/i18n/es-ES.json'
}
});
});
</script>
</body>
</html>

View File

@@ -84,7 +84,7 @@ $cantidadBitacoras = contarBitacorasDisponibles($permisosBitacoras);
function obtenerTextoPermiso($permiso, $tipoUsuario) {
$textos = [
'registro_accesos' => ($tipoUsuario === 'super_admin') ? 'Registro de accesos' : null,
'registro_usuarios' => ($tipoUsuario === 'super_admin') ? 'Registro de usuarios' : null,
'registro_usuarios' => ($tipoUsuario === 'super_admin') ? 'Registro de cambios de usuarios' : null,
'registro_agencias' => ($tipoUsuario === 'super_admin') ? 'Registro de agencias' : null,
'acceso_usuarios_agencias' => ($tipoUsuario === 'admin_agencia' || $tipoUsuario === 'agente_aduanal') ? 'Registros de accesos' : null,
'registro_vinculaciones' => ($tipoUsuario === 'admin_agencia' || $tipoUsuario === 'agente_aduanal') ? 'Vinculaciones (Agencia)' : null,