cambios atorados
This commit is contained in:
@@ -22,11 +22,6 @@ function dashboard()
|
|||||||
include __DIR__ . '/../../views/agencias/dashboard_agencias.php';
|
include __DIR__ . '/../../views/agencias/dashboard_agencias.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
function solicitudesVinculacion()
|
|
||||||
{
|
|
||||||
include __DIR__ . '/../../views/agencias/solicitudes_vinculacion.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
function alta()
|
function alta()
|
||||||
{
|
{
|
||||||
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'admin_agencia') {
|
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'admin_agencia') {
|
||||||
@@ -34,6 +29,76 @@ function alta()
|
|||||||
exit;
|
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';
|
include __DIR__ . '/../../views/agencias/alta_agentes.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,244 +24,158 @@ function dashboard()
|
|||||||
include __DIR__ . '/../../views/agentes/dashboard_agentes.php';
|
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');
|
header('Location: /IMPORTADORES/login');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = getConnection();
|
$conn = getConnection();
|
||||||
|
|
||||||
$sql = "SELECT id_importador, nombre_empresa, email, telefono, creado_en
|
if (!$conn) {
|
||||||
FROM importadores
|
die("Error de conexión: " . print_r(sqlsrv_errors(), true));
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
// DEBUG: Verificar query de agencia
|
||||||
if (!($_SESSION['usuario_id'] ?? false) || $_SESSION['tipo_usuario'] !== 'agente_aduanal') {
|
if ($stmtAgencia === false) {
|
||||||
header('Location: /IMPORTADORES/login');
|
die("Error en consulta de agencia: " . print_r(sqlsrv_errors(), true));
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = getConnection();
|
$rowAgencia = sqlsrv_fetch_array($stmtAgencia, SQLSRV_FETCH_ASSOC);
|
||||||
|
|
||||||
$sql = "SELECT request_id, company_name, rfc, email, phone, request_date,opinion_file
|
// DEBUG: Verificar si se encontró la agencia
|
||||||
FROM solicitudes_importadores
|
if (!$rowAgencia) {
|
||||||
WHERE request_status = 'pending'
|
die("No se encontró agencia vinculada el agente ID: " . $_SESSION['usuario_id']);
|
||||||
ORDER BY request_date DESC";
|
|
||||||
|
|
||||||
$stmt = sqlsrv_query($conn, $sql);
|
|
||||||
$solicitudes = [];
|
|
||||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
|
||||||
$solicitudes[] = $row;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
include __DIR__ . '/../../views/agentes/solicitudes_pendientes.php';
|
$id_agencia = $rowAgencia['id_agencia'];
|
||||||
}
|
|
||||||
|
|
||||||
function aprobar_solicitud()
|
// Primero, verificar si hay registros en la tabla importador_agencia
|
||||||
{
|
$sqlCount = "SELECT COUNT(*) as total FROM importador_agencia WHERE id_agencia = ?";
|
||||||
$conn = getConnection();
|
$stmtCount = sqlsrv_query($conn, $sqlCount, [$id_agencia]);
|
||||||
$id = $_GET['id'] ?? null;
|
$rowCount = sqlsrv_fetch_array($stmtCount, SQLSRV_FETCH_ASSOC);
|
||||||
|
|
||||||
if (!$id || !is_numeric($id)) {
|
// Verificar registros activos y aprobados
|
||||||
die("❌ ID inválido.");
|
$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
|
||||||
|
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]);
|
||||||
|
|
||||||
|
// DEBUG: Verificar query principal
|
||||||
|
if ($stmt === false) {
|
||||||
|
die("Error en consulta principal: " . print_r(sqlsrv_errors(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtener la solicitud
|
$vinculados = [];
|
||||||
$sql = "SELECT * FROM solicitudes_importadores WHERE request_id = ?";
|
if ($stmt !== false) {
|
||||||
$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)) {
|
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||||
$row['nombre'] = decrypt($row['nombre']);
|
$vinculados[] = $row;
|
||||||
$row['email'] = decrypt($row['email']);
|
|
||||||
$importadores[] = $row;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
include __DIR__ . '/../../views/agentes/importadores_activos.php';
|
include __DIR__ . '/../../views/vinculaciones/importadores_vinculados.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggle_estado()
|
function desvincularAgente()
|
||||||
{
|
{
|
||||||
if (!($_SESSION['usuario_id'] ?? false) || $_SESSION['tipo_usuario'] !== 'agente_aduanal') {
|
if (!isset($_SESSION['usuario_id']) || $_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');
|
header('Location: /IMPORTADORES/login');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "
|
// Verificar que se recibió el ID de la relación
|
||||||
SELECT u.id_usuario, u.nombre, b.email, b.ip, b.fecha, b.exito, b.detalle
|
$id_relacion = $_GET['id'] ?? null;
|
||||||
FROM dbo.bitacora_login b
|
if (!$id_relacion || !is_numeric($id_relacion)) {
|
||||||
JOIN dbo.usuarios_sistema u ON u.id_usuario = b.id_usuario
|
header('Location: /IMPORTADORES/agentes/vinculados?error=invalid_id');
|
||||||
ORDER BY b.fecha DESC
|
exit;
|
||||||
";
|
|
||||||
|
|
||||||
$stmt = sqlsrv_query($conn, $sql);
|
|
||||||
if ($stmt === false) {
|
|
||||||
die("Error en bitacora(): " . print_r(sqlsrv_errors(), true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$bitacoras = [];
|
$conn = getConnection();
|
||||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
|
||||||
$row['nombre'] = decrypt($row['nombre']); // Desencripta aquí
|
|
||||||
$bitacoras[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
include __DIR__ . '/../../views/agentes/bitacora.php';
|
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';
|
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
|
<?php
|
||||||
// app/controllers/productos_frecuentes.php
|
// app/controllers/productos_frecuentes.php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../helpers/session.php';
|
require_once __DIR__ . '/../helpers/session.php';
|
||||||
require_once __DIR__ . '/../../config/database.php';
|
require_once __DIR__ . '/../../config/database.php';
|
||||||
// 1) Composer autoload (phpdotenv y demás libs)
|
// 1) Composer autoload (phpdotenv y demás libs)
|
||||||
@@ -20,8 +18,6 @@ function index()
|
|||||||
|
|
||||||
function ajax_paises()
|
function ajax_paises()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// Sólo importadores pueden usarlo
|
// Sólo importadores pueden usarlo
|
||||||
if (empty($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'importador') {
|
if (empty($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'importador') {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
@@ -47,8 +43,6 @@ function ajax_paises()
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function ajax_proveedores()
|
function ajax_proveedores()
|
||||||
{
|
{
|
||||||
// 1) Asegura que la respuesta sea JSON
|
// 1) Asegura que la respuesta sea JSON
|
||||||
@@ -93,10 +87,8 @@ function ajax_proveedores()
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function lista()
|
function lista()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (empty($_SESSION['usuario_id'])) {
|
if (empty($_SESSION['usuario_id'])) {
|
||||||
header('Location: /IMPORTADORES/login');
|
header('Location: /IMPORTADORES/login');
|
||||||
exit;
|
exit;
|
||||||
@@ -290,18 +282,17 @@ function actualizar()
|
|||||||
* Muestra formulario de importación masiva **/
|
* Muestra formulario de importación masiva **/
|
||||||
function importacion_csv()
|
function importacion_csv()
|
||||||
{
|
{
|
||||||
session_start();
|
|
||||||
if (empty($_SESSION['usuario_id'])) {
|
if (empty($_SESSION['usuario_id'])) {
|
||||||
header('Location: /IMPORTADORES/login');
|
header('Location: /IMPORTADORES/login');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
include __DIR__ . '/../../views/productos_frecuentes/importacion_csv.php';
|
include __DIR__ . '/../../views/productos_frecuentes/importacion_csv.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax_unidades()
|
function ajax_unidades()
|
||||||
{
|
{
|
||||||
|
// Sólo importadores pueden usarlo
|
||||||
|
|
||||||
if (empty($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'importador') {
|
if (empty($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'importador') {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['results' => []]);
|
echo json_encode(['results' => []]);
|
||||||
@@ -324,8 +315,6 @@ function ajax_unidades()
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** POST /IMPORTADORES/productos_frecuentes/procesar_csv
|
/** POST /IMPORTADORES/productos_frecuentes/procesar_csv
|
||||||
* Procesa el upload y la inserción de CSV **/
|
* Procesa el upload y la inserción de CSV **/
|
||||||
function procesar_csv()
|
function procesar_csv()
|
||||||
|
|||||||
@@ -12,37 +12,32 @@ function vinculacionesUsuario()
|
|||||||
|
|
||||||
$conn = getConnection();
|
$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 = "
|
$sql = "
|
||||||
SELECT
|
SELECT *
|
||||||
ia.*,
|
FROM importador_agencia ia
|
||||||
aa.id_agencia, aa.nombre_agencia, aa.rfc_agencia, aa.telefono, aa.direccion
|
INNER JOIN agencias_aduanales aa ON ia.id_agencia = aa.id_agencia
|
||||||
FROM importador_agencia ia
|
WHERE ia.id_importador = ? AND ia.activo = 1
|
||||||
INNER JOIN agencias_aduanales aa ON ia.id_agencia = aa.id_agencia
|
ORDER BY ia.fecha_vinculacion DESC
|
||||||
WHERE ia.id_importador = ?
|
";
|
||||||
AND ia.activo = 1
|
$stmt = sqlsrv_query($conn, $sql, [$_SESSION['usuario_id']]);
|
||||||
AND ia.estado = 'APROBADO'
|
|
||||||
ORDER BY ia.fecha_vinculacion DESC
|
|
||||||
";
|
|
||||||
$stmt = sqlsrv_query($conn, $sql, [$id_importador]);
|
|
||||||
|
|
||||||
$vinculaciones = [];
|
$vinculaciones = [];
|
||||||
if ($stmt !== false) {
|
if ($stmt !== false) {
|
||||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||||
$vinculaciones[] = $row;
|
$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';
|
include __DIR__ . '/../../views/vinculaciones/vinculaciones_importador.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
function usuariosVinculados()
|
function vinculacionesAgencia()
|
||||||
{
|
{
|
||||||
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'admin_agencia') {
|
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'admin_agencia') {
|
||||||
header('Location: /IMPORTADORES/login');
|
header('Location: /IMPORTADORES/login');
|
||||||
@@ -57,7 +52,7 @@ function usuariosVinculados()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtener la agencia del administrador actual
|
// Obtener la agencia del administrador actual
|
||||||
$sqlAgencia = "SELECT id_agencia FROM agencias_aduanales WHERE id_administrador = ?";
|
$sqlAgencia = "SELECT id_agencia FROM agencias_aduanales WHERE id_administrador = ?";
|
||||||
$stmtAgencia = sqlsrv_query($conn, $sqlAgencia, [$_SESSION['usuario_id']]);
|
$stmtAgencia = sqlsrv_query($conn, $sqlAgencia, [$_SESSION['usuario_id']]);
|
||||||
|
|
||||||
// DEBUG: Verificar query de agencia
|
// DEBUG: Verificar query de agencia
|
||||||
@@ -74,23 +69,26 @@ function usuariosVinculados()
|
|||||||
|
|
||||||
$id_agencia = $rowAgencia['id_agencia'];
|
$id_agencia = $rowAgencia['id_agencia'];
|
||||||
|
|
||||||
|
// === CONSULTA DE IMPORTADORES ===
|
||||||
// Primero, verificar si hay registros en la tabla importador_agencia
|
// Primero, verificar si hay registros en la tabla importador_agencia
|
||||||
$sqlCount = "SELECT COUNT(*) as total FROM importador_agencia WHERE id_agencia = ?";
|
$sqlCount = "SELECT COUNT(*) as total FROM importador_agencia WHERE id_agencia = ?";
|
||||||
$stmtCount = sqlsrv_query($conn, $sqlCount, [$id_agencia]);
|
$stmtCount = sqlsrv_query($conn, $sqlCount, [$id_agencia]);
|
||||||
$rowCount = sqlsrv_fetch_array($stmtCount, SQLSRV_FETCH_ASSOC);
|
$rowCount = sqlsrv_fetch_array($stmtCount, SQLSRV_FETCH_ASSOC);
|
||||||
|
|
||||||
// Verificar registros activos y aprobados
|
// Verificar registros activos y aprobados
|
||||||
$sqlCountActive = "SELECT COUNT(*) as total FROM importador_agencia WHERE id_agencia = ? AND activo = 1 AND estado = 'APROBADO'";
|
$sqlCountActive = "SELECT COUNT(*) as total FROM importador_agencia WHERE id_agencia = ? AND activo = 1 AND estado = 'APROBADO'";
|
||||||
$stmtCountActive = sqlsrv_query($conn, $sqlCountActive, [$id_agencia]);
|
$stmtCountActive = sqlsrv_query($conn, $sqlCountActive, [$id_agencia]);
|
||||||
$rowCountActive = sqlsrv_fetch_array($stmtCountActive, SQLSRV_FETCH_ASSOC);
|
$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 = "
|
$sql = "
|
||||||
SELECT
|
SELECT
|
||||||
ia.*,
|
ia.*,
|
||||||
u.nombre as importador_nombre,
|
u.nombre as importador_nombre,
|
||||||
|
u.tipo_usuario as tipo_usuario_sistema,
|
||||||
ig.rfc,
|
ig.rfc,
|
||||||
ig.telefono
|
ig.telefono,
|
||||||
|
'importador' as tipo_vinculacion
|
||||||
FROM importador_agencia ia
|
FROM importador_agencia ia
|
||||||
INNER JOIN usuarios_sistema u ON ia.id_importador = u.id_usuario
|
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 informacion_general ig ON u.id_usuario = ig.id_usuario
|
||||||
@@ -101,7 +99,7 @@ function usuariosVinculados()
|
|||||||
|
|
||||||
// DEBUG: Verificar query principal
|
// DEBUG: Verificar query principal
|
||||||
if ($stmt === false) {
|
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 = [];
|
$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()
|
function nuevaVinculacion()
|
||||||
@@ -190,7 +234,7 @@ function vincular()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function desvincular()
|
function desvincularAgencia()
|
||||||
{
|
{
|
||||||
// ✅ CORREGIR: Debe ser admin_agencia, no importador
|
// ✅ CORREGIR: Debe ser admin_agencia, no importador
|
||||||
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'admin_agencia') {
|
if (!isset($_SESSION['usuario_id']) || $_SESSION['tipo_usuario'] !== 'admin_agencia') {
|
||||||
@@ -200,63 +244,108 @@ function desvincular()
|
|||||||
|
|
||||||
// Verificar que se recibió el ID de la relación
|
// Verificar que se recibió el ID de la relación
|
||||||
$id_relacion = $_GET['id'] ?? null;
|
$id_relacion = $_GET['id'] ?? null;
|
||||||
|
$tipo = $_GET['tipo'] ?? null;
|
||||||
|
|
||||||
if (!$id_relacion || !is_numeric($id_relacion)) {
|
if (!$id_relacion || !is_numeric($id_relacion)) {
|
||||||
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?error=invalid_id');
|
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?error=invalid_id');
|
||||||
exit;
|
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();
|
$conn = getConnection();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Iniciar transacción
|
// Iniciar transacción
|
||||||
sqlsrv_begin_transaction($conn);
|
sqlsrv_begin_transaction($conn);
|
||||||
|
|
||||||
// 1. Verificar que la relación existe y pertenece a la agencia del admin
|
if ($tipo === 'importador') {
|
||||||
$sqlVerificar = "
|
|
||||||
SELECT
|
|
||||||
ia.*,
|
|
||||||
aa.id_administrador,
|
|
||||||
u.nombre as importador_nombre
|
|
||||||
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 = ?
|
|
||||||
";
|
|
||||||
$stmtVerificar = sqlsrv_query($conn, $sqlVerificar, [$id_relacion, $_SESSION['usuario_id']]);
|
|
||||||
$relacion = sqlsrv_fetch_array($stmtVerificar, SQLSRV_FETCH_ASSOC);
|
|
||||||
|
|
||||||
if (!$relacion) {
|
// Verificar relación de importador
|
||||||
throw new Exception('Relación no encontrada o no tienes permisos para desvincularla');
|
$sqlVerificar = "
|
||||||
|
SELECT
|
||||||
|
ia.*,
|
||||||
|
aa.id_administrador,
|
||||||
|
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 = ? 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 de importador no encontrada o no tienes permisos para desvincularla');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($relacion['activo'] == 0) {
|
||||||
|
throw new Exception('Esta relación de importador ya está inactiva');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desactivar la relación de importador
|
||||||
|
$sqlDesactivar = "
|
||||||
|
UPDATE importador_agencia
|
||||||
|
SET activo = 0,
|
||||||
|
fecha_desvinculacion = GETDATE(),
|
||||||
|
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 = ?
|
||||||
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = ?
|
|
||||||
";
|
|
||||||
$stmtDesactivar = sqlsrv_query($conn, $sqlDesactivar, [$id_relacion]);
|
$stmtDesactivar = sqlsrv_query($conn, $sqlDesactivar, [$id_relacion]);
|
||||||
|
|
||||||
if (!$stmtDesactivar) {
|
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
|
// Confirmar transacción
|
||||||
sqlsrv_commit($conn);
|
sqlsrv_commit($conn);
|
||||||
|
|
||||||
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?success=unlinked');
|
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?success=unlinked&tipo=' . $tipo);
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// Revertir transacción en caso de error
|
// Revertir transacción en caso de error
|
||||||
sqlsrv_rollback($conn);
|
sqlsrv_rollback($conn);
|
||||||
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?error=unlinked_failed');
|
header('Location: /IMPORTADORES/vinculaciones/usuariosVinculados?error=unlinked_failed&message=' . urlencode($e->getMessage()));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,7 +454,7 @@ function solicitudesVinculacion()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
include __DIR__ . '/../../views/agencias/solicitudes_vinculacion.php';
|
include __DIR__ . '/../../views/vinculaciones/solicitudes_vinculacion.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
function aprobarVinculacion()
|
function aprobarVinculacion()
|
||||||
@@ -552,97 +641,3 @@ function denegarVinculacion()
|
|||||||
exit;
|
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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php else: ?>
|
|
||||||
<tr>
|
|
||||||
<td colspan="8" class="text-center">No hay agencias registradas aún.</td>
|
|
||||||
</tr>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Dashboard | Administrador</title>
|
<title>Dashboard | Administrador</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<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">
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.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>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
@@ -39,7 +38,7 @@
|
|||||||
|
|
||||||
<!-- 📄 CONTENIDO -->
|
<!-- 📄 CONTENIDO -->
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h4 class="mb-4">👥 Alta de Usuarios</h4>
|
<h3 class="mb-4">👥 Alta de Usuarios</h3>
|
||||||
<!-- FORMULARIO -->
|
<!-- FORMULARIO -->
|
||||||
<div class="card p-4 mb-4 shadow-sm bg-white">
|
<div class="card p-4 mb-4 shadow-sm bg-white">
|
||||||
<form action="/IMPORTADORES/administrador/guardar_usuario" method="POST">
|
<form action="/IMPORTADORES/administrador/guardar_usuario" method="POST">
|
||||||
@@ -71,7 +70,7 @@
|
|||||||
<h4 class="mb-4">✅ Usuarios Activos</h4>
|
<h4 class="mb-4">✅ Usuarios Activos</h4>
|
||||||
<div class="card p-3 shadow-sm">
|
<div class="card p-3 shadow-sm">
|
||||||
<div class="table-responsive">
|
<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">
|
<thead class="table-dark">
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
@@ -108,7 +107,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('#tabla-activos').DataTable({
|
$('#tabla-usuarios-activos').DataTable({
|
||||||
order: [],
|
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'
|
||||||
|
|||||||
@@ -48,9 +48,9 @@
|
|||||||
<div class="card shadow-sm p-3">
|
<div class="card shadow-sm p-3">
|
||||||
<h5 class="text-primary">Aprobar agencias</h5>
|
<h5 class="text-primary">Aprobar agencias</h5>
|
||||||
<p>Aprueba las agencias que solicitaron un registro.</p>
|
<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' : '' ?>">
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -58,9 +58,9 @@
|
|||||||
<div class="card shadow-sm p-3">
|
<div class="card shadow-sm p-3">
|
||||||
<h5 class="text-success">Alta de agencias</h5>
|
<h5 class="text-success">Alta de agencias</h5>
|
||||||
<p>Da de alta manualmente una agencia.</p>
|
<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' : '' ?>">
|
class="btn btn-success btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/sistemas/altaAgencias' ? 'active' : '' ?>">
|
||||||
Nuevo agente
|
Nueva agencia
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -69,9 +69,9 @@
|
|||||||
<div class="card shadow-sm p-3">
|
<div class="card shadow-sm p-3">
|
||||||
<h5 class="text-info">Aprobar de usuarios</h5>
|
<h5 class="text-info">Aprobar de usuarios</h5>
|
||||||
<p>Aprueba los usuarios que solicitaron un registro.</p>
|
<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' : '' ?>">
|
class="btn btn-info btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/sistemas/aprobarUsuarios' ? 'active' : '' ?>">
|
||||||
Ver usuarios
|
Ver usuarios solicitantes
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -80,9 +80,9 @@
|
|||||||
<div class="card shadow-sm p-3">
|
<div class="card shadow-sm p-3">
|
||||||
<h5 class="text-indigo">Alta de usuarios</h5>
|
<h5 class="text-indigo">Alta de usuarios</h5>
|
||||||
<p>Da de alta manualmente a un usuario.</p>
|
<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' : '' ?>">
|
class="btn btn-indigo btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/sistemas/altaUsuarios' ? 'active' : '' ?>">
|
||||||
Nuevo agente
|
Nuevo usuario
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
<div class="card shadow-sm p-3">
|
<div class="card shadow-sm p-3">
|
||||||
<h5 class="text-warning">Configuración</h5>
|
<h5 class="text-warning">Configuración</h5>
|
||||||
<p>Administra los datos de tu agencia.</p>
|
<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' : '' ?>">
|
class="btn btn-warning btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/sistemas/configuracion' ? 'active' : '' ?>">
|
||||||
Configurar
|
Configurar
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -38,33 +38,87 @@
|
|||||||
<!-- 📄 CONTENIDO -->
|
<!-- 📄 CONTENIDO -->
|
||||||
<div class="content px-4">
|
<div class="content px-4">
|
||||||
<h3 class="mb-4">Administración de Agentes</h3>
|
<h3 class="mb-4">Administración de Agentes</h3>
|
||||||
|
|
||||||
<!-- FORMULARIO -->
|
<!-- 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">
|
||||||
<h5 class="mb-3">➕ Nuevo Agente</h5>
|
<form action="/IMPORTADORES/agencias/guardarAgente" method="POST">
|
||||||
<div class="row g-3">
|
<h5 class="mb-3">➕ Nuevo Agente</h5>
|
||||||
<div class="col-md-4">
|
<div class="row g-3">
|
||||||
<input name="nombre" class="form-control" placeholder="Nombre completo" required>
|
<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>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="text-end mt-4">
|
||||||
<input name="email" type="email" class="form-control" placeholder="Correo electrónico" required>
|
<button class="btn btn-success px-4">Registrar</button>
|
||||||
</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>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
|
</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 class="text-end mt-4">
|
</div>
|
||||||
<button class="btn btn-success px-4">Registrar</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</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'])): ?>
|
<?php if (isset($_GET['success'])): ?>
|
||||||
<script>
|
<script>
|
||||||
<?php if ($_GET['success'] === 'created'): ?>
|
<?php if ($_GET['success'] === 'created'): ?>
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ include __DIR__ . '/../partials/sidebar_agente.php';
|
|||||||
<div class="row g-4">
|
<div class="row g-4">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="card shadow-sm p-3">
|
<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>
|
<p>Consulta los que ya fueron autorizados.</p>
|
||||||
<a href="/IMPORTADORES/agentes/activos"
|
<a href="/IMPORTADORES/agentes/vinculados"
|
||||||
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/activos' ? 'active' : '' ?>">
|
class="btn btn-primary btn-sm mt-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/vinculados' ? 'active' : '' ?>">
|
||||||
Ver importadores
|
Ver importadores
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -63,17 +63,6 @@ include __DIR__ . '/../partials/sidebar_agente.php';
|
|||||||
</div>
|
</div>
|
||||||
</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="col-md-4">
|
||||||
<div class="card shadow-sm p-3">
|
<div class="card shadow-sm p-3">
|
||||||
<h5 class="text-orange">Locaciones</h5>
|
<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
|
<?php include __DIR__ . '/../partials/sidebar_configuracion.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;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="es">
|
<html lang="es">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php include __DIR__ . '/../partials/sidebar_administrador.php'; ?>
|
<?php include __DIR__ . '/../partials/sidebar_configuracion.php'; ?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="es">
|
<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>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="card shadow-sm p-3">
|
<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>
|
<p>Ver registros de los usuarios.</p>
|
||||||
<a href="/IMPORTADORES/bitacoras/usuarios"
|
<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
|
Ver registro de usuarios
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="card shadow-sm p-3">
|
<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>
|
<p>Ver registros de las agencias.</p>
|
||||||
<a href="/IMPORTADORES/bitacoras/agencias"
|
<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
|
Ver registro de agencias
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="card shadow-sm p-3">
|
<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>
|
<p>Ver mi actividad en la plataforma.</p>
|
||||||
<a href="/IMPORTADORES/bitacoras/miAcceso"
|
<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
|
Ver mis accesos
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -90,20 +90,20 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="card shadow-sm p-3">
|
<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>
|
<p>Ver las vinculaciones de mi agencia.</p>
|
||||||
<a href="/IMPORTADORES/bitacoras/vinculaciones"
|
<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
|
Ver actividad
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="card shadow-sm p-3">
|
<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>
|
<p>Ver mi actividad en la plataforma.</p>
|
||||||
<a href="/IMPORTADORES/bitacoras/miAcceso"
|
<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
|
Ver mis accesos
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -123,10 +123,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="card shadow-sm p-3">
|
<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>
|
<p>Ver mi actividad en la plataforma.</p>
|
||||||
<a href="/IMPORTADORES/bitacoras/miAcceso"
|
<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
|
Ver mis accesos
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -146,10 +146,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="card shadow-sm p-3">
|
<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>
|
<p>Ver mi actividad en la plataforma.</p>
|
||||||
<a href="/IMPORTADORES/bitacoras/miAcceso"
|
<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
|
Ver mis accesos
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</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>
|
</a>
|
||||||
|
|
||||||
<!-- USUARIOS ACTIVOS -->
|
<!-- USUARIOS ACTIVOS -->
|
||||||
<a href="/IMPORTADORES/vinculaciones/usuariosVinculados"
|
<a href="/IMPORTADORES/vinculaciones/vinculacionesAgencia"
|
||||||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/IMPORTADORES/vinculaciones/usuariosVinculados') ? 'active' : '' ?>">
|
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/IMPORTADORES/vinculaciones/vinculacionesAgencia') ? 'active' : '' ?>">
|
||||||
👥 Usuarios Vinculados
|
👥 Usuarios Vinculados
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@@ -90,8 +90,8 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<!-- USUARIOS ACTIVOS -->
|
<!-- USUARIOS ACTIVOS -->
|
||||||
<a href="/IMPORTADORES/vinculaciones/usuariosVinculados"
|
<a href="/IMPORTADORES/vinculaciones/vinculacionesAgencia"
|
||||||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/IMPORTADORES/vinculaciones/usuariosVinculados') ? 'active' : '' ?>">
|
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/IMPORTADORES/vinculaciones/vinculacionesAgencia') ? 'active' : '' ?>">
|
||||||
✅ Usuarios Vinculados
|
✅ Usuarios Vinculados
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,8 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<!-- IMPORTADORES VINCULADOS -->
|
<!-- IMPORTADORES VINCULADOS -->
|
||||||
<a href="/IMPORTADORES/agentes/activos"
|
<a href="/IMPORTADORES/agentes/vinculados"
|
||||||
class="nav-link px-3 py-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/activos' ? 'active' : '' ?>">
|
class="nav-link px-3 py-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/vinculados' ? 'active' : '' ?>">
|
||||||
🔗 Vinculados
|
🔗 Vinculados
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@@ -142,17 +142,42 @@
|
|||||||
🏠 Inicio
|
🏠 Inicio
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<!-- IMPORTADORES ACTIVOS -->
|
<!-- IMPORTADORES VINCULADOS -->
|
||||||
<a href="/IMPORTADORES/agentes/activos"
|
<a href="/IMPORTADORES/agentes/vinculados"
|
||||||
class="nav-link px-3 py-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/activos' ? 'active' : '' ?>">
|
class="nav-link px-3 py-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/vinculados' ? 'active' : '' ?>">
|
||||||
✅ Importadores Activos
|
🔗 Vinculados
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<!-- BITÁCORA -->
|
<!-- Patentes -->
|
||||||
<a href="/IMPORTADORES/agentes/bitacora"
|
<?php if ($esVistaPatente): ?>
|
||||||
class="nav-link px-3 py-2 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/agentes/bitacora' ? 'active' : '' ?>">
|
<?php $enDashboardPatente = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/patente/dashboard'; ?>
|
||||||
🕓 Bitácora
|
<a class="nav-link px-3 py-2 d-flex justify-content-between align-items-center <?= $esVistaPatente ? 'active' : '' ?>"
|
||||||
</a>
|
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 -->
|
<!-- LOCACIONES -->
|
||||||
<?php if ($esVistaLocaciones): ?>
|
<?php if ($esVistaLocaciones): ?>
|
||||||
@@ -185,37 +210,6 @@
|
|||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?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 -->
|
<!-- CONFIGURACIÓN -->
|
||||||
<a href="/IMPORTADORES/configuracion"
|
<a href="/IMPORTADORES/configuracion"
|
||||||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/configuracion') ? 'active' : '' ?>">
|
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/configuracion') ? 'active' : '' ?>">
|
||||||
|
|||||||
@@ -5,7 +5,11 @@
|
|||||||
<title>Dashboard | Agente Aduanal</title>
|
<title>Dashboard | Agente Aduanal</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://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>
|
<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>
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||||
<style>
|
<style>
|
||||||
body { font-family: 'Segoe UI', sans-serif; background-color: #f4f6f9; }
|
body { font-family: 'Segoe UI', sans-serif; background-color: #f4f6f9; }
|
||||||
@@ -31,33 +35,31 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h4>✅ Importadores Activos</h4>
|
<h4>✅ Importadores Vinculados</h4>
|
||||||
|
|
||||||
<div class="card p-3 shadow-sm">
|
<div class="card p-3 shadow-sm">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped" id="tabla-activos">
|
<table class="table table-striped" id="tabla-importadores-vinculados">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>Nombre</th>
|
<th>Nombre</th>
|
||||||
<th>Correo</th>
|
<th>RFC</th>
|
||||||
<th>Fecha Registro</th>
|
<th>Teléfono</th>
|
||||||
|
<th>Fecha de Vinculación</th>
|
||||||
<th>Acciones</th>
|
<th>Acciones</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($importadores as $i): ?>
|
<?php foreach ($vinculados as $v): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?= $i['id_usuario'] ?></td>
|
<td><?= $v['id_importador'] ?></td>
|
||||||
<td><?= htmlspecialchars(($i['nombre'])) ?></td>
|
<td><?= htmlspecialchars(decrypt($v['importador_nombre'])) ?></td>
|
||||||
<td><?= htmlspecialchars($i['email']) ?></td>
|
<td><?= htmlspecialchars($v['rfc']) ?></td>
|
||||||
<td><?= isset($i['creado_en']) && $i['creado_en'] instanceof DateTime ? $i['creado_en']->format('Y-m-d H:i') : '' ?></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>
|
<td>
|
||||||
<?php if (isset($i['activo']) && $i['activo'] == 1): ?>
|
<a href="/IMPORTADORES/agentes/desvincularAgente?id=<?= $v['id_relacion'] ?>" class="btn btn-sm btn-danger">Desvincular</a>
|
||||||
<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; ?>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@@ -67,14 +69,34 @@
|
|||||||
</div>
|
</div>
|
||||||
</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'])): ?>
|
<?php if (isset($_GET['success'])): ?>
|
||||||
<script>
|
<script>
|
||||||
Swal.fire({
|
<?php if ($_GET['success'] === 'unlinked'): ?>
|
||||||
icon: 'success',
|
Swal.fire({ icon: 'success', title: 'Usuario desvinculado',
|
||||||
title: 'Estado actualizado',
|
text: 'El usuario se ha desvinculado correctamente.',
|
||||||
text: 'El estado del usuario se ha actualizado correctamente.',
|
confirmButtonColor: '#198754' });
|
||||||
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>
|
</script>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
@@ -75,10 +75,6 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php else: ?>
|
|
||||||
<tr>
|
|
||||||
<td colspan="8" class="text-center">No hay agencias registradas aún.</td>
|
|
||||||
</tr>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php include __DIR__ . '/../partials/sidebar_agencia.php'; ?>
|
<?php include __DIR__ . '/../partials/sidebar_agencia.php'; ?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Dashboard | Agencia Aduanal</title>
|
<title>Dashboard | Agencia Aduanal</title>
|
||||||
@@ -45,6 +46,8 @@
|
|||||||
<th>Nombre</th>
|
<th>Nombre</th>
|
||||||
<th>RFC</th>
|
<th>RFC</th>
|
||||||
<th>Teléfono</th>
|
<th>Teléfono</th>
|
||||||
|
<th>Usuario</th>
|
||||||
|
<th>Vinculación</th>
|
||||||
<th>Fecha de Vinculación</th>
|
<th>Fecha de Vinculación</th>
|
||||||
<th>Acciones</th>
|
<th>Acciones</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -57,9 +60,19 @@
|
|||||||
<td><?= htmlspecialchars(decrypt($v['importador_nombre'] ?? '')) ?></td>
|
<td><?= htmlspecialchars(decrypt($v['importador_nombre'] ?? '')) ?></td>
|
||||||
<td><?= htmlspecialchars($v['rfc'] ?? '') ?></td>
|
<td><?= htmlspecialchars($v['rfc'] ?? '') ?></td>
|
||||||
<td><?= htmlspecialchars($v['telefono'] ?? '') ?></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><?= !empty($v['fecha_vinculacion']) ? $v['fecha_vinculacion']->format('Y-m-d H:i') : '' ?></td>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
<td><?= htmlspecialchars($v['direccion'] ?? '') ?></td>
|
<td><?= htmlspecialchars($v['direccion'] ?? '') ?></td>
|
||||||
<td><?= !empty($v['fecha_vinculacion']) ? $v['fecha_vinculacion']->format('Y-m-d H:i') : '' ?></td>
|
<td><?= !empty($v['fecha_vinculacion']) ? $v['fecha_vinculacion']->format('Y-m-d H:i') : '' ?></td>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user