Ajuste patentes
This commit is contained in:
@@ -69,25 +69,26 @@ function guardar()
|
|||||||
$mf_paterno = trim($_POST['mf_paterno'] ?? '');
|
$mf_paterno = trim($_POST['mf_paterno'] ?? '');
|
||||||
$mf_materno = trim($_POST['mf_materno'] ?? '');
|
$mf_materno = trim($_POST['mf_materno'] ?? '');
|
||||||
|
|
||||||
$vp_inicio = (int)($_POST['vp_inicio'] ?? 0);
|
// Ahora manejamos como VARCHAR - permitir vacío o valor válido
|
||||||
$vp_final = (int)($_POST['vp_final'] ?? 0);
|
$vp_inicio = trim($_POST['vp_inicio'] ?? '');
|
||||||
$vp_siguiente = (int)($_POST['vp_siguiente'] ?? 0);
|
$vp_final = trim($_POST['vp_final'] ?? '');
|
||||||
|
$vp_siguiente = trim($_POST['vp_siguiente'] ?? '');
|
||||||
|
|
||||||
$vpe_inicio = (int)($_POST['vpe_inicio'] ?? 0);
|
$vpe_inicio = trim($_POST['vpe_inicio'] ?? '');
|
||||||
$vpe_final = (int)($_POST['vpe_final'] ?? 0);
|
$vpe_final = trim($_POST['vpe_final'] ?? '');
|
||||||
$vpe_siguiente = (int)($_POST['vpe_siguiente'] ?? 0);
|
$vpe_siguiente = trim($_POST['vpe_siguiente'] ?? '');
|
||||||
|
|
||||||
$vat_pb_inicio = (int)($_POST['vat_pb_inicio'] ?? 0);
|
$vat_pb_inicio = trim($_POST['vat_pb_inicio'] ?? '');
|
||||||
$vat_pb_final = (int)($_POST['vat_pb_final'] ?? 0);
|
$vat_pb_final = trim($_POST['vat_pb_final'] ?? '');
|
||||||
$vat_pb_siguiente = (int)($_POST['vat_pb_siguiente'] ?? 0);
|
$vat_pb_siguiente = trim($_POST['vat_pb_siguiente'] ?? '');
|
||||||
|
|
||||||
$vcc_inicio = (int)($_POST['vcc_inicio'] ?? 0);
|
$vcc_inicio = trim($_POST['vcc_inicio'] ?? '');
|
||||||
$vcc_final = (int)($_POST['vcc_final'] ?? 0);
|
$vcc_final = trim($_POST['vcc_final'] ?? '');
|
||||||
$vcc_siguiente = (int)($_POST['vcc_siguiente'] ?? 0);
|
$vcc_siguiente = trim($_POST['vcc_siguiente'] ?? '');
|
||||||
|
|
||||||
$vae_inicio = (int)($_POST['vae_inicio'] ?? 0);
|
$vae_inicio = trim($_POST['vae_inicio'] ?? '');
|
||||||
$vae_final = (int)($_POST['vae_final'] ?? 0);
|
$vae_final = trim($_POST['vae_final'] ?? '');
|
||||||
$vae_siguiente = (int)($_POST['vae_siguiente'] ?? 0);
|
$vae_siguiente = trim($_POST['vae_siguiente'] ?? '');
|
||||||
|
|
||||||
// Validaciones generales
|
// Validaciones generales
|
||||||
if (empty($aduana) || empty($patente) || empty($agente_aduanal) || empty($rfc) || empty($curp) || empty($razon_social)) {
|
if (empty($aduana) || empty($patente) || empty($agente_aduanal) || empty($rfc) || empty($curp) || empty($razon_social)) {
|
||||||
@@ -99,6 +100,32 @@ function guardar()
|
|||||||
if (strlen($rfc) > 13) die("❌ El RFC no puede exceder 13 caracteres.");
|
if (strlen($rfc) > 13) die("❌ El RFC no puede exceder 13 caracteres.");
|
||||||
if (strlen($curp) > 18) die("❌ El CURP no puede exceder 18 caracteres.");
|
if (strlen($curp) > 18) die("❌ El CURP no puede exceder 18 caracteres.");
|
||||||
|
|
||||||
|
// Validaciones para campos de folios - ahora son VARCHAR(10)
|
||||||
|
function validarFolio($valor, $campo) {
|
||||||
|
if (!empty($valor)) {
|
||||||
|
if (strlen($valor) > 10) die("❌ El campo {$campo} no puede exceder 10 caracteres.");
|
||||||
|
// Opcional: Si quieres mantener solo números, descomenta la siguiente línea
|
||||||
|
// if (!is_numeric($valor)) die("❌ El campo {$campo} debe ser numérico.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validar todos los campos de folios
|
||||||
|
validarFolio($vp_inicio, 'VP Inicio');
|
||||||
|
validarFolio($vp_final, 'VP Final');
|
||||||
|
validarFolio($vp_siguiente, 'VP Siguiente');
|
||||||
|
validarFolio($vpe_inicio, 'VPE Inicio');
|
||||||
|
validarFolio($vpe_final, 'VPE Final');
|
||||||
|
validarFolio($vpe_siguiente, 'VPE Siguiente');
|
||||||
|
validarFolio($vat_pb_inicio, 'VAT PB Inicio');
|
||||||
|
validarFolio($vat_pb_final, 'VAT PB Final');
|
||||||
|
validarFolio($vat_pb_siguiente, 'VAT PB Siguiente');
|
||||||
|
validarFolio($vcc_inicio, 'VCC Inicio');
|
||||||
|
validarFolio($vcc_final, 'VCC Final');
|
||||||
|
validarFolio($vcc_siguiente, 'VCC Siguiente');
|
||||||
|
validarFolio($vae_inicio, 'VAE Inicio');
|
||||||
|
validarFolio($vae_final, 'VAE Final');
|
||||||
|
validarFolio($vae_siguiente, 'VAE Siguiente');
|
||||||
|
|
||||||
// Validar duplicado para este usuario
|
// Validar duplicado para este usuario
|
||||||
$sqlCheck = "SELECT COUNT(*) as count FROM dbo.agentes_aduanales WHERE aduana = ? AND patente = ? AND id_usuario = ?";
|
$sqlCheck = "SELECT COUNT(*) as count FROM dbo.agentes_aduanales WHERE aduana = ? AND patente = ? AND id_usuario = ?";
|
||||||
$stmtCheck = sqlsrv_query($conn, $sqlCheck, [$aduana, $patente, $id_usuario]);
|
$stmtCheck = sqlsrv_query($conn, $sqlCheck, [$aduana, $patente, $id_usuario]);
|
||||||
@@ -110,6 +137,23 @@ function guardar()
|
|||||||
|
|
||||||
sqlsrv_free_stmt($stmtCheck);
|
sqlsrv_free_stmt($stmtCheck);
|
||||||
|
|
||||||
|
// Convertir valores vacíos a NULL para la base de datos
|
||||||
|
$vp_inicio = empty($vp_inicio) ? null : $vp_inicio;
|
||||||
|
$vp_final = empty($vp_final) ? null : $vp_final;
|
||||||
|
$vp_siguiente = empty($vp_siguiente) ? null : $vp_siguiente;
|
||||||
|
$vpe_inicio = empty($vpe_inicio) ? null : $vpe_inicio;
|
||||||
|
$vpe_final = empty($vpe_final) ? null : $vpe_final;
|
||||||
|
$vpe_siguiente = empty($vpe_siguiente) ? null : $vpe_siguiente;
|
||||||
|
$vat_pb_inicio = empty($vat_pb_inicio) ? null : $vat_pb_inicio;
|
||||||
|
$vat_pb_final = empty($vat_pb_final) ? null : $vat_pb_final;
|
||||||
|
$vat_pb_siguiente = empty($vat_pb_siguiente) ? null : $vat_pb_siguiente;
|
||||||
|
$vcc_inicio = empty($vcc_inicio) ? null : $vcc_inicio;
|
||||||
|
$vcc_final = empty($vcc_final) ? null : $vcc_final;
|
||||||
|
$vcc_siguiente = empty($vcc_siguiente) ? null : $vcc_siguiente;
|
||||||
|
$vae_inicio = empty($vae_inicio) ? null : $vae_inicio;
|
||||||
|
$vae_final = empty($vae_final) ? null : $vae_final;
|
||||||
|
$vae_siguiente = empty($vae_siguiente) ? null : $vae_siguiente;
|
||||||
|
|
||||||
// Insertar registro
|
// Insertar registro
|
||||||
$sql = "INSERT INTO dbo.agentes_aduanales
|
$sql = "INSERT INTO dbo.agentes_aduanales
|
||||||
(aduana, patente, agente_aduanal, rfc, curp, razon_social, id_usuario, activo,
|
(aduana, patente, agente_aduanal, rfc, curp, razon_social, id_usuario, activo,
|
||||||
@@ -187,6 +231,7 @@ function actualizar()
|
|||||||
|
|
||||||
$conn = getConnection();
|
$conn = getConnection();
|
||||||
|
|
||||||
|
// Capturar campos del formulario - Datos generales
|
||||||
$id_agente = (int)($_POST['id_agente'] ?? 0);
|
$id_agente = (int)($_POST['id_agente'] ?? 0);
|
||||||
$aduana = trim($_POST['aduana'] ?? '');
|
$aduana = trim($_POST['aduana'] ?? '');
|
||||||
$patente = trim($_POST['patente'] ?? '');
|
$patente = trim($_POST['patente'] ?? '');
|
||||||
@@ -200,25 +245,26 @@ function actualizar()
|
|||||||
$mf_paterno = trim($_POST['mf_paterno'] ?? '');
|
$mf_paterno = trim($_POST['mf_paterno'] ?? '');
|
||||||
$mf_materno = trim($_POST['mf_materno'] ?? '');
|
$mf_materno = trim($_POST['mf_materno'] ?? '');
|
||||||
|
|
||||||
$vp_inicio = (int)($_POST['vp_inicio'] ?? 0);
|
// Ahora manejamos como VARCHAR - permitir vacío o valor válido
|
||||||
$vp_final = (int)($_POST['vp_final'] ?? 0);
|
$vp_inicio = trim($_POST['vp_inicio'] ?? '');
|
||||||
$vp_siguiente = (int)($_POST['vp_siguiente'] ?? 0);
|
$vp_final = trim($_POST['vp_final'] ?? '');
|
||||||
|
$vp_siguiente = trim($_POST['vp_siguiente'] ?? '');
|
||||||
|
|
||||||
$vpe_inicio = (int)($_POST['vpe_inicio'] ?? 0);
|
$vpe_inicio = trim($_POST['vpe_inicio'] ?? '');
|
||||||
$vpe_final = (int)($_POST['vpe_final'] ?? 0);
|
$vpe_final = trim($_POST['vpe_final'] ?? '');
|
||||||
$vpe_siguiente = (int)($_POST['vpe_siguiente'] ?? 0);
|
$vpe_siguiente = trim($_POST['vpe_siguiente'] ?? '');
|
||||||
|
|
||||||
$vat_pb_inicio = (int)($_POST['vat_pb_inicio'] ?? 0);
|
$vat_pb_inicio = trim($_POST['vat_pb_inicio'] ?? '');
|
||||||
$vat_pb_final = (int)($_POST['vat_pb_final'] ?? 0);
|
$vat_pb_final = trim($_POST['vat_pb_final'] ?? '');
|
||||||
$vat_pb_siguiente = (int)($_POST['vat_pb_siguiente'] ?? 0);
|
$vat_pb_siguiente = trim($_POST['vat_pb_siguiente'] ?? '');
|
||||||
|
|
||||||
$vcc_inicio = (int)($_POST['vcc_inicio'] ?? 0);
|
$vcc_inicio = trim($_POST['vcc_inicio'] ?? '');
|
||||||
$vcc_final = (int)($_POST['vcc_final'] ?? 0);
|
$vcc_final = trim($_POST['vcc_final'] ?? '');
|
||||||
$vcc_siguiente = (int)($_POST['vcc_siguiente'] ?? 0);
|
$vcc_siguiente = trim($_POST['vcc_siguiente'] ?? '');
|
||||||
|
|
||||||
$vae_inicio = (int)($_POST['vae_inicio'] ?? 0);
|
$vae_inicio = trim($_POST['vae_inicio'] ?? '');
|
||||||
$vae_final = (int)($_POST['vae_final'] ?? 0);
|
$vae_final = trim($_POST['vae_final'] ?? '');
|
||||||
$vae_siguiente = (int)($_POST['vae_siguiente'] ?? 0);
|
$vae_siguiente = trim($_POST['vae_siguiente'] ?? '');
|
||||||
|
|
||||||
if (!$id_agente || empty($aduana) || empty($patente) || empty($agente_aduanal) || empty($rfc) || empty($curp) || empty($razon_social)) {
|
if (!$id_agente || empty($aduana) || empty($patente) || empty($agente_aduanal) || empty($rfc) || empty($curp) || empty($razon_social)) {
|
||||||
die("❌ Datos inválidos o incompletos.");
|
die("❌ Datos inválidos o incompletos.");
|
||||||
@@ -241,6 +287,23 @@ function actualizar()
|
|||||||
|
|
||||||
sqlsrv_free_stmt($stmtCheck);
|
sqlsrv_free_stmt($stmtCheck);
|
||||||
|
|
||||||
|
// Convertir valores vacíos a NULL para la base de datos
|
||||||
|
$vp_inicio = empty($vp_inicio) ? null : $vp_inicio;
|
||||||
|
$vp_final = empty($vp_final) ? null : $vp_final;
|
||||||
|
$vp_siguiente = empty($vp_siguiente) ? null : $vp_siguiente;
|
||||||
|
$vpe_inicio = empty($vpe_inicio) ? null : $vpe_inicio;
|
||||||
|
$vpe_final = empty($vpe_final) ? null : $vpe_final;
|
||||||
|
$vpe_siguiente = empty($vpe_siguiente) ? null : $vpe_siguiente;
|
||||||
|
$vat_pb_inicio = empty($vat_pb_inicio) ? null : $vat_pb_inicio;
|
||||||
|
$vat_pb_final = empty($vat_pb_final) ? null : $vat_pb_final;
|
||||||
|
$vat_pb_siguiente = empty($vat_pb_siguiente) ? null : $vat_pb_siguiente;
|
||||||
|
$vcc_inicio = empty($vcc_inicio) ? null : $vcc_inicio;
|
||||||
|
$vcc_final = empty($vcc_final) ? null : $vcc_final;
|
||||||
|
$vcc_siguiente = empty($vcc_siguiente) ? null : $vcc_siguiente;
|
||||||
|
$vae_inicio = empty($vae_inicio) ? null : $vae_inicio;
|
||||||
|
$vae_final = empty($vae_final) ? null : $vae_final;
|
||||||
|
$vae_siguiente = empty($vae_siguiente) ? null : $vae_siguiente;
|
||||||
|
|
||||||
// UPDATE
|
// UPDATE
|
||||||
$sql = "UPDATE dbo.agentes_aduanales SET
|
$sql = "UPDATE dbo.agentes_aduanales SET
|
||||||
aduana = ?, patente = ?, agente_aduanal = ?, rfc = ?, curp = ?, razon_social = ?,
|
aduana = ?, patente = ?, agente_aduanal = ?, rfc = ?, curp = ?, razon_social = ?,
|
||||||
|
|||||||
@@ -663,10 +663,14 @@ function actualizar() {
|
|||||||
|
|
||||||
/** “Soft-delete” de una factura **/
|
/** “Soft-delete” de una factura **/
|
||||||
function eliminar() {
|
function eliminar() {
|
||||||
if (!($_SESSION['usuario_id'] ?? false)) { header('Location: /IMPORTADORES/login'); exit; }
|
if (!($_SESSION['usuario_id'] ?? false)) {
|
||||||
|
header('Location: /IMPORTADORES/login');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
$id = (int) ($_GET['id'] ?? 0);
|
$id = (int) ($_GET['id'] ?? 0);
|
||||||
$conn = getConnection();
|
$conn = getConnection();
|
||||||
sqlsrv_query($conn, "UPDATE dbo.solicitud_importacion_factura SET status = 0, updated_at = GETDATE() WHERE id_solicitud = ? AND id_importador = ?",[$id,$_SESSION['usuario_id']]);
|
sqlsrv_query($conn, "UPDATE dbo.solicitud_importacion_factura SET status = 0, updated_at = GETDATE() WHERE id_solicitud = ? AND id_importador = ?",[$id,$_SESSION['usuario_id']]);
|
||||||
|
|
||||||
header('Location: /IMPORTADORES/solicitud_importacion/lista?deleted=ok'); exit;
|
header('Location: /IMPORTADORES/solicitud_importacion/lista?deleted=ok'); exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
patentes.txt
30
patentes.txt
@@ -12,20 +12,20 @@ CREATE TABLE agentes_aduanales (
|
|||||||
mf_nombre VARCHAR(50),
|
mf_nombre VARCHAR(50),
|
||||||
mf_paterno VARCHAR(50),
|
mf_paterno VARCHAR(50),
|
||||||
mf_materno VARCHAR(50),
|
mf_materno VARCHAR(50),
|
||||||
vp_inicio INT DEFAULT 0,
|
vp_inicio VARCHAR(10) NULL DEFAULT '000',
|
||||||
vp_final INT DEFAULT 0,
|
vp_final VARCHAR(10) NULL DEFAULT '000',
|
||||||
vp_siguiente INT DEFAULT 0,
|
vp_siguiente VARCHAR(10) NULL DEFAULT '000',
|
||||||
vpe_inicio INT DEFAULT 0,
|
vpe_inicio VARCHAR(10) NULL DEFAULT '000',
|
||||||
vpe_final INT DEFAULT 0,
|
vpe_final VARCHAR(10) NULL DEFAULT '000',
|
||||||
vpe_siguiente INT DEFAULT 0,
|
vpe_siguiente VARCHAR(10) NULL DEFAULT '000',
|
||||||
vat_pb_inicio INT DEFAULT 0,
|
vat_pb_inicio VARCHAR(10) NULL DEFAULT '000',
|
||||||
vat_pb_final INT DEFAULT 0,
|
vat_pb_final VARCHAR(10) NULL DEFAULT '000',
|
||||||
vat_pb_siguiente INT DEFAULT 0,
|
vat_pb_siguiente VARCHAR(10) NULL DEFAULT '000',
|
||||||
vcc_inicio INT DEFAULT 0,
|
vcc_inicio VARCHAR(10) NULL DEFAULT '000',
|
||||||
vcc_final INT DEFAULT 0,
|
vcc_final VARCHAR(10) NULL DEFAULT '000',
|
||||||
vcc_siguiente INT DEFAULT 0,
|
vcc_siguiente VARCHAR(10) NULL DEFAULT '000',
|
||||||
vae_inicio INT DEFAULT 0,
|
vae_inicio VARCHAR(10) NULL DEFAULT '000',
|
||||||
vae_final INT DEFAULT 0,
|
vae_final VARCHAR(10) NULL DEFAULT '000',
|
||||||
vae_siguiente INT DEFAULT 0
|
vae_siguiente VARCHAR(10) NULL DEFAULT '000'
|
||||||
FOREIGN KEY (id_usuario) REFERENCES usuarios_sistema(id_usuario)
|
FOREIGN KEY (id_usuario) REFERENCES usuarios_sistema(id_usuario)
|
||||||
)
|
)
|
||||||
@@ -154,17 +154,17 @@
|
|||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vp_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
<label for="vp_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vp_inicio" id="vp_inicio" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vp_inicio" id="vp_inicio" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vp_final" class="col-md-1 col-form-label">Final:</label>
|
<label for="vp_final" class="col-md-1 col-form-label">Final:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vp_final" id="vp_final" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vp_final" id="vp_final" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vp_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
<label for="vp_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vp_siguiente" id="vp_siguiente" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vp_siguiente" id="vp_siguiente" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
</div><hr>
|
</div><hr>
|
||||||
|
|
||||||
@@ -174,17 +174,17 @@
|
|||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vpe_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
<label for="vpe_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vpe_inicio" id="vpe_inicio" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vpe_inicio" id="vpe_inicio" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vpe_final" class="col-md-1 col-form-label">Final:</label>
|
<label for="vpe_final" class="col-md-1 col-form-label">Final:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vpe_final" id="vpe_final" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vpe_final" id="vpe_final" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vpe_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
<label for="vpe_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vpe_siguiente" id="vpe_siguiente" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vpe_siguiente" id="vpe_siguiente" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
</div><hr>
|
</div><hr>
|
||||||
|
|
||||||
@@ -194,17 +194,17 @@
|
|||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vat_pb_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
<label for="vat_pb_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vat_pb_inicio" id="vat_pb_inicio" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vat_pb_inicio" id="vat_pb_inicio" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vat_pb_final" class="col-md-1 col-form-label">Final:</label>
|
<label for="vat_pb_final" class="col-md-1 col-form-label">Final:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vat_pb_final" id="vat_pb_final" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vat_pb_final" id="vat_pb_final" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vat_pb_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
<label for="vat_pb_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vat_pb_siguiente" id="vat_pb_siguiente" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vat_pb_siguiente" id="vat_pb_siguiente" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
</div><hr>
|
</div><hr>
|
||||||
|
|
||||||
@@ -214,17 +214,17 @@
|
|||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vcc_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
<label for="vcc_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vcc_inicio" id="vcc_inicio" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vcc_inicio" id="vcc_inicio" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vcc_final" class="col-md-1 col-form-label">Final:</label>
|
<label for="vcc_final" class="col-md-1 col-form-label">Final:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vcc_final" id="vcc_final" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vcc_final" id="vcc_final" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vcc_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
<label for="vcc_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vcc_siguiente" id="vcc_siguiente" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vcc_siguiente" id="vcc_siguiente" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
</div><hr>
|
</div><hr>
|
||||||
|
|
||||||
@@ -234,17 +234,17 @@
|
|||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vae_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
<label for="vae_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vae_inicio" id="vae_inicio" type="text" maxlength="3" class="form-control" placeholder="000" value="000">
|
<input name="vae_inicio" id="vae_inicio" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vae_final" class="col-md-1 col-form-label">Final:</label>
|
<label for="vae_final" class="col-md-1 col-form-label">Final:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vae_final" id="vae_final" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vae_final" id="vae_final" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vae_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
<label for="vae_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vae_siguiente" id="vae_siguiente" type="text" maxlength="3" class="form-control" placeholder="000">
|
<input name="vae_siguiente" id="vae_siguiente" type="text" maxlength="3" class="form-control" value="000">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -327,105 +327,55 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const vp_inicio = document.getElementById('vp_inicio').value;
|
// Obtener campos de folios (ahora VARCHAR)
|
||||||
const vp_final = document.getElementById('vp_final').value;
|
const folios = [
|
||||||
const vp_siguiente = document.getElementById('vp_siguiente').value;
|
{ id: 'vp_inicio', nombre: 'VP Inicio' },
|
||||||
const vpe_inicio = document.getElementById('vpe_inicio').value;
|
{ id: 'vp_final', nombre: 'VP Final' },
|
||||||
const vpe_final = document.getElementById('vpe_final').value;
|
{ id: 'vp_siguiente', nombre: 'VP Siguiente' },
|
||||||
const vpe_siguiente = document.getElementById('vpe_siguiente').value;
|
{ id: 'vpe_inicio', nombre: 'VPE Inicio' },
|
||||||
const vat_pb_inicio = document.getElementById('vat_pb_inicio').value;
|
{ id: 'vpe_final', nombre: 'VPE Final' },
|
||||||
const vat_pb_final = document.getElementById('vat_pb_final').value;
|
{ id: 'vpe_siguiente', nombre: 'VPE Siguiente' },
|
||||||
const vat_pb_siguiente = document.getElementById('vat_pb_siguiente').value;
|
{ id: 'vat_pb_inicio', nombre: 'VAT PB Inicio' },
|
||||||
const vcc_inicio = document.getElementById('vcc_inicio').value;
|
{ id: 'vat_pb_final', nombre: 'VAT PB Final' },
|
||||||
const vcc_final = document.getElementById('vcc_final').value;
|
{ id: 'vat_pb_siguiente', nombre: 'VAT PB Siguiente' },
|
||||||
const vcc_siguiente = document.getElementById('vcc_siguiente').value;
|
{ id: 'vcc_inicio', nombre: 'VCC Inicio' },
|
||||||
const vae_inicio = document.getElementById('vae_inicio').value;
|
{ id: 'vcc_final', nombre: 'VCC Final' },
|
||||||
const vae_final = document.getElementById('vae_final').value;
|
{ id: 'vcc_siguiente', nombre: 'VCC Siguiente' },
|
||||||
const vae_siguiente = document.getElementById('vae_siguiente').value;
|
{ id: 'vae_inicio', nombre: 'VAE Inicio' },
|
||||||
|
{ id: 'vae_final', nombre: 'VAE Final' },
|
||||||
|
{ id: 'vae_siguiente', nombre: 'VAE Siguiente' }
|
||||||
|
];
|
||||||
|
|
||||||
// Validaciones Números de Validación y Folios
|
// Validar campos de folios
|
||||||
if (vp_inicio !== '' && !soloNumerosRegex.test(vp_inicio)) {
|
for (let folio of folios) {
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
|
const valor = document.getElementById(folio.id).value.trim();
|
||||||
document.getElementById('vp_inicio').focus();
|
|
||||||
return;
|
if (valor !== '') {
|
||||||
}
|
// Validar longitud máxima
|
||||||
if (vp_final !== '' && !soloNumerosRegex.test(vp_final)) {
|
if (valor.length > 10) {
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
|
Swal.fire({ icon: 'error', title: 'Campo demasiado largo', text: `${folio.nombre} no puede exceder 10 caracteres.`, confirmButtonColor: '#dc3545' });
|
||||||
document.getElementById('vp_final').focus();
|
document.getElementById(folio.id).focus();
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vp_siguiente !== '' && !soloNumerosRegex.test(vp_siguiente)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vp_siguiente').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vpe_inicio !== '' && !soloNumerosRegex.test(vpe_inicio)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vpe_inicio').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vpe_final !== '' && !soloNumerosRegex.test(vpe_final)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vpe_final').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vpe_siguiente !== '' && !soloNumerosRegex.test(vpe_siguiente)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vpe_siguiente').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vat_pb_inicio !== '' && !soloNumerosRegex.test(vat_pb_inicio)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vat_pb_inicio').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vat_pb_final !== '' && !soloNumerosRegex.test(vat_pb_final)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vat_pb_final').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vat_pb_siguiente !== '' && !soloNumerosRegex.test(vat_pb_siguiente)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vat_pb_siguiente').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vcc_inicio !== '' && !soloNumerosRegex.test(vcc_inicio)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vcc_inicio').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vcc_final !== '' && !soloNumerosRegex.test(vcc_final)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vcc_final').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vcc_siguiente !== '' && !soloNumerosRegex.test(vcc_siguiente)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vcc_siguiente').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vae_inicio !== '' && !soloNumerosRegex.test(vae_inicio)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vae_inicio').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vae_final !== '' && !soloNumerosRegex.test(vae_final)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vae_final').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vae_siguiente !== '' && !soloNumerosRegex.test(vae_siguiente)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vae_siguiente').focus();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ SI TODAS LAS VALIDACIONES PASAN, ENVIAR EL FORMULARIO
|
// Opcional: Si quieres mantener solo números, descomenta estas líneas
|
||||||
// Mostrar indicador de carga
|
/*
|
||||||
|
if (!soloNumerosRegex.test(valor)) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Guardando...', text: 'Por favor espere', allowOutsideClick: false, showConfirmButton: false,
|
icon: 'error',
|
||||||
willOpen: () => { Swal.showLoading(); }
|
title: 'Campo inválido',
|
||||||
|
text: `${folio.nombre} solo puede contener números.`,
|
||||||
|
confirmButtonColor: '#dc3545'
|
||||||
});
|
});
|
||||||
|
document.getElementById(folio.id).focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si todas las validaciones pasan, mostrar carga y enviar
|
||||||
|
Swal.fire({ title: 'Guardando...', text: 'Por favor espere', allowOutsideClick: false, showConfirmButton: false, willOpen: () => { Swal.showLoading(); } });
|
||||||
|
|
||||||
// SI TODAS LAS VALIDACIONES PASAN, ENVIAR EL FORMULARIO
|
// SI TODAS LAS VALIDACIONES PASAN, ENVIAR EL FORMULARIO
|
||||||
this.submit();
|
this.submit();
|
||||||
|
|||||||
@@ -163,19 +163,19 @@
|
|||||||
<label for="vp_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
<label for="vp_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vp_inicio" id="vp_inicio" type="text" maxlength="3" class="form-control"
|
<input name="vp_inicio" id="vp_inicio" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_inicio'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_inicio'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vp_final" class="col-md-1 col-form-label">Final:</label>
|
<label for="vp_final" class="col-md-1 col-form-label">Final:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vp_final" id="vp_final" type="text" maxlength="3" class="form-control"
|
<input name="vp_final" id="vp_final" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_final'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_final'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vp_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
<label for="vp_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vp_siguiente" id="vp_siguiente" type="text" maxlength="3" class="form-control"
|
<input name="vp_siguiente" id="vp_siguiente" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_siguiente'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_siguiente'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
</div><hr>
|
</div><hr>
|
||||||
|
|
||||||
@@ -186,19 +186,19 @@
|
|||||||
<label for="vpe_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
<label for="vpe_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vpe_inicio" id="vpe_inicio" type="text" maxlength="3" class="form-control"
|
<input name="vpe_inicio" id="vpe_inicio" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_inicio'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_inicio'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vpe_final" class="col-md-1 col-form-label">Final:</label>
|
<label for="vpe_final" class="col-md-1 col-form-label">Final:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vpe_final" id="vpe_final" type="text" maxlength="3" class="form-control"
|
<input name="vpe_final" id="vpe_final" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_final'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_final'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vpe_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
<label for="vpe_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vpe_siguiente" id="vpe_siguiente" type="text" maxlength="3" class="form-control"
|
<input name="vpe_siguiente" id="vpe_siguiente" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_siguiente'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_siguiente'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
</div><hr>
|
</div><hr>
|
||||||
|
|
||||||
@@ -209,19 +209,19 @@
|
|||||||
<label for="vat_pb_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
<label for="vat_pb_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vat_pb_inicio" id="vat_pb_inicio" type="text" maxlength="3" class="form-control"
|
<input name="vat_pb_inicio" id="vat_pb_inicio" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_inicio'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_inicio'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vat_pb_final" class="col-md-1 col-form-label">Final:</label>
|
<label for="vat_pb_final" class="col-md-1 col-form-label">Final:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vat_pb_final" id="vat_pb_final" type="text" maxlength="3" class="form-control"
|
<input name="vat_pb_final" id="vat_pb_final" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_final'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_final'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vat_pb_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
<label for="vat_pb_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vat_pb_siguiente" id="vat_pb_siguiente" type="text" maxlength="3" class="form-control"
|
<input name="vat_pb_siguiente" id="vat_pb_siguiente" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_siguiente'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_siguiente'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
</div><hr>
|
</div><hr>
|
||||||
|
|
||||||
@@ -232,19 +232,19 @@
|
|||||||
<label for="vcc_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
<label for="vcc_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vcc_inicio" id="vcc_inicio" type="text" maxlength="3" class="form-control"
|
<input name="vcc_inicio" id="vcc_inicio" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_inicio'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_inicio'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vcc_final" class="col-md-1 col-form-label">Final:</label>
|
<label for="vcc_final" class="col-md-1 col-form-label">Final:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vcc_final" id="vcc_final" type="text" maxlength="3" class="form-control"
|
<input name="vcc_final" id="vcc_final" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_final'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_final'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vcc_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
<label for="vcc_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vcc_siguiente" id="vcc_siguiente" type="text" maxlength="3" class="form-control"
|
<input name="vcc_siguiente" id="vcc_siguiente" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_siguiente'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_siguiente'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
</div><hr>
|
</div><hr>
|
||||||
|
|
||||||
@@ -255,19 +255,19 @@
|
|||||||
<label for="vae_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
<label for="vae_inicio" class="col-md-1 col-form-label">Inicio:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vae_inicio" id="vae_inicio" type="text" maxlength="3" class="form-control"
|
<input name="vae_inicio" id="vae_inicio" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_inicio'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_inicio'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vae_final" class="col-md-1 col-form-label">Final:</label>
|
<label for="vae_final" class="col-md-1 col-form-label">Final:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vae_final" id="vae_final" type="text" maxlength="3" class="form-control"
|
<input name="vae_final" id="vae_final" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_final'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_final'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<label for="vae_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
<label for="vae_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input name="vae_siguiente" id="vae_siguiente" type="text" maxlength="3" class="form-control"
|
<input name="vae_siguiente" id="vae_siguiente" type="text" maxlength="3" class="form-control"
|
||||||
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_siguiente'] ?? '0')) ?>">
|
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_siguiente'] ?? '')) ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -350,105 +350,55 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const vp_inicio = document.getElementById('vp_inicio').value;
|
// Obtener campos de folios (ahora VARCHAR)
|
||||||
const vp_final = document.getElementById('vp_final').value;
|
const folios = [
|
||||||
const vp_siguiente = document.getElementById('vp_siguiente').value;
|
{ id: 'vp_inicio', nombre: 'VP Inicio' },
|
||||||
const vpe_inicio = document.getElementById('vpe_inicio').value;
|
{ id: 'vp_final', nombre: 'VP Final' },
|
||||||
const vpe_final = document.getElementById('vpe_final').value;
|
{ id: 'vp_siguiente', nombre: 'VP Siguiente' },
|
||||||
const vpe_siguiente = document.getElementById('vpe_siguiente').value;
|
{ id: 'vpe_inicio', nombre: 'VPE Inicio' },
|
||||||
const vat_pb_inicio = document.getElementById('vat_pb_inicio').value;
|
{ id: 'vpe_final', nombre: 'VPE Final' },
|
||||||
const vat_pb_final = document.getElementById('vat_pb_final').value;
|
{ id: 'vpe_siguiente', nombre: 'VPE Siguiente' },
|
||||||
const vat_pb_siguiente = document.getElementById('vat_pb_siguiente').value;
|
{ id: 'vat_pb_inicio', nombre: 'VAT PB Inicio' },
|
||||||
const vcc_inicio = document.getElementById('vcc_inicio').value;
|
{ id: 'vat_pb_final', nombre: 'VAT PB Final' },
|
||||||
const vcc_final = document.getElementById('vcc_final').value;
|
{ id: 'vat_pb_siguiente', nombre: 'VAT PB Siguiente' },
|
||||||
const vcc_siguiente = document.getElementById('vcc_siguiente').value;
|
{ id: 'vcc_inicio', nombre: 'VCC Inicio' },
|
||||||
const vae_inicio = document.getElementById('vae_inicio').value;
|
{ id: 'vcc_final', nombre: 'VCC Final' },
|
||||||
const vae_final = document.getElementById('vae_final').value;
|
{ id: 'vcc_siguiente', nombre: 'VCC Siguiente' },
|
||||||
const vae_siguiente = document.getElementById('vae_siguiente').value;
|
{ id: 'vae_inicio', nombre: 'VAE Inicio' },
|
||||||
|
{ id: 'vae_final', nombre: 'VAE Final' },
|
||||||
|
{ id: 'vae_siguiente', nombre: 'VAE Siguiente' }
|
||||||
|
];
|
||||||
|
|
||||||
// Validaciones Números de Validación y Folios
|
// Validar campos de folios
|
||||||
if (!soloNumerosRegex.test(vp_inicio)) {
|
for (let folio of folios) {
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
|
const valor = document.getElementById(folio.id).value.trim();
|
||||||
document.getElementById('vp_inicio').focus();
|
|
||||||
return;
|
if (valor !== '') {
|
||||||
}
|
// Validar longitud máxima
|
||||||
if (!soloNumerosRegex.test(vp_final)) {
|
if (valor.length > 10) {
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
|
Swal.fire({ icon: 'error', title: 'Campo demasiado largo', text: `${folio.nombre} no puede exceder 10 caracteres.`, confirmButtonColor: '#dc3545' });
|
||||||
document.getElementById('vp_final').focus();
|
document.getElementById(folio.id).focus();
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vp_siguiente)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vp_siguiente').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vpe_inicio)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vpe_inicio').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vpe_final)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vpe_final').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vpe_siguiente)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vpe_siguiente').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vat_pb_inicio)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vat_pb_inicio').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vat_pb_final)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vat_pb_final').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vat_pb_siguiente)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vat_pb_siguiente').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vcc_inicio)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vcc_inicio').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vcc_final)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vcc_final').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vcc_siguiente)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vcc_siguiente').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vae_inicio)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vae_inicio').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vae_final)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vae_final').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!soloNumerosRegex.test(vae_siguiente)) {
|
|
||||||
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
|
|
||||||
document.getElementById('vae_siguiente').focus();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ SI TODAS LAS VALIDACIONES PASAN, ENVIAR EL FORMULARIO
|
// Opcional: Si quieres mantener solo números, descomenta estas líneas
|
||||||
// Mostrar indicador de carga
|
/*
|
||||||
|
if (!soloNumerosRegex.test(valor)) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Guardando...', text: 'Por favor espere', allowOutsideClick: false, showConfirmButton: false,
|
icon: 'error',
|
||||||
willOpen: () => { Swal.showLoading(); }
|
title: 'Campo inválido',
|
||||||
|
text: `${folio.nombre} solo puede contener números.`,
|
||||||
|
confirmButtonColor: '#dc3545'
|
||||||
});
|
});
|
||||||
|
document.getElementById(folio.id).focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si todas las validaciones pasan, mostrar carga y enviar
|
||||||
|
Swal.fire({ title: 'Guardando...', text: 'Por favor espere', allowOutsideClick: false, showConfirmButton: false, willOpen: () => { Swal.showLoading(); } });
|
||||||
|
|
||||||
// SI TODAS LAS VALIDACIONES PASAN, ENVIAR EL FORMULARIO
|
// SI TODAS LAS VALIDACIONES PASAN, ENVIAR EL FORMULARIO
|
||||||
this.submit();
|
this.submit();
|
||||||
|
|||||||
Reference in New Issue
Block a user