inicio
This commit is contained in:
2025-05-05 11:03:01 -06:00
commit c73e3f2327
185 changed files with 17573 additions and 0 deletions

View File

@@ -0,0 +1,142 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Panel de Administración - Usuarios</title>
<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>
</head>
<body>
<?php
include __DIR__ . '/../partials/sidebar_sistemas.php';
?>
<!-- 📄 CONTENIDO -->
<div class="content px-4">
<h3 class="mb-4">Administración de Usuarios</h3>
<!-- FORMULARIO -->
<form action="/IMPORTADORES/sistemas/guardar_usuario" method="POST" class="card p-4 mb-5 shadow-sm">
<h5 class="mb-3"> Nuevo Usuario</h5>
<div class="row g-3">
<div class="col-md-4">
<input name="nombre" class="form-control" placeholder="Nombre completo" required>
</div>
<div class="col-md-4">
<input name="email" type="email" class="form-control" placeholder="Correo electrónico" required>
</div>
<div class="col-md-2">
<input name="password" type="password" class="form-control" placeholder="Contraseña" required>
</div>
<div class="col-md-2">
<select name="tipo_usuario" class="form-select" required>
<option value="">Tipo</option>
<option value="agente_aduanal">Agente Aduanal</option>
<option value="importador">Importador</option>
</select>
</div>
</div>
<div class="text-end mt-4">
<button class="btn btn-success px-4">Registrar</button>
</div>
</form>
<!-- TABLA DE USUARIOS -->
<div class="card p-4 shadow-sm">
<h5 class="mb-3">👁️ Usuarios Registrados</h5>
<div class="table-responsive">
<table class="table table-striped table-hover align-middle">
<thead>
<tr>
<th>#</th>
<th>Nombre</th>
<th>Correo</th>
<th>Tipo</th>
<th>Estado</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<?php if (!empty($usuarios)): ?>
<?php foreach ($usuarios as $u): ?>
<tr>
<td><?= $u['id_usuario'] ?></td>
<td><?= decrypt($u['nombre']) ?></td>
<td><?= decrypt($u['email']) ?></td>
<td><?= ucfirst($u['tipo_usuario']) ?></td>
<td>
<span class="badge <?= $u['activo'] ? 'bg-success' : 'bg-danger' ?>">
<?= $u['activo'] ? 'Activo' : 'Inactivo' ?>
</span>
</td>
<td>
<a href="/IMPORTADORES/sistemas/toggle_estado?id=<?= $u['id_usuario'] ?>" class="btn btn-sm btn-warning">Toggle</a>
<a href="/IMPORTADORES/sistemas/reset_password?id=<?= $u['id_usuario'] ?>" class="btn btn-sm btn-secondary">Reset</a>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="6" class="text-center">No hay usuarios registrados aún.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<?php if (isset($_GET['reset'], $_GET['pass'], $_GET['email']) && $_GET['reset'] === 'ok'): ?>
<script>
const nuevaPassword = "<?= htmlspecialchars($_GET["pass"]) ?>";
const emailUsuario = "<?= htmlspecialchars($_GET["email"]) ?>";
Swal.fire({
icon: 'success',
title: 'Contraseña restablecida',
html: `
Nueva contraseña generada:<br>
<strong style="font-size:18px;">${nuevaPassword}</strong>
<div class="mt-3">
<button class="btn btn-outline-primary btn-sm" onclick="copiarPassword()">📋 Copiar</button>
<button class="btn btn-outline-success btn-sm" onclick="enviarPorCorreo()">📧 Enviar por correo</button>
</div>
`,
showConfirmButton: false,
});
function copiarPassword() {
navigator.clipboard.writeText(nuevaPassword).then(() => {
Swal.fire('Copiado', 'La contraseña fue copiada al portapapeles.', 'success');
});
}
function enviarPorCorreo() {
fetch(`/IMPORTADORES/sistemas/enviar_password?email=${encodeURIComponent(emailUsuario)}&pass=${encodeURIComponent(nuevaPassword)}`)
.then(response => response.text())
.then(data => {
Swal.fire('Enviado', 'La contraseña fue enviada al correo del usuario.', 'success');
})
.catch(() => {
Swal.fire('Error', 'No se pudo enviar el correo.', 'error');
});
}
</script>
<?php endif; ?>
</body>
</html>

View File

@@ -0,0 +1,50 @@
<head>
<meta charset="UTF-8">
<title>Panel de Administración - Usuarios</title>
<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>
</head>
<?php
include __DIR__ . '/../partials/sidebar_sistemas.php';
?>
<div class="content px-4 pt-5 mt-4">
<h4>🕵️ Bitácora de Accesos</h4>
<table class="table table-hover mt-3 align-middle">
<thead class="table-dark">
<tr>
<th>#</th>
<th>ID Usuario</th>
<th>Correo</th>
<th>IP</th>
<th>Fecha</th>
<th>Éxito</th>
<th>Detalle</th>
</tr>
</thead>
<tbody>
<?php foreach ($registros as $r): ?>
<tr>
<td><?= $r['id'] ?></td>
<td><?= $r['id_usuario'] ?></td>
<td><?= htmlspecialchars($r['email']) ?></td>
<td><?= htmlspecialchars($r['ip']) ?></td>
<td><?= $r['fecha'] instanceof DateTime ? $r['fecha']->format('Y-m-d H:i') : htmlspecialchars($r['fecha']) ?></td>
<td>
<span class="badge <?= $r['exito'] ? 'bg-success' : 'bg-danger' ?>">
<?= $r['exito'] ? 'Sí' : 'No' ?>
</span>
</td>
<td><?= htmlspecialchars($r['detalle']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>

View File

@@ -0,0 +1,42 @@
<head>
<meta charset="UTF-8">
<title>Panel de Administración - Usuarios</title>
<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>
</head>
<?php
include __DIR__ . '/../partials/sidebar_sistemas.php';
?>
<div class="content px-4 pt-5 mt-4">
<h4>🛠️ Bitácora de 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>

View File

@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Login Sistemas</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container mt-5" style="max-width: 400px;">
<h4 class="mb-4 text-center">Acceso Administrativo</h4>
<form action="/IMPORTADORES/sistemas/login" method="POST">
<div class="mb-3">
<label class="form-label">Correo</label>
<input type="email" name="email" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">Contraseña</label>
<input type="password" name="clave" class="form-control" required>
</div>
<div class="d-grid">
<button class="btn btn-primary">Entrar</button>
</div>
</form>
</div>
</body>
</html>