Merge branch 'main' of https://github.com/AduanaSoft/IMPORTADORES
This commit is contained in:
@@ -233,7 +233,7 @@
|
||||
|
||||
<!-- Activo -->
|
||||
<div class="form-check mb-4">
|
||||
<input id="status" name="status" type="checkbox" class="hide form-check-input" <?= $factura['status']==1?'checked':'' ?>>
|
||||
<input id="status" value=1 name="status" type="checkbox" class="hide form-check-input" <?= $factura['status']==1?'checked':'' ?>>
|
||||
<label for="status" class="hide form-check-label">Activo</label>
|
||||
</div>
|
||||
|
||||
@@ -269,6 +269,7 @@
|
||||
// ✅ 2. FUNCIÓN PARA CARGAR PROVEEDORES (CON PROMESA)
|
||||
function cargarProveedores() {
|
||||
const proveedorEl = document.getElementById('proveedor_id');
|
||||
// Obtenemos la cadena con la ID del proveedor guardado
|
||||
const proveedorActual = '<?= htmlspecialchars($proveedor_clave_actual ?? '') ?>';
|
||||
|
||||
return fetch('/IMPORTADORES/solicitud_importacion/ajax_proveedores')
|
||||
@@ -287,8 +288,8 @@
|
||||
opt.value = item.id;
|
||||
opt.textContent = item.text;
|
||||
|
||||
// ✅ Pre-seleccionar si coincide con el proveedor actual
|
||||
if (item.id === proveedorActual && proveedorActual !== '') {
|
||||
// Comparar forzando a cadena para que coincida con proveedorActual
|
||||
if (String(item.id) === proveedorActual && proveedorActual !== '') {
|
||||
opt.selected = true;
|
||||
}
|
||||
|
||||
@@ -395,4 +396,4 @@
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -151,29 +151,42 @@
|
||||
// $row.find('.status-select').prop('disabled', disable);
|
||||
}
|
||||
|
||||
// Al cambiar el select de status
|
||||
$('#tabla-solicitudes').on('change', '.status-select', function () {
|
||||
const $sel = $(this);
|
||||
const id = $sel.data('id');
|
||||
const status = $sel.val();
|
||||
const $row = $sel.closest('tr');
|
||||
// Bloquear botones localmente
|
||||
updateRowStatus($row, status);
|
||||
// Al cambiar el select de status
|
||||
$('#tabla-solicitudes').on('change', '.status-select', function () {
|
||||
const $sel = $(this);
|
||||
const id = $sel.data('id');
|
||||
const status = $sel.val();
|
||||
const $row = $sel.closest('tr');
|
||||
// Bloquear botones localmente
|
||||
updateRowStatus($row, status);
|
||||
|
||||
// Llamada AJAX
|
||||
$.post(
|
||||
'/IMPORTADORES/solicitud_importacion/update_status',
|
||||
{ id: id, status: status },
|
||||
null,
|
||||
'json'
|
||||
)
|
||||
.done(function(res) {
|
||||
if (!res.success) {
|
||||
Swal.fire('Error', 'No se pudo actualizar status', 'error');
|
||||
} else if (res.numeroPedimentoLocal) {
|
||||
// Si vino numeroPedimentoLocal, mostramos alerta específica
|
||||
Swal.fire(
|
||||
'Importación solicitada',
|
||||
'Se generó el número de pedimento: ' + res.numeroPedimentoLocal,
|
||||
'success'
|
||||
);
|
||||
// Además podrías actualizar en la tabla la celda de "Pedimento" si quieres:
|
||||
$row.find('td:nth-child(4)').text(res.numeroPedimentoLocal);
|
||||
}
|
||||
// Si success pero no viene numeroPedimentoLocal, no hacemos nada especial.
|
||||
})
|
||||
.fail(function() {
|
||||
Swal.fire('Error', 'No se pudo conectar al servidor', 'error');
|
||||
});
|
||||
});
|
||||
|
||||
// Llamada AJAX
|
||||
$.post(
|
||||
'/IMPORTADORES/solicitud_importacion/update_status',
|
||||
{ id: id, status: status },
|
||||
function(res) {
|
||||
if (!res.success) {
|
||||
Swal.fire('Error','No se pudo actualizar status','error');
|
||||
}
|
||||
},
|
||||
'json'
|
||||
).fail(() => {
|
||||
Swal.fire('Error','No se pudo conectar al servidor','error');
|
||||
});
|
||||
});
|
||||
|
||||
// Al cargar, aplica bloqueo si ya está en “Solicitar importación”
|
||||
$('#tabla-solicitudes tbody tr').each(function () {
|
||||
|
||||
Reference in New Issue
Block a user