cambios atorados
This commit is contained in:
@@ -22,11 +22,6 @@ function dashboard()
|
||||
include __DIR__ . '/../../views/agencias/dashboard_agencias.php';
|
||||
}
|
||||
|
||||
function solicitudesVinculacion()
|
||||
{
|
||||
include __DIR__ . '/../../views/agencias/solicitudes_vinculacion.php';
|
||||
}
|
||||
|
||||
function alta()
|
||||
{
|
||||
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'admin_agencia') {
|
||||
@@ -34,6 +29,76 @@ function alta()
|
||||
exit;
|
||||
}
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
// DEBUG: Verificar conexión
|
||||
if (!$conn) {
|
||||
die("Error de conexión: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
// Obtener la agencia del administrador actual
|
||||
$sqlAgencia = "SELECT id_agencia FROM agencias_aduanales WHERE id_administrador = ?";
|
||||
$stmtAgencia = sqlsrv_query($conn, $sqlAgencia, [$_SESSION['usuario_id']]);
|
||||
|
||||
// DEBUG: Verificar query de agencia
|
||||
if ($stmtAgencia === false) {
|
||||
die("Error en consulta de agencia: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
$rowAgencia = sqlsrv_fetch_array($stmtAgencia, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
// DEBUG: Verificar si se encontró la agencia
|
||||
if (!$rowAgencia) {
|
||||
die("No se encontró agencia para el administrador ID: " . $_SESSION['usuario_id']);
|
||||
}
|
||||
|
||||
$id_agencia = $rowAgencia['id_agencia'];
|
||||
|
||||
// === CONSULTA DE AGENTES ADUANALES ===
|
||||
// Verificar si hay registros en la tabla agente_agencia
|
||||
$sqlCount = "SELECT COUNT(*) as total FROM agente_agencia WHERE id_agencia = ?";
|
||||
$stmtCount = sqlsrv_query($conn, $sqlCount, [$id_agencia]);
|
||||
$rowCount = sqlsrv_fetch_array($stmtCount, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
// Verificar registros activos
|
||||
$sqlCountActive = "SELECT COUNT(*) as total FROM agente_agencia WHERE id_agencia = ? AND activo = 1";
|
||||
$stmtCountActive = sqlsrv_query($conn, $sqlCountActive, [$id_agencia]);
|
||||
$rowCountActive = sqlsrv_fetch_array($stmtCountActive, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
// Consulta de agentes vinculados ACTIVOS a MI agencia
|
||||
$sql = "
|
||||
SELECT
|
||||
u.id_usuario,
|
||||
u.nombre,
|
||||
u.email,
|
||||
u.tipo_usuario as tipo_usuario_sistema,
|
||||
u.activo,
|
||||
u.creado_en,
|
||||
u.creado_por,
|
||||
aa.fecha_asignacion as fecha_vinculacion,
|
||||
aa.id_relacion,
|
||||
'agente' as tipo_vinculacion
|
||||
FROM agente_agencia aa
|
||||
INNER JOIN usuarios_sistema u ON aa.id_agente = u.id_usuario
|
||||
WHERE aa.id_agencia = ?
|
||||
AND aa.activo = 1
|
||||
AND u.activo = 1
|
||||
ORDER BY aa.fecha_asignacion DESC
|
||||
";
|
||||
$stmt = sqlsrv_query($conn, $sql, [$id_agencia]);
|
||||
|
||||
// DEBUG: Verificar query de agentes
|
||||
if ($stmt === false) {
|
||||
die("Error en consulta de agentes: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
$agentes = [];
|
||||
if ($stmt !== false) {
|
||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
$agentes[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
include __DIR__ . '/../../views/agencias/alta_agentes.php';
|
||||
}
|
||||
|
||||
|
||||
@@ -24,244 +24,158 @@ function dashboard()
|
||||
include __DIR__ . '/../../views/agentes/dashboard_agentes.php';
|
||||
}
|
||||
|
||||
function importadores_activos()
|
||||
function vinculados()
|
||||
{
|
||||
if (!($_SESSION['usuario_id'] ?? false) || $_SESSION['tipo_usuario'] !== 'agente_aduanal') {
|
||||
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'agente_aduanal') {
|
||||
header('Location: /IMPORTADORES/login');
|
||||
exit;
|
||||
}
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
$sql = "SELECT id_importador, nombre_empresa, email, telefono, creado_en
|
||||
FROM importadores
|
||||
WHERE estatus = 'aprobado'
|
||||
ORDER BY creado_en DESC";
|
||||
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
$importadores = [];
|
||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
$importadores[] = $row;
|
||||
if (!$conn) {
|
||||
die("Error de conexión: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
include __DIR__ . '/../../views/agentes/importadores_activos.php';
|
||||
}
|
||||
// Obtener la agencia del administrador actual
|
||||
$sqlAgencia = "SELECT id_agencia FROM agente_agencia WHERE id_agente = ? AND activo = 1";
|
||||
$stmtAgencia = sqlsrv_query($conn, $sqlAgencia, [$_SESSION['usuario_id']]);
|
||||
|
||||
function solicitudes_pendientes() {
|
||||
if (!($_SESSION['usuario_id'] ?? false) || $_SESSION['tipo_usuario'] !== 'agente_aduanal') {
|
||||
header('Location: /IMPORTADORES/login');
|
||||
exit;
|
||||
// DEBUG: Verificar query de agencia
|
||||
if ($stmtAgencia === false) {
|
||||
die("Error en consulta de agencia: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
$conn = getConnection();
|
||||
$rowAgencia = sqlsrv_fetch_array($stmtAgencia, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
$sql = "SELECT request_id, company_name, rfc, email, phone, request_date,opinion_file
|
||||
FROM solicitudes_importadores
|
||||
WHERE request_status = 'pending'
|
||||
ORDER BY request_date DESC";
|
||||
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
$solicitudes = [];
|
||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
$solicitudes[] = $row;
|
||||
// DEBUG: Verificar si se encontró la agencia
|
||||
if (!$rowAgencia) {
|
||||
die("No se encontró agencia vinculada el agente ID: " . $_SESSION['usuario_id']);
|
||||
}
|
||||
|
||||
include __DIR__ . '/../../views/agentes/solicitudes_pendientes.php';
|
||||
}
|
||||
$id_agencia = $rowAgencia['id_agencia'];
|
||||
|
||||
function aprobar_solicitud()
|
||||
{
|
||||
$conn = getConnection();
|
||||
$id = $_GET['id'] ?? null;
|
||||
// Primero, verificar si hay registros en la tabla importador_agencia
|
||||
$sqlCount = "SELECT COUNT(*) as total FROM importador_agencia WHERE id_agencia = ?";
|
||||
$stmtCount = sqlsrv_query($conn, $sqlCount, [$id_agencia]);
|
||||
$rowCount = sqlsrv_fetch_array($stmtCount, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
if (!$id || !is_numeric($id)) {
|
||||
die("❌ ID inválido.");
|
||||
}
|
||||
|
||||
// Obtener la solicitud
|
||||
$sql = "SELECT * FROM solicitudes_importadores WHERE request_id = ?";
|
||||
$stmt = sqlsrv_query($conn, $sql, [$id]);
|
||||
$solicitud = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
if (!$solicitud) {
|
||||
die("❌ Solicitud no encontrada.");
|
||||
}
|
||||
|
||||
// Validar que no haya sido aprobada ya
|
||||
if ($solicitud['request_status'] === 'approved') {
|
||||
die("⚠️ Esta solicitud ya fue aprobada.");
|
||||
}
|
||||
|
||||
// Preparar datos
|
||||
$nombre = decrypt($solicitud['company_name']);
|
||||
$email = $solicitud['email'];
|
||||
$tipo = 'importador';
|
||||
|
||||
// Generar contraseña aleatoria
|
||||
$password_plain = bin2hex(random_bytes(5));
|
||||
$password_hash = password_hash($password_plain, PASSWORD_DEFAULT);
|
||||
|
||||
// Encriptar datos sensibles
|
||||
$nombre_encrypt = encrypt($nombre);
|
||||
$email_encrypt = encrypt($email);
|
||||
|
||||
// Insertar en usuarios_sistema
|
||||
$sqlInsert = "INSERT INTO usuarios_sistema (nombre, email, password_hash, tipo_usuario, activo, creado_en, dos factores)
|
||||
VALUES (?, ?, ?, ?, 1, GETDATE()), 0";
|
||||
$stmtInsert = sqlsrv_query($conn, $sqlInsert, [
|
||||
$nombre_encrypt, $email_encrypt, $password_hash, $tipo
|
||||
]);
|
||||
|
||||
if (!$stmtInsert) {
|
||||
die("❌ Error al crear usuario: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
// Actualizar solicitud
|
||||
$sqlUpdate = "UPDATE solicitudes_importadores
|
||||
SET request_status = 'approved', approval_date = GETDATE(), approved_by = ?
|
||||
WHERE request_id = ?";
|
||||
$stmtUpdate = sqlsrv_query($conn, $sqlUpdate, [$_SESSION['usuario_id'] ?? null, $id]);
|
||||
|
||||
if (!$stmtUpdate) {
|
||||
die("❌ Error al actualizar solicitud: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
// Enviar correo al importador
|
||||
$mail = new PHPMailer(true);
|
||||
try {
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'secure.emailsrvr.com';
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = 'noreply@aduanasoft.com.mx';
|
||||
$mail->Password = $_ENV['SMTP_PASS'];
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$mail->Port = 587;
|
||||
|
||||
$mail->setFrom('noreply@aduanasoft.com.mx', 'SIIH | AduanaSoft');
|
||||
$mail->addAddress($email);
|
||||
$mail->CharSet = 'UTF-8';
|
||||
$mail->isHTML(true);
|
||||
$mail->Subject = 'Tu acceso a la plataforma SIIH ha sido autorizado';
|
||||
|
||||
$mail->Body = "
|
||||
<div style='font-family: Segoe UI, sans-serif; background-color: #f4f6f9; padding: 40px;'>
|
||||
<div style='max-width: 600px; margin: auto; background: #fff; border: 1px solid #ddd; border-radius: 10px; overflow: hidden;'>
|
||||
<div style='background: linear-gradient(to right, #003366, #0055A5); padding: 20px; text-align: center;'>
|
||||
<h2 style='color: white;'>¡Bienvenido a SIIH!</h2>
|
||||
</div>
|
||||
<div style='padding: 30px; color: #333; font-size: 16px;'>
|
||||
<p>Tu registro como importador ha sido aprobado. Aquí tienes tus credenciales de acceso:</p>
|
||||
<p><strong>Correo:</strong> $email</p>
|
||||
<p><strong>Contraseña:</strong> $password_plain</p>
|
||||
<p>📌 Te recomendamos cambiar tu contraseña una vez que ingreses al sistema.</p>
|
||||
<p><a href='http://siih.aduanasoft.com/IMPORTADORES/login' class='btn btn-primary'>Ir al sistema</a></p>
|
||||
</div>
|
||||
<div style='background: #e9ecef; text-align: center; padding: 15px; font-size: 13px; color: #666;'>
|
||||
© " . date('Y') . " SIIH · Desarrollado por AduanaSoft
|
||||
</div>
|
||||
</div>
|
||||
</div>";
|
||||
|
||||
$mail->send();
|
||||
} catch (Exception $e) {
|
||||
error_log("Error al enviar correo: {$mail->ErrorInfo}");
|
||||
}
|
||||
|
||||
header("Location: /IMPORTADORES/AGENTES/solicitudes_pendientes");
|
||||
exit;
|
||||
}
|
||||
|
||||
function activos()
|
||||
{
|
||||
if (!($_SESSION['usuario_id'] ?? false)) {
|
||||
die("⚠️ No autorizado.");
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../helpers/crypto.php';
|
||||
$conn = getConnection();
|
||||
|
||||
$sql = "SELECT id_usuario, nombre, email, tipo_usuario, creado_en, activo
|
||||
FROM usuarios_sistema
|
||||
WHERE tipo_usuario = 'importador'
|
||||
ORDER BY creado_en DESC";
|
||||
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
$importadores = [];
|
||||
|
||||
if ($stmt) {
|
||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
$row['nombre'] = decrypt($row['nombre']);
|
||||
$row['email'] = decrypt($row['email']);
|
||||
$importadores[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
include __DIR__ . '/../../views/agentes/importadores_activos.php';
|
||||
}
|
||||
|
||||
function toggle_estado()
|
||||
{
|
||||
if (!($_SESSION['usuario_id'] ?? false) || $_SESSION['tipo_usuario'] !== 'agente_aduanal') {
|
||||
die("⚠️ No autorizado.");
|
||||
}
|
||||
|
||||
$id = $_GET['id'] ?? null;
|
||||
|
||||
if (!$id || !is_numeric($id)) {
|
||||
die("❌ ID inválido.");
|
||||
}
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
$sql = "SELECT activo FROM usuarios_sistema WHERE id_usuario = ?";
|
||||
$stmt = sqlsrv_query($conn, $sql, [$id]);
|
||||
|
||||
if (!$stmt || !($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC))) {
|
||||
die("❌ Usuario no encontrado.");
|
||||
}
|
||||
|
||||
$nuevoEstado = $row['activo'] == 1 ? 0 : 1;
|
||||
|
||||
$update = "UPDATE usuarios_sistema SET activo = ? WHERE id_usuario = ?";
|
||||
$result = sqlsrv_query($conn, $update, [$nuevoEstado, $id]);
|
||||
|
||||
if (!$result) {
|
||||
die("❌ Error al actualizar: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
// Guardar en bitácora
|
||||
require_once __DIR__ . '/../helpers/bitacoras.php';
|
||||
registrar_bitacora_usuario($_SESSION['usuario_id'], 'toggle_estado', "Modificó estado del usuario $id a $nuevoEstado");
|
||||
|
||||
header("Location: /IMPORTADORES/agentes/activos");
|
||||
exit;
|
||||
}
|
||||
|
||||
function bitacora()
|
||||
{
|
||||
$conn = getConnection();
|
||||
if (!($_SESSION['usuario_id'] ?? false)) {
|
||||
header('Location: /IMPORTADORES/login');
|
||||
exit;
|
||||
}
|
||||
// Verificar registros activos y aprobados
|
||||
$sqlCountActive = "SELECT COUNT(*) as total FROM importador_agencia WHERE id_agencia = ? AND activo = 1 AND estado = 'APROBADO'";
|
||||
$stmtCountActive = sqlsrv_query($conn, $sqlCountActive, [$id_agencia]);
|
||||
$rowCountActive = sqlsrv_fetch_array($stmtCountActive, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
// Consulta corregida: solo usuarios vinculados ACTIVOS a MI agencia
|
||||
$sql = "
|
||||
SELECT u.id_usuario, u.nombre, 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.fecha DESC
|
||||
SELECT
|
||||
ia.*,
|
||||
u.nombre as importador_nombre,
|
||||
ig.rfc,
|
||||
ig.telefono,
|
||||
aa.nombre_agencia
|
||||
FROM importador_agencia ia
|
||||
INNER JOIN usuarios_sistema u ON ia.id_importador = u.id_usuario
|
||||
LEFT JOIN informacion_general ig ON u.id_usuario = ig.id_usuario
|
||||
LEFT JOIN agencias_aduanales aa ON ia.id_agencia = aa.id_agencia
|
||||
WHERE ia.id_agencia = ? AND ia.activo = 1 AND ia.estado = 'APROBADO'
|
||||
ORDER BY ia.fecha_vinculacion DESC
|
||||
";
|
||||
$stmt = sqlsrv_query($conn, $sql, [$id_agencia]);
|
||||
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
// DEBUG: Verificar query principal
|
||||
if ($stmt === false) {
|
||||
die("Error en bitacora(): " . print_r(sqlsrv_errors(), true));
|
||||
die("Error en consulta principal: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
$bitacoras = [];
|
||||
$vinculados = [];
|
||||
if ($stmt !== false) {
|
||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
$row['nombre'] = decrypt($row['nombre']); // Desencripta aquí
|
||||
$bitacoras[] = $row;
|
||||
$vinculados[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
include __DIR__ . '/../../views/agentes/bitacora.php';
|
||||
include __DIR__ . '/../../views/vinculaciones/importadores_vinculados.php';
|
||||
}
|
||||
|
||||
function desvincularAgente()
|
||||
{
|
||||
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'agente_aduanal') {
|
||||
header('Location: /IMPORTADORES/login');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Verificar que se recibió el ID de la relación
|
||||
$id_relacion = $_GET['id'] ?? null;
|
||||
if (!$id_relacion || !is_numeric($id_relacion)) {
|
||||
header('Location: /IMPORTADORES/agentes/vinculados?error=invalid_id');
|
||||
exit;
|
||||
}
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
try {
|
||||
// Iniciar transacción
|
||||
sqlsrv_begin_transaction($conn);
|
||||
|
||||
// 1. Primero obtener la agencia del agente aduanal
|
||||
$sqlAgenciaAgente = "
|
||||
SELECT id_agencia
|
||||
FROM agente_agencia
|
||||
WHERE id_agente = ? AND activo = 1
|
||||
";
|
||||
$stmtAgenciaAgente = sqlsrv_query($conn, $sqlAgenciaAgente, [$_SESSION['usuario_id']]);
|
||||
|
||||
if ($stmtAgenciaAgente === false) {
|
||||
throw new Exception('Error en la consulta de agencia-agente: ' . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
$agenciaAgente = sqlsrv_fetch_array($stmtAgenciaAgente, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
|
||||
$id_agencia_agente = $agenciaAgente['id_agencia'];
|
||||
|
||||
// 2. Verificar que la relación existe y pertenece a la MISMA agencia del agente
|
||||
$sqlVerificar = "
|
||||
SELECT
|
||||
ia.*,
|
||||
u.id_usuario, u.nombre as importador_nombre, aa.nombre_agencia
|
||||
FROM importador_agencia ia
|
||||
INNER JOIN usuarios_sistema u ON ia.id_importador = u.id_usuario
|
||||
INNER JOIN agencias_aduanales aa ON ia.id_agencia = aa.id_agencia
|
||||
WHERE ia.id_relacion = ? AND ia.id_agencia = ?
|
||||
";
|
||||
$stmtVerificar = sqlsrv_query($conn, $sqlVerificar, [$id_relacion, $id_agencia_agente]);
|
||||
|
||||
if ($stmtVerificar === false) {
|
||||
throw new Exception('Error en la consulta de verificación: ' . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
$relacion = sqlsrv_fetch_array($stmtVerificar, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
|
||||
// 4. Desactivar la relación (no eliminar, mantener historial)
|
||||
$sqlDesactivar = "
|
||||
UPDATE importador_agencia
|
||||
SET activo = 0,
|
||||
estado = 'DESVINCULADO'
|
||||
WHERE id_relacion = ?
|
||||
";
|
||||
$stmtDesactivar = sqlsrv_query($conn, $sqlDesactivar, [$id_relacion]);
|
||||
|
||||
if ($stmtDesactivar === false) {
|
||||
throw new Exception('Error al desactivar la relación: ' . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
// Confirmar transacción
|
||||
sqlsrv_commit($conn);
|
||||
|
||||
header('Location: /IMPORTADORES/agentes/vinculados?success=unlinked');
|
||||
exit;
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Revertir transacción en caso de error
|
||||
sqlsrv_rollback($conn);
|
||||
error_log("Error desvinculando importador: " . $e->getMessage());
|
||||
header('Location: /IMPORTADORES/agentes/vinculados?error=unlinked_failed');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -47,3 +47,96 @@ function lista()
|
||||
|
||||
include __DIR__ . '/../../views/locaciones/lista.php';
|
||||
}
|
||||
|
||||
function desvincularUsuario()
|
||||
{
|
||||
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'importador') {
|
||||
header('Location: /IMPORTADORES/login');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Verificar que se recibió el ID de la relación
|
||||
$id_relacion = $_GET['id'] ?? null;
|
||||
if (!$id_relacion || !is_numeric($id_relacion)) {
|
||||
header('Location: /IMPORTADORES/vinculaciones/vinculacionesUsuario?error=invalid_id');
|
||||
exit;
|
||||
}
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
try {
|
||||
// Iniciar transacción
|
||||
sqlsrv_begin_transaction($conn);
|
||||
|
||||
// 1. Verificar que la relación existe y pertenece a la agencia del admin
|
||||
$sqlVerificar = "
|
||||
SELECT
|
||||
ia.*,
|
||||
u.id_usuario, u.nombre as importador_nombre, aa.nombre_agencia
|
||||
FROM importador_agencia ia
|
||||
INNER JOIN usuarios_sistema u ON ia.id_importador = u.id_usuario
|
||||
INNER JOIN agencias_aduanales aa ON ia.id_agencia = aa.id_agencia
|
||||
WHERE ia.id_relacion = ? AND ia.id_importador = ?
|
||||
";
|
||||
$stmtVerificar = sqlsrv_query($conn, $sqlVerificar, [$id_relacion, $_SESSION['usuario_id']]);
|
||||
|
||||
// Verificar si la consulta fue exitosa
|
||||
if ($stmtVerificar === false) {
|
||||
$errors = sqlsrv_errors();
|
||||
error_log("Error en consulta verificar: " . print_r($errors, true));
|
||||
throw new Exception('Error en la consulta de verificación');
|
||||
}
|
||||
|
||||
$relacion = sqlsrv_fetch_array($stmtVerificar, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
if (!$relacion) {
|
||||
throw new Exception('Relación no encontrada o no tienes permisos para desvincularla');
|
||||
}
|
||||
|
||||
if ($relacion['activo'] == 0) {
|
||||
throw new Exception('Esta relación ya está inactiva');
|
||||
}
|
||||
|
||||
// 2. Desactivar la relación (no eliminar, mantener historial)
|
||||
$sqlDesactivar = "
|
||||
UPDATE importador_agencia
|
||||
SET activo = 0,
|
||||
fecha_desvinculacion = GETDATE(),
|
||||
estado = 'DESVINCULADO'
|
||||
WHERE id_relacion = ? AND id_importador = ?
|
||||
";
|
||||
|
||||
$stmtDesactivar = sqlsrv_query($conn, $sqlDesactivar, [$id_relacion, $_SESSION['usuario_id']]);
|
||||
|
||||
if ($stmtDesactivar === false) {
|
||||
$errors = sqlsrv_errors();
|
||||
error_log("Error en actualización: " . print_r($errors, true));
|
||||
throw new Exception('Error al desactivar la relación');
|
||||
}
|
||||
|
||||
// Verificar que se actualizó al menos una fila
|
||||
$filasAfectadas = sqlsrv_rows_affected($stmtDesactivar);
|
||||
if ($filasAfectadas === 0) {
|
||||
throw new Exception('No se pudo actualizar la relación');
|
||||
}
|
||||
|
||||
// Limpiar statements
|
||||
sqlsrv_free_stmt($stmtVerificar);
|
||||
sqlsrv_free_stmt($stmtDesactivar);
|
||||
|
||||
// Confirmar transacción
|
||||
sqlsrv_commit($conn);
|
||||
sqlsrv_close($conn);
|
||||
|
||||
header('Location: /IMPORTADORES/vinculaciones/vinculacionesUsuario?success=unlinked');
|
||||
exit;
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Revertir transacción en caso de error
|
||||
sqlsrv_rollback($conn);
|
||||
sqlsrv_close($conn);
|
||||
|
||||
header('Location: /IMPORTADORES/vinculaciones/vinculacionesUsuario?error=unlinked_failed&msg=' . urlencode($e->getMessage()));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
// app/controllers/productos_frecuentes.php
|
||||
|
||||
|
||||
|
||||
require_once __DIR__ . '/../helpers/session.php';
|
||||
require_once __DIR__ . '/../../config/database.php';
|
||||
// 1) Composer autoload (phpdotenv y demás libs)
|
||||
@@ -20,8 +18,6 @@ function index()
|
||||
|
||||
function ajax_paises()
|
||||
{
|
||||
|
||||
|
||||
// Sólo importadores pueden usarlo
|
||||
if (empty($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'importador') {
|
||||
http_response_code(401);
|
||||
@@ -47,8 +43,6 @@ function ajax_paises()
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ajax_proveedores()
|
||||
{
|
||||
// 1) Asegura que la respuesta sea JSON
|
||||
@@ -93,10 +87,8 @@ function ajax_proveedores()
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function lista()
|
||||
{
|
||||
|
||||
if (empty($_SESSION['usuario_id'])) {
|
||||
header('Location: /IMPORTADORES/login');
|
||||
exit;
|
||||
@@ -290,18 +282,17 @@ function actualizar()
|
||||
* Muestra formulario de importación masiva **/
|
||||
function importacion_csv()
|
||||
{
|
||||
session_start();
|
||||
if (empty($_SESSION['usuario_id'])) {
|
||||
header('Location: /IMPORTADORES/login');
|
||||
exit;
|
||||
}
|
||||
|
||||
include __DIR__ . '/../../views/productos_frecuentes/importacion_csv.php';
|
||||
}
|
||||
|
||||
function ajax_unidades()
|
||||
{
|
||||
|
||||
|
||||
// Sólo importadores pueden usarlo
|
||||
if (empty($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'importador') {
|
||||
http_response_code(401);
|
||||
echo json_encode(['results' => []]);
|
||||
@@ -324,8 +315,6 @@ function ajax_unidades()
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** POST /IMPORTADORES/productos_frecuentes/procesar_csv
|
||||
* Procesa el upload y la inserción de CSV **/
|
||||
function procesar_csv()
|
||||
|
||||
@@ -12,37 +12,32 @@ function vinculacionesUsuario()
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
$id_importador = $_SESSION['usuario_id'];
|
||||
// DEBUG: Verificar conexión
|
||||
if (!$conn) {
|
||||
die("Error de conexión: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
// Consulta de todas las relaciones del importador
|
||||
$sql = "
|
||||
SELECT
|
||||
ia.*,
|
||||
aa.id_agencia, aa.nombre_agencia, aa.rfc_agencia, aa.telefono, aa.direccion
|
||||
SELECT *
|
||||
FROM importador_agencia ia
|
||||
INNER JOIN agencias_aduanales aa ON ia.id_agencia = aa.id_agencia
|
||||
WHERE ia.id_importador = ?
|
||||
AND ia.activo = 1
|
||||
AND ia.estado = 'APROBADO'
|
||||
WHERE ia.id_importador = ? AND ia.activo = 1
|
||||
ORDER BY ia.fecha_vinculacion DESC
|
||||
";
|
||||
$stmt = sqlsrv_query($conn, $sql, [$id_importador]);
|
||||
$stmt = sqlsrv_query($conn, $sql, [$_SESSION['usuario_id']]);
|
||||
|
||||
$vinculaciones = [];
|
||||
if ($stmt !== false) {
|
||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
$vinculaciones[] = $row;
|
||||
}
|
||||
sqlsrv_free_stmt($stmt);
|
||||
} else {
|
||||
// Manejo de errores
|
||||
$errors = sqlsrv_errors();
|
||||
error_log("Error en consulta vinculaciones: " . print_r($errors, true));
|
||||
}
|
||||
|
||||
sqlsrv_close($conn);
|
||||
include __DIR__ . '/../../views/vinculaciones/vinculaciones_importador.php';
|
||||
}
|
||||
|
||||
function usuariosVinculados()
|
||||
function vinculacionesAgencia()
|
||||
{
|
||||
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'admin_agencia') {
|
||||
header('Location: /IMPORTADORES/login');
|
||||
@@ -74,6 +69,7 @@ function usuariosVinculados()
|
||||
|
||||
$id_agencia = $rowAgencia['id_agencia'];
|
||||
|
||||
// === CONSULTA DE IMPORTADORES ===
|
||||
// Primero, verificar si hay registros en la tabla importador_agencia
|
||||
$sqlCount = "SELECT COUNT(*) as total FROM importador_agencia WHERE id_agencia = ?";
|
||||
$stmtCount = sqlsrv_query($conn, $sqlCount, [$id_agencia]);
|
||||
@@ -84,13 +80,15 @@ function usuariosVinculados()
|
||||
$stmtCountActive = sqlsrv_query($conn, $sqlCountActive, [$id_agencia]);
|
||||
$rowCountActive = sqlsrv_fetch_array($stmtCountActive, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
// Consulta corregida: solo usuarios vinculados ACTIVOS a MI agencia
|
||||
// Consulta de importadores vinculados ACTIVOS a MI agencia
|
||||
$sql = "
|
||||
SELECT
|
||||
ia.*,
|
||||
u.nombre as importador_nombre,
|
||||
u.tipo_usuario as tipo_usuario_sistema,
|
||||
ig.rfc,
|
||||
ig.telefono
|
||||
ig.telefono,
|
||||
'importador' as tipo_vinculacion
|
||||
FROM importador_agencia ia
|
||||
INNER JOIN usuarios_sistema u ON ia.id_importador = u.id_usuario
|
||||
LEFT JOIN informacion_general ig ON u.id_usuario = ig.id_usuario
|
||||
@@ -101,7 +99,7 @@ function usuariosVinculados()
|
||||
|
||||
// DEBUG: Verificar query principal
|
||||
if ($stmt === false) {
|
||||
die("Error en consulta principal: " . print_r(sqlsrv_errors(), true));
|
||||
die("Error en consulta de importadores: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
$vinculados = [];
|
||||
@@ -111,7 +109,53 @@ function usuariosVinculados()
|
||||
}
|
||||
}
|
||||
|
||||
include __DIR__ . '/../../views/agencias/usuarios_vinculados.php';
|
||||
// === CONSULTA DE AGENTES ADUANALES ===
|
||||
// Verificar si hay registros en la tabla agente_agencia
|
||||
$sqlCount2 = "SELECT COUNT(*) as total FROM agente_agencia WHERE id_agencia = ?";
|
||||
$stmtCount2 = sqlsrv_query($conn, $sqlCount2, [$id_agencia]);
|
||||
$rowCount2 = sqlsrv_fetch_array($stmtCount2, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
// Verificar registros activos
|
||||
$sqlCountActive2 = "SELECT COUNT(*) as total FROM agente_agencia WHERE id_agencia = ? AND activo = 1";
|
||||
$stmtCountActive2 = sqlsrv_query($conn, $sqlCountActive2, [$id_agencia]);
|
||||
$rowCountActive2 = sqlsrv_fetch_array($stmtCountActive2, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
// Consulta de agentes vinculados ACTIVOS a MI agencia
|
||||
$sql2 = "
|
||||
SELECT
|
||||
aa.*,
|
||||
aa.fecha_asignacion as fecha_vinculacion,
|
||||
u.nombre as importador_nombre,
|
||||
u.tipo_usuario as tipo_usuario_sistema,
|
||||
ig.rfc,
|
||||
ig.telefono,
|
||||
'agente' as tipo_vinculacion
|
||||
FROM agente_agencia aa
|
||||
INNER JOIN usuarios_sistema u ON aa.id_agente = u.id_usuario
|
||||
LEFT JOIN informacion_general ig ON u.id_usuario = ig.id_usuario
|
||||
WHERE aa.id_agencia = ? AND aa.activo = 1
|
||||
ORDER BY aa.fecha_asignacion DESC
|
||||
";
|
||||
$stmt2 = sqlsrv_query($conn, $sql2, [$id_agencia]);
|
||||
|
||||
// DEBUG: Verificar query de agentes
|
||||
if ($stmt2 === false) {
|
||||
die("Error en consulta de agentes: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
// AGREGAR los agentes al array existente (no sobrescribir)
|
||||
if ($stmt2 !== false) {
|
||||
while ($row = sqlsrv_fetch_array($stmt2, SQLSRV_FETCH_ASSOC)) {
|
||||
$vinculados[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
// Opcional: Ordenar todo el array por fecha de vinculación
|
||||
usort($vinculados, function($a, $b) {
|
||||
return $b['fecha_vinculacion'] <=> $a['fecha_vinculacion'];
|
||||
});
|
||||
|
||||
include __DIR__ . '/../../views/vinculaciones/usuarios_vinculados.php';
|
||||
}
|
||||
|
||||
function nuevaVinculacion()
|
||||
@@ -190,7 +234,7 @@ function vincular()
|
||||
}
|
||||
}
|
||||
|
||||
function desvincular()
|
||||
function desvincularAgencia()
|
||||
{
|
||||
// ✅ CORREGIR: Debe ser admin_agencia, no importador
|
||||
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'admin_agencia') {
|
||||
@@ -200,40 +244,51 @@ function desvincular()
|
||||
|
||||
// Verificar que se recibió el ID de la relación
|
||||
$id_relacion = $_GET['id'] ?? null;
|
||||
$tipo = $_GET['tipo'] ?? null;
|
||||
|
||||
if (!$id_relacion || !is_numeric($id_relacion)) {
|
||||
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?error=invalid_id');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Validar que el tipo sea válido
|
||||
if (!in_array($tipo, ['importador', 'agente'])) {
|
||||
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?error=invalid_type');
|
||||
exit;
|
||||
}
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
try {
|
||||
// Iniciar transacción
|
||||
sqlsrv_begin_transaction($conn);
|
||||
|
||||
// 1. Verificar que la relación existe y pertenece a la agencia del admin
|
||||
if ($tipo === 'importador') {
|
||||
|
||||
// Verificar relación de importador
|
||||
$sqlVerificar = "
|
||||
SELECT
|
||||
ia.*,
|
||||
aa.id_administrador,
|
||||
u.nombre as importador_nombre
|
||||
u.nombre as usuario_nombre,
|
||||
u.tipo_usuario
|
||||
FROM importador_agencia ia
|
||||
INNER JOIN agencias_aduanales aa ON ia.id_agencia = aa.id_agencia
|
||||
INNER JOIN usuarios_sistema u ON ia.id_importador = u.id_usuario
|
||||
WHERE ia.id_relacion = ? AND aa.id_administrador = ?
|
||||
WHERE ia.id_relacion = ? AND aa.id_administrador = ? AND u.tipo_usuario = 'importador'
|
||||
";
|
||||
$stmtVerificar = sqlsrv_query($conn, $sqlVerificar, [$id_relacion, $_SESSION['usuario_id']]);
|
||||
$relacion = sqlsrv_fetch_array($stmtVerificar, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
if (!$relacion) {
|
||||
throw new Exception('Relación no encontrada o no tienes permisos para desvincularla');
|
||||
throw new Exception('Relación de importador no encontrada o no tienes permisos para desvincularla');
|
||||
}
|
||||
|
||||
if ($relacion['activo'] == 0) {
|
||||
throw new Exception('Esta relación ya está inactiva');
|
||||
throw new Exception('Esta relación de importador ya está inactiva');
|
||||
}
|
||||
|
||||
// 2. Desactivar la relación (no eliminar, mantener historial)
|
||||
// Desactivar la relación de importador
|
||||
$sqlDesactivar = "
|
||||
UPDATE importador_agencia
|
||||
SET activo = 0,
|
||||
@@ -241,22 +296,56 @@ function desvincular()
|
||||
estado = 'DESVINCULADO'
|
||||
WHERE id_relacion = ?
|
||||
";
|
||||
|
||||
} else if ($tipo === 'agente') {
|
||||
// Verificar relación de agente aduanal
|
||||
$sqlVerificar = "
|
||||
SELECT
|
||||
aa.*,
|
||||
ag.id_administrador,
|
||||
u.nombre as usuario_nombre,
|
||||
u.tipo_usuario
|
||||
FROM agente_agencia aa
|
||||
INNER JOIN agencias_aduanales ag ON aa.id_agencia = ag.id_agencia
|
||||
INNER JOIN usuarios_sistema u ON aa.id_agente = u.id_usuario
|
||||
WHERE aa.id_relacion = ? AND ag.id_administrador = ? AND u.tipo_usuario = 'agente_aduanal'
|
||||
";
|
||||
$stmtVerificar = sqlsrv_query($conn, $sqlVerificar, [$id_relacion, $_SESSION['usuario_id']]);
|
||||
$relacion = sqlsrv_fetch_array($stmtVerificar, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
if (!$relacion) {
|
||||
throw new Exception('Relación de agente no encontrada o no tienes permisos para desvincularla');
|
||||
}
|
||||
|
||||
if ($relacion['activo'] == 0) {
|
||||
throw new Exception('Esta relación de agente ya está inactiva');
|
||||
}
|
||||
|
||||
// Desactivar la relación de agente
|
||||
$sqlDesactivar = "
|
||||
UPDATE agente_agencia
|
||||
SET activo = 0,
|
||||
fecha_desvinculacion = GETDATE()
|
||||
WHERE id_relacion = ?
|
||||
";
|
||||
}
|
||||
|
||||
$stmtDesactivar = sqlsrv_query($conn, $sqlDesactivar, [$id_relacion]);
|
||||
|
||||
if (!$stmtDesactivar) {
|
||||
throw new Exception('Error al desactivar la relación');
|
||||
throw new Exception('Error al desactivar la relación de ' . $tipo);
|
||||
}
|
||||
|
||||
// Confirmar transacción
|
||||
sqlsrv_commit($conn);
|
||||
|
||||
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?success=unlinked');
|
||||
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?success=unlinked&tipo=' . $tipo);
|
||||
exit;
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Revertir transacción en caso de error
|
||||
sqlsrv_rollback($conn);
|
||||
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?error=unlinked_failed');
|
||||
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?error=unlinked_failed&message=' . urlencode($e->getMessage()));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -365,7 +454,7 @@ function solicitudesVinculacion()
|
||||
}
|
||||
}
|
||||
|
||||
include __DIR__ . '/../../views/agencias/solicitudes_vinculacion.php';
|
||||
include __DIR__ . '/../../views/vinculaciones/solicitudes_vinculacion.php';
|
||||
}
|
||||
|
||||
function aprobarVinculacion()
|
||||
@@ -552,97 +641,3 @@ function denegarVinculacion()
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function desvincularUsuario()
|
||||
{
|
||||
// ✅ CORREGIR: Debe ser admin_agencia, no importador
|
||||
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'importador') {
|
||||
header('Location: /IMPORTADORES/login');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Verificar que se recibió el ID de la relación
|
||||
$id_relacion = $_GET['id'] ?? null;
|
||||
if (!$id_relacion || !is_numeric($id_relacion)) {
|
||||
header('Location: /IMPORTADORES/vinculaciones/vinculacionesUsuario?error=invalid_id');
|
||||
exit;
|
||||
}
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
try {
|
||||
// Iniciar transacción
|
||||
sqlsrv_begin_transaction($conn);
|
||||
|
||||
// 1. Verificar que la relación existe y pertenece a la agencia del admin
|
||||
$sqlVerificar = "
|
||||
SELECT
|
||||
ia.*,
|
||||
u.id_usuario, u.nombre as importador_nombre, aa.nombre_agencia
|
||||
FROM importador_agencia ia
|
||||
INNER JOIN usuarios_sistema u ON ia.id_importador = u.id_usuario
|
||||
INNER JOIN agencias_aduanales aa ON ia.id_agencia = aa.id_agencia
|
||||
WHERE ia.id_relacion = ? AND ia.id_importador = ?
|
||||
";
|
||||
$stmtVerificar = sqlsrv_query($conn, $sqlVerificar, [$id_relacion, $_SESSION['usuario_id']]);
|
||||
|
||||
// Verificar si la consulta fue exitosa
|
||||
if ($stmtVerificar === false) {
|
||||
$errors = sqlsrv_errors();
|
||||
error_log("Error en consulta verificar: " . print_r($errors, true));
|
||||
throw new Exception('Error en la consulta de verificación');
|
||||
}
|
||||
|
||||
$relacion = sqlsrv_fetch_array($stmtVerificar, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
if (!$relacion) {
|
||||
throw new Exception('Relación no encontrada o no tienes permisos para desvincularla');
|
||||
}
|
||||
|
||||
if ($relacion['activo'] == 0) {
|
||||
throw new Exception('Esta relación ya está inactiva');
|
||||
}
|
||||
|
||||
// 2. Desactivar la relación (no eliminar, mantener historial)
|
||||
$sqlDesactivar = "
|
||||
UPDATE importador_agencia
|
||||
SET activo = 0,
|
||||
fecha_desvinculacion = GETDATE(),
|
||||
estado = 'DESVINCULADO'
|
||||
WHERE id_relacion = ? AND id_importador = ?
|
||||
";
|
||||
|
||||
$stmtDesactivar = sqlsrv_query($conn, $sqlDesactivar, [$id_relacion, $_SESSION['usuario_id']]);
|
||||
|
||||
if ($stmtDesactivar === false) {
|
||||
$errors = sqlsrv_errors();
|
||||
error_log("Error en actualización: " . print_r($errors, true));
|
||||
throw new Exception('Error al desactivar la relación');
|
||||
}
|
||||
|
||||
// Verificar que se actualizó al menos una fila
|
||||
$filasAfectadas = sqlsrv_rows_affected($stmtDesactivar);
|
||||
if ($filasAfectadas === 0) {
|
||||
throw new Exception('No se pudo actualizar la relación');
|
||||
}
|
||||
|
||||
// Limpiar statements
|
||||
sqlsrv_free_stmt($stmtVerificar);
|
||||
sqlsrv_free_stmt($stmtDesactivar);
|
||||
|
||||
// Confirmar transacción
|
||||
sqlsrv_commit($conn);
|
||||
sqlsrv_close($conn);
|
||||
|
||||
header('Location: /IMPORTADORES/vinculaciones/vinculacionesUsuario?success=unlinked');
|
||||
exit;
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Revertir transacción en caso de error
|
||||
sqlsrv_rollback($conn);
|
||||
sqlsrv_close($conn);
|
||||
|
||||
header('Location: /IMPORTADORES/vinculaciones/vinculacionesUsuario?error=unlinked_failed&msg=' . urlencode($e->getMessage()));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -73,10 +73,6 @@
|
||||
</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>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>Dashboard | Administrador</title>
|
||||
<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://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>
|
||||
@@ -39,7 +38,7 @@
|
||||
|
||||
<!-- 📄 CONTENIDO -->
|
||||
<div class="content">
|
||||
<h4 class="mb-4">👥 Alta de Usuarios</h4>
|
||||
<h3 class="mb-4">👥 Alta de Usuarios</h3>
|
||||
<!-- FORMULARIO -->
|
||||
<div class="card p-4 mb-4 shadow-sm bg-white">
|
||||
<form action="/IMPORTADORES/administrador/guardar_usuario" method="POST">
|
||||
@@ -71,7 +70,7 @@
|
||||
<h4 class="mb-4">✅ Usuarios Activos</h4>
|
||||
<div class="card p-3 shadow-sm">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover align-middle" id="tabla-activos">
|
||||
<table class="table table-striped table-hover align-middle" id="tabla-usuarios-activos">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
@@ -108,7 +107,7 @@
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#tabla-activos').DataTable({
|
||||
$('#tabla-usuarios-activos').DataTable({
|
||||
order: [],
|
||||
language: {
|
||||
url: 'https://cdn.datatables.net/plug-ins/1.13.4/i18n/es-ES.json'
|
||||
|
||||
@@ -48,9 +48,9 @@
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-primary">Aprobar agencias</h5>
|
||||
<p>Aprueba las agencias que solicitaron un registro.</p>
|
||||
<a href="/IMPORTADORES/sistemas/aprobarAgencias"
|
||||
<a href="/IMPORTADORES/administrador/aprobarAgencias"
|
||||
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/sistemas/aprobarAgencias' ? 'active' : '' ?>">
|
||||
Ver bitácora</a>
|
||||
Ver agencias solicitantes</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -58,9 +58,9 @@
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-success">Alta de agencias</h5>
|
||||
<p>Da de alta manualmente una agencia.</p>
|
||||
<a href="/IMPORTADORES/sistemas/altaAgencias"
|
||||
<a href="/IMPORTADORES/administrador/altaAgencias"
|
||||
class="btn btn-success btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/sistemas/altaAgencias' ? 'active' : '' ?>">
|
||||
Nuevo agente
|
||||
Nueva agencia
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -69,9 +69,9 @@
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-info">Aprobar de usuarios</h5>
|
||||
<p>Aprueba los usuarios que solicitaron un registro.</p>
|
||||
<a href="/IMPORTADORES/sistemas/aprobarUsuarios"
|
||||
<a href="/IMPORTADORES/administrador/aprobarUsuarios"
|
||||
class="btn btn-info btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/sistemas/aprobarUsuarios' ? 'active' : '' ?>">
|
||||
Ver usuarios
|
||||
Ver usuarios solicitantes
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -80,9 +80,9 @@
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-indigo">Alta de usuarios</h5>
|
||||
<p>Da de alta manualmente a un usuario.</p>
|
||||
<a href="/IMPORTADORES/sistemas/altaUsuarios"
|
||||
<a href="/IMPORTADORES/administrador/altaUsuarios"
|
||||
class="btn btn-indigo btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/sistemas/altaUsuarios' ? 'active' : '' ?>">
|
||||
Nuevo agente
|
||||
Nuevo usuario
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -91,7 +91,7 @@
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-warning">Configuración</h5>
|
||||
<p>Administra los datos de tu agencia.</p>
|
||||
<a href="/IMPORTADORES/sistemas/configuracion"
|
||||
<a href="/IMPORTADORES/administrador/configuracion"
|
||||
class="btn btn-warning btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/sistemas/configuracion' ? 'active' : '' ?>">
|
||||
Configurar
|
||||
</a>
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
<!-- 📄 CONTENIDO -->
|
||||
<div class="content px-4">
|
||||
<h3 class="mb-4">Administración de Agentes</h3>
|
||||
|
||||
<!-- FORMULARIO -->
|
||||
<form action="/IMPORTADORES/agencias/guardarAgente" method="POST" class="card p-4 mb-5 shadow-sm">
|
||||
<div class="card p-4 mb-4 shadow-sm bg-white">
|
||||
<form action="/IMPORTADORES/agencias/guardarAgente" method="POST">
|
||||
<h5 class="mb-3">➕ Nuevo Agente</h5>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
@@ -65,6 +65,60 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h4 class="mb-4">✅ Agentes Activos</h4>
|
||||
<div class="card p-3 shadow-sm">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover align-middle" id="tabla-agentes-activos">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Nombre</th>
|
||||
<th>Correo</th>
|
||||
<th>Tipo</th>
|
||||
<th>Creado por</th>
|
||||
<th>Fecha Registro</th>
|
||||
<th>Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($agentes as $a): ?>
|
||||
<tr>
|
||||
<td><?= $a['id_usuario'] ?></td>
|
||||
<td><?= htmlspecialchars(decrypt($a['nombre'])) ?></td>
|
||||
<td><?= htmlspecialchars(decrypt($a['email'])) ?></td>
|
||||
<td><?= htmlspecialchars($a['tipo_usuario_sistema']) ?></td>
|
||||
<td><?= htmlspecialchars($a['creado_por']) ?></td>
|
||||
<td><?= isset($a['creado_en']) && $a['creado_en'] instanceof DateTime ? $a['creado_en']->format('Y-m-d H:i') : '' ?></td>
|
||||
<td>
|
||||
<?php if (in_array($a['tipo_usuario_sistema'], ['agente_aduanal'])): ?>
|
||||
<a href="/IMPORTADORES/vinculaciones/desvincularAgencia?id=<?= $a['id_relacion'] ?>&tipo=<?= $a['tipo_vinculacion'] ?>"
|
||||
class="btn btn-sm btn-danger"
|
||||
onclick="return confirm('¿Está seguro de que desea desvincular este usuario?')">
|
||||
Desvincular
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span class="text-muted small">N/A</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#tabla-agentes-activos').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'] === 'created'): ?>
|
||||
|
||||
@@ -43,10 +43,10 @@ include __DIR__ . '/../partials/sidebar_agente.php';
|
||||
<div class="row g-4">
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-primary">Importadores activos</h5>
|
||||
<h5 class="text-primary">Importadores vinculados</h5>
|
||||
<p>Consulta los que ya fueron autorizados.</p>
|
||||
<a href="/IMPORTADORES/agentes/activos"
|
||||
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/activos' ? 'active' : '' ?>">
|
||||
<a href="/IMPORTADORES/agentes/vinculados"
|
||||
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/vinculados' ? 'active' : '' ?>">
|
||||
Ver importadores
|
||||
</a>
|
||||
</div>
|
||||
@@ -63,17 +63,6 @@ include __DIR__ . '/../partials/sidebar_agente.php';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-info">Bitácora del sistema</h5>
|
||||
<p>Revisa los accesos y acciones recientes.</p>
|
||||
<a href="/IMPORTADORES/agentes/bitacora"
|
||||
class="btn btn-info btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/bitacora' ? 'active' : '' ?>">
|
||||
Ver bitácora
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-orange">Locaciones</h5>
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php include __DIR__ . '/../partials/sidebar_agente.php'; ?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Dashboard | Agente Aduanal</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>
|
||||
<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; }
|
||||
.sidebar .nav-link { font-weight: normal; color: white; transition: all 0.3s ease; }
|
||||
.sidebar .nav-link:hover,
|
||||
.sidebar .nav-link.active { background-color: #495057; color: #fff; }
|
||||
.content { margin-top: 56px; padding: 40px 20px; position: relative; z-index: 1; background-color: #f4f6f9; transition: margin-left 0.3s ease; }
|
||||
.navbar { position: fixed; top: 0; width: 100%; z-index: 1050; }
|
||||
/* A partir de dispositivos medianos (>=768px), deja espacio lateral */
|
||||
@media (min-width: 768px) { .content { margin-left: 250px; /* Ancho del sidebar */ } }
|
||||
/* En móviles, sin margen lateral */
|
||||
@media (max-width: 767.98px) {
|
||||
.content { margin-left: 0; }
|
||||
.sidebar .nav-link { font-weight: normal; color: #343a40; background-color: transparent; }
|
||||
.sidebar .nav-link:hover,
|
||||
.sidebar .nav-link.active { background-color: #e9ecef; color: #212529; }
|
||||
}
|
||||
.card { border-radius: 12px; }
|
||||
.table thead th { background: #343a40; color: #fff; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="content">
|
||||
<h4>📥 Solicitudes Pendientes</h4>
|
||||
|
||||
<div class="card p-3 shadow-sm">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="tabla-pendientes">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Empresa</th>
|
||||
<th>RFC</th>
|
||||
<th>Correo</th>
|
||||
<th>Teléfono</th>
|
||||
<th>Fecha</th>
|
||||
<th>Archivo SAT</th>
|
||||
<th>Acción</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($solicitudes as $s): ?>
|
||||
<tr>
|
||||
<td><?= $s['request_id'] ?></td>
|
||||
<td><?= htmlspecialchars(decrypt($s['company_name'])) ?></td>
|
||||
<td><?= htmlspecialchars(decrypt($s['rfc'])) ?></td>
|
||||
<td><?= htmlspecialchars($s['email']) ?></td>
|
||||
<td><?= htmlspecialchars($s['phone']) ?></td>
|
||||
<td><?= $s['request_date'] ? $s['request_date']->format('Y-m-d H:i') : '' ?></td>
|
||||
<td>
|
||||
<?php if (!empty($s['opinion_file'])): ?>
|
||||
<a href="/IMPORTADORES/ver_opinion.php?file=<?= urlencode($s['opinion_file']) ?>" target="_blank" class="btn btn-sm btn-outline-secondary">Ver PDF</a>
|
||||
<?php else: ?>
|
||||
<span class="text-muted">No adjunto</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/IMPORTADORES/agentes/aprobar_solicitud?id=<?= $s['request_id'] ?>" class="btn btn-sm btn-success">Aprobar</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php include __DIR__ . '/../partials/sidebar_configuracion.php'; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Dashboard | Configuración</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>
|
||||
<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; }
|
||||
.sidebar .nav-link { font-weight: bold; color: white; transition: all 0.3s ease; }
|
||||
.sidebar .nav-link:hover,
|
||||
.sidebar .nav-link.active { background-color: #495057; color: #fff; }
|
||||
.content { margin-top: 56px; padding: 40px 20px; position: relative; z-index: 1; background-color: #f4f6f9; transition: margin-left 0.3s ease; }
|
||||
.navbar { position: fixed; top: 0; width: 100%; z-index: 1050; }
|
||||
/* A partir de dispositivos medianos (>=768px), deja espacio lateral */
|
||||
@media (min-width: 768px) { .content { margin-left: 250px; /* Ancho del sidebar */ } }
|
||||
/* En móviles, sin margen lateral */
|
||||
@media (max-width: 767.98px) {
|
||||
.content { margin-left: 0; }
|
||||
.sidebar .nav-link { font-weight: normal; color: #343a40; background-color: transparent; }
|
||||
.sidebar .nav-link:hover,
|
||||
.sidebar .nav-link.active { background-color: #e9ecef; color: #212529; }
|
||||
}
|
||||
.card { border-radius: 12px; }
|
||||
table.dataTable thead th { background: #343a40; color: #fff; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,30 +1,4 @@
|
||||
<?php
|
||||
// Aseguramos que el usuario esté autenticado
|
||||
if (!isset($_SESSION['usuario_id'])) {
|
||||
header('Location: /IMPORTADORES/login');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Determinar el tipo de usuario
|
||||
$tipoUsuario = $_SESSION['tipo_usuario'] ?? 'importador';
|
||||
|
||||
// Incluir el sidebar correspondiente
|
||||
switch ($tipoUsuario) {
|
||||
case 'super_admin':
|
||||
include __DIR__ . '/../partials/sidebar_administrador.php';
|
||||
break;
|
||||
case 'admin_agencia':
|
||||
include __DIR__ . '/../partials/sidebar_agencia.php';
|
||||
break;
|
||||
case 'agente_aduanal':
|
||||
include __DIR__ . '/../partials/sidebar_agente.php';
|
||||
break;
|
||||
case 'importador':
|
||||
default:
|
||||
include __DIR__ . '/../partials/sidebar_importador.php';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<?php include __DIR__ . '/../partials/sidebar_configuracion.php'; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php include __DIR__ . '/../partials/sidebar_administrador.php'; ?>
|
||||
<?php include __DIR__ . '/../partials/sidebar_configuracion.php'; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php include __DIR__ . '/../partials/sidebar_configuracion.php'; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Dashboard | Configuración</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>
|
||||
<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; }
|
||||
.sidebar .nav-link { font-weight: bold; color: white; transition: all 0.3s ease; }
|
||||
.sidebar .nav-link:hover,
|
||||
.sidebar .nav-link.active { background-color: #495057; color: #fff; }
|
||||
.content { margin-top: 56px; padding: 40px 20px; position: relative; z-index: 1; background-color: #f4f6f9; transition: margin-left 0.3s ease; }
|
||||
.navbar { position: fixed; top: 0; width: 100%; z-index: 1050; }
|
||||
/* A partir de dispositivos medianos (>=768px), deja espacio lateral */
|
||||
@media (min-width: 768px) { .content { margin-left: 250px; /* Ancho del sidebar */ } }
|
||||
/* En móviles, sin margen lateral */
|
||||
@media (max-width: 767.98px) {
|
||||
.content { margin-left: 0; }
|
||||
.sidebar .nav-link { font-weight: normal; color: #343a40; background-color: transparent; }
|
||||
.sidebar .nav-link:hover,
|
||||
.sidebar .nav-link.active { background-color: #e9ecef; color: #212529; }
|
||||
}
|
||||
.card { border-radius: 12px; }
|
||||
table.dataTable thead th { background: #343a40; color: #fff; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -47,30 +47,30 @@
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-primary">Registro de usuarios</h5>
|
||||
<h5 class="text-success">Registro de usuarios</h5>
|
||||
<p>Ver registros de los usuarios.</p>
|
||||
<a href="/IMPORTADORES/bitacoras/usuarios"
|
||||
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/usuarios' ? 'active' : '' ?>">
|
||||
class="btn btn-success btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/usuarios' ? 'active' : '' ?>">
|
||||
Ver registro de usuarios
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-primary">Registro de agencias</h5>
|
||||
<h5 class="text-info">Registro de agencias</h5>
|
||||
<p>Ver registros de las agencias.</p>
|
||||
<a href="/IMPORTADORES/bitacoras/agencias"
|
||||
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/agencias' ? 'active' : '' ?>">
|
||||
class="btn btn-info btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/agencias' ? 'active' : '' ?>">
|
||||
Ver registro de agencias
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-primary">Mi actividad</h5>
|
||||
<h5 class="text-warning">Mi actividad</h5>
|
||||
<p>Ver mi actividad en la plataforma.</p>
|
||||
<a href="/IMPORTADORES/bitacoras/miAcceso"
|
||||
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/miAcceso' ? 'active' : '' ?>">
|
||||
class="btn btn-warning btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/miAcceso' ? 'active' : '' ?>">
|
||||
Ver mis accesos
|
||||
</a>
|
||||
</div>
|
||||
@@ -90,20 +90,20 @@
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-primary">Registro de vinculaciones</h5>
|
||||
<h5 class="text-success">Registro de vinculaciones</h5>
|
||||
<p>Ver las vinculaciones de mi agencia.</p>
|
||||
<a href="/IMPORTADORES/bitacoras/vinculaciones"
|
||||
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/vinculaciones' ? 'active' : '' ?>">
|
||||
class="btn btn-success btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/vinculaciones' ? 'active' : '' ?>">
|
||||
Ver actividad
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-primary">Mi actividad</h5>
|
||||
<h5 class="text-info">Mi actividad</h5>
|
||||
<p>Ver mi actividad en la plataforma.</p>
|
||||
<a href="/IMPORTADORES/bitacoras/miAcceso"
|
||||
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/miAcceso' ? 'active' : '' ?>">
|
||||
class="btn btn-info btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/miAcceso' ? 'active' : '' ?>">
|
||||
Ver mis accesos
|
||||
</a>
|
||||
</div>
|
||||
@@ -123,10 +123,10 @@
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-primary">Mi actividad</h5>
|
||||
<h5 class="text-success">Mi actividad</h5>
|
||||
<p>Ver mi actividad en la plataforma.</p>
|
||||
<a href="/IMPORTADORES/bitacoras/miAcceso"
|
||||
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/miAcceso' ? 'active' : '' ?>">
|
||||
class="btn btn-success btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/miAcceso' ? 'active' : '' ?>">
|
||||
Ver mis accesos
|
||||
</a>
|
||||
</div>
|
||||
@@ -146,10 +146,10 @@
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm p-3">
|
||||
<h5 class="text-primary">Mi actividad</h5>
|
||||
<h5 class="text-success">Mi actividad</h5>
|
||||
<p>Ver mi actividad en la plataforma.</p>
|
||||
<a href="/IMPORTADORES/bitacoras/miAcceso"
|
||||
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/miAcceso' ? 'active' : '' ?>">
|
||||
class="btn btn-success btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/miAcceso' ? 'active' : '' ?>">
|
||||
Ver mis accesos
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php include __DIR__ . '/../partials/sidebar_configuracion.php'; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Dashboard | Configuración</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>
|
||||
<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; }
|
||||
.sidebar .nav-link { font-weight: bold; color: white; transition: all 0.3s ease; }
|
||||
.sidebar .nav-link:hover,
|
||||
.sidebar .nav-link.active { background-color: #495057; color: #fff; }
|
||||
.content { margin-top: 56px; padding: 40px 20px; position: relative; z-index: 1; background-color: #f4f6f9; transition: margin-left 0.3s ease; }
|
||||
.navbar { position: fixed; top: 0; width: 100%; z-index: 1050; }
|
||||
/* A partir de dispositivos medianos (>=768px), deja espacio lateral */
|
||||
@media (min-width: 768px) { .content { margin-left: 250px; /* Ancho del sidebar */ } }
|
||||
/* En móviles, sin margen lateral */
|
||||
@media (max-width: 767.98px) {
|
||||
.content { margin-left: 0; }
|
||||
.sidebar .nav-link { font-weight: normal; color: #343a40; background-color: transparent; }
|
||||
.sidebar .nav-link:hover,
|
||||
.sidebar .nav-link.active { background-color: #e9ecef; color: #212529; }
|
||||
}
|
||||
.card { border-radius: 12px; }
|
||||
table.dataTable thead th { background: #343a40; color: #fff; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php include __DIR__ . '/../partials/sidebar_configuracion.php'; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Dashboard | Configuración</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>
|
||||
<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; }
|
||||
.sidebar .nav-link { font-weight: bold; color: white; transition: all 0.3s ease; }
|
||||
.sidebar .nav-link:hover,
|
||||
.sidebar .nav-link.active { background-color: #495057; color: #fff; }
|
||||
.content { margin-top: 56px; padding: 40px 20px; position: relative; z-index: 1; background-color: #f4f6f9; transition: margin-left 0.3s ease; }
|
||||
.navbar { position: fixed; top: 0; width: 100%; z-index: 1050; }
|
||||
/* A partir de dispositivos medianos (>=768px), deja espacio lateral */
|
||||
@media (min-width: 768px) { .content { margin-left: 250px; /* Ancho del sidebar */ } }
|
||||
/* En móviles, sin margen lateral */
|
||||
@media (max-width: 767.98px) {
|
||||
.content { margin-left: 0; }
|
||||
.sidebar .nav-link { font-weight: normal; color: #343a40; background-color: transparent; }
|
||||
.sidebar .nav-link:hover,
|
||||
.sidebar .nav-link.active { background-color: #e9ecef; color: #212529; }
|
||||
}
|
||||
.card { border-radius: 12px; }
|
||||
table.dataTable thead th { background: #343a40; color: #fff; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -49,8 +49,8 @@
|
||||
</a>
|
||||
|
||||
<!-- USUARIOS ACTIVOS -->
|
||||
<a href="/IMPORTADORES/vinculaciones/usuariosVinculados"
|
||||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/IMPORTADORES/vinculaciones/usuariosVinculados') ? 'active' : '' ?>">
|
||||
<a href="/IMPORTADORES/vinculaciones/vinculacionesAgencia"
|
||||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/IMPORTADORES/vinculaciones/vinculacionesAgencia') ? 'active' : '' ?>">
|
||||
👥 Usuarios Vinculados
|
||||
</a>
|
||||
|
||||
@@ -90,8 +90,8 @@
|
||||
</a>
|
||||
|
||||
<!-- USUARIOS ACTIVOS -->
|
||||
<a href="/IMPORTADORES/vinculaciones/usuariosVinculados"
|
||||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/IMPORTADORES/vinculaciones/usuariosVinculados') ? 'active' : '' ?>">
|
||||
<a href="/IMPORTADORES/vinculaciones/vinculacionesAgencia"
|
||||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/IMPORTADORES/vinculaciones/vinculacionesAgencia') ? 'active' : '' ?>">
|
||||
✅ Usuarios Vinculados
|
||||
</a>
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
</a>
|
||||
|
||||
<!-- IMPORTADORES VINCULADOS -->
|
||||
<a href="/IMPORTADORES/agentes/activos"
|
||||
class="nav-link px-3 py-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/activos' ? 'active' : '' ?>">
|
||||
<a href="/IMPORTADORES/agentes/vinculados"
|
||||
class="nav-link px-3 py-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/vinculados' ? 'active' : '' ?>">
|
||||
🔗 Vinculados
|
||||
</a>
|
||||
|
||||
@@ -142,17 +142,42 @@
|
||||
🏠 Inicio
|
||||
</a>
|
||||
|
||||
<!-- IMPORTADORES ACTIVOS -->
|
||||
<a href="/IMPORTADORES/agentes/activos"
|
||||
class="nav-link px-3 py-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/activos' ? 'active' : '' ?>">
|
||||
✅ Importadores Activos
|
||||
<!-- IMPORTADORES VINCULADOS -->
|
||||
<a href="/IMPORTADORES/agentes/vinculados"
|
||||
class="nav-link px-3 py-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/vinculados' ? 'active' : '' ?>">
|
||||
🔗 Vinculados
|
||||
</a>
|
||||
|
||||
<!-- BITÁCORA -->
|
||||
<a href="/IMPORTADORES/agentes/bitacora"
|
||||
class="nav-link px-3 py-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/bitacora' ? 'active' : '' ?>">
|
||||
🕓 Bitácora
|
||||
<!-- Patentes -->
|
||||
<?php if ($esVistaPatente): ?>
|
||||
<?php $enDashboardPatente = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/patente/dashboard'; ?>
|
||||
<a class="nav-link px-3 py-2 d-flex justify-content-between align-items-center <?= $esVistaPatente ? 'active' : '' ?>"
|
||||
href="<?= $enDashboardPatente ? '#submenuAgentesAduanales' : 'IMPORTADORES/patente/dashboard' ?>"
|
||||
<?= $enDashboardPatente ? 'data-bs-toggle="collapse"' : '' ?>
|
||||
role="button" aria-expanded="true" aria-controls="submenuAgentesAduanales"
|
||||
onclick="<?= $enDashboardPatente ? '' : 'event.preventDefault(); window.location.href = \'/IMPORTADORES/patente/dashboard\';' ?>">
|
||||
📑 Patentes
|
||||
<span class="badge bg-secondary">2</span>
|
||||
</a>
|
||||
<div class="collapse show" id="submenuAgentesAduanales">
|
||||
<nav class="nav flex-column ms-3">
|
||||
<a href="/IMPORTADORES/patente/lista"
|
||||
class="nav-link px-3 py-1 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/patente/lista' ? 'active' : '' ?>">
|
||||
• Ver Patentes
|
||||
</a>
|
||||
<a href="/IMPORTADORES/patente/alta"
|
||||
class="nav-link px-3 py-1 <?= str_contains($_SERVER['REQUEST_URI'], '/IMPORTADORES/patente/alta') ? 'active' : '' ?>">
|
||||
• Nueva Patente
|
||||
</a>
|
||||
</nav>
|
||||
</div>
|
||||
<?php elseif ($esVistaAgentes || $esVistaLocaciones): ?>
|
||||
<a href="/IMPORTADORES/patente/dashboard"
|
||||
class="nav-link px-3 py-2 d-flex justify-content-between align-items-center">
|
||||
📑 Patentes
|
||||
<span class="badge bg-secondary">2</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- LOCACIONES -->
|
||||
<?php if ($esVistaLocaciones): ?>
|
||||
@@ -185,37 +210,6 @@
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Patentes -->
|
||||
<?php if ($esVistaPatente): ?>
|
||||
<?php $enDashboardPatente = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/patente/dashboard'; ?>
|
||||
<a class="nav-link px-3 py-2 d-flex justify-content-between align-items-center <?= $esVistaPatente ? 'active' : '' ?>"
|
||||
href="<?= $enDashboardPatente ? '#submenuAgentesAduanales' : 'IMPORTADORES/patente/dashboard' ?>"
|
||||
<?= $enDashboardPatente ? 'data-bs-toggle="collapse"' : '' ?>
|
||||
role="button" aria-expanded="true" aria-controls="submenuAgentesAduanales"
|
||||
onclick="<?= $enDashboardPatente ? '' : 'event.preventDefault(); window.location.href = \'/IMPORTADORES/patente/dashboard\';' ?>">
|
||||
📑 Patentes
|
||||
<span class="badge bg-secondary">2</span>
|
||||
</a>
|
||||
<div class="collapse show" id="submenuAgentesAduanales">
|
||||
<nav class="nav flex-column ms-3">
|
||||
<a href="/IMPORTADORES/patente/lista"
|
||||
class="nav-link px-3 py-1 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/patente/lista' ? 'active' : '' ?>">
|
||||
• Ver Patentes
|
||||
</a>
|
||||
<a href="/IMPORTADORES/patente/alta"
|
||||
class="nav-link px-3 py-1 <?= str_contains($_SERVER['REQUEST_URI'], '/IMPORTADORES/patente/alta') ? 'active' : '' ?>">
|
||||
• Nueva Patentes
|
||||
</a>
|
||||
</nav>
|
||||
</div>
|
||||
<?php elseif ($esVistaAgentes || $esVistaLocaciones): ?>
|
||||
<a href="/IMPORTADORES/patente/dashboard"
|
||||
class="nav-link px-3 py-2 d-flex justify-content-between align-items-center">
|
||||
📑 Patentes
|
||||
<span class="badge bg-secondary">2</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- CONFIGURACIÓN -->
|
||||
<a href="/IMPORTADORES/configuracion"
|
||||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/configuracion') ? 'active' : '' ?>">
|
||||
|
||||
@@ -5,7 +5,11 @@
|
||||
<title>Dashboard | Agente Aduanal</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; }
|
||||
@@ -31,33 +35,31 @@
|
||||
<body>
|
||||
|
||||
<div class="content">
|
||||
<h4>✅ Importadores Activos</h4>
|
||||
<h4>✅ Importadores Vinculados</h4>
|
||||
|
||||
<div class="card p-3 shadow-sm">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="tabla-activos">
|
||||
<table class="table table-striped" id="tabla-importadores-vinculados">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Nombre</th>
|
||||
<th>Correo</th>
|
||||
<th>Fecha Registro</th>
|
||||
<th>RFC</th>
|
||||
<th>Teléfono</th>
|
||||
<th>Fecha de Vinculación</th>
|
||||
<th>Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($importadores as $i): ?>
|
||||
<?php foreach ($vinculados as $v): ?>
|
||||
<tr>
|
||||
<td><?= $i['id_usuario'] ?></td>
|
||||
<td><?= htmlspecialchars(($i['nombre'])) ?></td>
|
||||
<td><?= htmlspecialchars($i['email']) ?></td>
|
||||
<td><?= isset($i['creado_en']) && $i['creado_en'] instanceof DateTime ? $i['creado_en']->format('Y-m-d H:i') : '' ?></td>
|
||||
<td><?= $v['id_importador'] ?></td>
|
||||
<td><?= htmlspecialchars(decrypt($v['importador_nombre'])) ?></td>
|
||||
<td><?= htmlspecialchars($v['rfc']) ?></td>
|
||||
<td><?= htmlspecialchars($v['telefono']) ?></td>
|
||||
<td><?= isset($v['fecha_vinculacion']) && $v['fecha_vinculacion'] instanceof DateTime ? $v['fecha_vinculacion']->format('Y-m-d H:i') : '' ?></td>
|
||||
<td>
|
||||
<?php if (isset($i['activo']) && $i['activo'] == 1): ?>
|
||||
<a href="/IMPORTADORES/agentes/toggle_estado?id=<?= $i['id_usuario'] ?>&success=1" class="btn btn-sm btn-danger">Suspender</a>
|
||||
<?php else: ?>
|
||||
<a href="/IMPORTADORES/agentes/toggle_estado?id=<?= $i['id_usuario'] ?>&success=1" class="btn btn-sm btn-success">Activar</a>
|
||||
<?php endif; ?>
|
||||
<a href="/IMPORTADORES/agentes/desvincularAgente?id=<?= $v['id_relacion'] ?>" class="btn btn-sm btn-danger">Desvincular</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
@@ -67,14 +69,34 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#tabla-importadores-vinculados').DataTable({
|
||||
order: [],
|
||||
language: {
|
||||
url: 'https://cdn.datatables.net/plug-ins/1.13.4/i18n/es-ES.json'
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php if (isset($_GET['success'])): ?>
|
||||
<script>
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Estado actualizado',
|
||||
text: 'El estado del usuario se ha actualizado correctamente.',
|
||||
confirmButtonColor: '#198754'
|
||||
});
|
||||
<?php if ($_GET['success'] === 'unlinked'): ?>
|
||||
Swal.fire({ icon: 'success', title: 'Usuario desvinculado',
|
||||
text: 'El usuario se ha desvinculado correctamente.',
|
||||
confirmButtonColor: '#198754' });
|
||||
<?php endif; ?>
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($_GET['error'])): ?>
|
||||
<script>
|
||||
<?php if ($_GET['error'] === 'unlinked_failed'): ?>
|
||||
Swal.fire({ icon: 'error', title: 'Desvinculación fallida', text: 'No se ha podido desvincular el usuario.', confirmButtonColor: '#dc3545' });
|
||||
<?php elseif ($_GET['error'] === 'invalid_id'): ?>
|
||||
Swal.fire({ icon: 'error', title: 'ID inválido', text: 'El identificador de la relación no es válido.', confirmButtonColor: '#dc3545' });
|
||||
<?php endif; ?>
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -75,10 +75,6 @@
|
||||
</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>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php include __DIR__ . '/../partials/sidebar_agencia.php'; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Dashboard | Agencia Aduanal</title>
|
||||
@@ -45,6 +46,8 @@
|
||||
<th>Nombre</th>
|
||||
<th>RFC</th>
|
||||
<th>Teléfono</th>
|
||||
<th>Usuario</th>
|
||||
<th>Vinculación</th>
|
||||
<th>Fecha de Vinculación</th>
|
||||
<th>Acciones</th>
|
||||
</tr>
|
||||
@@ -57,9 +60,19 @@
|
||||
<td><?= htmlspecialchars(decrypt($v['importador_nombre'] ?? '')) ?></td>
|
||||
<td><?= htmlspecialchars($v['rfc'] ?? '') ?></td>
|
||||
<td><?= htmlspecialchars($v['telefono'] ?? '') ?></td>
|
||||
<td><?= htmlspecialchars($v['tipo_usuario_sistema'] ?? '') ?></td>
|
||||
<td><?= htmlspecialchars(ucfirst($v['tipo_vinculacion'] ?? '')) ?></td>
|
||||
<td><?= !empty($v['fecha_vinculacion']) ? $v['fecha_vinculacion']->format('Y-m-d H:i') : '' ?></td>
|
||||
<td>
|
||||
<a href="/IMPORTADORES/vinculaciones/desvincular?id=<?= $v['id_relacion'] ?>" class="btn btn-sm btn-danger">Desvincular</a>
|
||||
<?php if (in_array($v['tipo_usuario_sistema'], ['importador', 'agente_aduanal'])): ?>
|
||||
<a href="/IMPORTADORES/vinculaciones/desvincularAgencia?id=<?= $v['id_relacion'] ?>&tipo=<?= $v['tipo_vinculacion'] ?>"
|
||||
class="btn btn-sm btn-danger"
|
||||
onclick="return confirm('¿Está seguro de que desea desvincular este usuario?')">
|
||||
Desvincular
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span class="text-muted small">N/A</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
@@ -65,7 +65,7 @@
|
||||
<td><?= htmlspecialchars($v['direccion'] ?? '') ?></td>
|
||||
<td><?= !empty($v['fecha_vinculacion']) ? $v['fecha_vinculacion']->format('Y-m-d H:i') : '' ?></td>
|
||||
<td>
|
||||
<a href="/IMPORTADORES/vinculaciones/desvincularUsuario?id=<?= $v['id_relacion'] ?>" class="btn btn-sm btn-danger">Desvincular</a>
|
||||
<a href="/IMPORTADORES/importadores/desvincularUsuario?id=<?= $v['id_relacion'] ?>" class="btn btn-sm btn-danger">Desvincular</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user