Aprobación de Agencias
This commit is contained in:
@@ -44,8 +44,8 @@
|
||||
.card-hover:hover { transform: translateY(-8px) scale(1.02); box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.15) !important; }
|
||||
.btn-pulse { animation: pulse 2s infinite; }
|
||||
@keyframes pulse {
|
||||
0% { transform: scale(1); }
|
||||
50% { transform: scale(1.05); }
|
||||
0% { transform: scale(1); }
|
||||
50% { transform: scale(1.05); }
|
||||
100% { transform: scale(1); }
|
||||
}
|
||||
.fade-in-up { animation: fadeInUp 0.8s ease-out; }
|
||||
@@ -72,8 +72,8 @@
|
||||
.form-control:not(.no-animation).shake { animation: shake 0.5s ease-in-out; }
|
||||
@keyframes shake {
|
||||
0%, 100% { transform: translateX(0); }
|
||||
25% { transform: translateX(-5px); }
|
||||
75% { transform: translateX(5px); }
|
||||
25% { transform: translateX(-5px); }
|
||||
75% { transform: translateX(5px); }
|
||||
}
|
||||
/* Floating labels para inputs texto */
|
||||
.form-floating-custom { position: relative; margin-bottom: 1.5rem; }
|
||||
@@ -94,14 +94,14 @@
|
||||
.form-control.valid:not(.no-animation) { border-color: #198754; background: linear-gradient(45deg, #fff, #f8fff9); animation: successGlow 1s ease-in-out; }
|
||||
@keyframes successGlow {
|
||||
0% { box-shadow: 0 0 5px rgba(25, 135, 84, 0.5); }
|
||||
50% { box-shadow: 0 0 20px rgba(25, 135, 84, 0.8); }
|
||||
50% { box-shadow: 0 0 20px rgba(25, 135, 84, 0.8); }
|
||||
100% { box-shadow: 0 0 5px rgba(25, 135, 84, 0.5); }
|
||||
}
|
||||
.input-typing:not(.no-animation) { position: relative; }
|
||||
.input-typing:not(.no-animation)::after { content: '|'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); opacity: 0; animation: blink 1s infinite; color: #0d6efd; }
|
||||
.input-typing:not(.no-animation):focus::after { opacity: 1; }
|
||||
@keyframes blink {
|
||||
0%, 50% { opacity: 1; }
|
||||
0%, 50% { opacity: 1; }
|
||||
51%, 100% { opacity: 0; }
|
||||
}
|
||||
.input-ripple:not(.no-animation) { position: relative; overflow: hidden; }
|
||||
@@ -169,8 +169,8 @@
|
||||
.form-floating-fecha .form-control:not(:placeholder-shown) ~ .form-label { opacity: 1; top: 0; transform: translateY(-50%) scale(0.85); color: #0d6efd; font-weight: 600; }
|
||||
.form-floating-fecha .form-control:focus, .form-floating-fecha .form-control:not(:placeholder-shown) { padding-top: 1.625rem; padding-bottom: 0.625rem; }
|
||||
/* ========== ESTILOS PARA CAMPO FOTO (SIN ANIMACIONES) ========== */
|
||||
.no-animation, .no-border-style { transition: none !important; border: 1px solid #ccc !important; box-shadow: none !important; background: #fff !important; }
|
||||
.no-animation:focus { transform: none !important; border: 1px solid #0d6efd !important; box-shadow: none !important; }
|
||||
.no-animation, .no-border-style { transition: none !important; border: none; box-shadow: none !important; background: #fff !important; }
|
||||
.no-animation:focus { transform: none !important; border: none; box-shadow: none !important; }
|
||||
.no-animation:hover { animation: none !important; }
|
||||
.no-animation::before, .no-animation::after { display: none !important; }
|
||||
</style>
|
||||
@@ -290,6 +290,7 @@
|
||||
const telefonoRegex = /^\d{3}\s\d{7}$/;
|
||||
const emailRegex = /^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||||
const soloNumerosRegex = /^[0-9]+$/;
|
||||
const fechaRegex = /^\d{2}\/\d{2}\/\d{4}$/; // formato dd/mm/aaaa
|
||||
|
||||
// VALIDAR CAMPOS OBLIGATORIOS PRIMERO
|
||||
if (!transportista_id) {
|
||||
@@ -320,7 +321,7 @@
|
||||
if (!soloNumerosRegex.test(numero_licencia)) {
|
||||
Swal.fire({ icon: 'error', title: 'Número de Licencia inválido', text: 'El número de licencia solo puede contener números', confirmButtonColor: '#dc3545'
|
||||
});
|
||||
document.getElementById('Clave').focus();
|
||||
document.getElementById('numero_licencia').focus();
|
||||
return;
|
||||
}
|
||||
// VALIDAR CAMPOS OPCIONALES (solo si tienen contenido)
|
||||
@@ -336,8 +337,19 @@
|
||||
}
|
||||
// VALIDAR FECHA DE INGRESO (solo si se proporciona)
|
||||
if (fecha_ingreso) {
|
||||
const fechaIngreso = new Date(fecha_ingreso);
|
||||
const fechaActual = new Date();
|
||||
// Validar formato primero
|
||||
if (!fechaRegex.test(fecha_ingreso)) {
|
||||
Swal.fire({ icon: 'error', title: 'Formato de fecha inválido', text: 'La fecha debe tener el formato dd/mm/aaaa', confirmButtonColor: '#dc3545' });
|
||||
document.getElementById('fecha_ingreso').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Convertir fecha correctamente (dd/mm/aaaa -> mm/dd/aaaa)
|
||||
const [dia, mes, año] = fecha_ingreso.split('/');
|
||||
const fechaIngreso = new Date(año, mes - 1, dia); // mes - 1 porque Date usa 0-11
|
||||
const fechaActual = new Date();
|
||||
fechaActual.setHours(0, 0, 0, 0); // Normalizar a medianoche
|
||||
|
||||
if (fechaIngreso > fechaActual) {
|
||||
Swal.fire({ icon: 'error', title: 'Fecha inválida', text: 'La fecha de ingreso no puede ser futura.', confirmButtonColor: '#dc3545' });
|
||||
document.getElementById('fecha_ingreso').focus();
|
||||
@@ -415,21 +427,6 @@
|
||||
isValid = false;
|
||||
}
|
||||
});
|
||||
|
||||
// Si todo es válido, enviar el formulario
|
||||
if (isValid) {
|
||||
// Mostrar indicador de carga
|
||||
const submitBtn = form.querySelector('button[type="submit"]');
|
||||
const originalText = submitBtn.textContent;
|
||||
submitBtn.disabled = true;
|
||||
submitBtn.innerHTML = '<span class="spinner-border spinner-border-sm me-2"></span>Guardando...';
|
||||
|
||||
// Aquí puedes enviar el formulario real
|
||||
form.submit();
|
||||
} else {
|
||||
// Mostrar mensaje de error
|
||||
showNotification('Por favor, complete todos los campos obligatorios correctamente.', 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -465,56 +462,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Validación específica para campos de texto
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Validación del número de licencia (solo números y letras)
|
||||
const licenciaInput = document.getElementById('numero_licencia');
|
||||
if (licenciaInput) {
|
||||
licenciaInput.addEventListener('input', function() {
|
||||
this.value = this.value.replace(/[^A-Za-z0-9]/g, '');
|
||||
});
|
||||
}
|
||||
|
||||
// Validación del teléfono (solo números)
|
||||
const telefonoInput = document.getElementById('telefono');
|
||||
if (telefonoInput) {
|
||||
telefonoInput.addEventListener('input', function() {
|
||||
this.value = this.value.replace(/[^0-9]/g, '');
|
||||
});
|
||||
}
|
||||
|
||||
// Validación del email en tiempo real
|
||||
const emailInput = document.getElementById('email');
|
||||
if (emailInput) {
|
||||
emailInput.addEventListener('input', function() {
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
if (this.value && !emailRegex.test(this.value)) {
|
||||
this.setCustomValidity('Por favor, ingrese un email válido');
|
||||
} else {
|
||||
this.setCustomValidity('');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Función para mostrar notificaciones
|
||||
function showNotification(message, type = 'info') {
|
||||
// Crear el elemento de notificación
|
||||
const notification = document.createElement('div');
|
||||
notification.className = `alert alert-${type === 'error' ? 'danger' : type} alert-dismissible fade show position-fixed`;
|
||||
notification.style.cssText = ` top: 20px; right: 20px; z-index: 9999; min-width: 300px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);`;
|
||||
notification.innerHTML = `${message} <button type="button" class="btn-close" data-bs-dismiss="alert"></button>`;
|
||||
|
||||
document.body.appendChild(notification);
|
||||
|
||||
// Auto-remover después de 5 segundos
|
||||
setTimeout(() => {
|
||||
if (notification.parentNode) {
|
||||
notification.remove();
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// Inicializar Flatpickr para la fecha
|
||||
flatpickr("#fecha_ingreso", {
|
||||
dateFormat: "d/m/Y",
|
||||
|
||||
Reference in New Issue
Block a user