509 lines
26 KiB
PHP
509 lines
26 KiB
PHP
<?php
|
|
$tipoUsuario = $_SESSION['tipo_usuario'] ?? null;
|
|
|
|
if ($tipoUsuario === 'agente_aduanal') {
|
|
include __DIR__ . '/../partials/sidebar_agente.php';
|
|
} elseif ($tipoUsuario === 'admin_agencia') {
|
|
include __DIR__ . '/../partials/sidebar_agencia.php';
|
|
} else {
|
|
// Sidebar por defecto o error
|
|
echo "<!-- ⚠️ No se encontró sidebar para el tipo de usuario -->";
|
|
}
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>CONFIGURACIÓN ADUANA / PATENTE</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>
|
|
<!-- SweetAlert2 -->
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
<!-- Font Awesome -->
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
|
<!-- Animate.css para animaciones adicionales -->
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
|
|
<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; }
|
|
.btn-indigo { background-color: #6610f2; color: white;}
|
|
.btn-indigo:hover { background-color: #520dc2; color: white;}
|
|
.text-indigo { color: orangeRed;}
|
|
.btn-orange { background-color: orangeRed; color: white;}
|
|
.btn-orange:hover { background-color: #ff3600; color: white;}
|
|
.text-orange { color: orangeRed;}
|
|
/* A partir de dispositivos medianos (>=768px), deja espacio lateral */
|
|
@media (min-width: 768px) {
|
|
.content { margin-left: 250px; /* Ancho del sidebar */ }
|
|
.nav-tabs .nav-link { padding: 10px 15px; font-size: 14px; min-width: 120px; }
|
|
}
|
|
/* 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; }
|
|
/* Estilos mejorados para las pestañas */
|
|
.nav-tabs { border-bottom: 1px solid #dee2e6; margin-bottom: 0; }
|
|
.nav-tabs .nav-item { margin-bottom: -1px; }
|
|
.nav-tabs .nav-link { border: 1px solid transparent; border-radius: 0.375rem 0.375rem 0 0; padding: 12px 20px; color: #495057; background-color: #f8f9fa;
|
|
font-weight: 500; white-space: nowrap; min-width: 150px; text-align: center; transition: all 0.3s ease; }
|
|
.nav-tabs .nav-link:hover { border-color: #e9ecef #e9ecef #dee2e6; background-color: #e9ecef; color: #212529; }
|
|
.nav-tabs .nav-link.active { color: #495057; background-color: #fff; border-color: #dee2e6 #dee2e6 #fff; border-bottom: 2px solid #fff; }
|
|
/* Asegurar que las pestañas sean completamente visibles */
|
|
.nav-tabs .nav-item:first-child .nav-link { margin-left: 0; }
|
|
.nav-tabs .nav-item:last-child .nav-link { margin-right: 0; }
|
|
.tab-content { padding: 10px; }
|
|
/* Animaciones personalizadas */
|
|
.card-hover { transition: all 0.3s ease; cursor: pointer; }
|
|
.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); }
|
|
100% { transform: scale(1); }
|
|
}
|
|
.fade-in-up { animation: fadeInUp 0.8s ease-out; }
|
|
@keyframes fadeInUp {
|
|
from { opacity: 0; transform: translateY(30px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
/* Responsive animations */
|
|
@media (max-width: 768px) { .card-hover:hover { transform: translateY(-4px) scale(1.01); } }
|
|
/* Efecto de glow para elementos activos */
|
|
.btn.active { box-shadow: 0 0 20px rgba(var(--bs-primary-rgb), 0.5); }
|
|
/* Animación para el título */
|
|
.title-glow { text-shadow: 0 0 10px rgba(0, 123, 255, 0.3); }
|
|
/* Efecto para botones */
|
|
.btn-animated { transition: all 0.3s ease; position: relative; overflow: hidden; }
|
|
.btn-animated:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); }
|
|
.btn-animated::before { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
|
|
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent); transition: left 0.5s; }
|
|
.btn-animated:hover::before { left: 100%; }
|
|
/* ========== ANIMACIONES PARA INPUTS TEXTO ========== */
|
|
.form-control:not(.no-animation) { transition: all 0.3s ease; border: 2px solid #dee2e6; position: relative; }
|
|
.form-control:not(.no-animation):focus { border-color: #0d6efd; box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25), 0 0 20px rgba(13, 110, 253, 0.3); transform: translateY(-2px); }
|
|
.form-control:not(.no-animation):not(:placeholder-shown) { /*border-color: #198754; background-color: #f8fff9;*/ }
|
|
.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); }
|
|
}
|
|
/* Floating labels para inputs texto */
|
|
.form-floating-custom { position: relative; margin-bottom: 1.5rem; }
|
|
.form-floating-custom .form-control { padding: 1rem 0.75rem 0.5rem 0.75rem; height: auto; }
|
|
.form-floating-custom .form-label { position: absolute; top: 0.75rem; left: 0.75rem; transition: all 0.3s ease; pointer-events: none; color: #6c757d; z-index: 2; }
|
|
.form-floating-custom .form-control:focus ~ .form-label,
|
|
.form-floating-custom .form-control:not(:placeholder-shown) ~ .form-label { top: 0.25rem; font-size: 0.75rem; color: #0d6efd; font-weight: 600; }
|
|
.input-pulse:hover:not(.no-animation) { animation: inputPulse 0.6s ease-in-out; }
|
|
@keyframes inputPulse {
|
|
0% { transform: scale(1); }
|
|
50% { transform: scale(1.02); }
|
|
100% { transform: scale(1); }
|
|
}
|
|
.input-gradient:not(.no-animation) { position: relative; overflow: hidden; }
|
|
.input-gradient:not(.no-animation)::before { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
|
|
background: linear-gradient(90deg, transparent, rgba(13, 110, 253, 0.3), transparent); transition: left 0.5s; pointer-events: none; z-index: 1; }
|
|
.input-gradient:not(.no-animation):focus::before { left: 100%; }
|
|
.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); }
|
|
100% { box-shadow: 0 0 5px rgba(25, 135, 84, 0.5); }
|
|
}
|
|
/* Animación para los campos del formulario */
|
|
.form-group-animated { opacity: 0; transform: translateY(20px); animation: slideUp 0.6s ease-out forwards; }
|
|
.form-group-animated:nth-child(1) { animation-delay: 0.1s; }
|
|
.form-group-animated:nth-child(2) { animation-delay: 0.2s; }
|
|
.form-group-animated:nth-child(3) { animation-delay: 0.3s; }
|
|
.form-group-animated:nth-child(4) { animation-delay: 0.4s; }
|
|
.form-group-animated:nth-child(5) { animation-delay: 0.5s; }
|
|
.form-group-animated:nth-child(6) { animation-delay: 0.6s; }
|
|
.form-group-animated:nth-child(7) { animation-delay: 0.7s; }
|
|
.form-group-animated:nth-child(8) { animation-delay: 0.8s; }
|
|
.form-group-animated:nth-child(9) { animation-delay: 0.9s; }
|
|
.form-group-animated:nth-child(10) { animation-delay: 1.0s; }
|
|
@keyframes slideUp { to { opacity: 1; transform: translateY(0); } }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="content">
|
|
<h4 class="mb-4 animate__animated animate__fadeInDown title_glow">CONFIGURACIÓN ADUANA / PATENTE</h4>
|
|
<div class="card p-4 shadow-sm bg-white card-hover position-relative h-auto fade-in-up">
|
|
<!-- Se agrega enctype para subir archivos -->
|
|
<form action="/IMPORTADORES/patente/guardar" method="POST" id="formAltaPatente">
|
|
<!-- Pestañas de navegación -->
|
|
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
|
<li class="nav-item" role="presentation">
|
|
<button class="nav-link active" id="general-tab" data-bs-toggle="tab" data-bs-target="#general"
|
|
type="button" role="tab" aria-controls="general" aria-selected="true">
|
|
General
|
|
</button>
|
|
</li>
|
|
<li class="nav-item" role="presentation">
|
|
<button class="nav-link" id="validacion-tab" data-bs-toggle="tab" data-bs-target="#validacion"
|
|
type="button" role="tab" aria-controls="validacion" aria-selected="false">
|
|
Números de Validación y Folios
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
|
|
<!-- Contenido de las pestañas -->
|
|
<div class="tab-content" id="myTabContent">
|
|
<!-- Pestaña General -->
|
|
<div class="tab-pane fade show active" id="general" role="tabpanel" aria-labelledby="general-tab">
|
|
<p style="font-weight: bold;">Datos de la Patente / Aduana</p>
|
|
<div class="row mb-3 form-group-animated">
|
|
<label for="aduana" class="col-md-2 col-form-label">Aduana</label>
|
|
<div class="col-md-3 form-group-animated">
|
|
<input name="aduana" id="aduana" type="text" maxlength="3" class="form-control" required>
|
|
</div>
|
|
<label for="aduana" class="col-md-2 col-form-label">[ Sin Sección ]</label>
|
|
</div>
|
|
|
|
<div class="row mb-3 form-group-animated">
|
|
<label for="patente" class="col-md-2 col-form-label">Patente</label>
|
|
<div class="col-md-3 form-group-animated">
|
|
<input name="patente" id="patente" type="text" maxlength="4" class="form-control" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3 form-group-animated">
|
|
<label for="agente_aduanal" class="col-md-2 col-form-label">Agente Aduanal</label>
|
|
<div class="col-md-10 form-group-animated">
|
|
<input name="agente_aduanal" id="agente_aduanal" type="text" class="form-control" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3 form-group-animated">
|
|
<label for="rfc" class="col-md-2 col-form-label">RFC</label>
|
|
<div class="col-md-6 form-group-animated">
|
|
<input name="rfc" id="rfc" type="text" maxlength="13" class="form-control" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3 form-group-animated">
|
|
<label for="curp" class="col-md-2 col-form-label">CURP</label>
|
|
<div class="col-md-6 form-group-animated">
|
|
<input name="curp" id="curp" type="text" maxlength="18" class="form-control" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3 form-group-animated">
|
|
<label for="razon_social" class="col-md-2 col-form-label">Razón Social</label>
|
|
<div class="col-md-10 form-group-animated">
|
|
<input name="razon_social" id="razon_social" type="text" class="form-control" required>
|
|
</div>
|
|
</div><hr>
|
|
|
|
<div class="col mb-3 form-group-animated">
|
|
<P>Capturar para el llenado de la Manifestación de Valor</P>
|
|
<p style="font-weight: bold;">Datos del Agente Aduanal:</p>
|
|
<div class="row mb-3 form-group-animated">
|
|
<label for="mf_nombre" class="col-md-2 col-form-label">Nombre(s)</label>
|
|
<div class="col-md-9">
|
|
<input name="mf_nombre" id="mf_nombre" type="text" class="form-control">
|
|
</div>
|
|
</div>
|
|
<div class="row mb-3 form-group-animated">
|
|
<label for="mf_paterno" class="col-md-2 col-form-label">Apellido Paterno</label>
|
|
<div class="col-md-9 form-group-animated">
|
|
<input name="mf_paterno" id="mf_paterno" type="text" class="form-control">
|
|
</div>
|
|
</div>
|
|
<div class="row mb-3 form-group-animated">
|
|
<label for="mf_materno" class="col-md-2 col-form-label">Apellido Materno</label>
|
|
<div class="col-md-9 form-group-animated">
|
|
<input name="mf_materno" id="mf_materno" type="text" class="form-control">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Pestaña Números de Validación y Folios -->
|
|
<div class="tab-pane fade" id="validacion" role="tabpanel" aria-labelledby="validacion-tab">
|
|
<p style="font-weight: bold;">Números de Validación y Folios</p>
|
|
<!-- Pedimentos -->
|
|
<p>Números de Validación para Pedimentos</p>
|
|
<div class="row mb-3 form-group-animated">
|
|
<div class="col-md-1"></div>
|
|
<label for="vp_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vp_inicio" id="vp_inicio" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
<div class="col-md-1"></div>
|
|
<label for="vp_final" class="col-md-1 col-form-label">Final:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vp_final" id="vp_final" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
<div class="col-md-1"></div>
|
|
<label for="vp_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vp_siguiente" id="vp_siguiente" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
</div><hr>
|
|
|
|
<!-- Pago Electrónico -->
|
|
<p>Números de Validación para Pago Electrónico</p>
|
|
<div class="row mb-3 form-group-animated">
|
|
<div class="col-md-1"></div>
|
|
<label for="vpe_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vpe_inicio" id="vpe_inicio" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
<div class="col-md-1"></div>
|
|
<label for="vpe_final" class="col-md-1 col-form-label">Final:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vpe_final" id="vpe_final" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
<div class="col-md-1"></div>
|
|
<label for="vpe_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vpe_siguiente" id="vpe_siguiente" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
</div><hr>
|
|
|
|
<!-- Avisos Traslado / Plantas-Bodegas -->
|
|
<p>Números de Validación para Avisos Traslado / Plantas-Bodegas</p>
|
|
<div class="row mb-3 form-group-animated">
|
|
<div class="col-md-1"></div>
|
|
<label for="vat_pb_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vat_pb_inicio" id="vat_pb_inicio" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
<div class="col-md-1"></div>
|
|
<label for="vat_pb_final" class="col-md-1 col-form-label">Final:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vat_pb_final" id="vat_pb_final" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
<div class="col-md-1"></div>
|
|
<label for="vat_pb_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vat_pb_siguiente" id="vat_pb_siguiente" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
</div><hr>
|
|
|
|
<!-- Validación y Folio de Cartas Cupo -->
|
|
<p>Números de Validación para Cartas Cupo</p>
|
|
<div class="row mb-3 form-group-animated">
|
|
<div class="col-md-1"></div>
|
|
<label for="vcc_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vcc_inicio" id="vcc_inicio" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
<div class="col-md-1"></div>
|
|
<label for="vcc_final" class="col-md-1 col-form-label">Final:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vcc_final" id="vcc_final" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
<div class="col-md-1"></div>
|
|
<label for="vcc_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vcc_siguiente" id="vcc_siguiente" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
</div><hr>
|
|
|
|
<!-- Avisos Electrónicos -->
|
|
<p>Números de Validación para Avisos Electrónicos</p>
|
|
<div class="row mb-3 form-group-animated">
|
|
<div class="col-md-1"></div>
|
|
<label for="vae_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vae_inicio" id="vae_inicio" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
<div class="col-md-1"></div>
|
|
<label for="vae_final" class="col-md-1 col-form-label">Final:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vae_final" id="vae_final" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
<div class="col-md-1"></div>
|
|
<label for="vae_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
|
<div class="col-md-1 form-group-animated">
|
|
<input name="vae_siguiente" id="vae_siguiente" type="text" maxlength="3" class="form-control" value="000">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="text-end mt-4 form-group-animated">
|
|
<button type="submit" class="btn btn-primary mt-auto w-auto btn-animated">Registrar</button>
|
|
<a href="/IMPORTADORES/patente/lista" class="btn btn-secondary ms-2 mt-auto w-auto btn-animated">Cancelar</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById('formAltaPatente').addEventListener('submit', function(e) {
|
|
e.preventDefault(); // Prevenir envío por defecto
|
|
|
|
// Obtener todos los campos correctamente
|
|
const aduana = document.getElementById('aduana').value;
|
|
const patente = document.getElementById('patente').value;
|
|
const agente_aduanal = document.getElementById('agente_aduanal').value.trim();
|
|
const rfc = document.getElementById('rfc').value.trim();
|
|
const curp = document.getElementById('curp').value.trim();
|
|
const razon_social = document.getElementById('razon_social').value.trim();
|
|
|
|
// Expresiones regulares
|
|
const rfcRegex = /^[A-ZÑ&]{3,4}\d{6}[A-Z0-9]{3}$/;
|
|
const curpRegex = /^[A-Z]{4}[0-9]{6}[HM](AS|BC|BS|CC|CL|CM|CS|CH|DF|DG|GT|GR|HG|JC|MC|MN|MS|NT|NL|OC|PL|QT|QR|SP|SL|SR|TC|TS|TL|VZ|YN|ZS)[A-Z]{3}[A-Z0-9]{2}$/;
|
|
const soloNumerosRegex = /^[0-9]+$/;
|
|
|
|
if (!aduana) {
|
|
Swal.fire({ icon: 'warning', title: 'Campo requerido', text: 'La aduana es obligatoria.', confirmButtonColor: '#dc3545' });
|
|
document.getElementById('aduana').focus();
|
|
return;
|
|
}
|
|
if (!soloNumerosRegex.test(aduana)) {
|
|
Swal.fire({ icon: 'error', title: 'Aduana inválida', text: 'La aduana solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
document.getElementById('aduana').focus();
|
|
return;
|
|
}
|
|
if (!patente) {
|
|
Swal.fire({ icon: 'warning', title: 'Campo requerido', text: 'La patente es obligatoria.', confirmButtonColor: '#dc3545' });
|
|
document.getElementById('patente').focus();
|
|
return;
|
|
}
|
|
if (!soloNumerosRegex.test(patente)) {
|
|
Swal.fire({ icon: 'error', title: 'Patente inválida', text: 'La patente solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
document.getElementById('patente').focus();
|
|
return;
|
|
}
|
|
if (!agente_aduanal) {
|
|
Swal.fire({ icon: 'warning', title: 'Campo requerido', text: 'El agente aduanal es obligatorio.', confirmButtonColor: '#dc3545' });
|
|
document.getElementById('agente_aduanal').focus();
|
|
return;
|
|
}
|
|
if (!rfc) {
|
|
Swal.fire({ icon: 'warning', title: 'Campo requerido', text: 'El RFC es obligatorio.', confirmButtonColor: '#dc3545' });
|
|
document.getElementById('rfc').focus();
|
|
return;
|
|
}
|
|
if (!rfcRegex.test(rfc)) {
|
|
Swal.fire({ icon: 'error', title: 'RFC inválido', text: 'El RFC debe tener 12 o 13 caracteres con el formato correcto (ej. ABC123456XYZ).', confirmButtonColor: '#dc3545' });
|
|
document.getElementById('rfc').focus();
|
|
return;
|
|
}
|
|
if (!curp) {
|
|
Swal.fire({ icon: 'warning', title: 'Campo requerido', text: 'El CURP es obligatorio.', confirmButtonColor: '#dc3545' });
|
|
document.getElementById('curp').focus();
|
|
return;
|
|
}
|
|
if (curp && !curpRegex.test(curp)) {
|
|
Swal.fire({ icon: 'error', title: 'CURP inválido', text: 'El CURP debe tener 18 caracteres con el formato correcto.', confirmButtonColor: '#dc3545'
|
|
});
|
|
document.getElementById('curp').focus();
|
|
return;
|
|
}
|
|
if (!razon_social) {
|
|
Swal.fire({ icon: 'warning', title: 'Campo requerido', text: 'La razón social es obligatoria.', confirmButtonColor: '#dc3545' });
|
|
document.getElementById('razon_social').focus();
|
|
return;
|
|
}
|
|
|
|
// Obtener campos de folios (ahora VARCHAR)
|
|
const folios = [
|
|
{ id: 'vp_inicio', nombre: 'VP Inicio' },
|
|
{ id: 'vp_final', nombre: 'VP Final' },
|
|
{ id: 'vp_siguiente', nombre: 'VP Siguiente' },
|
|
{ id: 'vpe_inicio', nombre: 'VPE Inicio' },
|
|
{ id: 'vpe_final', nombre: 'VPE Final' },
|
|
{ id: 'vpe_siguiente', nombre: 'VPE Siguiente' },
|
|
{ id: 'vat_pb_inicio', nombre: 'VAT PB Inicio' },
|
|
{ id: 'vat_pb_final', nombre: 'VAT PB Final' },
|
|
{ id: 'vat_pb_siguiente', nombre: 'VAT PB Siguiente' },
|
|
{ id: 'vcc_inicio', nombre: 'VCC Inicio' },
|
|
{ id: 'vcc_final', nombre: 'VCC Final' },
|
|
{ id: 'vcc_siguiente', nombre: 'VCC Siguiente' },
|
|
{ id: 'vae_inicio', nombre: 'VAE Inicio' },
|
|
{ id: 'vae_final', nombre: 'VAE Final' },
|
|
{ id: 'vae_siguiente', nombre: 'VAE Siguiente' }
|
|
];
|
|
|
|
// Validar campos de folios
|
|
for (let folio of folios) {
|
|
const valor = document.getElementById(folio.id).value.trim();
|
|
|
|
if (valor !== '') {
|
|
// Validar longitud máxima
|
|
if (valor.length > 10) {
|
|
Swal.fire({ icon: 'error', title: 'Campo demasiado largo', text: `${folio.nombre} no puede exceder 10 caracteres.`, confirmButtonColor: '#dc3545' });
|
|
document.getElementById(folio.id).focus();
|
|
return;
|
|
}
|
|
|
|
// Opcional: Si quieres mantener solo números, descomenta estas líneas
|
|
/*
|
|
if (!soloNumerosRegex.test(valor)) {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Campo inválido',
|
|
text: `${folio.nombre} solo puede contener números.`,
|
|
confirmButtonColor: '#dc3545'
|
|
});
|
|
document.getElementById(folio.id).focus();
|
|
return;
|
|
}
|
|
*/
|
|
}
|
|
}
|
|
|
|
// Si todas las validaciones pasan, mostrar carga y enviar
|
|
Swal.fire({ title: 'Guardando...', text: 'Por favor espere', allowOutsideClick: false, showConfirmButton: false, willOpen: () => { Swal.showLoading(); } });
|
|
|
|
// SI TODAS LAS VALIDACIONES PASAN, ENVIAR EL FORMULARIO
|
|
this.submit();
|
|
});
|
|
// Script para manejar las animaciones de validación
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const inputs = document.querySelectorAll('input.form-control');
|
|
|
|
inputs.forEach(input => {
|
|
// Validación en tiempo real
|
|
input.addEventListener('input', function() {
|
|
if (this.checkValidity()) {
|
|
this.classList.remove('shake');
|
|
this.classList.add('valid');
|
|
} else {
|
|
this.classList.remove('valid');
|
|
}
|
|
});
|
|
|
|
// Efecto shake en campos inválidos
|
|
input.addEventListener('invalid', function() {
|
|
this.classList.add('shake');
|
|
setTimeout(() => {
|
|
this.classList.remove('shake');
|
|
}, 500);
|
|
});
|
|
});
|
|
|
|
// Validación del formulario
|
|
document.getElementById('formAltaPatente').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
|
|
let isValid = true;
|
|
inputs.forEach(input => {
|
|
if (!input.checkValidity()) {
|
|
input.classList.add('shake');
|
|
isValid = false;
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|