solicitudes impo
This commit is contained in:
@@ -233,7 +233,7 @@
|
||||
|
||||
<!-- Activo -->
|
||||
<div class="form-check mb-4">
|
||||
<input id="status" value=1 name="status" type="checkbox" class="hide form-check-input" <?= $factura['status']==1?'checked':'' ?>>
|
||||
<input id="status" value=1 name="status" type="hidden" <?= $factura['status']==1?'checked':'' ?>>
|
||||
<label for="status" class="hide form-check-label">Activo</label>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -41,11 +41,14 @@
|
||||
<div class="content">
|
||||
<h4>📄 Solicitudes de Importación</h4>
|
||||
<a href="/IMPORTADORES/solicitud_importacion/crear" class="btn btn-success mb-3">➕ Nueva Solicitud</a>
|
||||
<button class="btn btn-warning mb-3" id="btn-solicitar-masivo">🚚 Solicitar Importación Masiva</button>
|
||||
|
||||
<div class="card p-3 shadow-sm">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="tabla-solicitudes">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox" id="select-all"></th>
|
||||
<th>#</th>
|
||||
<th>Factura</th>
|
||||
<th>Fecha</th>
|
||||
@@ -65,6 +68,9 @@
|
||||
<tbody>
|
||||
<?php foreach($facturas as $f): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" class="select-solicitud" value="<?= $f['id_solicitud'] ?>">
|
||||
</td>
|
||||
<td><?= $f['id_solicitud'] ?></td>
|
||||
<td><?= htmlspecialchars($f['numero_factura']) ?></td>
|
||||
<td><?= htmlspecialchars($f['fecha_factura']) ?></td>
|
||||
@@ -332,8 +338,59 @@
|
||||
<?php elseif(isset($_GET['created'])): ?>
|
||||
Swal.fire('¡Listo!','Solicitud creada.','success');
|
||||
<?php elseif(isset($_GET['updated'])): ?>
|
||||
Swal.fire('¡Listo!','Solicitud actualizada.','success');
|
||||
Swal.fire('¡Listo!','Solicitud actualizada. El estatus actual cambio a en proceso. ','success');
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
// Marcar o desmarcar todos
|
||||
$('#select-all').on('change', function () {
|
||||
$('.select-solicitud').prop('checked', this.checked);
|
||||
});
|
||||
|
||||
// Acción masiva
|
||||
$('#btn-solicitar-masivo').on('click', function () {
|
||||
const selected = $('.select-solicitud:checked').map(function () {
|
||||
return $(this).val();
|
||||
}).get();
|
||||
|
||||
if (selected.length === 0) {
|
||||
Swal.fire('Sin selección', 'Selecciona al menos una solicitud.', 'info');
|
||||
return;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: `¿Solicitar importación para ${selected.length} solicitudes?`,
|
||||
text: 'Se actualizará el estatus a "Solicitar importación" (2)',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sí, proceder',
|
||||
cancelButtonText: 'Cancelar'
|
||||
}).then(result => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: '/IMPORTADORES/solicitud_importacion/actualizar_masivo',
|
||||
method: 'POST',
|
||||
data: { ids: selected, status: 2 },
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
if (res.success) {
|
||||
Swal.fire('¡Hecho!', `${res.actualizadas} solicitudes actualizadas.`, 'success')
|
||||
.then(() => location.reload());
|
||||
} else {
|
||||
Swal.fire('Error', res.error || 'No se pudieron actualizar.', 'error');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
Swal.fire('Error', 'No se pudo contactar al servidor.', 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user