Registro de agencias

This commit is contained in:
2025-07-07 11:41:11 -06:00
parent a3e2f8e45e
commit 9925a0bf55
2 changed files with 203 additions and 55 deletions

View File

@@ -112,12 +112,12 @@ $color2 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')
</div>
<div class="col-md-12">
<label for="opinion_file" class="form-label">Padrón de importadores o encargo conferido (PDF) *</label>
<input type="file" class="form-control" name="opinion_file" id="opinion_file" accept=".pdf" required>
<label for="opinion_file_importador" class="form-label">Padrón de importadores o encargo conferido (PDF) *</label>
<input type="file" class="form-control" name="opinion_file" id="opinion_file_importador" accept=".pdf" required>
</div>
<div class="col-md-12 text-center recaptcha">
<div class="g-recaptcha" data-sitekey="6LfkMB8rAAAAAH-BEC1cMYij1HEhw4sTaEOl-UCA"></div>
<div class="g-recaptcha" id="recaptcha-importador" data-sitekey="6LfkMB8rAAAAAH-BEC1cMYij1HEhw4sTaEOl-UCA"></div>
</div>
<div class="col-md-12 text-end mt-4">
@@ -157,8 +157,8 @@ $color2 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')
placeholder="Ej: Calle, num.externo, num.interno, colonia, municipio, código postal, estado" required>
</div>
<div class="col-md-12">
<label for="opinion_file" class="form-label">Padrón de importadores o encargo conferido (PDF) *</label>
<input type="file" class="form-control" name="opinion_file" id="opinion_file" accept=".pdf" required>
<label for="opinion_file_agencia" class="form-label">Padrón de importadores o encargo conferido (PDF) *</label>
<input type="file" class="form-control" name="opinion_file" id="opinion_file_agencia" accept=".pdf" required>
</div><hr>
<p><strong>Administrador de la Agencia</strong></p>
<div class="col-md-6">
@@ -171,7 +171,7 @@ $color2 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')
</div>
<div class="col-md-12 text-center recaptcha">
<div class="g-recaptcha" data-sitekey="6LfkMB8rAAAAAH-BEC1cMYij1HEhw4sTaEOl-UCA"></div>
<div class="g-recaptcha" id="recaptcha-agencia" data-sitekey="6LfkMB8rAAAAAH-BEC1cMYij1HEhw4sTaEOl-UCA"></div>
</div>
<div class="col-md-12 text-end mt-4">
@@ -201,33 +201,51 @@ $color2 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')
function alternarFormulario() {
const formImportador = document.getElementById('formImportadorContainer');
const formAgencia = document.getElementById('formAgenciaContainer');
const btnToggle = document.getElementById('btnToggle');
const formAgencia = document.getElementById('formAgenciaContainer');
const btnToggle = document.getElementById('btnToggle');
if (formularioActual === 'importador') {
// Cambiar a formulario de agencia
formImportador.classList.remove('active');
formAgencia.classList.add('active');
btnToggle.textContent = '🔄 Registro de Importador';
btnToggle.classList.remove('btn-white');
btnToggle.classList.add('btn-white');
formularioActual = 'agencia';
formularioActual = 'agencia';
} else {
// Cambiar a formulario de importador
formAgencia.classList.remove('active');
formImportador.classList.add('active');
btnToggle.textContent = '🔄 Registro de Agencia Aduanal';
btnToggle.classList.remove('btn-white');
btnToggle.classList.add('btn-white');
formularioActual = 'importador';
formularioActual = 'importador';
}
// Resetear reCAPTCHA si está disponible
if (typeof grecaptcha !== 'undefined') {
grecaptcha.reset();
try{
grecaptcha.reset(0); // Reset primer reCAPTCHA
grecaptcha.reset(1); // Reset primer reCAPTCHA
} catch (e) {
console.log('Error resetting reCAPTCHA:', e);
}
}
}
// Función para obtener la respuesta del reCAPTCHA activo
function getActiveRecaptchaResponse() {
if (typeof grecaptcha !== 'undefined') {
try {
if (formularioActual === 'importador') {
return grecaptcha.getResponse(0) || grecaptcha.getResponse();
} else {
return grecaptcha.getResponse(1) || grecaptcha.getResponse();
}
} catch (e) {
console.log('Error getting reCAPTCHA response:', e);
return '';
}
}
return '';
}
// Inicializar al cargar la página
document.addEventListener('DOMContentLoaded', function() {
// Por defecto mostrar el formulario de importador
@@ -243,8 +261,8 @@ $color2 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')
const rfc = document.getElementById('rfc').value.trim().toUpperCase();
const email = document.getElementById('email').value.trim();
const phone = document.getElementById('phone').value.trim();
const archivo = document.getElementById('opinion_file').files[0];
const recaptcha = grecaptcha.getResponse();
const archivo = document.getElementById('opinion_file_importador').files[0];
const recaptcha = getActiveRecaptchaResponse();
// Expresiones regulares
const emailRegex = /^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
@@ -293,14 +311,15 @@ $color2 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')
// Validación de archivo PDF
if (!archivo) {
Swal.fire({ icon: 'warning', title: 'Campo requerido', text: 'El padrón de importadores es obligatorio.', confirmButtonColor: '#dc3545' });
document.getElementById('opinion_file').focus();
document.getElementById('opinion_file_importador').focus();
return;
}
if (!archivo || archivo.type !== 'application/pdf') {
Swal.fire({ icon: 'error', title: 'Formato de documento inválido', text: 'Solo se permite subir archivos PDF.', confirmButtonColor: '#dc3545' });
return; }
return;
}
// Validación de reCAPTCHA
if (recaptcha.length === 0) {
if (!recaptcha || recaptcha.length === 0) {
Swal.fire({ icon: 'warning', title: 'Verificación requerida', text: 'Por favor completa el reCAPTCHA.', confirmButtonColor: '#dc3545' });
return;
}
@@ -320,7 +339,7 @@ $color2 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')
const archivo = document.getElementById('opinion_file').files[0];
const nombre_admin = document.getElementById('nombre_admin').value.trim();
const correo_admin = document.getElementById('correo_admin').value.trim();
const recaptcha = grecaptcha.getResponse();
const recaptcha = getActiveRecaptchaResponse();
// Expresiones regulares
const correoRegex = /^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
@@ -375,7 +394,7 @@ $color2 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')
// Validación de archivo PDF
if (!archivo) {
Swal.fire({ icon: 'warning', title: 'Campo requerido', text: 'El padrón de importadores es obligatorio.', confirmButtonColor: '#dc3545' });
document.getElementById('opinion_file').focus();
document.getElementById('opinion_file_agencia').focus();
return;
}
if (!archivo || archivo.type !== 'application/pdf') {
@@ -399,7 +418,7 @@ $color2 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')
return;
}
// Validación de reCAPTCHA
if (recaptcha.length === 0) {
if (!recaptcha || recaptcha.length === 0) {
Swal.fire({ icon: 'warning', title: 'Verificación requerida', text: 'Por favor completa el reCAPTCHA.', confirmButtonColor: '#dc3545' });
return;
}