Cambios
This commit is contained in:
@@ -418,6 +418,7 @@ function guardar_usuario()
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$conn = getConnection();
|
$conn = getConnection();
|
||||||
|
|
||||||
// 1. Capturar y validar datos
|
// 1. Capturar y validar datos
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
require_once __DIR__ . '/../helpers/session.php';
|
require_once __DIR__ . '/../helpers/session.php';
|
||||||
require_once __DIR__ . '/../../config/database.php';
|
require_once __DIR__ . '/../../config/database.php';
|
||||||
require_once __DIR__ . '/../helpers/crypto.php';
|
require_once __DIR__ . '/../helpers/crypto.php';
|
||||||
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
|
use PHPMailer\PHPMailer\Exception;
|
||||||
|
|
||||||
|
loadEnv();
|
||||||
|
|
||||||
// Función para obtener catálogos visibles del usuario
|
// Función para obtener catálogos visibles del usuario
|
||||||
function obtenerCatalogosVisibles($idUsuario)
|
function obtenerCatalogosVisibles($idUsuario)
|
||||||
@@ -228,6 +234,21 @@ function vincular()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtener información del importador y la agencia para el correo
|
||||||
|
$infoSql = "SELECT
|
||||||
|
u.nombre AS nombre_importador, u.email AS email_importador,
|
||||||
|
a.nombre_agencia, a.email AS email_agencia,
|
||||||
|
admin.email AS admin_email, admin.nombre AS admin_nombre
|
||||||
|
FROM usuarios_sistema u
|
||||||
|
CROSS JOIN agencias_aduanales a
|
||||||
|
LEFT JOIN usuarios_sistema admin
|
||||||
|
ON a.id_administrador = admin.id_usuario
|
||||||
|
WHERE u.id_usuario = ?
|
||||||
|
AND a.id_agencia = ?
|
||||||
|
";
|
||||||
|
$infoStmt = sqlsrv_query($conn, $infoSql, [$id_importador, $id_agencia]);
|
||||||
|
$info = sqlsrv_fetch_array($infoStmt, SQLSRV_FETCH_ASSOC);
|
||||||
|
|
||||||
// Insertar la nueva solicitud
|
// Insertar la nueva solicitud
|
||||||
$sql = "INSERT INTO solicitudes_vinculacion
|
$sql = "INSERT INTO solicitudes_vinculacion
|
||||||
(id_importador, id_agencia, mensaje, estado, fecha_solicitud)
|
(id_importador, id_agencia, mensaje, estado, fecha_solicitud)
|
||||||
@@ -237,6 +258,48 @@ function vincular()
|
|||||||
$stmt = sqlsrv_prepare($conn, $sql, $params);
|
$stmt = sqlsrv_prepare($conn, $sql, $params);
|
||||||
|
|
||||||
if ($stmt && sqlsrv_execute($stmt)) {
|
if ($stmt && sqlsrv_execute($stmt)) {
|
||||||
|
// Enviar notificación al administrador de la agencia
|
||||||
|
if (!empty($info['admin_email'])) {
|
||||||
|
$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 | Sistema Integral para Importadores de Hidrocarburos');
|
||||||
|
$mail->addAddress($info['admin_email']);
|
||||||
|
$mail->CharSet = 'UTF-8';
|
||||||
|
$mail->isHTML(true);
|
||||||
|
$mail->Subject = 'Nueva solicitud de vinculación en SIIH';
|
||||||
|
|
||||||
|
$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;'>¡Nueva solicitud de vinculación!</h2>
|
||||||
|
</div>
|
||||||
|
<div style='padding: 30px; color: #333; font-size: 16px;'>
|
||||||
|
<p>El importador <strong>{$info['nombre_importador']}</strong> ha solicitado vincularse con su agencia <strong>{$info['nombre_agencia']}</strong>.</p>
|
||||||
|
<p><strong>Correo del importador:</strong> {$info['email_importador']}</p>
|
||||||
|
<p>Por favor, revise la solicitud en su panel de administración para aprobarla o rechazarla.</p>
|
||||||
|
</div>
|
||||||
|
<div style='background: #e9ecef; text-align: center; padding: 15px; font-size: 13px; color: #666;'>
|
||||||
|
© " . date('Y') . " SIIH · Sistema Integral para Importadores de Hidrocarburos
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
";
|
||||||
|
|
||||||
|
$mail->send();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
error_log("Error al enviar correo: " . $mail->ErrorInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
header('Location: /IMPORTADORES/vinculaciones/nuevaVinculacion?success=sended_request');
|
header('Location: /IMPORTADORES/vinculaciones/nuevaVinculacion?success=sended_request');
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
@@ -257,6 +320,18 @@ function cancelarVinculacion()
|
|||||||
$id_importador = $_SESSION['usuario_id'];
|
$id_importador = $_SESSION['usuario_id'];
|
||||||
$id_agencia = (int) $_GET['id'];
|
$id_agencia = (int) $_GET['id'];
|
||||||
|
|
||||||
|
// Obtener información para el correo
|
||||||
|
$infoSql = "SELECT
|
||||||
|
u.nombre AS nombre_importador, u.email AS email_importador,
|
||||||
|
a.nombre_agencia
|
||||||
|
FROM solicitudes_vinculacion sv
|
||||||
|
JOIN usuarios_sistema u ON sv.id_importador = u.id_usuario
|
||||||
|
JOIN agencias_aduanales a ON sv.id_agencia = a.id_agencia
|
||||||
|
WHERE sv.id_importador = ? AND sv.id_agencia = ? AND sv.estado = 'PENDIENTE'";
|
||||||
|
|
||||||
|
$infoStmt = sqlsrv_query($conn, $infoSql, [$id_importador, $id_agencia]);
|
||||||
|
$info = sqlsrv_fetch_array($infoStmt, SQLSRV_FETCH_ASSOC);
|
||||||
|
|
||||||
$sql = "UPDATE solicitudes_vinculacion
|
$sql = "UPDATE solicitudes_vinculacion
|
||||||
SET estado = 'CANCELADA', fecha_respuesta = GETDATE()
|
SET estado = 'CANCELADA', fecha_respuesta = GETDATE()
|
||||||
WHERE id_importador = ?
|
WHERE id_importador = ?
|
||||||
@@ -267,6 +342,48 @@ function cancelarVinculacion()
|
|||||||
$stmt = sqlsrv_prepare($conn, $sql, $params);
|
$stmt = sqlsrv_prepare($conn, $sql, $params);
|
||||||
|
|
||||||
if ($stmt && sqlsrv_execute($stmt)) {
|
if ($stmt && sqlsrv_execute($stmt)) {
|
||||||
|
// Enviar notificación al importador
|
||||||
|
if (!empty($info['email_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 | Sistema Integral para Importadores de Hidrocarburos');
|
||||||
|
$mail->addAddress($info['email_importador']);
|
||||||
|
$mail->CharSet = 'UTF-8';
|
||||||
|
$mail->isHTML(true);
|
||||||
|
$mail->Subject = 'Cancelación de solicitud de vinculación en SIIH';
|
||||||
|
|
||||||
|
$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;'>Solicitud cancelada</h2>
|
||||||
|
</div>
|
||||||
|
<div style='padding: 30px; color: #333; font-size: 16px;'>
|
||||||
|
<p>Estimado/a <strong>{$info['nombre_importador']}</strong>,</p>
|
||||||
|
<p>Has cancelado tu solicitud de vinculación con la agencia <strong>{$info['nombre_agencia']}</strong>.</p>
|
||||||
|
<p>Si esto fue un error, puedes volver a solicitar la vinculación desde tu panel de importador.</p>
|
||||||
|
</div>
|
||||||
|
<div style='background: #e9ecef; text-align: center; padding: 15px; font-size: 13px; color: #666;'>
|
||||||
|
© " . date('Y') . " SIIH · Sistema Integral para Importadores de Hidrocarburos
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
";
|
||||||
|
|
||||||
|
$mail->send();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
error_log("Error al enviar correo: " . $mail->ErrorInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
header('Location: /IMPORTADORES/vinculaciones/nuevaVinculacion?success=cancelled');
|
header('Location: /IMPORTADORES/vinculaciones/nuevaVinculacion?success=cancelled');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -296,12 +413,16 @@ function desvincularUsuario()
|
|||||||
|
|
||||||
// 1. Verificar que la relación existe y pertenece a la agencia del admin
|
// 1. Verificar que la relación existe y pertenece a la agencia del admin
|
||||||
$sqlVerificar = "SELECT
|
$sqlVerificar = "SELECT
|
||||||
ia.*, u.id_usuario, u.nombre as importador_nombre, aa.nombre_agencia
|
ia.*, u.id_usuario, u.nombre as importador_nombre, u.email as importador_email,
|
||||||
|
aa.nombre_agencia, aa.email as agencia_email,
|
||||||
|
admin.email as admin_email, admin.nombre as admin_nombre
|
||||||
FROM importador_agencia ia
|
FROM importador_agencia ia
|
||||||
INNER JOIN usuarios_sistema u
|
INNER JOIN usuarios_sistema u
|
||||||
ON ia.id_importador = u.id_usuario
|
ON ia.id_importador = u.id_usuario
|
||||||
INNER JOIN agencias_aduanales aa
|
INNER JOIN agencias_aduanales aa
|
||||||
ON ia.id_agencia = aa.id_agencia
|
ON ia.id_agencia = aa.id_agencia
|
||||||
|
LEFT JOIN usuarios_sistema admin
|
||||||
|
ON aa.id_administrador = admin.id_usuario
|
||||||
WHERE ia.id_relacion = ?
|
WHERE ia.id_relacion = ?
|
||||||
AND ia.id_importador = ?
|
AND ia.id_importador = ?
|
||||||
";
|
";
|
||||||
@@ -358,6 +479,93 @@ function desvincularUsuario()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enviar notificaciones por correo
|
||||||
|
if (!empty($relacion['importador_email'])) {
|
||||||
|
// Notificación al importador
|
||||||
|
$mailImportador = new PHPMailer(true);
|
||||||
|
try {
|
||||||
|
$mailImportador->isSMTP();
|
||||||
|
$mailImportador->Host = 'secure.emailsrvr.com';
|
||||||
|
$mailImportador->SMTPAuth = true;
|
||||||
|
$mailImportador->Username = 'noreply@aduanasoft.com.mx';
|
||||||
|
$mailImportador->Password = $_ENV['SMTP_PASS'];
|
||||||
|
$mailImportador->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||||
|
$mailImportador->Port = 587;
|
||||||
|
|
||||||
|
$mailImportador->setFrom('noreply@aduanasoft.com.mx', 'SIIH | Sistema Integral para Importadores de Hidrocarburos');
|
||||||
|
$mailImportador->addAddress($relacion['importador_email']);
|
||||||
|
$mailImportador->CharSet = 'UTF-8';
|
||||||
|
$mailImportador->isHTML(true);
|
||||||
|
$mailImportador->Subject = 'Confirmación de desvinculación en SIIH';
|
||||||
|
|
||||||
|
$mailImportador->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;'>Desvinculación completada</h2>
|
||||||
|
</div>
|
||||||
|
<div style='padding: 30px; color: #333; font-size: 16px;'>
|
||||||
|
<p>Estimado/a <strong>{$relacion['importador_nombre']}</strong>,</p>
|
||||||
|
<p>Has sido desvinculado de la agencia <strong>{$relacion['nombre_agencia']}</strong>.</p>
|
||||||
|
<p><strong>Fecha de desvinculación:</strong> " . date('d/m/Y H:i:s') . "</p>
|
||||||
|
<p>Si esto es un error, por favor contacta al administrador de la agencia.</p>
|
||||||
|
</div>
|
||||||
|
<div style='background: #e9ecef; text-align: center; padding: 15px; font-size: 13px; color: #666;'>
|
||||||
|
© " . date('Y') . " SIIH · Sistema Integral para Importadores de Hidrocarburos
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
";
|
||||||
|
|
||||||
|
$mailImportador->send();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
error_log("Error al enviar correo a importador: " . $mailImportador->ErrorInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($relacion['admin_email'])) {
|
||||||
|
// Notificación al administrador de la agencia
|
||||||
|
$mailAdmin = new PHPMailer(true);
|
||||||
|
try {
|
||||||
|
$mailAdmin->isSMTP();
|
||||||
|
$mailAdmin->Host = 'secure.emailsrvr.com';
|
||||||
|
$mailAdmin->SMTPAuth = true;
|
||||||
|
$mailAdmin->Username = 'noreply@aduanasoft.com.mx';
|
||||||
|
$mailAdmin->Password = $_ENV['SMTP_PASS'];
|
||||||
|
$mailAdmin->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||||
|
$mailAdmin->Port = 587;
|
||||||
|
|
||||||
|
$mailAdmin->setFrom('noreply@aduanasoft.com.mx', 'SIIH | Sistema Integral para Importadores de Hidrocarburos');
|
||||||
|
$mailAdmin->addAddress($relacion['admin_email']);
|
||||||
|
$mailAdmin->CharSet = 'UTF-8';
|
||||||
|
$mailAdmin->isHTML(true);
|
||||||
|
$mailAdmin->Subject = 'Notificación de desvinculación en SIIH';
|
||||||
|
|
||||||
|
$mailAdmin->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;'>Notificación de desvinculación</h2>
|
||||||
|
</div>
|
||||||
|
<div style='padding: 30px; color: #333; font-size: 16px;'>
|
||||||
|
<p>Estimado/a <strong>{$relacion['admin_nombre']}</strong>,</p>
|
||||||
|
<p>El importador <strong>{$relacion['importador_nombre']}</strong> se ha desvinculado de su agencia <strong>{$relacion['nombre_agencia']}</strong>.</p>
|
||||||
|
<p><strong>Correo del importador:</strong> {$relacion['importador_email']}</p>
|
||||||
|
<p><strong>Fecha de desvinculación:</strong> " . date('d/m/Y H:i:s') . "</p>
|
||||||
|
</div>
|
||||||
|
<div style='background: #e9ecef; text-align: center; padding: 15px; font-size: 13px; color: #666;'>
|
||||||
|
© " . date('Y') . " SIIH · Sistema Integral para Importadores de Hidrocarburos
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
";
|
||||||
|
|
||||||
|
$mailAdmin->send();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
error_log("Error al enviar correo a administrador: " . $mailAdmin->ErrorInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Limpiar statements
|
// Limpiar statements
|
||||||
if (isset($stmtVerificar) && is_resource($stmtVerificar)) {
|
if (isset($stmtVerificar) && is_resource($stmtVerificar)) {
|
||||||
sqlsrv_free_stmt($stmtVerificar);
|
sqlsrv_free_stmt($stmtVerificar);
|
||||||
@@ -369,7 +577,6 @@ function desvincularUsuario()
|
|||||||
sqlsrv_free_stmt($stmtActualizarAgencia);
|
sqlsrv_free_stmt($stmtActualizarAgencia);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Confirmar transacción
|
// Confirmar transacción
|
||||||
sqlsrv_commit($conn);
|
sqlsrv_commit($conn);
|
||||||
sqlsrv_close($conn);
|
sqlsrv_close($conn);
|
||||||
|
|||||||
@@ -131,6 +131,10 @@ function obtenerConfiguracion($conn)
|
|||||||
// Función auxiliar para enviar email
|
// Función auxiliar para enviar email
|
||||||
function enviarEmailConfirmacion($destinatario, $datosEmpresa, $esAgencia = false)
|
function enviarEmailConfirmacion($destinatario, $datosEmpresa, $esAgencia = false)
|
||||||
{
|
{
|
||||||
|
if ($datosEmpresa['status'] !== 'pending') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$mail = new PHPMailer(true);
|
$mail = new PHPMailer(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -422,9 +422,7 @@ function guardar()
|
|||||||
$patente_id = $_POST['patente'] ?? null;
|
$patente_id = $_POST['patente'] ?? null;
|
||||||
|
|
||||||
if ($patente_id) {
|
if ($patente_id) {
|
||||||
$stmtValidatePatente = sqlsrv_query($conn,
|
$stmtValidatePatente = sqlsrv_query($conn, "SELECT id_agente FROM dbo.agentes_aduanales WHERE id_agente = ? AND id_agencia = ? AND activo = 1", [$patente_id, $id_agencia]);
|
||||||
"SELECT id_agente FROM dbo.agentes_aduanales WHERE id_agente = ? AND id_agencia = ? AND activo = 1",
|
|
||||||
[$patente_id, $id_agencia]);
|
|
||||||
|
|
||||||
if (!$stmtValidatePatente || !sqlsrv_fetch_array($stmtValidatePatente, SQLSRV_FETCH_ASSOC)) {
|
if (!$stmtValidatePatente || !sqlsrv_fetch_array($stmtValidatePatente, SQLSRV_FETCH_ASSOC)) {
|
||||||
die("❌ La patente seleccionada no es válida para su agencia.");
|
die("❌ La patente seleccionada no es válida para su agencia.");
|
||||||
@@ -562,9 +560,9 @@ function guardar()
|
|||||||
if(!empty($_POST['partidas'])&&is_array($_POST['partidas'])){
|
if(!empty($_POST['partidas'])&&is_array($_POST['partidas'])){
|
||||||
|
|
||||||
$sqlP = "INSERT INTO dbo.solicitud_importacion_partidas
|
$sqlP = "INSERT INTO dbo.solicitud_importacion_partidas
|
||||||
(id_solicitud, descripcion, cantidad_comercial, cantidad_tarifa, valor_factura, peso_bruto, unidad_comercial_id, tasa_preferencial)
|
(id_solicitud, descripcion, cantidad_comercial, cantidad_tarifa, valor_factura, peso_bruto, unidad_comercial_id, tasa_preferencial)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
";
|
||||||
$partidas_insertadas = 0; // ← contador
|
$partidas_insertadas = 0; // ← contador
|
||||||
|
|
||||||
foreach ($_POST['partidas'] as $i => $p) {
|
foreach ($_POST['partidas'] as $i => $p) {
|
||||||
@@ -637,46 +635,47 @@ function enviarNotificacionNuevaSolicitud($email, $nombreUsuario, $datosSolicitu
|
|||||||
</div>' : '';
|
</div>' : '';
|
||||||
|
|
||||||
$mail->Body = "
|
$mail->Body = "
|
||||||
<div style='font-family: Segoe UI, sans-serif; background-color: #f4f6f9; padding: 30px;'>
|
<div style='font-family: Segoe UI, sans-serif; background-color: #f4f6f9; padding: 30px;'>
|
||||||
<div style='max-width: 600px; margin: auto; background: #fff; border: 1px solid #ccc; border-radius: 10px;'>
|
<div style='max-width: 600px; margin: auto; background: #fff; border: 1px solid #ccc; border-radius: 10px;'>
|
||||||
<div style='background: linear-gradient(to right, #003366, #0055A5); padding: 20px; text-align: center;'>
|
<div style='background: linear-gradient(to right, #003366, #0055A5); padding: 20px; text-align: center;'>
|
||||||
<h2 style='color: white; margin: 0;'>📥 Nueva Solicitud Registrada</h2>
|
h2 style='color: white; margin: 0;'>📥 Nueva Solicitud Registrada</h2>
|
||||||
</div>
|
</div>
|
||||||
<div style='padding: 20px;'>
|
<div style='padding: 20px;'>
|
||||||
$tipoNotificacion
|
$tipoNotificacion
|
||||||
<p>Hola <strong>" . htmlspecialchars($nombreUsuario) . "</strong>,</p>
|
<p>Hola <strong>" . htmlspecialchars($nombreUsuario) . "</strong>,</p>
|
||||||
<p>Tu solicitud de importación ha sido registrada correctamente con los siguientes datos:</p>
|
<p>Tu solicitud de importación ha sido registrada correctamente con los siguientes datos:</p>
|
||||||
|
|
||||||
<div style='background: #f8f9fa; padding: 15px; border-radius: 8px; margin: 15px 0;'>
|
<div style='background: #f8f9fa; padding: 15px; border-radius: 8px; margin: 15px 0;'>
|
||||||
<table style='width: 100%; border-collapse: collapse;'>
|
<table style='width: 100%; border-collapse: collapse;'>
|
||||||
<tr>
|
<tr>
|
||||||
<td style='padding: 5px 0; font-weight: bold;'>ID Solicitud:</td>
|
<td style='padding: 5px 0; font-weight: bold;'>ID Solicitud:</td>
|
||||||
<td style='padding: 5px 0;'>$idSolicitud</td>
|
<td style='padding: 5px 0;'>$idSolicitud</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style='padding: 5px 0; font-weight: bold;'>Número de Factura:</td>
|
<td style='padding: 5px 0; font-weight: bold;'>Número de Factura:</td>
|
||||||
<td style='padding: 5px 0;'>$numeroFactura</td>
|
<td style='padding: 5px 0;'>$numeroFactura</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style='padding: 5px 0; font-weight: bold;'>Fecha:</td>
|
<td style='padding: 5px 0; font-weight: bold;'>Fecha:</td>
|
||||||
<td style='padding: 5px 0;'>$fechaFactura</td>
|
<td style='padding: 5px 0;'>$fechaFactura</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style='padding: 5px 0; font-weight: bold;'>Valor:</td>
|
<td style='padding: 5px 0; font-weight: bold;'>Valor:</td>
|
||||||
<td style='padding: 5px 0;'>$valorFactura $tipoMoneda</td>
|
<td style='padding: 5px 0;'>$valorFactura $tipoMoneda</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>Puedes consultar el estado de tu solicitud accediendo a tu panel de control.</p>
|
||||||
|
<br>
|
||||||
|
<p style='color: #888; font-size: 14px;'>Si no realizaste esta acción, contacta al administrador del sistema.</p>
|
||||||
|
</div>
|
||||||
|
<div style='background: #e9ecef; text-align: center; padding: 10px; font-size: 13px; color: #666;'>
|
||||||
|
© " . date('Y') . " SIIH · Desarrollado por AduanaSoft
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>Puedes consultar el estado de tu solicitud accediendo a tu panel de control.</p>
|
|
||||||
<br>
|
|
||||||
<p style='color: #888; font-size: 14px;'>Si no realizaste esta acción, contacta al administrador del sistema.</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div style='background: #e9ecef; text-align: center; padding: 10px; font-size: 13px; color: #666;'>
|
";
|
||||||
© " . date('Y') . " SIIH · Desarrollado por AduanaSoft
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>";
|
|
||||||
|
|
||||||
$envioExitoso = $mail->send();
|
$envioExitoso = $mail->send();
|
||||||
|
|
||||||
@@ -929,8 +928,13 @@ function actualizar()
|
|||||||
if (!empty($p['id_partida']) && intval($p['id_partida']) > 0) {
|
if (!empty($p['id_partida']) && intval($p['id_partida']) > 0) {
|
||||||
// ACTUALIZAR partida existente
|
// ACTUALIZAR partida existente
|
||||||
$sql = "UPDATE dbo.solicitud_importacion_partidas SET
|
$sql = "UPDATE dbo.solicitud_importacion_partidas SET
|
||||||
descripcion = ?, cantidad_comercial = ?, cantidad_tarifa = ?,
|
descripcion = ?,
|
||||||
valor_factura = ?, peso_bruto = ?, unidad_comercial_id = ?, tasa_preferencial = ?
|
cantidad_comercial = ?,
|
||||||
|
cantidad_tarifa = ?,
|
||||||
|
valor_factura = ?,
|
||||||
|
peso_bruto = ?,
|
||||||
|
unidad_comercial_id = ?,
|
||||||
|
tasa_preferencial = ?
|
||||||
WHERE id_partida = ?
|
WHERE id_partida = ?
|
||||||
AND id_solicitud = ?
|
AND id_solicitud = ?
|
||||||
";
|
";
|
||||||
@@ -1287,7 +1291,7 @@ function update_status()
|
|||||||
ON s.id_importador = u.id_usuario
|
ON s.id_importador = u.id_usuario
|
||||||
WHERE u.id_usuario = ?
|
WHERE u.id_usuario = ?
|
||||||
AND s.id_solicitud = ?
|
AND s.id_solicitud = ?
|
||||||
";
|
";
|
||||||
$stmtNotif = sqlsrv_prepare($conn, $sqlNotif, [$_SESSION['usuario_id'], $id]);
|
$stmtNotif = sqlsrv_prepare($conn, $sqlNotif, [$_SESSION['usuario_id'], $id]);
|
||||||
|
|
||||||
if ($stmtNotif && sqlsrv_execute($stmtNotif)) {
|
if ($stmtNotif && sqlsrv_execute($stmtNotif)) {
|
||||||
@@ -1858,7 +1862,8 @@ function pdf() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NUEVA FUNCIÓN: Obtener información del proveedor por clave
|
// NUEVA FUNCIÓN: Obtener información del proveedor por clave
|
||||||
function obtenerProveedorPorClave($clave) {
|
function obtenerProveedorPorClave($clave)
|
||||||
|
{
|
||||||
// Obtener token de la API
|
// Obtener token de la API
|
||||||
$token = getApiToken();
|
$token = getApiToken();
|
||||||
if (!$token) {
|
if (!$token) {
|
||||||
@@ -1906,7 +1911,8 @@ function obtenerProveedorPorClave($clave) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generarHTMLPDF($solicitud, $partidas, $configuracion, $proveedor_info = null) {
|
function generarHTMLPDF($solicitud, $partidas, $configuracion, $proveedor_info = null)
|
||||||
|
{
|
||||||
// Formatear fecha
|
// Formatear fecha
|
||||||
$fecha_expedicion = $solicitud['fecha_factura']->format('d/m/Y');
|
$fecha_expedicion = $solicitud['fecha_factura']->format('d/m/Y');
|
||||||
$fecha_vencimiento = $solicitud['fecha_factura']->modify('+30 days')->format('d/m/Y');
|
$fecha_vencimiento = $solicitud['fecha_factura']->modify('+30 days')->format('d/m/Y');
|
||||||
@@ -2047,162 +2053,163 @@ function generarHTMLPDF($solicitud, $partidas, $configuracion, $proveedor_info =
|
|||||||
}
|
}
|
||||||
|
|
||||||
$html = '
|
$html = '
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Solicitud de Importación</title>
|
<title>Solicitud de Importación</title>
|
||||||
<style>
|
<style>
|
||||||
body { font-family: Arial, sans-serif; font-size: 9px; margin: 0; padding: 15px; line-height: 1.2; }
|
body { font-family: Arial, sans-serif; font-size: 9px; margin: 0; padding: 15px; line-height: 1.2; }
|
||||||
/** Encabezado **/
|
/** Encabezado **/
|
||||||
.header { padding-bottom: 50px; }
|
.header { padding-bottom: 50px; }
|
||||||
.logo-section { width: 20%; text-align: left; }
|
.logo-section { width: 20%; text-align: left; }
|
||||||
.logo { max-width: 125px; height: auto; vertical-align: top; }
|
.logo { max-width: 125px; height: auto; vertical-align: top; }
|
||||||
.company-info { width: 60%; text-align: center; vertical-align: top; font-size: 12px; }
|
.company-info { width: 60%; text-align: center; vertical-align: top; font-size: 12px; }
|
||||||
.company-name { font-weight: bold; font-size: 25px; margin-bottom: 3px; }
|
.company-name { font-weight: bold; font-size: 25px; margin-bottom: 3px; }
|
||||||
.invoice-info { width: 20%; text-align: right; vertical-align: top; font-size: 12px; }
|
.invoice-info { width: 20%; text-align: right; vertical-align: top; font-size: 12px; }
|
||||||
/** Sección de Información **/
|
/** Sección de Información **/
|
||||||
.info-section { border: 1px solid black; border-collapse: collapse; width: 100%; table-layout: fixed; }
|
.info-section { border: 1px solid black; border-collapse: collapse; width: 100%; table-layout: fixed; }
|
||||||
.clave-section { border: 0.5px solid black; border-collapse: collapse; width: 100%; table-layout: fixed; padding-bottom: 15px; }
|
.clave-section { border: 0.5px solid black; border-collapse: collapse; width: 100%; table-layout: fixed; padding-bottom: 15px; }
|
||||||
/** Información del Proveedor **/
|
/** Información del Proveedor **/
|
||||||
.proveedor-info { width: 100%; }
|
.proveedor-info { width: 100%; }
|
||||||
.provedor-info table { width: 100%; border-collapse: collapse; table-layout: fixed; }
|
.provedor-info table { width: 100%; border-collapse: collapse; table-layout: fixed; }
|
||||||
.p-field { width: 100px; background-color: #d0d0d0; font-weight: bold; text-align: center; font-size: 12px; }
|
.p-field { width: 100px; background-color: #d0d0d0; font-weight: bold; text-align: center; font-size: 12px; }
|
||||||
.field { border-bottom: 0.5px solid #000; padding: 5px; font-size: 12px; }
|
.field { border-bottom: 0.5px solid #000; padding: 5px; font-size: 12px; }
|
||||||
/** Fechas **/
|
/** Fechas **/
|
||||||
.dates-info { width: 25%; border: 1px solid #000; }
|
.dates-info { width: 25%; border: 1px solid #000; }
|
||||||
.dates-info table { width: 100%; border-collapse: collapse; table-layout: fixed; }
|
.dates-info table { width: 100%; border-collapse: collapse; table-layout: fixed; }
|
||||||
.d-field { background-color: #d0d0d0; font-weight: bold; text-align: center; font-size: 12px; }
|
.d-field { background-color: #d0d0d0; font-weight: bold; text-align: center; font-size: 12px; }
|
||||||
.date { font-weight: bold; text-align: center; font-size: 12px; padding: 7.5px; }
|
.date { font-weight: bold; text-align: center; font-size: 12px; padding: 7.5px; }
|
||||||
/** Partidas **/
|
/** Partidas **/
|
||||||
.products-table { border-collapse: collapse; border: 0.5px solid #000; }
|
.products-table { border-collapse: collapse; border: 0.5px solid #000; }
|
||||||
.products-table td { border: 0.5px solid #000; padding: 10px; text-align: center; font-size: 10px; }
|
.products-table td { border: 0.5px solid #000; padding: 10px; text-align: center; font-size: 10px; }
|
||||||
.products-table th { border: 0.5px solid #000; padding: 5px; background-color: #d0d0d0; font-weight: bold; text-align: center; }
|
.products-table th { border: 0.5px solid #000; padding: 5px; background-color: #d0d0d0; font-weight: bold; text-align: center; }
|
||||||
.text-center { text-align: center; }
|
.text-center { text-align: center; }
|
||||||
.text-right { text-align: right; }
|
.text-right { text-align: right; }
|
||||||
.font-bold { font-weight: bold; }
|
.font-bold { font-weight: bold; }
|
||||||
/** Total **/
|
/** Total **/
|
||||||
.totals-section { float: right; width: 250px; }
|
.totals-section { float: right; width: 250px; }
|
||||||
.total-row { display: flex; justify-content: space-between; margin-top: 25px; font-size: 12px; }
|
.total-row { display: flex; justify-content: space-between; margin-top: 25px; font-size: 12px; }
|
||||||
/** Nota inferior **/
|
/** Nota inferior **/
|
||||||
.footer-info { }
|
.footer-info { }
|
||||||
.footer-note { font-size: 10px; background-color: #d0d0d0; padding: 5px; border: 0.5px solid #000; }
|
.footer-note { font-size: 10px; background-color: #d0d0d0; padding: 5px; border: 0.5px solid #000; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- ENCABEZADO -->
|
<!-- ENCABEZADO -->
|
||||||
<table class="header" cellspacing="0" cellpadding="0" width="100%">
|
<table class="header" cellspacing="0" cellpadding="0" width="100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="logo-section">
|
<td class="logo-section">
|
||||||
<img src="' . htmlspecialchars($configuracion['logo_url'] ?? 'assets/img/logo_siih.png') . '" alt="Logo" class="logo"><br>
|
<img src="' . htmlspecialchars($configuracion['logo_url'] ?? 'assets/img/logo_siih.png') . '" alt="Logo" class="logo"><br>
|
||||||
</td>
|
</td>
|
||||||
<td class="company-info">
|
<td class="company-info">
|
||||||
<div class="company-name">' . htmlspecialchars($solicitud['importador_nombre']) . '</div>
|
<div class="company-name">' . htmlspecialchars($solicitud['importador_nombre']) . '</div>
|
||||||
<div>' . htmlspecialchars($direccion_completa ?: 'Dirección no disponible') . '</div>
|
<div>' . htmlspecialchars($direccion_completa ?: 'Dirección no disponible') . '</div>
|
||||||
<div>RFC: ' . htmlspecialchars($solicitud['importador_rfc'] ?? 'No disponible') . '</div>
|
<div>RFC: ' . htmlspecialchars($solicitud['importador_rfc'] ?? 'No disponible') . '</div>
|
||||||
<div>Tel: ' . htmlspecialchars($solicitud['telefono'] ?? 'No disponible') . '</div>
|
<div>Tel: ' . htmlspecialchars($solicitud['telefono'] ?? 'No disponible') . '</div>
|
||||||
<div>Email: ' . htmlspecialchars($solicitud['correo'] ?? 'No disponible') . '</div>
|
<div>Email: ' . htmlspecialchars($solicitud['correo'] ?? 'No disponible') . '</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="invoice-info">
|
<td class="invoice-info">
|
||||||
<div><strong>' . htmlspecialchars($configuracion['nombre_plataforma'] ?? 'Sistema Integral para Importadores de Hidrocarburos') . '</strong></div><br>
|
<div><strong>' . htmlspecialchars($configuracion['nombre_plataforma'] ?? 'Sistema Integral para Importadores de Hidrocarburos') . '</strong></div><br>
|
||||||
<div class="invoice-title">Solicitud de Importación</div>
|
<div class="invoice-title">Solicitud de Importación</div>
|
||||||
<div><strong>No. ' . htmlspecialchars($solicitud['id_solicitud']) . '</strong></div>
|
<div><strong>No. ' . htmlspecialchars($solicitud['id_solicitud']) . '</strong></div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- SECCIÓN DE INFORMACIÓN DEL PROVEEDOR Y FECHAS -->
|
<!-- SECCIÓN DE INFORMACIÓN DEL PROVEEDOR Y FECHAS -->
|
||||||
<table class="info-section" cellspacing="0" cellpadding="0">
|
<table class="info-section" cellspacing="0" cellpadding="0">
|
||||||
<tr>
|
<tr>
|
||||||
<!-- PROVEEDOR -->
|
<!-- PROVEEDOR -->
|
||||||
<td>
|
<td>
|
||||||
<table class="proveedor-info" cellspacing="0" cellpadding="0">
|
<table class="proveedor-info" cellspacing="0" cellpadding="0">
|
||||||
|
<tr>
|
||||||
|
<td class="p-field">RAZÓN SOCIAL:</td>
|
||||||
|
<td class="field">' . htmlspecialchars($proveedor_nombre) . '</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table class="proveedor-info" cellspacing="0" cellpadding="0">
|
||||||
|
<tr>
|
||||||
|
<td class="p-field" style="height: 45px;">DIRECCIÓN:</td>
|
||||||
|
<td class="field">' . htmlspecialchars($proveedor_direccion) . '</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table class="proveedor-info" cellspacing="0" cellpadding="0">
|
||||||
|
<tr>
|
||||||
|
<td class="p-field">RFC:</td>
|
||||||
|
<td class="field" style="border-bottom: none;">' . htmlspecialchars($proveedor_rfc) . '</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
<!-- FECHAS -->
|
||||||
|
<td class="dates-info">
|
||||||
|
<table cellspacing="0" cellpadding="2">
|
||||||
|
<tr><td class="d-field" style="border-left: 0.5px solid black;">FECHA DE EXPEDICIÓN</td></tr>
|
||||||
|
<tr><td class="date" style="border-bottom: 0.5px solid black;">' . $fecha_expedicion . '</td></tr>
|
||||||
|
<tr><td class="d-field" style="border-left: 0.5px solid black;">FECHA DE VENCIMIENTO</td></tr>
|
||||||
|
<tr><td class="date">' . $fecha_vencimiento . '</td></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table class="clave-section" cellspacing="0" cellpadding="0">
|
||||||
|
<tr>
|
||||||
|
<td class="p-field">CLAVE:</td>
|
||||||
|
<td class="field" style="border-bottom: none;">' . htmlspecialchars($solicitud['proveedor_clave'] ?? 'No disponible') . '</td>
|
||||||
|
<td class="p-field">TELÉFONO:</td>
|
||||||
|
<td class="field" style="border-bottom: none;">' . htmlspecialchars($proveedor_telefono) . '</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- TABLA DE PRODUCTOS/PARTIDAS -->
|
||||||
|
<table class="products-table" cellspacing="0" cellpadding="0" width="100%">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="p-field">RAZÓN SOCIAL:</td>
|
<th>Producto</th>
|
||||||
<td class="field">' . htmlspecialchars($proveedor_nombre) . '</td>
|
<th>Unidad de Medida</th>
|
||||||
|
<th>Precio Unitario</th>
|
||||||
|
<th>Cantidad</th>
|
||||||
|
<th>Total</th>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</thead>
|
||||||
<table class="proveedor-info" cellspacing="0" cellpadding="0">
|
<tbody>';
|
||||||
<tr>
|
|
||||||
<td class="p-field" style="height: 45px;">DIRECCIÓN:</td>
|
|
||||||
<td class="field">' . htmlspecialchars($proveedor_direccion) . '</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<table class="proveedor-info" cellspacing="0" cellpadding="0">
|
|
||||||
<tr>
|
|
||||||
<td class="p-field">RFC:</td>
|
|
||||||
<td class="field" style="border-bottom: none;">' . htmlspecialchars($proveedor_rfc) . '</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
<!-- FECHAS -->
|
|
||||||
<td class="dates-info">
|
|
||||||
<table cellspacing="0" cellpadding="2">
|
|
||||||
<tr><td class="d-field" style="border-left: 0.5px solid black;">FECHA DE EXPEDICIÓN</td></tr>
|
|
||||||
<tr><td class="date" style="border-bottom: 0.5px solid black;">' . $fecha_expedicion . '</td></tr>
|
|
||||||
<tr><td class="d-field" style="border-left: 0.5px solid black;">FECHA DE VENCIMIENTO</td></tr>
|
|
||||||
<tr><td class="date">' . $fecha_vencimiento . '</td></tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<table class="clave-section" cellspacing="0" cellpadding="0">
|
|
||||||
<tr>
|
|
||||||
<td class="p-field">CLAVE:</td>
|
|
||||||
<td class="field" style="border-bottom: none;">' . htmlspecialchars($solicitud['proveedor_clave'] ?? 'No disponible') . '</td>
|
|
||||||
<td class="p-field">TELÉFONO:</td>
|
|
||||||
<td class="field" style="border-bottom: none;">' . htmlspecialchars($proveedor_telefono) . '</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<!-- TABLA DE PRODUCTOS/PARTIDAS -->
|
// Agregar partidas
|
||||||
<table class="products-table" cellspacing="0" cellpadding="0" width="100%">
|
foreach ($partidas as $partida) {
|
||||||
<thead>
|
$precio_unitario = (float)($partida['precio_unitario'] ?? 0);
|
||||||
<tr>
|
$cantidad = (float)($partida['cantidad_comercial'] ?? 0);
|
||||||
<th>Producto</th>
|
$valor_partida = (float)($partida['valor_factura'] ?? 0);
|
||||||
<th>Unidad de Medida</th>
|
|
||||||
<th>Precio Unitario</th>
|
|
||||||
<th>Cantidad</th>
|
|
||||||
<th>Total</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>';
|
|
||||||
|
|
||||||
// Agregar partidas
|
$html .= '
|
||||||
foreach ($partidas as $partida) {
|
<tr>
|
||||||
$precio_unitario = (float)($partida['precio_unitario'] ?? 0);
|
<td>' . htmlspecialchars($partida['descripcion']) . '</td>
|
||||||
$cantidad = (float)($partida['cantidad_comercial'] ?? 0);
|
<td>' . htmlspecialchars($partida['unidad_descripcion'] ?? 'Unidad de servicio (E48)') . '</td>
|
||||||
$valor_partida = (float)($partida['valor_factura'] ?? 0);
|
<td>' . $moneda_codigo . ' ' . number_format($precio_unitario > 0 ? $precio_unitario : $valor_partida, 2) . '</td>
|
||||||
|
<td>' . number_format($cantidad > 0 ? $cantidad : 1, 0) . '</td>
|
||||||
|
<td>' . $moneda_codigo . ' ' . number_format($valor_partida, 2) . '</td>
|
||||||
|
</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
$html .= '
|
$html .= '
|
||||||
<tr>
|
</tbody>
|
||||||
<td>' . htmlspecialchars($partida['descripcion']) . '</td>
|
</table>
|
||||||
<td>' . htmlspecialchars($partida['unidad_descripcion'] ?? 'Unidad de servicio (E48)') . '</td>
|
|
||||||
<td>' . $moneda_codigo . ' ' . number_format($precio_unitario > 0 ? $precio_unitario : $valor_partida, 2) . '</td>
|
|
||||||
<td>' . number_format($cantidad > 0 ? $cantidad : 1, 0) . '</td>
|
|
||||||
<td>' . $moneda_codigo . ' ' . number_format($valor_partida, 2) . '</td>
|
|
||||||
</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= '
|
<!-- NOTA INFERIOR -->
|
||||||
</tbody>
|
<div class="footer-info">
|
||||||
</table>
|
<div class="footer-note">' . $total_texto . '</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- NOTA INFERIOR -->
|
<!-- TOTALES -->
|
||||||
<div class="footer-info">
|
<div class="totals-section">
|
||||||
<div class="footer-note">' . $total_texto . '</div>
|
<div class="total-row text-right">
|
||||||
</div>
|
<span><strong>Total:</strong></span>
|
||||||
|
<span><strong>' . $moneda_codigo . ' ' . number_format($total, 2) . '</strong></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- TOTALES -->
|
</body>
|
||||||
<div class="totals-section">
|
</html>
|
||||||
<div class="total-row text-right">
|
';
|
||||||
<span><strong>Total:</strong></span>
|
|
||||||
<span><strong>' . $moneda_codigo . ' ' . number_format($total, 2) . '</strong></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>';
|
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
@@ -302,12 +302,24 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
let isValid = true;
|
let isValid = true;
|
||||||
|
const inputs = document.querySelectorAll('input.form-control, select.form-select');
|
||||||
|
|
||||||
|
// Validar todos los campos
|
||||||
inputs.forEach(input => {
|
inputs.forEach(input => {
|
||||||
if (!input.checkValidity()) {
|
if (!input.checkValidity()) {
|
||||||
input.classList.add('shake');
|
input.classList.add('shake');
|
||||||
isValid = false;
|
isValid = false;
|
||||||
|
setTimeout(() => input.classList.remove('shake'), 500);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Si todo es válido, enviar el formulario
|
||||||
|
if (isValid) {
|
||||||
|
this.submit(); // Esta línea faltaba en tu código original
|
||||||
|
} else {
|
||||||
|
// Mostrar mensaje de error si lo deseas
|
||||||
|
Swal.fire({ title: 'Campos incompletos', text: 'Por favor complete todos los campos requeridos', icon: 'error' });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@
|
|||||||
<div class="col-md-4 animate__animated animate__fadeInUp" style="animation-delay: <?= $delay ?>s;">
|
<div class="col-md-4 animate__animated animate__fadeInUp" style="animation-delay: <?= $delay ?>s;">
|
||||||
<div class="card shadow-sm p-3 card-hover position-relative h-100">
|
<div class="card shadow-sm p-3 card-hover position-relative h-100">
|
||||||
<div class="card-body p-0 d-flex flex-column">
|
<div class="card-body p-0 d-flex flex-column">
|
||||||
<h5 class="text-success mb-3">Aprobar de usuarios</h5>
|
<h5 class="text-success mb-3">Aprobar usuarios</h5>
|
||||||
<p class="text-muted small flex-grow-1 mb-4">Aprueba los usuarios que solicitaron un registro.</p>
|
<p class="text-muted small flex-grow-1 mb-4">Aprueba los usuarios que solicitaron un registro.</p>
|
||||||
<div class="mt-auto">
|
<div class="mt-auto">
|
||||||
<button class="btn btn-success btn-sm mt-auto w-100 btn-animated"
|
<button class="btn btn-success btn-sm mt-auto w-100 btn-animated"
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ if ($tipoUsuario === 'agente_aduanal') {
|
|||||||
|
|
||||||
<div class="col-md-4 d-flex align-items-end form-group-animated">
|
<div class="col-md-4 d-flex align-items-end form-group-animated">
|
||||||
<button type="submit" class="btn btn-success W-100 btn-animated">
|
<button type="submit" class="btn btn-success W-100 btn-animated">
|
||||||
<i class="fas fa-plus"></i> Registrar Estado
|
Registrar
|
||||||
</button>
|
</button>
|
||||||
<a href="/IMPORTADORES/locaciones/lista" class="btn btn-secondary ms-2 W-100 btn-animated">Cancelar</a>
|
<a href="/IMPORTADORES/locaciones/lista" class="btn btn-secondary ms-2 W-100 btn-animated">Cancelar</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -186,7 +186,7 @@ if ($tipoUsuario === 'agente_aduanal') {
|
|||||||
|
|
||||||
<div class="col-md-4 d-flex align-items-end form-group-animated">
|
<div class="col-md-4 d-flex align-items-end form-group-animated">
|
||||||
<button type="submit" class="btn btn-success W-100 btn-animated">
|
<button type="submit" class="btn btn-success W-100 btn-animated">
|
||||||
<i class="fas fa-plus"></i> Registrar Ciudad
|
Registrar
|
||||||
</button>
|
</button>
|
||||||
<a href="/IMPORTADORES/locaciones/lista" class="btn btn-secondary ms-2 W-100 btn-animated">Cancelar</a>
|
<a href="/IMPORTADORES/locaciones/lista" class="btn btn-secondary ms-2 W-100 btn-animated">Cancelar</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -173,16 +173,16 @@ if (!isset($_SESSION['email_recuperacion'])) {
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const form = document.getElementById('formCodigo');
|
const form = document.getElementById('formCodigo');
|
||||||
const mensaje = document.getElementById('mensaje');
|
const mensaje = document.getElementById('mensaje');
|
||||||
const inputCodigo = document.getElementById('codigo');
|
const inputCodigo = document.getElementById('codigo');
|
||||||
const btnVerificar = document.getElementById('btnVerificar');
|
const btnVerificar = document.getElementById('btnVerificar');
|
||||||
const btnReenviar = document.getElementById('btnReenviarRespaldo');
|
const btnReenviar = document.getElementById('btnReenviarRespaldo');
|
||||||
const clearBtn = document.getElementById('clearCode');
|
const clearBtn = document.getElementById('clearCode');
|
||||||
const intentosInfo = document.getElementById('intentosInfo');
|
const intentosInfo = document.getElementById('intentosInfo');
|
||||||
|
|
||||||
let intentosRealizados = 0;
|
let intentosRealizados = 0;
|
||||||
const maxIntentos = 3; // ⬅️ Cambiado de 5 a 3 para el controlador interno
|
const maxIntentos = 5;
|
||||||
|
|
||||||
// Auto-focus en el input al cargar
|
// Auto-focus en el input al cargar
|
||||||
inputCodigo.focus();
|
inputCodigo.focus();
|
||||||
@@ -220,6 +220,14 @@ if (!isset($_SESSION['email_recuperacion'])) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Auto-envío cuando se completen 6 dígitos (opcional)
|
||||||
|
inputCodigo.addEventListener('input', function() {
|
||||||
|
if (this.value.length === 6) {
|
||||||
|
// Opcional: enviar automáticamente después de un breve delay
|
||||||
|
// setTimeout(() => form.dispatchEvent(new Event('submit')), 500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Manejo del formulario
|
// Manejo del formulario
|
||||||
form.addEventListener('submit', function(e) {
|
form.addEventListener('submit', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -227,7 +235,7 @@ if (!isset($_SESSION['email_recuperacion'])) {
|
|||||||
const codigo = inputCodigo.value.trim();
|
const codigo = inputCodigo.value.trim();
|
||||||
if (!validarCodigo(codigo)) return;
|
if (!validarCodigo(codigo)) return;
|
||||||
|
|
||||||
enviarCodigoInterno(codigo);
|
enviarCodigo(codigo);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Validación del código
|
// Validación del código
|
||||||
@@ -252,8 +260,8 @@ if (!isset($_SESSION['email_recuperacion'])) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ⬅️ NUEVA FUNCIÓN: Enviar código para verificación INTERNA
|
// Enviar código para verificación
|
||||||
function enviarCodigoInterno(codigo) {
|
function enviarCodigo(codigo) {
|
||||||
// Mostrar estado de carga
|
// Mostrar estado de carga
|
||||||
btnVerificar.disabled = true;
|
btnVerificar.disabled = true;
|
||||||
btnVerificar.classList.add('loading');
|
btnVerificar.classList.add('loading');
|
||||||
@@ -262,43 +270,34 @@ if (!isset($_SESSION['email_recuperacion'])) {
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('codigo', codigo);
|
formData.append('codigo', codigo);
|
||||||
|
|
||||||
fetch('/IMPORTADORES/reset/verificarCodigoInterno', {
|
fetch('/IMPORTADORES/login/verificarCodigo', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
credentials: 'same-origin'
|
credentials: 'same-origin'
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => response.json())
|
||||||
// ⬅️ IMPORTANTE: Verificar si la respuesta es un redirect (302/200 HTML)
|
.then(data => {
|
||||||
if (response.ok && response.headers.get('content-type')?.includes('text/html')) {
|
if (data.blocked) {
|
||||||
// Si el servidor devolvió HTML, significa que hubo un redirect exitoso
|
mostrarError(data.message); // <-- función personalizada con un div bonito
|
||||||
mostrarExito("✅ Código verificado correctamente. Redirigiendo...");
|
setTimeout(() => {
|
||||||
inputCodigo.classList.add('success');
|
window.location.href = data.redirect;
|
||||||
inputCodigo.disabled = true;
|
}, 4000);
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.href = '/IMPORTADORES/reset/cambiarPasswordInternoView';
|
|
||||||
}, 1500);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si no es HTML, intentar parsear como JSON (para errores)
|
|
||||||
return response.json();
|
|
||||||
})
|
|
||||||
.then(data => {
|
|
||||||
if (!data) return; // Ya fue manejado arriba como éxito
|
|
||||||
|
|
||||||
// Manejar respuestas de error JSON
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
|
// Código correcto
|
||||||
mostrarExito(data.message);
|
mostrarExito(data.message);
|
||||||
inputCodigo.classList.add('success');
|
inputCodigo.classList.add('success');
|
||||||
inputCodigo.disabled = true;
|
inputCodigo.disabled = true;
|
||||||
|
|
||||||
|
// Redirigir al formulario de cambio de contraseña
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = '/IMPORTADORES/reset/cambiarPasswordInternoView';
|
window.location.href = '/IMPORTADORES/login/cambiarPasswordVista';
|
||||||
}, 1500);
|
}, 1500);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
manejarCodigoIncorrectoInterno(data);
|
// Código incorrecto
|
||||||
|
manejarCodigoIncorrecto(data);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -315,56 +314,35 @@ if (!isset($_SESSION['email_recuperacion'])) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ⬅️ NUEVA FUNCIÓN: Manejar errores específicos del controlador interno
|
// Mostrar error de cuenta bloqueada
|
||||||
function manejarCodigoIncorrectoInterno(data) {
|
function mostrarError(mensaje) {
|
||||||
|
const mensajeDiv = document.getElementById('mensaje');
|
||||||
|
mensajeDiv.innerHTML = `
|
||||||
|
<div class="text-danger fade-in">
|
||||||
|
<i class="fas fa-exclamation-triangle me-2"></i> ${mensaje}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manejar código incorrecto
|
||||||
|
function manejarCodigoIncorrecto(data) {
|
||||||
intentosRealizados++;
|
intentosRealizados++;
|
||||||
|
|
||||||
mostrarError(data.message || "❌ Código incorrecto.");
|
mostrarError(data.message);
|
||||||
inputCodigo.classList.add('error');
|
inputCodigo.classList.add('error');
|
||||||
|
|
||||||
// Limpiar input y enfocar para nuevo intento
|
// Limpiar input y enfocar para nuevo intento
|
||||||
limpiarYEnfocarInput();
|
limpiarYEnfocarInput();
|
||||||
|
|
||||||
// Actualizar contador de intentos
|
// Actualizar contador de intentos
|
||||||
actualizarContadorIntentosInterno();
|
actualizarContadorIntentos();
|
||||||
|
|
||||||
// Si se excedieron los intentos (3 para interno)
|
// Si se bloqueó el código
|
||||||
if (intentosRealizados >= maxIntentos) {
|
if (data.blocked) {
|
||||||
bloquearFormularioInterno();
|
bloquearFormulario();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ⬅️ MODIFICADA: Actualizar contador de intentos para interno
|
|
||||||
function actualizarContadorIntentosInterno() {
|
|
||||||
if (intentosRealizados > 0) {
|
|
||||||
const restantes = maxIntentos - intentosRealizados;
|
|
||||||
intentosInfo.innerHTML = `
|
|
||||||
<i class="fas fa-exclamation-triangle text-warning me-1"></i>
|
|
||||||
Intentos restantes: <strong>${restantes}</strong> de ${maxIntentos}
|
|
||||||
`;
|
|
||||||
intentosInfo.classList.add('fade-in');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ⬅️ MODIFICADA: Bloquear formulario para interno
|
|
||||||
function bloquearFormularioInterno() {
|
|
||||||
inputCodigo.disabled = true;
|
|
||||||
btnVerificar.disabled = true;
|
|
||||||
if (btnReenviar) btnReenviar.disabled = true;
|
|
||||||
|
|
||||||
intentosInfo.innerHTML = `
|
|
||||||
<i class="fas fa-ban text-danger me-1"></i>
|
|
||||||
<span class="text-danger">Demasiados intentos fallidos</span>
|
|
||||||
`;
|
|
||||||
|
|
||||||
mostrarError("❌ Demasiados intentos fallidos. Redirigiendo...");
|
|
||||||
|
|
||||||
// Redirigir a la página de seguridad después de 3 segundos
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.href = '/IMPORTADORES/seguridad/index';
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Limpiar input y enfocar
|
// Limpiar input y enfocar
|
||||||
function limpiarYEnfocarInput() {
|
function limpiarYEnfocarInput() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -372,7 +350,7 @@ if (!isset($_SESSION['email_recuperacion'])) {
|
|||||||
inputCodigo.classList.remove('error');
|
inputCodigo.classList.remove('error');
|
||||||
inputCodigo.focus();
|
inputCodigo.focus();
|
||||||
clearBtn.style.display = 'none';
|
clearBtn.style.display = 'none';
|
||||||
}, 1500);
|
}, 1500); // Esperar 1.5 segundos antes de limpiar
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualizar contador visual
|
// Actualizar contador visual
|
||||||
@@ -385,6 +363,35 @@ if (!isset($_SESSION['email_recuperacion'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actualizar contador de intentos
|
||||||
|
function actualizarContadorIntentos() {
|
||||||
|
if (intentosRealizados > 0) {
|
||||||
|
const restantes = maxIntentos - intentosRealizados;
|
||||||
|
intentosInfo.innerHTML = `
|
||||||
|
<i class="fas fa-exclamation-triangle text-warning me-1"></i>
|
||||||
|
Intentos restantes: <strong>${restantes}</strong> de ${maxIntentos}
|
||||||
|
`;
|
||||||
|
intentosInfo.classList.add('fade-in');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bloquear formulario cuando se exceden intentos
|
||||||
|
function bloquearFormulario() {
|
||||||
|
inputCodigo.disabled = true;
|
||||||
|
btnVerificar.disabled = true;
|
||||||
|
btnReenviar.disabled = true;
|
||||||
|
|
||||||
|
intentosInfo.innerHTML = `
|
||||||
|
<i class="fas fa-ban text-danger me-1"></i>
|
||||||
|
<span class="text-danger">Código bloqueado por seguridad</span>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Redirigir a solicitar nuevo código después de 5 segundos
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.href = '/IMPORTADORES/login/recuperar';
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
// Funciones de utilidad para mensajes
|
// Funciones de utilidad para mensajes
|
||||||
function mostrarMensaje(texto, tipo) {
|
function mostrarMensaje(texto, tipo) {
|
||||||
mensaje.innerHTML = `<div class="${tipo} fade-in">${texto}</div>`;
|
mensaje.innerHTML = `<div class="${tipo} fade-in">${texto}</div>`;
|
||||||
@@ -407,39 +414,40 @@ if (!isset($_SESSION['email_recuperacion'])) {
|
|||||||
mensaje.innerHTML = '';
|
mensaje.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manejo del botón de reenvío (si existe)
|
// Manejo del botón de reenvío
|
||||||
if (btnReenviar) {
|
btnReenviar.addEventListener("click", function() {
|
||||||
btnReenviar.addEventListener("click", function() {
|
const btnOriginalText = this.innerHTML;
|
||||||
const btnOriginalText = this.innerHTML;
|
|
||||||
|
|
||||||
this.disabled = true;
|
// Deshabilitar botón temporalmente
|
||||||
this.innerHTML = '<i class="fas fa-spinner fa-spin me-1"></i>Enviando...';
|
this.disabled = true;
|
||||||
|
this.innerHTML = '<i class="fas fa-spinner fa-spin me-1"></i>Enviando...';
|
||||||
|
|
||||||
fetch("/IMPORTADORES/reset/reenviarCodigoInterno", {
|
fetch("/IMPORTADORES/login/reenviarCodigo", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||||
body: "accion=reenviarCodigo"
|
body: "accion=reenviarCodigo"
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
mostrarInfo(data.message);
|
mostrarInfo(data.message);
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.disabled = false;
|
|
||||||
this.innerHTML = btnOriginalText;
|
|
||||||
}, 30000);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error:', error);
|
|
||||||
mostrarError("❌ Error al reenviar código.");
|
|
||||||
|
|
||||||
|
// Habilitar botón después de 30 segundos
|
||||||
|
setTimeout(() => {
|
||||||
this.disabled = false;
|
this.disabled = false;
|
||||||
this.innerHTML = btnOriginalText;
|
this.innerHTML = btnOriginalText;
|
||||||
});
|
}, 30000);
|
||||||
});
|
})
|
||||||
}
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
mostrarError("❌ Error al reenviar código.");
|
||||||
|
|
||||||
// Manejar tecla Enter
|
// Restaurar botón en caso de error
|
||||||
|
this.disabled = false;
|
||||||
|
this.innerHTML = btnOriginalText;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Manejar tecla Enter en cualquier parte del formulario
|
||||||
document.addEventListener('keypress', function(e) {
|
document.addEventListener('keypress', function(e) {
|
||||||
if (e.key === 'Enter' && !btnVerificar.disabled) {
|
if (e.key === 'Enter' && !btnVerificar.disabled) {
|
||||||
form.dispatchEvent(new Event('submit'));
|
form.dispatchEvent(new Event('submit'));
|
||||||
|
|||||||
@@ -85,7 +85,6 @@
|
|||||||
<th>País Origen/Destino</th>
|
<th>País Origen/Destino</th>
|
||||||
<th>País Comprador/Vendedor</th>
|
<th>País Comprador/Vendedor</th>
|
||||||
<th>Uso Mercancía</th>
|
<th>Uso Mercancía</th>
|
||||||
<th>Estado Mercancía</th>
|
|
||||||
<th>Preferencia</th>
|
<th>Preferencia</th>
|
||||||
<th>Frecuencia Uso</th>
|
<th>Frecuencia Uso</th>
|
||||||
<th>Acciones</th>
|
<th>Acciones</th>
|
||||||
@@ -104,7 +103,6 @@
|
|||||||
<td><?= htmlspecialchars($row['pais_origen_destino']) ?></td>
|
<td><?= htmlspecialchars($row['pais_origen_destino']) ?></td>
|
||||||
<td><?= htmlspecialchars($row['pais_comprador_vendedor']) ?></td>
|
<td><?= htmlspecialchars($row['pais_comprador_vendedor']) ?></td>
|
||||||
<td><?= htmlspecialchars($row['uso_mercancia']) ?></td>
|
<td><?= htmlspecialchars($row['uso_mercancia']) ?></td>
|
||||||
<td><?= htmlspecialchars($row['estado_mercancia']) ?></td>
|
|
||||||
<td><?= htmlspecialchars($row['preferencia']) ?></td>
|
<td><?= htmlspecialchars($row['preferencia']) ?></td>
|
||||||
<td><?= htmlspecialchars($row['frecuencia_uso']) ?></td>
|
<td><?= htmlspecialchars($row['frecuencia_uso']) ?></td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
|
|||||||
@@ -98,9 +98,9 @@
|
|||||||
<td><?= $ag['creado_en'] ? $ag['creado_en']->format('Y-m-d H:i') : '' ?></td>
|
<td><?= $ag['creado_en'] ? $ag['creado_en']->format('Y-m-d H:i') : '' ?></td>
|
||||||
<td>
|
<td>
|
||||||
<?php if (!empty($ag['estado_solicitud']) && $ag['estado_solicitud'] === 'PENDIENTE'): ?>
|
<?php if (!empty($ag['estado_solicitud']) && $ag['estado_solicitud'] === 'PENDIENTE'): ?>
|
||||||
<a href="/IMPORTADORES/importadores/cancelarVinculacion?id=<?= $ag['id_agencia'] ?>" class="btn btn-sm btn-danger mt-auto w-auto btn-animated">Cancelar solicitud</a>
|
<button onclick="confirmCancelRequest(<?= $ag['id_agencia'] ?>)" class="btn btn-sm btn-danger mt-auto w-auto btn-animated">Cancelar solicitud</button>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a href="/IMPORTADORES/importadores/vincular?id=<?= $ag['id_agencia'] ?>" class="btn btn-sm btn-success mt-auto w-auto btn-animated">Vincular</a>
|
<button onclick="confirmLinkAgency(<?= $ag['id_agencia'] ?>)" class="btn btn-sm btn-success mt-auto w-auto btn-animated">Vincular</button>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -121,6 +121,36 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function confirmLinkAgency(id) {
|
||||||
|
Swal.fire({
|
||||||
|
title: '¿Quieres vincularte a esta agencia?',
|
||||||
|
text: 'Podrás usarla para tus operaciones.',
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Sí, vincularme',
|
||||||
|
cancelButtonText: 'Cancelar'
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
window.location.href = `/IMPORTADORES/importadores/vincular?id=${id}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmCancelRequest(id) {
|
||||||
|
Swal.fire({
|
||||||
|
title: '¿Quieres cancelar la solicitud?',
|
||||||
|
text: 'Esta acción no se puede deshacer.',
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Sí, cancelar solicitud',
|
||||||
|
cancelButtonText: 'Cancelar'
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
window.location.href = `/IMPORTADORES/importadores/cancelarVinculacion?id=${id}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php if (isset($_GET['success'])): ?>
|
<?php if (isset($_GET['success'])): ?>
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
<a href="/IMPORTADORES/vinculaciones/nuevaVinculacion" class="btn btn-success mb-3 mt-auto w-auto btn-animated fade-in-up">➕ Nueva Vinculación</a>
|
<a href="/IMPORTADORES/vinculaciones/nuevaVinculacion" class="btn btn-success mb-3 mt-auto w-auto btn-animated fade-in-up">➕ Nueva Vinculación</a>
|
||||||
<!-- TABLA DE VINCULACIÓN USUARIO -->
|
<!-- TABLA DE VINCULACIÓN USUARIO -->
|
||||||
<div class="card p-3 shadow-sm card-hover position-relative h-auto fade-in-up">
|
<div class="card p-3 shadow-sm card-hover position-relative h-auto fade-in-up">
|
||||||
<h5 class="mb-3">🏪 Agencia Vinculadas</h5>
|
<h5 class="mb-3">🏪 Agencias Vinculadas</h5>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-hover align-middle" id="tabla-vinculaciones-usuario">
|
<table class="table table-striped table-hover align-middle" id="tabla-vinculaciones-usuario">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
<?php if ($v['id_agencia'] == ($_SESSION['id_agencia_en_uso'] ?? null)): ?>
|
<?php if ($v['id_agencia'] == ($_SESSION['id_agencia_en_uso'] ?? null)): ?>
|
||||||
<span class="badge bg-secondary">En uso</span>
|
<span class="badge bg-secondary">En uso</span>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a href="/IMPORTADORES/importadores/cambiarAgenciaActiva?id=<?= $v['id_agencia'] ?>" class="btn btn-sm btn-success mt-auto w-auto btn-animated">Usar Agencia</a>
|
<button onclick="confirmChangeAgency(<?= $v['id_agencia'] ?>)" class="btn btn-sm btn-success mt-auto w-auto btn-animated">Usar Agencia</button>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<button onclick="confirmUnlink(<?= $v['id_relacion'] ?>)" class="btn btn-sm btn-danger mt-auto w-auto btn-animated">Desvincular</button>
|
<button onclick="confirmUnlink(<?= $v['id_relacion'] ?>)" class="btn btn-sm btn-danger mt-auto w-auto btn-animated">Desvincular</button>
|
||||||
</td>
|
</td>
|
||||||
@@ -138,6 +138,21 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function confirmChangeAgency(id) {
|
||||||
|
Swal.fire({
|
||||||
|
title: '¿Quieres cambiar de agencia?',
|
||||||
|
text: 'Dejaras de usar la agencia actual y cambiarás a la nueva.',
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Sí, cambiar agencia',
|
||||||
|
cancelButtonText: 'Cancelar'
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
window.location.href = `/IMPORTADORES/importadores/cambiarAgenciaActiva?id=${id}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php if (isset($_GET['success'])): ?>
|
<?php if (isset($_GET['success'])): ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user