Revisión 2.1
This commit is contained in:
@@ -41,13 +41,19 @@
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Contenedor *</label>
|
||||
<input name="vehiculo" id="vehEdit" class="form-control"
|
||||
value="<?= htmlspecialchars($t['vehiculo']) ?>" required>
|
||||
<div class="d-flex align-items-center">
|
||||
<input name="vehiculo" id="vehiculo" class="form-control" maxlength="20"
|
||||
value="<?= htmlspecialchars($t['vehiculo']) ?>" required>
|
||||
<button type="button" class="btn btn-outline-secondary ms-2" data-bs-toggle="modal" data-bs-target="#infoContenedor" style="border: none;">ℹ️</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Identificador fiscal *</label>
|
||||
<input name="identificador_fiscal" id="fiscEdit" class="form-control"
|
||||
value="<?= htmlspecialchars($t['identificador_fiscal']) ?>" required>
|
||||
<label class="form-label">Identificación fiscal *</label>
|
||||
<div class="d-flex align-items-center">
|
||||
<input name="identificador_fiscal" id="identificador_fiscal" class="form-control" maxlength="20"
|
||||
value="<?= htmlspecialchars($t['identificador_fiscal']) ?>" required>
|
||||
<button type="button" class="btn btn-outline-secondary ms-2" data-bs-toggle="modal" data-bs-target="#infoIdentificacion" style="border: none;">ℹ️</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Foto actual</label><br>
|
||||
@@ -59,15 +65,15 @@
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Reemplazar foto (opcional)</label>
|
||||
<input type="file" name="foto" id="fotoEdit" class="form-control" accept="image/*">
|
||||
<input type="file" name="foto" id="foto" class="form-control" accept="image/*">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Transportista *</label>
|
||||
<select name="id_transportista" id="trEdit" class="form-select" required>
|
||||
<select name="id_transportista" id="transportista" class="form-select" required>
|
||||
<?php foreach($transportistas as $tr): ?>
|
||||
<option value="<?= $tr['id_transportista'] ?>"
|
||||
<?= $tr['id_transportista']==$t['id_transportista']?'selected':'' ?>>
|
||||
<?= htmlspecialchars($tr['nombre']) ?>
|
||||
<?= htmlspecialchars(($tr['clave_identificador'] . ' - ' . $tr['nombre'] . ' - ' . $tr['ciudad_nombre'] . ' - ' . $tr['domicilio'])) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
@@ -80,38 +86,70 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Modales movidos FUERA del formulario -->
|
||||
<!-- Modal de ayuda - Contenedor -->
|
||||
<div class="modal fade" id="infoContenedor" tabindex="-1" aria-labelledby="infoContenedorLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="infoContenedorLabel">Info - Contenedor</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cerrar"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<strong>• Número económico del vehículo.</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal de ayuda - Identificación Fiscal -->
|
||||
<div class="modal fade" id="infoIdentificacion" tabindex="-1" aria-labelledby="infoIdentificacionLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="infoIdentificacionLabel">Info - Identificación Fiscal</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cerrar"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
• Si el medio de transporte es <strong>vehículo terrestre</strong>, se anotarán las <strong>placas de circulación</strong> del mismo.<br><br>
|
||||
• Si el medio de transporte es <strong>ferrocarril</strong>, se anotará el <strong>número de furgón o plataforma</strong>.<br><br>
|
||||
• Si el medio de transporte es <strong>marítimo</strong>, se anotará el <strong>nombre de la embarcación</strong>.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('formTransEdit').addEventListener('submit', function(e) {
|
||||
e.preventDefault(); // Prevenir envío por defecto
|
||||
|
||||
// Campos que validamos:
|
||||
const veh = document.getElementById('vehEdit').value.trim();
|
||||
const fisc = document.getElementById('fiscEdit').value.trim();
|
||||
const trans = document.getElementById('trEdit').value;
|
||||
const fotoF = document.getElementById('fotoEdit').files[0];
|
||||
const veh = document.getElementById('vehiculo').value.trim();
|
||||
const fisc = document.getElementById('identificador_fiscal').value.trim();
|
||||
const trans = document.getElementById('transportista').value;
|
||||
const fotoF = document.getElementById('foto').files[0];
|
||||
|
||||
// Validaciones de campos obligatorios
|
||||
if (!veh) {
|
||||
e.preventDefault();
|
||||
Swal.fire({ icon:'error', title:'Vehículo requerido', text:'Por favor ingresa el nombre del vehículo.', confirmButtonColor: '#dc3545'});
|
||||
document.querySelector('input[name="veh"]').focus();
|
||||
Swal.fire({ icon:'error', title:'Contenedor requerido', text:'Por favor ingresa el número económico del vehículo.', confirmButtonColor: '#dc3545'});
|
||||
document.getElementById('vehiculo').focus();
|
||||
return;
|
||||
}
|
||||
if (!fisc) {
|
||||
e.preventDefault();
|
||||
Swal.fire({ icon:'error', title:'Identificador fiscal requerido', text:'Por favor ingresa el identificador fiscal.', confirmButtonColor: '#dc3545' });
|
||||
document.querySelector('input[name="fisc"]').focus();
|
||||
Swal.fire({ icon:'error', title:'Identificación fiscal requerida', text:'Por favor ingresa la identificación fiscal.', confirmButtonColor: '#dc3545' });
|
||||
document.getElementById('identificador_fiscal').focus();
|
||||
return;
|
||||
}
|
||||
if (!trans) {
|
||||
e.preventDefault();
|
||||
Swal.fire({ icon:'error', title:'Transportista no seleccionado', text:'Debes elegir un transportista.', confirmButtonColor: '#dc3545' });
|
||||
document.querySelector('input[name="trans"]').focus();
|
||||
document.getElementById('transportista').focus();
|
||||
return;
|
||||
}
|
||||
if (fotoF && fotoF.size > 2 * 1024 * 1024) { // 2 MB
|
||||
e.preventDefault();
|
||||
return Swal.fire({ icon:'error', title:'Foto demasiado grande', text:'La imagen no debe exceder 2 MB.' });
|
||||
}
|
||||
// Si todas las validaciones pasan, el formulario se envía.
|
||||
this.submit();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user