diff --git a/app/controllers/bitacoras.php b/app/controllers/bitacoras.php index 421fe62..548c79d 100644 --- a/app/controllers/bitacoras.php +++ b/app/controllers/bitacoras.php @@ -4,20 +4,36 @@ require_once __DIR__ . '/../helpers/crypto.php'; session_start(); -function login() +function index() { - if (!isset($_SESSION['usuario_id'])) { - die("⚠️ No autorizado."); + include __DIR__ . '/../../views/bitacoras/dashboard_bitacoras.php'; +} + +function lista() +{ + if (!($_SESSION['usuario_id'] ?? false)) { + header('Location: /IMPORTADORES/login'); + exit; } $conn = getConnection(); - $sql = "SELECT id, id_usuario, email, ip, fecha, exito, detalle FROM bitacora_login ORDER BY fecha DESC"; - $stmt = sqlsrv_query($conn, $sql); + $sql = " + SELECT u.id_usuario, u.nombre, b.id, b.email, b.ip, b.fecha, b.exito, b.detalle + FROM dbo.bitacora_login b + JOIN dbo.usuarios_sistema u ON u.id_usuario = b.id_usuario + ORDER BY b.id DESC + "; - $logins = []; + $stmt = sqlsrv_query($conn, $sql); + if ($stmt === false) { + die("Error en lista(): " . print_r(sqlsrv_errors(), true)); + } + + $bitacoras = []; while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) { - $logins[] = $row; + $row['nombre'] = decrypt($row['nombre']); // Desencripta aquí + $bitacoras[] = $row; } include __DIR__ . '/../../views/bitacoras/bitacora_login.php'; @@ -40,4 +56,4 @@ function usuarios() } include __DIR__ . '/../../views/bitacoras/bitacora_usuarios.php'; -} +} \ No newline at end of file diff --git a/app/controllers/configuracion.php b/app/controllers/configuracion.php index f7fc6f1..fd494e2 100644 --- a/app/controllers/configuracion.php +++ b/app/controllers/configuracion.php @@ -107,9 +107,4 @@ function preferencias() function seguridad() { include __DIR__ . '/../../views/configuracion/seguridad.php'; -} - -function bitacoras() -{ - include __DIR__ . '/../../views/configuracion/bitacoras.php'; } \ No newline at end of file diff --git a/views/bitacoras/bitacora_login.php b/views/bitacoras/bitacora_login.php new file mode 100644 index 0000000..b04d72e --- /dev/null +++ b/views/bitacoras/bitacora_login.php @@ -0,0 +1,136 @@ + + + + + + Dashboard | Configuración + + + + + + + + + + + +
+

👥 Acceso de Usuarios

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
IDNombreCorreoIPFechaEstatusDetalles
format('Y-m-d H:i:s') ?> + +
+
+
+
+ + + + + \ No newline at end of file diff --git a/views/configuracion/bitacoras.php b/views/bitacoras/dashboard_bitacoras.php similarity index 80% rename from views/configuracion/bitacoras.php rename to views/bitacoras/dashboard_bitacoras.php index b3a9659..e28238c 100644 --- a/views/configuracion/bitacoras.php +++ b/views/bitacoras/dashboard_bitacoras.php @@ -78,9 +78,23 @@ include __DIR__ . '/../partials/sidebar_configuracion.php'; -
+

📖 Bitácoras

+
+
+
+
Registro de Accesos
+

Ver actividad de los usuarios.

+ + Ver Accesos + +
+
+
+ +
\ No newline at end of file diff --git a/views/choferes/lista.php b/views/choferes/lista.php index 2cdd1d8..c3a3cd6 100644 --- a/views/choferes/lista.php +++ b/views/choferes/lista.php @@ -13,7 +13,6 @@ -