Sprint 2
This commit is contained in:
@@ -84,17 +84,22 @@ include __DIR__ . '/../partials/sidebar_configuracion.php';
|
||||
<h4 class="mb-4">ℹ️ Información General</h4>
|
||||
<div class="card shadow-sm p-4 mb-4 bg-white">
|
||||
<form>
|
||||
<div class="row mb-2">
|
||||
<div class="row mb-3">
|
||||
<label class="col-md-2 col-form-label">Clave:</label>
|
||||
<div class="col-md-3">
|
||||
<input type="text" class="form-control" value="<?= htmlspecialchars($datos['clave'] ?? '') ?>" disabled>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1"></div>
|
||||
<div class="col-md-3"></div>
|
||||
|
||||
<label class="col-md-2 col-form-label">Tipo de identificador:</label>
|
||||
<div class="col-md-4">
|
||||
<input type="text" class="form-control" value="<?= htmlspecialchars($datos['tipo_identificador'] ?? '') ?>" disabled>
|
||||
<div class="col-md-2">
|
||||
<select name="tipo_identificador" class="form-control" disabled>
|
||||
<option value="">-- Selecciona una opción --</option>
|
||||
<option value="1" <?= ($datos['tipo_identificador'] ?? '') == '1' ? 'selected' : '' ?>>1 - RFC</option>
|
||||
<option value="2" <?= ($datos['tipo_identificador'] ?? '') == '2' ? 'selected' : '' ?>>2 - CURP</option>
|
||||
<option value="3" <?= ($datos['tipo_identificador'] ?? '') == '3' ? 'selected' : '' ?>>3 - SIN TAX ID</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -88,20 +88,23 @@ include __DIR__ . '/../partials/sidebar_configuracion.php';
|
||||
<h4 class="mb-4">✏️ Editar Información</h4>
|
||||
<div class="card shadow-sm p-4 mb-4 bg-white">
|
||||
<form id="form-edicion" method="POST" action="/IMPORTADORES/configuracion/guardar">
|
||||
<div class="row mb-2">
|
||||
<div class="row mb-3">
|
||||
<label class="col-md-2 col-form-label">Clave:</label>
|
||||
<div class="col-md-3">
|
||||
<input type="text" name="clave" maxlength="8"
|
||||
class="form-control" value="<?= htmlspecialchars($datos['clave'] ?? '') ?>" disabled>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1"></div>
|
||||
<div class="col-md-3"></div>
|
||||
|
||||
<label class="col-md-2 col-form-label">Tipo de identificador:</label>
|
||||
<div class="col-md-4">
|
||||
<input type="number" name="tipo_identificador"
|
||||
class="form-control" value="<?= htmlspecialchars($datos['tipo_identificador'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['tipo_identificador'] ?? '') ?>'">
|
||||
<div class="col-md-2">
|
||||
<select name="tipo_identificador" class="form-control" required>
|
||||
<option value="">-- Selecciona una opción --</option>
|
||||
<option value="1" <?= ($datos['tipo_identificador'] ?? '') == '1' ? 'selected' : '' ?>>1 - RFC</option>
|
||||
<option value="2" <?= ($datos['tipo_identificador'] ?? '') == '2' ? 'selected' : '' ?>>2 - CURP</option>
|
||||
<option value="3" <?= ($datos['tipo_identificador'] ?? '') == '3' ? 'selected' : '' ?>>3 - SIN TAX ID</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -123,87 +126,78 @@ include __DIR__ . '/../partials/sidebar_configuracion.php';
|
||||
<label class="col-md-1 col-form-label">CURP:</label>
|
||||
<div class="col-md-5">
|
||||
<input type="text" name="curp" maxlength="18"
|
||||
class="form-control" value="<?= htmlspecialchars($datos['curp'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['curp'] ?? '') ?>'">
|
||||
class="form-control" value="<?= htmlspecialchars($datos['curp'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-md-2 col-form-label">Calle:</label>
|
||||
<div class="col-md-10">
|
||||
<input type="text" name="calle" class="form-control" value="<?= htmlspecialchars($datos['calle'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['calle'] ?? '') ?>'">
|
||||
<input type="text" name="calle" class="form-control" value="<?= htmlspecialchars($datos['calle'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-md-2 col-form-label">Núm. Exterior:</label>
|
||||
<div class="col-md-2">
|
||||
<input type="number" name="num_exterior" class="form-control" value="<?= htmlspecialchars($datos['num_exterior'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['num_exterior'] ?? '') ?>'">
|
||||
<input type="text" name="num_exterior" class="form-control" value="<?= htmlspecialchars($datos['num_exterior'] ?? '') ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-4"></div>
|
||||
|
||||
<label class="col-md-2 col-form-label">Núm. Interior:</label>
|
||||
<div class="col-md-2">
|
||||
<input type="text" name="num_interior" class="form-control" value="<?= htmlspecialchars($datos['num_interior'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['num_interior'] ?? '') ?>'">
|
||||
<input type="text" name="num_interior" class="form-control" value="<?= htmlspecialchars($datos['num_interior'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-md-2 col-form-label">Ciudad / Localidad:</label>
|
||||
<div class="col-md-3">
|
||||
<input type="text" name="ciudad" class="form-control" value="<?= htmlspecialchars($datos['ciudad'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['ciudad'] ?? '') ?>'">
|
||||
<input type="text" name="ciudad" class="form-control" value="<?= htmlspecialchars($datos['ciudad'] ?? '') ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-1"></div>
|
||||
|
||||
<label class="col-md-1 col-form-label">Colonia:</label>
|
||||
<div class="col-md-5">
|
||||
<input type="text" name="colonia" class="form-control" value="<?= htmlspecialchars($datos['colonia'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['colonia'] ?? '') ?>'">
|
||||
<input type="text" name="colonia" class="form-control" value="<?= htmlspecialchars($datos['colonia'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-md-2 col-form-label">País:</label>
|
||||
<div class="col-md-3">
|
||||
<input type="text" name="pais" class="form-control" value="<?= htmlspecialchars($datos['pais'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['pais'] ?? '') ?>'">
|
||||
<input type="text" name="pais" class="form-control" value="<?= htmlspecialchars($datos['pais'] ?? '') ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3"></div>
|
||||
|
||||
<label class="col-md-2 col-form-label">Código Postal:</label>
|
||||
<div class="col-md-2">
|
||||
<input type="number" name="codigo_postal" class="form-control" value="<?= htmlspecialchars($datos['codigo_postal'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['codigo_postal'] ?? '') ?>'">
|
||||
<input type="number" name="codigo_postal" class="form-control" value="<?= htmlspecialchars($datos['codigo_postal'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-md-2 col-form-label">Municipio:</label>
|
||||
<div class="col-md-4">
|
||||
<input type="text" name="municipio" class="form-control" value="<?= htmlspecialchars($datos['municipio'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['municipio'] ?? '') ?>'">
|
||||
<input type="text" name="municipio" class="form-control" value="<?= htmlspecialchars($datos['municipio'] ?? '') ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-1"></div>
|
||||
|
||||
<label class="col-md-1 col-form-label">Estado:</label>
|
||||
<div class="col-md-4">
|
||||
<input type="text" name="estado" class="form-control" value="<?= htmlspecialchars($datos['estado'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['estado'] ?? '') ?>'">
|
||||
<input type="text" name="estado" class="form-control" value="<?= htmlspecialchars($datos['estado'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-md-2 col-form-label">Teléfono:</label>
|
||||
<div class="col-md-5">
|
||||
<input type="text" class="form-control" value="<?= htmlspecialchars($datos['telefono'] ?? '') ?>" disabled>
|
||||
<input type="text" name="telefono" maxlength="11"
|
||||
class="form-control" value="<?= htmlspecialchars($datos['telefono'] ?? '') ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-1"></div>
|
||||
@@ -211,8 +205,7 @@ include __DIR__ . '/../partials/sidebar_configuracion.php';
|
||||
<label class="col-md-1 col-form-label">Fax:</label>
|
||||
<div class="col-md-3">
|
||||
<input type="text" name="fax" maxlength="12"
|
||||
class="form-control" value="<?= htmlspecialchars($datos['fax'] ?? '') ?>"
|
||||
onfocus="this.value=''" onblur="if(this.value=='') this.value='<?= htmlspecialchars($datos['fax'] ?? '') ?>'">
|
||||
class="form-control" value="<?= htmlspecialchars($datos['fax'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -227,9 +220,7 @@ include __DIR__ . '/../partials/sidebar_configuracion.php';
|
||||
<label class="col-md-2 col-form-label">Observaciones:</label>
|
||||
<div class="col-md-10">
|
||||
<?php $valor_obs = htmlspecialchars($datos['observaciones'] ?? ''); ?>
|
||||
<textarea name="observaciones" class="form-control" rows="3"
|
||||
onfocus="if(this.value === '<?= $valor_obs ?>') this.value=''"
|
||||
onblur="if(this.value === '') this.value='<?= $valor_obs ?>'"><?= $valor_obs ?></textarea>
|
||||
<textarea name="observaciones" class="form-control" rows="3"><?= $valor_obs ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; justify-content: right;">
|
||||
@@ -241,38 +232,44 @@ include __DIR__ . '/../partials/sidebar_configuracion.php';
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script>
|
||||
document.getElementById('form-edicion').addEventListener('submit', function (event) {
|
||||
event.preventDefault(); // Evita que el formulario se envíe
|
||||
document.getElementById('form-edicion').addEventListener('submit', function (event) {
|
||||
event.preventDefault(); // Evita que el formulario se envíe
|
||||
|
||||
const curp = document.querySelector('[name="curp"]').value.trim();
|
||||
const fax = document.querySelector('[name="fax"]').value.trim();
|
||||
const curp = document.querySelector('[name="curp"]').value.trim();
|
||||
const telefono = document.querySelector('input[name="telefono"]').value.trim();
|
||||
const fax = document.querySelector('[name="fax"]').value.trim();
|
||||
|
||||
let errores = [];
|
||||
let errores = [];
|
||||
|
||||
// Validación CURP
|
||||
if (!/^[A-Z]{4}[0-9]{6}[HM](AS|BC|BS|CC|CL|CM|CS|CH|DF|DG|GT|GR|HG|JC|MC|MN|MS|NT|NL|OC|PL|QT|QR|SP|SL|SR|TC|TS|TL|VZ|YN|ZS)[A-Z]{3}[A-Z0-9]{2}$/.test(curp)) {
|
||||
errores.push('La CURP no tiene el formato correcto.');
|
||||
}
|
||||
// Validación CURP
|
||||
if (!/^[A-Z]{4}[0-9]{6}[HM](AS|BC|BS|CC|CL|CM|CS|CH|DF|DG|GT|GR|HG|JC|MC|MN|MS|NT|NL|OC|PL|QT|QR|SP|SL|SR|TC|TS|TL|VZ|YN|ZS)[A-Z]{3}[A-Z0-9]{2}$/.test(curp)) {
|
||||
errores.push('La CURP no tiene el formato correcto.');
|
||||
}
|
||||
|
||||
// Validación Fax
|
||||
if (fax !== '' && !/^\d{3} \d{3} \d{4}$/.test(fax)) {
|
||||
errores.push('El número de fax debe tener el formato: 123 456 7890.');
|
||||
}
|
||||
// Validación Teléfono - Ajustada para permitir diferentes formatos
|
||||
if (telefono !== '' && !/^\d{10,11}$/.test(telefono.replace(/\s/g, ''))) {
|
||||
errores.push('El número de teléfono debe tener 10 u 11 dígitos.');
|
||||
}
|
||||
|
||||
// Si hay errores, mostrar alerta y no enviar
|
||||
if (errores.length > 0) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Errores en el formulario',
|
||||
html: errores.map(e => `<p>${e}</p>`).join('')
|
||||
});
|
||||
return; // Evita que el formulario se envíe
|
||||
}
|
||||
// Validación Fax
|
||||
if (fax !== '' && !/^\d{3}\s?\d{3}\s?\d{4}$/.test(fax)) {
|
||||
errores.push('El número de fax debe tener el formato: 123 456 7890 o 1234567890.');
|
||||
}
|
||||
|
||||
// Si no hay errores, enviar el formulario
|
||||
this.submit(); // Esto sí lo envía manualmente
|
||||
});
|
||||
// Si hay errores, mostrar alerta y no enviar
|
||||
if (errores.length > 0) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Errores en el formulario',
|
||||
html: errores.map(e => `<p>${e}</p>`).join('')
|
||||
});
|
||||
return; // Evita que el formulario se envíe
|
||||
}
|
||||
|
||||
// Si no hay errores, enviar el formulario
|
||||
this.submit(); // Esto sí lo envía manualmente
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user