seccion expediente electronico

This commit is contained in:
2025-05-21 10:58:02 -06:00
parent d10d68f607
commit f7ba0e3381
91 changed files with 876 additions and 28 deletions

View File

@@ -11,6 +11,7 @@
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
<style>
table.dataTable thead th { background: #343a40; color: #fff; }
body { font-family: 'Segoe UI', sans-serif; background-color: #f4f6f9; }
@@ -74,11 +75,14 @@
.card {
border-radius: 12px;
}
.status-select:disabled {
background-color: #e9ecef;
color: #6c757d;
}
</style>
</head>
<body>
<?php include __DIR__ . '/../partials/sidebar_importador.php'; ?>
<br><br>
<div class="content">
<h4>📄 Solicitudes de Importación</h4>
<a href="/IMPORTADORES/solicitud_importacion/crear" class="btn btn-success mb-3"> Nueva Solicitud</a>
@@ -97,6 +101,8 @@
<th>Vinculación</th>
<th>Transportista</th>
<th>PDF</th>
<!-- Nueva columna Status -->
<th>Status</th>
<th>Acciones</th>
</tr>
</thead>
@@ -127,6 +133,19 @@
📄 PDF
</a>
</td>
<!-- Celda de Status -->
<td>
<select
class="form-select status-select"
data-id="<?= $f['id_solicitud'] ?>"
>
<option value="1" <?= $f['status']==1 ? 'selected' : '' ?>>1 En proceso</option>
<option value="2" <?= $f['status']==2 ? 'selected' : '' ?>>2 Solicitar importación</option>
<option value="3" <?= $f['status']==3 ? 'selected' : '' ?>>3 Con agencia aduana</option>
<option value="4" <?= $f['status']==4 ? 'selected' : '' ?>>4 En proceso de pago</option>
<option value="5" <?= $f['status']==5 ? 'selected' : '' ?>>5 Pedimento generado</option>
</select>
</td>
<td>
<a href="/IMPORTADORES/solicitud_importacion/editar?id=<?= $f['id_solicitud'] ?>"
class="btn btn-sm btn-primary">✏️</a>
@@ -158,22 +177,58 @@
}
$(document).ready(function () {
$('#tabla-solicitudes').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.13.4/i18n/es-ES.json'
}
// Inicializa DataTable
const table = $('#tabla-solicitudes').DataTable({
language: { url: '//cdn.datatables.net/plug-ins/1.13.4/i18n/es-ES.json' }
});
});
<?php if(isset($_GET['deleted'])): ?>
Swal.fire('¡Hecho!','Solicitud eliminada.','success');
<?php endif; ?>
<?php if(isset($_GET['created'])): ?>
Swal.fire('¡Listo!','Solicitud creada.','success');
<?php endif; ?>
<?php if(isset($_GET['updated'])): ?>
Swal.fire('¡Listo!','Solicitud actualizada.','success');
<?php endif; ?>
// Función para bloquear o desbloquear acciones según status
function updateRowStatus($row, status) {
const disable = status === '2'; // 2 = Solicitar importación
$row.find('a.btn, button.btn').prop('disabled', disable);
// Si quieres bloquear también el propio select:
// $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);
// 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 () {
const $sel = $(this).find('.status-select');
if ($sel.length) updateRowStatus($(this), $sel.val());
});
// Mensajes SweetAlert tras acciones
<?php if(isset($_GET['deleted'])): ?>
Swal.fire('¡Hecho!','Solicitud eliminada.','success');
<?php elseif(isset($_GET['created'])): ?>
Swal.fire('¡Listo!','Solicitud creada.','success');
<?php elseif(isset($_GET['updated'])): ?>
Swal.fire('¡Listo!','Solicitud actualizada.','success');
<?php endif; ?>
});
</script>
</body>
</html>