Requerimientos sprint 2
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- SweetAlert2 -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', sans-serif;
|
||||
@@ -67,18 +70,42 @@
|
||||
<body>
|
||||
<br><br><br>
|
||||
|
||||
<div class="content">
|
||||
<div class="content">
|
||||
<h4 class="mb-4">🚛 Alta de Transportista</h4>
|
||||
<form action="/IMPORTADORES/transportistas/guardar" method="POST" class="card p-4 shadow-sm">
|
||||
<form action="/IMPORTADORES/transportistas/guardar" method="POST" class="card p-4 shadow-sm" id="formAltaTransportista">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4"><input name="clave" class="form-control" placeholder="Clave" required></div>
|
||||
<div class="col-md-4"><input name="nombre" class="form-control" placeholder="Nombre completo" required></div>
|
||||
<div class="col-md-4"><input name="rfc" class="form-control" placeholder="RFC" required></div>
|
||||
<div class="col-md-4"><input name="curp" class="form-control" placeholder="CURP"></div>
|
||||
<div class="col-md-4"><input name="telefono" class="form-control" placeholder="Teléfono" required></div>
|
||||
<div class="col-md-4"><input name="caat" class="form-control" placeholder="Código CAAT" required></div>
|
||||
<div class="col-md-4">
|
||||
<label for="clave" class="form-label">Clave *</label>
|
||||
<input name="clave" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label for="nombre" class="form-label">Nombre *</label>
|
||||
<input name="nombre" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label for="rfc" class="form-label">RFC *</label>
|
||||
<input name="rfc" class="form-control" maxlength="13" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label for="curp" class="form-label">CURP *</label>
|
||||
<input name="curp" class="form-control" maxlength="18" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label for="telefono" class="form-label">Teléfono *</label>
|
||||
<input name="telefono" class="form-control" maxlength="11" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label for="caat" class="form-label">Código CAAT *</label>
|
||||
<input name="caat" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label for="pais" class="form-label">País *</label>
|
||||
<select id="pais" name="pais" class="form-select" required>
|
||||
<option value="">Selecciona país</option>
|
||||
<?php foreach($paises as $p): ?>
|
||||
@@ -90,19 +117,25 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label for="entidad" class="form-label">Entidad *</label>
|
||||
<select id="estado" name="entidad" class="form-select" required disabled>
|
||||
<option value="">Primero país…</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label for="ciudad" class="form-label">Ciudad *</label>
|
||||
<select id="ciudad" name="ciudad" class="form-select" required disabled>
|
||||
<option value="">Primero estado…</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8"><input name="domicilio" class="form-control" placeholder="Domicilio completo" required></div>
|
||||
<div class="col-md-8">
|
||||
<label for="domicilio" class="form-label">Domicilio *</label>
|
||||
<input name="domicilio" class="form-control" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-end mt-4">
|
||||
<button class="btn btn-success px-4">Guardar Transportista</button>
|
||||
</div>
|
||||
@@ -110,6 +143,49 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('formAltaTransportista').addEventListener('submit', function(e) {
|
||||
const rfcInput = document.querySelector('input[name="rfc"]');
|
||||
const curpInput = document.querySelector('input[name="curp"]');
|
||||
const telefonoInput = document.querySelector('input[name="telefono"]');
|
||||
|
||||
const rfc = rfcInput.value.trim().toUpperCase();
|
||||
const curp = curpInput.value.trim();
|
||||
const telefono = telefonoInput.value.trim();
|
||||
|
||||
// Expresiones regulares
|
||||
const curpRegex = /^[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}$/;
|
||||
const rfcRegex = /^[A-ZÑ&]{3,4}\d{6}[A-Z0-9]{3}$/;
|
||||
const telefonoRegex = /^\d{3}\s\d{7}$/;
|
||||
|
||||
// Validación de correo
|
||||
if (!curpRegex.test(curp)) {
|
||||
e.preventDefault();
|
||||
Swal.fire("CURP inválido", "No tiene el formato correcto.", "error");
|
||||
emailInput.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Validación de RFC
|
||||
if (!rfcRegex.test(rfc)) {
|
||||
e.preventDefault();
|
||||
Swal.fire("RFC inválido", "El RFC debe tener 12 o 13 caracteres con el formato correcto (ej. ABC123456XYZ).", "error");
|
||||
rfcInput.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Validación de teléfono
|
||||
if (!telefonoRegex.test(telefono)) {
|
||||
e.preventDefault();
|
||||
Swal.fire("Teléfono inválido", "Debe tener 10 dígitos en el formato: 3 dígitos (LADA), espacio, y 7 dígitos. Ejemplo: 123 4567890", "error");
|
||||
phoneInput.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Si no hay errores, enviar el formulario
|
||||
this.submit(); // Esto sí lo envía manualmente
|
||||
});
|
||||
|
||||
// Active inputs entidad y ciudad
|
||||
// 1) Cuando elige país → cargo estados
|
||||
document.getElementById('pais').addEventListener('change', e => {
|
||||
const pid = e.target.value;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<!-- views/transportistas/lista.php -->
|
||||
<?php include __DIR__ . '/../partials/sidebar_importador.php'; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
||||
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>🚚 Mis Transportistas</title>
|
||||
@@ -80,13 +79,7 @@
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<body>
|
||||
<?php include __DIR__ . '/../partials/sidebar_importador.php'; ?>
|
||||
|
||||
<div class="content">
|
||||
<br>
|
||||
@@ -158,7 +151,7 @@
|
||||
function confirmDelete(id) {
|
||||
Swal.fire({
|
||||
title: '¿Eliminar transportista?',
|
||||
text: 'Esto sólo lo desactivará; no se podrá volver a usar.',
|
||||
text: 'Esto sólo lo eliminara completamente y no se podrá volver a usar.',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sí, eliminar',
|
||||
|
||||
Reference in New Issue
Block a user