Files
MVE/views/configuracion/editar.php
2025-07-18 12:21:26 -06:00

255 lines
13 KiB
PHP

<?php include __DIR__ . '/../partials/sidebar_configuracion.php'; ?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>✏️ Editar Información</title>
<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>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<!-- Animate.css para animaciones adicionales -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<style>
body { font-family: 'Segoe UI', sans-serif; background-color: #f4f6f9; }
.sidebar { width: 220px; height: 100vh; background-color: #343a40; position: fixed; top: 0; left: 0; padding-top: 56px; z-index: 1040; }
.sidebar .nav-link { font-weight: bold; color: white; transition: all 0.3s ease; }
.sidebar .nav-link:hover,
.sidebar .nav-link.active { background-color: #495057; color: #fff; }
.content { margin-top: 56px; padding: 40px 20px; position: relative; z-index: 1; background-color: #f4f6f9; transition: margin-left 0.3s ease; }
.navbar { position: fixed; top: 0; width: 100%; z-index: 1050; }
/* A partir de dispositivos medianos (>=768px), deja espacio lateral */
@media (min-width: 768px) { .content { margin-left: 250px; /* Ancho del sidebar */ } }
/* En móviles, sin margen lateral */
@media (max-width: 767.98px) {
.content { margin-left: 0; }
.sidebar .nav-link { font-weight: normal; color: #343a40; background-color: transparent; }
.sidebar .nav-link:hover,
.sidebar .nav-link.active { background-color: #e9ecef; color: #212529; }
}
.card { border-radius: 12px; }
/* Animaciones personalizadas */
.card-hover { transition: all 0.3s ease; cursor: pointer; }
.card-hover:hover { transform: translateY(-8px) scale(1.02); box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.15) !important; }
.btn-pulse { animation: pulse 2s infinite; }
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
.fade-in-up { animation: fadeInUp 0.8s ease-out; }
@keyframes fadeInUp {
from { opacity: 0; transform: translateY(30px); }
to { opacity: 1; transform: translateY(0); }
}
/* Responsive animations */
@media (max-width: 768px) { .card-hover:hover { transform: translateY(-4px) scale(1.01); } }
/* Efecto de glow para elementos activos */
.btn.active { box-shadow: 0 0 20px rgba(var(--bs-primary-rgb), 0.5); }
/* Animación para el título */
.title-glow { text-shadow: 0 0 10px rgba(0, 123, 255, 0.3); }
/* Efecto para botones */
.btn-animated { transition: all 0.3s ease; position: relative; overflow: hidden; }
.btn-animated:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); }
.btn-animated::before { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent); transition: left 0.5s; }
.btn-animated:hover::before { left: 100%; }
label {font-weight: bold; }
.error-msg { color: red; font-size: 0.9em; }
.section-header { background-color: #e9ecef; padding: 10px 15px; margin: 0 0 20px 0; border-radius: 8px 8px 0 0; font-weight: bold; color: #495057; }
/* ========== ANIMACIONES PARA INPUTS TEXTO ========== */
.form-control:not(.no-animation) { transition: all 0.3s ease; border: 2px solid #dee2e6; position: relative; }
.form-control:not(.no-animation).shake { animation: shake 0.5s ease-in-out; }
@keyframes shake {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-5px); }
75% { transform: translateX(5px); }
}
/* Animación para los campos del formulario */
.form-group-animated { opacity: 0; transform: translateY(20px); animation: slideUp 0.6s ease-out forwards; }
.form-group-animated:nth-child(1) { animation-delay: 0.1s; }
.form-group-animated:nth-child(2) { animation-delay: 0.2s; }
.form-group-animated:nth-child(3) { animation-delay: 0.3s; }
.form-group-animated:nth-child(4) { animation-delay: 0.4s; }
.form-group-animated:nth-child(5) { animation-delay: 0.5s; }
.form-group-animated:nth-child(6) { animation-delay: 0.6s; }
.form-group-animated:nth-child(7) { animation-delay: 0.7s; }
.form-group-animated:nth-child(8) { animation-delay: 0.8s; }
.form-group-animated:nth-child(9) { animation-delay: 0.9s; }
.form-group-animated:nth-child(10) { animation-delay: 1.0s; }
@keyframes slideUp { to { opacity: 1; transform: translateY(0); } }
</style>
</head>
<body>
<div class="content">
<h4 class="mb-4 animate__animated animate__fadeInDown title_glow">✏️ Editar Información</h4>
<div class="card shadow-sm p-4 mb-4 bg-white card-hover position-relative h-auto fade-in-up">
<div class="section-header form-group-animated">👤 Información Personal</div>
<form id="form-edicion" method="POST" action="/IMPORTADORES/configuracion/guardar">
<div class="row mb-3">
<label class="col-md-2 col-form-label form-group-animated">Clave:</label>
<div class="col-md-3 form-group-animated">
<input type="text" name="clave" maxlength="8" class="form-control" value="<?= htmlspecialchars($datos['clave'] ?? '') ?>" disabled>
</div>
<div class="col-md-3"></div>
<label class="col-md-2 col-form-label form-group-animated">Tipo de identificador:</label>
<div class="col-md-2 form-group-animated">
<select name="tipo_identificador" class="form-select" 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>
<div class="row mb-3">
<label class="col-md-2 col-form-label form-group-animated">Nombre:</label>
<div class="col-md-10 form-group-animated">
<input type="text" class="form-control" value="<?= htmlspecialchars($datos['nombre'] ?? '') ?>" disabled>
</div>
</div>
<div class="row mb-3">
<label class="col-md-2 col-form-label form-group-animated">RFC:</label>
<div class="col-md-3 form-group-animated">
<input type="text" class="form-control" value="<?= htmlspecialchars($datos['rfc'] ?? '') ?>" disabled>
</div>
<div class="col-md-1"></div>
<label class="col-md-1 col-form-label form-group-animated">CURP:</label>
<div class="col-md-5 form-group-animated">
<input type="text" name="curp" maxlength="18" class="form-control" value="<?= htmlspecialchars($datos['curp'] ?? '') ?>">
</div>
</div>
<div class="row mb-3">
<label class="col-md-2 col-form-label form-group-animated">Calle:</label>
<div class="col-md-10 form-group-animated">
<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 form-group-animated">Núm. Exterior:</label>
<div class="col-md-2 form-group-animated">
<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 form-group-animated">Núm. Interior:</label>
<div class="col-md-2 form-group-animated">
<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 form-group-animated">Ciudad / Localidad:</label>
<div class="col-md-3 form-group-animated">
<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 form-group-animated">Colonia:</label>
<div class="col-md-5 form-group-animated">
<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 form-group-animated">País:</label>
<div class="col-md-3 form-group-animated">
<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 form-group-animated">Código Postal:</label>
<div class="col-md-2 form-group-animated">
<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 form-group-animated">Municipio:</label>
<div class="col-md-4 form-group-animated">
<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 form-group-animated">Estado:</label>
<div class="col-md-4 form-group-animated">
<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 form-group-animated">Teléfono:</label>
<div class="col-md-5 form-group-animated">
<input type="text" name="telefono" maxlength="11" class="form-control" value="<?= htmlspecialchars($datos['telefono'] ?? '') ?>">
</div>
<div class="col-md-1"></div>
<label class="col-md-1 col-form-label form-group-animated">Fax:</label>
<div class="col-md-3 form-group-animated">
<input type="text" name="fax" maxlength="12" class="form-control" value="<?= htmlspecialchars($datos['fax'] ?? '') ?>">
</div>
</div>
<div class="row mb-3">
<label class="col-md-2 col-form-label form-group-animated">Correo:</label>
<div class="col-md-10 form-group-animated">
<input type="email" class="form-control" value="<?= htmlspecialchars($datos['correo'] ?? '') ?>" disabled>
</div>
</div>
<div class="row mb-3">
<label class="col-md-2 col-form-label form-group-animated">Observaciones:</label>
<div class="col-md-10 form-group-animated">
<?php $valor_obs = htmlspecialchars($datos['observaciones'] ?? ''); ?>
<textarea name="observaciones" class="form-control" rows="3"><?= $valor_obs ?></textarea>
</div>
</div>
<div style="display: flex; justify-content: right;" class="form-group-animated">
<a href="/IMPORTADORES/configuracion/index" class="btn btn-secondary ms-2 mt-auto w-auto btn-animated" style="margin-right: 10px;">Cancelar</a>
<button type="submit" class="btn btn-primary mt-auto w-auto btn-animated">💾 Guardar Cambios</button>
</div>
</form>
</div>
</div>
<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
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 = [];
// 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 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.');
}
// 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 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>