diff --git a/app/controllers/solicitud_importacion.php b/app/controllers/solicitud_importacion.php index 12a0381..306ca0f 100644 --- a/app/controllers/solicitud_importacion.php +++ b/app/controllers/solicitud_importacion.php @@ -576,12 +576,12 @@ function editar() $id_agencia = null; if ($row = sqlsrv_fetch_array($stmtAg, SQLSRV_FETCH_ASSOC)) { $id_agencia = $row['id_agencia_en_uso']; } - $stmt = sqlsrv_query($conn,"SELECT * FROM dbo.solicitud_importacion_factura WHERE id_solicitud=? AND id_importador=? AND id_agencia=?", [(int)$id_solicitud, $id_importador, $id_agencia]); + $stmt = sqlsrv_query($conn, "SELECT * FROM dbo.solicitud_importacion_factura WHERE id_solicitud=? AND id_importador=? AND id_agencia=?", [(int)$id_solicitud, $id_importador, $id_agencia]); if($stmt === false) { die(print_r(sqlsrv_errors(),true)); } - $factura = sqlsrv_fetch_array($stmt,SQLSRV_FETCH_ASSOC); + $factura = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC); if(!$factura) { die("❌ No autorizado."); } @@ -690,7 +690,11 @@ function actualizar() $chofer_id = (int)($_POST['chofer_id'] ?? 0); $status = isset($_POST['status']) ?? 1; $patente_id = $_POST['patente'] ?? null; - $proveedor_clave = $_POST['proveedor_clave'] ?? null; + $proveedor_clave = trim($_POST['proveedor_clave'] ?? null); + + if ($proveedor_clave === '') { + $proveedor_clave = null; + } // ✅ NUEVO: Validar que la patente pertenezca a la agencia del usuario (si se seleccionó una) if ($patente_id) { @@ -952,6 +956,7 @@ function generarPedimentoDesdeSolicitud($conn, $id, $usuarioId, $token) return ['success' => false, 'error' => $e->getMessage()]; } } + /** GET /IMPORTADORES/solicitud_importacion/ajax_proveedores * Devuelve JSON para poblar el select de Proveedor **/ function ajax_proveedores() @@ -972,7 +977,7 @@ function ajax_proveedores() $ch = curl_init($url); curl_setopt_array($ch, [ - CURLOPT_HTTPHEADER => ["Authorization: $token", 'Accept: application/json'], + CURLOPT_HTTPHEADER => ["Authorization: Bearer $token", 'Accept: application/json'], CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 5, ]); diff --git a/views/solicitud_importacion/crear.php b/views/solicitud_importacion/crear.php index 7d65db1..72613af 100644 --- a/views/solicitud_importacion/crear.php +++ b/views/solicitud_importacion/crear.php @@ -58,80 +58,6 @@ .btn-animated:hover::before { left: 100%; } .hide { display: none !important; } .alert { top: 75px; left: 275px; right: 50px; position: fixed; z-index: 1050; width: calc(100% - 285px); } - .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%; } - .form-label { font-weight: 500; } - /* ========== 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); } } - /* ========== ESTILOS PARA CAMPO FOTO (SIN ANIMACIONES) ========== */ - .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; } @@ -158,11 +84,11 @@
-
+
-
+
@@ -230,7 +156,7 @@
-
+
@@ -268,9 +194,9 @@
-
+
- +
@@ -295,9 +221,9 @@ - - - + + +
- - + +
- - - + + +
-
- -
+ -
+
-
- - Cancelar -
+ + Cancelar
@@ -590,67 +512,6 @@ }); }); }); - - // Script para manejar las animaciones de validación - document.addEventListener('DOMContentLoaded', function() { - const inputs = document.querySelectorAll('input.form-control, select.form_select'); - const selects = document.querySelectorAll('select.form_select'); - - 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); - }); - }); - - // Configurar selects - selects.forEach(select => { - select.addEventListener('change', function() { - updateSelectState(this); - }); - updateSelectState(select); - }); - - function updateSelectState(select) { - select.setAttribute('value', select.value); - - if (select.value && select.value !== '') { - select.classList.add('valid'); - select.classList.remove('invalid'); - } else { - select.classList.remove('valid'); - if (select.hasAttribute('required') && select.closest('form')?.classList.contains('was-validated')) { - select.classList.add('invalid'); - } - } - } - - // Validación del formulario - document.getElementById('altaProductoFrecuenteForm').addEventListener('submit', function(e) { - e.preventDefault(); - - let isValid = true; - inputs.forEach(input => { - if (!input.checkValidity()) { - input.classList.add('shake'); - isValid = false; - } - }); - }); - }); diff --git a/views/solicitud_importacion/editar.php b/views/solicitud_importacion/editar.php index e59c877..c05e5d8 100644 --- a/views/solicitud_importacion/editar.php +++ b/views/solicitud_importacion/editar.php @@ -156,8 +156,8 @@ value="">
- -
@@ -393,7 +393,7 @@ // ✅ 2. FUNCIÓN PARA CARGAR PROVEEDORES (CON PROMESA) function cargarProveedores() { - const proveedorEl = document.getElementById('proveedor_id'); + const proveedorEl = document.getElementById('proveedor_clave'); // Obtenemos la cadena con la ID del proveedor guardado const proveedorActual = ''; @@ -765,7 +765,7 @@ } // Validación del formulario - document.getElementById('altaProductoFrecuenteForm').addEventListener('submit', function(e) { + document.getElementById('solicitudForm').addEventListener('submit', function(e) { e.preventDefault(); let isValid = true;