Vinculaciones multi-agencia

This commit is contained in:
2025-06-25 12:38:50 -06:00
parent a830e3a84a
commit c5c698dbe4
62 changed files with 5107 additions and 1454 deletions

View File

@@ -1,11 +1,17 @@
<?php include __DIR__ . '/../partials/sidebar_sistemas.php'; ?>
<?php include __DIR__ . '/../partials/sidebar_administrador.php'; ?>
<html>
<!DOCTYPE html>
<html lang="es">
<head>
<title>Dashboard | Agencia Aduanal</title>
<meta charset="UTF-8">
<title>Dashboard | Administrador</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">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.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>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
body { font-family: 'Segoe UI', sans-serif; background-color: #f4f6f9; }
@@ -27,12 +33,89 @@
.card { border-radius: 12px; }
.table thead th { background: #343a40; color: #fff; }
</style>
</head>
<body>
<div class="content">
<h4>✅ Agencias Activas</h4>
<h4 class="mb-4">✅ Agencias Activas</h4>
<!-- TABLA DE AGENCIAS -->
<div class="card p-3 shadow-sm">
<div class="table-responsive">
<table class="table table-striped table-hover align-middle" id="tabla-agencias-activas">
<thead>
<tr>
<th>#</th>
<th>Nombre</th>
<th>RFC</th>
<th>Correo</th>
<th>Teléfono</th>
<th>Dirección</th>
<th>Fecha</th>
<th>Administrador</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<?php if (!empty($agencias)): ?>
<?php foreach ($agencias as $ag): ?>
<tr>
<td><?= $ag['id_agencia'] ?></td>
<td><?= htmlspecialchars(decrypt($ag['nombre_agencia'])) ?></td>
<td><?= htmlspecialchars($ag['rfc_agencia']) ?></td>
<td><?= htmlspecialchars(decrypt($ag['email'])) ?></td>
<td><?= htmlspecialchars($ag['telefono']) ?></td>
<td><?= htmlspecialchars($ag['direccion']) ?></td>
<td><?= $ag['creado_en'] ? $ag['creado_en']->format('Y-m-d H:i') : '' ?></td>
<td><?= htmlspecialchars($ag['id_administrador']) ?></td>
<td>
<?php if (isset($ag['activo']) && $ag['activo'] == 1): ?>
<a href="/IMPORTADORES/administrador/suspenderAgencia?id=<?= $ag['id_agencia'] ?>&success=1" class="btn btn-sm btn-danger">Suspender</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="8" class="text-center">No hay agencias registradas aún.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('#tabla-agencias-activas').DataTable({
order: [],
language: {
url: 'https://cdn.datatables.net/plug-ins/1.13.4/i18n/es-ES.json'
}
});
});
</script>
<?php if (isset($_GET['success'])): ?>
<script>
<?php if ($_GET['success'] === 'status_deactivated'): ?>
Swal.fire({ icon: 'success', title: 'Usuario desactivado', text: 'El usuario ha sido desactivado correctamente.', confirmButtonColor: '#198754' });
<?php endif; ?>
</script>
<?php endif; ?>
<?php if (isset($_GET['error'])): ?>
<script>
<?php if ($_GET['error'] === 'unauthorized'): ?>
Swal.fire({ icon: 'error', title: 'No autorizado', text: 'No tienes permisos para realizar esta acción.', confirmButtonColor: '#dc3545' });
<?php elseif ($_GET['error'] === 'invalid_id'): ?>
Swal.fire({ icon: 'error', title: 'ID inválido', text: 'El identificador del usuario no es válido.', confirmButtonColor: '#dc3545' });
<?php elseif ($_GET['error'] === 'agencia_not_found'): ?>
Swal.fire({ icon: 'error', title: 'Usuario no encontrado', text: 'No se encontró el usuario especificado.', confirmButtonColor: '#dc3545' });
<?php elseif ($_GET['error'] === 'update_failed'): ?>
Swal.fire({ icon: 'error', title: 'Error al actualizar', text: 'No se pudo actualizar el estado del usuario.', confirmButtonColor: '#dc3545' });
<?php endif; ?>
</script>
<?php endif; ?>
</body>
</html>