Avances bitácoras
This commit is contained in:
@@ -500,7 +500,7 @@ function aprobar_agencia()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualizar agencia con el ID del administrador
|
// Actualizar agencia con el ID del administrador
|
||||||
$sqlUpdateAgencia = "UPDATE agencias_aduanales SET id_administrador = ? WHERE id_agencia = ?";
|
$sqlUpdateAgencia = "UPDATE agencias_aduanales SET id_administrador = ? WHERE id_agencia = ?";
|
||||||
$stmtUpdateAgencia = sqlsrv_query($conn, $sqlUpdateAgencia, [$id_usuario, $id_agencia]);
|
$stmtUpdateAgencia = sqlsrv_query($conn, $sqlUpdateAgencia, [$id_usuario, $id_agencia]);
|
||||||
|
|
||||||
if (!$stmtUpdateAgencia) {
|
if (!$stmtUpdateAgencia) {
|
||||||
@@ -520,9 +520,9 @@ function aprobar_agencia()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualizar solicitud
|
// Actualizar solicitud
|
||||||
$sqlUpdate = "UPDATE solicitudes_agencias
|
$sqlUpdate = "UPDATE solicitudes_agencias
|
||||||
SET request_status = 'approved', approval_date = GETDATE(), approved_by = ?
|
SET request_status = 'approved', approval_date = GETDATE(), approved_by = ?
|
||||||
WHERE request_id = ?";
|
WHERE request_id = ?";
|
||||||
$stmtUpdate = sqlsrv_query($conn, $sqlUpdate, [$usuario_id, $id]);
|
$stmtUpdate = sqlsrv_query($conn, $sqlUpdate, [$usuario_id, $id]);
|
||||||
|
|
||||||
if (!$stmtUpdate) {
|
if (!$stmtUpdate) {
|
||||||
@@ -570,6 +570,8 @@ function aprobar_agencia()
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
error_log("Error al enviar correo: {$mail->ErrorInfo}");
|
error_log("Error al enviar correo: {$mail->ErrorInfo}");
|
||||||
}
|
}
|
||||||
|
// Registrar en bitácora
|
||||||
|
registrar_bitacora_agencia($id_agencia, $nombre, 'CREACION', $usuario_id);
|
||||||
|
|
||||||
header("Location: /IMPORTADORES/administrador/agenciasActivas");
|
header("Location: /IMPORTADORES/administrador/agenciasActivas");
|
||||||
exit;
|
exit;
|
||||||
@@ -659,7 +661,7 @@ function guardar_agencia()
|
|||||||
";
|
";
|
||||||
|
|
||||||
$paramsAdmin = [$nombre_admin_enc, $correo_admin_enc, $password_hash, $_SESSION['usuario_id']];
|
$paramsAdmin = [$nombre_admin_enc, $correo_admin_enc, $password_hash, $_SESSION['usuario_id']];
|
||||||
$stmtAdmin = sqlsrv_query($conn, $sqlInsertAdmin, $paramsAdmin);
|
$stmtAdmin = sqlsrv_query($conn, $sqlInsertAdmin, $paramsAdmin);
|
||||||
|
|
||||||
if (!$stmtAdmin) {
|
if (!$stmtAdmin) {
|
||||||
$errors = sqlsrv_errors();
|
$errors = sqlsrv_errors();
|
||||||
@@ -730,6 +732,9 @@ function guardar_agencia()
|
|||||||
|
|
||||||
error_log("Transacción confirmada exitosamente");
|
error_log("Transacción confirmada exitosamente");
|
||||||
|
|
||||||
|
// Registrar en bitácora
|
||||||
|
registrar_bitacora_agencia($id_agencia, $nombre_agencia, 'CREACION', $_SESSION['usuario_id']);
|
||||||
|
|
||||||
// 7️⃣ Enviar correo (DESPUÉS de confirmar transacción)
|
// 7️⃣ Enviar correo (DESPUÉS de confirmar transacción)
|
||||||
if (class_exists('PHPMailer\PHPMailer\PHPMailer')) {
|
if (class_exists('PHPMailer\PHPMailer\PHPMailer')) {
|
||||||
$mail = new PHPMailer(true);
|
$mail = new PHPMailer(true);
|
||||||
@@ -836,7 +841,7 @@ function suspender()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtener el estado actual
|
// Obtener el estado actual
|
||||||
$sqlEstado = "SELECT activo FROM usuarios_sistema WHERE id_usuario = ?";
|
$sqlEstado = "SELECT activo FROM usuarios_sistema WHERE id_usuario = ?";
|
||||||
$stmtEstado = sqlsrv_query($conn, $sqlEstado, [$id]);
|
$stmtEstado = sqlsrv_query($conn, $sqlEstado, [$id]);
|
||||||
|
|
||||||
if (!$stmtEstado || !($row = sqlsrv_fetch_array($stmtEstado, SQLSRV_FETCH_ASSOC))) {
|
if (!$stmtEstado || !($row = sqlsrv_fetch_array($stmtEstado, SQLSRV_FETCH_ASSOC))) {
|
||||||
@@ -847,7 +852,7 @@ function suspender()
|
|||||||
$nuevoEstado = $row['activo'] ? 0 : 1;
|
$nuevoEstado = $row['activo'] ? 0 : 1;
|
||||||
|
|
||||||
// Actualizar estado
|
// Actualizar estado
|
||||||
$sqlUpdate = "UPDATE usuarios_sistema SET activo = ? WHERE id_usuario = ?";
|
$sqlUpdate = "UPDATE usuarios_sistema SET activo = ? WHERE id_usuario = ?";
|
||||||
$stmtUpdate = sqlsrv_query($conn, $sqlUpdate, [$nuevoEstado, $id]);
|
$stmtUpdate = sqlsrv_query($conn, $sqlUpdate, [$nuevoEstado, $id]);
|
||||||
|
|
||||||
if (!$stmtUpdate) {
|
if (!$stmtUpdate) {
|
||||||
@@ -879,7 +884,7 @@ function activar()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtener el estado actual
|
// Obtener el estado actual
|
||||||
$sqlEstado = "SELECT activo FROM usuarios_sistema WHERE id_usuario = ?";
|
$sqlEstado = "SELECT activo FROM usuarios_sistema WHERE id_usuario = ?";
|
||||||
$stmtEstado = sqlsrv_query($conn, $sqlEstado, [$id]);
|
$stmtEstado = sqlsrv_query($conn, $sqlEstado, [$id]);
|
||||||
|
|
||||||
if (!$stmtEstado || !($row = sqlsrv_fetch_array($stmtEstado, SQLSRV_FETCH_ASSOC))) {
|
if (!$stmtEstado || !($row = sqlsrv_fetch_array($stmtEstado, SQLSRV_FETCH_ASSOC))) {
|
||||||
@@ -890,7 +895,7 @@ function activar()
|
|||||||
$nuevoEstado = $row['activo'] ? 0 : 1;
|
$nuevoEstado = $row['activo'] ? 0 : 1;
|
||||||
|
|
||||||
// Actualizar estado
|
// Actualizar estado
|
||||||
$sqlUpdate = "UPDATE usuarios_sistema SET activo = ? WHERE id_usuario = ?";
|
$sqlUpdate = "UPDATE usuarios_sistema SET activo = ? WHERE id_usuario = ?";
|
||||||
$stmtUpdate = sqlsrv_query($conn, $sqlUpdate, [$nuevoEstado, $id]);
|
$stmtUpdate = sqlsrv_query($conn, $sqlUpdate, [$nuevoEstado, $id]);
|
||||||
|
|
||||||
if (!$stmtUpdate) {
|
if (!$stmtUpdate) {
|
||||||
@@ -923,13 +928,13 @@ function reset_password()
|
|||||||
|
|
||||||
// 🔐 Generar contraseña aleatoria de 10 caracteres
|
// 🔐 Generar contraseña aleatoria de 10 caracteres
|
||||||
$randomPassword = bin2hex(random_bytes(5)); // genera algo como 'a8c4f1b92d'
|
$randomPassword = bin2hex(random_bytes(5)); // genera algo como 'a8c4f1b92d'
|
||||||
$passwordHash = password_hash($randomPassword, PASSWORD_DEFAULT);
|
$passwordHash = password_hash($randomPassword, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
$sqlEmail = "SELECT email FROM usuarios_sistema WHERE id_usuario = ?";
|
$sqlEmail = "SELECT email FROM usuarios_sistema WHERE id_usuario = ?";
|
||||||
$stmtEmail = sqlsrv_query($conn, $sqlEmail, [$id]);
|
$stmtEmail = sqlsrv_query($conn, $sqlEmail, [$id]);
|
||||||
$row = sqlsrv_fetch_array($stmtEmail, SQLSRV_FETCH_ASSOC);
|
$row = sqlsrv_fetch_array($stmtEmail, SQLSRV_FETCH_ASSOC);
|
||||||
|
|
||||||
$sql = "UPDATE usuarios_sistema SET password_hash = ? WHERE id_usuario = ?";
|
$sql = "UPDATE usuarios_sistema SET password_hash = ? WHERE id_usuario = ?";
|
||||||
$stmt = sqlsrv_query($conn, $sql, [$passwordHash, $id]);
|
$stmt = sqlsrv_query($conn, $sql, [$passwordHash, $id]);
|
||||||
|
|
||||||
if (!$stmt) {
|
if (!$stmt) {
|
||||||
@@ -1001,7 +1006,7 @@ function suspenderAgencia()
|
|||||||
|
|
||||||
$conn = getConnection();
|
$conn = getConnection();
|
||||||
|
|
||||||
$id = $_GET['id'] ?? null;
|
$id = $_GET['id'] ?? null;
|
||||||
|
|
||||||
if (!$id || !is_numeric($id)) {
|
if (!$id || !is_numeric($id)) {
|
||||||
header("Location: /IMPORTADORES/administrador/agenciasActivas?error=invalid_id");
|
header("Location: /IMPORTADORES/administrador/agenciasActivas?error=invalid_id");
|
||||||
@@ -1009,7 +1014,7 @@ function suspenderAgencia()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtener el estado actual
|
// Obtener el estado actual
|
||||||
$sqlEstado = "SELECT activo FROM agencias_aduanles WHERE id_usuario = ?";
|
$sqlEstado = "SELECT activo FROM agencias_aduanles WHERE id_usuario = ?";
|
||||||
$stmtEstado = sqlsrv_query($conn, $sqlEstado, [$id]);
|
$stmtEstado = sqlsrv_query($conn, $sqlEstado, [$id]);
|
||||||
|
|
||||||
if (!$stmtEstado || !($row = sqlsrv_fetch_array($stmtEstado, SQLSRV_FETCH_ASSOC))) {
|
if (!$stmtEstado || !($row = sqlsrv_fetch_array($stmtEstado, SQLSRV_FETCH_ASSOC))) {
|
||||||
@@ -1020,7 +1025,7 @@ function suspenderAgencia()
|
|||||||
$nuevoEstado = $row['activo'] ? 0 : 1;
|
$nuevoEstado = $row['activo'] ? 0 : 1;
|
||||||
|
|
||||||
// Actualizar estado
|
// Actualizar estado
|
||||||
$sqlUpdate = "UPDATE agencias_aduanles SET activo = ? WHERE id_usuario = ?";
|
$sqlUpdate = "UPDATE agencias_aduanles SET activo = ? WHERE id_usuario = ?";
|
||||||
$stmtUpdate = sqlsrv_query($conn, $sqlUpdate, [$nuevoEstado, $id]);
|
$stmtUpdate = sqlsrv_query($conn, $sqlUpdate, [$nuevoEstado, $id]);
|
||||||
|
|
||||||
if (!$stmtUpdate) {
|
if (!$stmtUpdate) {
|
||||||
@@ -1045,10 +1050,9 @@ function configuracion()
|
|||||||
die("ID de usuario no disponible en la sesión.");
|
die("ID de usuario no disponible en la sesión.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM informacion_general WHERE id_usuario = ?";
|
$sql = "SELECT * FROM informacion_general WHERE id_usuario = ?";
|
||||||
$params = [$id_usuario];
|
$params = [$id_usuario];
|
||||||
|
$stmt = sqlsrv_query($conn, $sql, $params);
|
||||||
$stmt = sqlsrv_query($conn, $sql, $params);
|
|
||||||
|
|
||||||
if ($stmt === false) {
|
if ($stmt === false) {
|
||||||
die(print_r(sqlsrv_errors(), true));
|
die(print_r(sqlsrv_errors(), true));
|
||||||
|
|||||||
@@ -11,16 +11,49 @@ function index()
|
|||||||
|
|
||||||
function sistema()
|
function sistema()
|
||||||
{
|
{
|
||||||
|
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'super_admin') {
|
||||||
|
header('Location: /IMPORTADORES/login');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn = getConnection();
|
||||||
|
$sql = "SELECT bl.*, u.nombre
|
||||||
|
FROM bitacora_login bl
|
||||||
|
INNER JOIN usuarios_sistema u
|
||||||
|
ON bl.id_usuario = u.id_usuario
|
||||||
|
ORDER BY fecha DESC";
|
||||||
|
$stmt = sqlsrv_query($conn, $sql);
|
||||||
|
|
||||||
|
$registros = [];
|
||||||
|
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||||
|
$registros[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
include __DIR__ . '/../../views/bitacoras/bitacora_sistema.php';
|
include __DIR__ . '/../../views/bitacoras/bitacora_sistema.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
function sistemaAgencia()
|
function sistemaAgencia()
|
||||||
{
|
{
|
||||||
|
|
||||||
include __DIR__ . '/../../views/bitacoras/sistema_agencia.php';
|
include __DIR__ . '/../../views/bitacoras/sistema_agencia.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
function usuarios()
|
function usuarios()
|
||||||
{
|
{
|
||||||
|
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'super_admin') {
|
||||||
|
header('Location: /IMPORTADORES/login');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn = getConnection();
|
||||||
|
$sql = "SELECT * FROM bitacora_usuarios ORDER BY fecha DESC";
|
||||||
|
$stmt = sqlsrv_query($conn, $sql);
|
||||||
|
|
||||||
|
$registros = [];
|
||||||
|
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||||
|
$registros[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
include __DIR__ . '/../../views/bitacoras/bitacora_usuarios.php';
|
include __DIR__ . '/../../views/bitacoras/bitacora_usuarios.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +69,24 @@ function vinculacionesUsuario()
|
|||||||
|
|
||||||
function agencias()
|
function agencias()
|
||||||
{
|
{
|
||||||
|
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'super_admin') {
|
||||||
|
header('Location: /IMPORTADORES/login');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn = getConnection();
|
||||||
|
$sql = "SELECT ba.*, u.nombre
|
||||||
|
FROM bitacora_login ba
|
||||||
|
INNER JOIN usuarios_sistema u
|
||||||
|
ON bl.id_usuario = u.id_usuario
|
||||||
|
ORDER BY fecha DESC";
|
||||||
|
$stmt = sqlsrv_query($conn, $sql);
|
||||||
|
|
||||||
|
$registros = [];
|
||||||
|
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||||
|
$registros[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
include __DIR__ . '/../../views/bitacoras/bitacora_agencias.php';
|
include __DIR__ . '/../../views/bitacoras/bitacora_agencias.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,3 +108,10 @@ function miAcceso()
|
|||||||
|
|
||||||
include __DIR__ . '/../../views/bitacoras/bitacora_usuario.php';
|
include __DIR__ . '/../../views/bitacoras/bitacora_usuario.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bitacoraUsuarios()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
include __DIR__ . '/../../views/admin/bitacora_usuarios.php';
|
||||||
|
}
|
||||||
@@ -1,28 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function registrarBitacora($conn, $idUsuario, $email, $ip, $exito, $detalle) {
|
function registrarBitacora($conn, $idUsuario, $email, $ip, $exito, $detalle)
|
||||||
$sql = "INSERT INTO bitacora_login (id_usuario, email, ip, exito, detalle)
|
{
|
||||||
VALUES (?, ?, ?, ?, ?)";
|
$sql = "INSERT INTO bitacora_login (id_usuario, email, ip, exito, detalle)
|
||||||
|
VALUES (?, ?, ?, ?, ?)";
|
||||||
$params = [$idUsuario, $email, $ip, $exito, $detalle];
|
$params = [$idUsuario, $email, $ip, $exito, $detalle];
|
||||||
sqlsrv_query($conn, $sql, $params);
|
sqlsrv_query($conn, $sql, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
function registrar_bitacora_usuario($usuarioId, $accion, $descripcion) {
|
function registrar_bitacora_usuario($usuarioId, $accion, $descripcion)
|
||||||
$conn = getConnection();
|
{
|
||||||
|
$conn = getConnection();
|
||||||
|
|
||||||
$sql = "INSERT INTO bitacora_usuarios (usuario_id, accion, descripcion)
|
$sql = "INSERT INTO bitacora_usuarios (usuario_id, accion, descripcion)
|
||||||
VALUES (?, ?, ?)";
|
VALUES (?, ?, ?)";
|
||||||
$params = [$usuarioId, $accion, $descripcion];
|
$params = [$usuarioId, $accion, $descripcion];
|
||||||
|
|
||||||
sqlsrv_query($conn, $sql, $params);
|
sqlsrv_query($conn, $sql, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
function registrar_bitacora_agencia($agenciaId, $nombreAgencia, $accion, $idAdmin) {
|
function registrar_bitacora_agencia($agenciaId, $nombreAgencia, $accion, $idAdmin)
|
||||||
$conn = getConnection();
|
{
|
||||||
|
$conn = getConnection();
|
||||||
|
|
||||||
$sql = "INSERT INTO bitacora_agencias (id_agencia, nombre, accion, realizado_por)
|
$sql = "INSERT INTO bitacora_agencias (id_agencia, nombre, accion, realizado_por, fecha)
|
||||||
VALUES (?, ?, ?, ?)";
|
VALUES (?, ?, ?, ?, GETDATE())";
|
||||||
$params = [$usuarioId, $nombre, $accion, $idAdmin];
|
$params = [$agenciaId, $nombreAgencia, $accion, $idAdmin];
|
||||||
|
$stmt = sqlsrv_query($conn, $sql, $params);
|
||||||
|
|
||||||
sqlsrv_query($conn, $sql, $params);
|
if (!$stmt) {
|
||||||
|
error_log("Error al registrar bitácora de agencia: " . print_r(sqlsrv_errors(), true));
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlsrv_close($conn);
|
||||||
}
|
}
|
||||||
@@ -34,5 +34,47 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -52,17 +52,17 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($bitacoras as $b): ?>
|
<?php foreach ($registros as $r): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?= htmlspecialchars($b['id_usuario']) ?></td>
|
<td><?= htmlspecialchars($r['id_usuario'] ?? '') ?></td>
|
||||||
<td><?= htmlspecialchars($b['nombre']) ?></td>
|
<td><?= htmlspecialchars(decrypt($r['nombre'] ?? '')) ?></td>
|
||||||
<td><?= htmlspecialchars($b['email']) ?></td>
|
<td><?= htmlspecialchars($r['email'] ?? '') ?></td>
|
||||||
<td><?= htmlspecialchars($b['ip']) ?></td>
|
<td><?= htmlspecialchars($r['ip'] ?? '') ?></td>
|
||||||
<td><?= $b['fecha']->format('Y-m-d H:i:s') ?></td>
|
<td><?= $r['fecha']->format('Y-m-d H:i:s') ?></td>
|
||||||
<td>
|
<td>
|
||||||
<?= $b['exito'] == 1 ? 'Éxito' : 'Fallido' ?>
|
<?= $r['exito'] == 1 ? 'Éxito' : 'Fallido' ?>
|
||||||
</td>
|
</td>
|
||||||
<td><?= htmlspecialchars($b['detalle']) ?></td>
|
<td><?= htmlspecialchars($r['detalle']) ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -74,6 +74,7 @@
|
|||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('#tabla-logins').DataTable({
|
$('#tabla-logins').DataTable({
|
||||||
|
order: [],
|
||||||
language: {
|
language: {
|
||||||
url: 'https://cdn.datatables.net/plug-ins/1.13.4/i18n/es-ES.json'
|
url: 'https://cdn.datatables.net/plug-ins/1.13.4/i18n/es-ES.json'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<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">
|
<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>
|
<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>
|
<style>
|
||||||
body { font-family: 'Segoe UI', sans-serif; background-color: #f4f6f9; }
|
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; }
|
.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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="content px-4 pt-5 mt-4">
|
<div class="content">
|
||||||
<h4>🛠️ Bitácora de Cambios de Usuario</h4>
|
<h4 class="mb-4">🛠️ Cambios de Usuario</h4>
|
||||||
|
|
||||||
<table class="table table-hover mt-3 align-middle">
|
<div class="card p-3 shadow-sm">
|
||||||
<thead class="table-dark">
|
<div class="table-responsive">
|
||||||
<tr>
|
<table class="table table-striped align-middle" id="tabla-bitacora-usuarios">
|
||||||
<th>#</th>
|
<thead class="table-dark">
|
||||||
<th>ID Usuario</th>
|
<tr>
|
||||||
<th>Acción</th>
|
<th>#</th>
|
||||||
<th>Descripción</th>
|
<th>ID Usuario</th>
|
||||||
<th>Fecha</th>
|
<th>Acción</th>
|
||||||
</tr>
|
<th>Descripción</th>
|
||||||
</thead>
|
<th>Fecha</th>
|
||||||
<tbody>
|
</tr>
|
||||||
<?php foreach ($registros as $r): ?>
|
</thead>
|
||||||
<tr>
|
<tbody>
|
||||||
<td><?= $r['id_bitacora'] ?></td>
|
<?php foreach ($registros as $r): ?>
|
||||||
<td><?= $r['usuario_id'] ?></td>
|
<tr>
|
||||||
<td><strong><?= htmlspecialchars($r['accion']) ?></strong></td>
|
<td><?= $r['id_bitacora'] ?></td>
|
||||||
<td><?= nl2br(htmlspecialchars($r['descripcion'])) ?></td>
|
<td><?= $r['usuario_id'] ?></td>
|
||||||
<td><?= $r['fecha'] instanceof DateTime ? $r['fecha']->format('Y-m-d H:i') : htmlspecialchars($r['fecha']) ?></td>
|
<td><strong><?= htmlspecialchars($r['accion']) ?></strong></td>
|
||||||
</tr>
|
<td><?= nl2br(htmlspecialchars($r['descripcion'])) ?></td>
|
||||||
<?php endforeach; ?>
|
<td><?= $r['fecha'] instanceof DateTime ? $r['fecha']->format('Y-m-d H:i') : htmlspecialchars($r['fecha']) ?></td>
|
||||||
</tbody>
|
</tr>
|
||||||
</table>
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -84,7 +84,7 @@ $cantidadBitacoras = contarBitacorasDisponibles($permisosBitacoras);
|
|||||||
function obtenerTextoPermiso($permiso, $tipoUsuario) {
|
function obtenerTextoPermiso($permiso, $tipoUsuario) {
|
||||||
$textos = [
|
$textos = [
|
||||||
'registro_accesos' => ($tipoUsuario === 'super_admin') ? 'Registro de accesos' : null,
|
'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,
|
'registro_agencias' => ($tipoUsuario === 'super_admin') ? 'Registro de agencias' : null,
|
||||||
'acceso_usuarios_agencias' => ($tipoUsuario === 'admin_agencia' || $tipoUsuario === 'agente_aduanal') ? 'Registros de accesos' : 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,
|
'registro_vinculaciones' => ($tipoUsuario === 'admin_agencia' || $tipoUsuario === 'agente_aduanal') ? 'Vinculaciones (Agencia)' : null,
|
||||||
|
|||||||
Reference in New Issue
Block a user