feat: eliminar cuenta (Google Play compliance), resiliencia offline soda y experiencia haptica sensorial
This commit is contained in:
@@ -6366,3 +6366,78 @@ body.dark-mode .admin-dash-bar-track {
|
||||
border-color: #0284c7 !important;
|
||||
box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25) !important;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
EXPERIENCIA TÁCTIL Y SENSORIAL MÓVIL (SIBOPAY NATIVE FEEL)
|
||||
========================================================================== */
|
||||
button, .btn-saas, .mode-btn, .login-submit-btn, .pos-btn, .limit-preset-pill, .pwa-nav-item, .quick-amount-pill, .theme-toggle-btn {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
button:not(:disabled):active,
|
||||
.tactile-press:active {
|
||||
transform: scale(0.97) !important;
|
||||
transition: transform 0.08s cubic-bezier(0.25, 1, 0.5, 1) !important;
|
||||
}
|
||||
|
||||
/* Estado de Red y Resiliencia Offline en POS */
|
||||
.pos-network-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 800;
|
||||
padding: 3px 10px;
|
||||
border-radius: 20px;
|
||||
transition: all 0.2s ease;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.pos-network-pill.online {
|
||||
background: #dcfce7;
|
||||
color: #166534;
|
||||
border: 1px solid #86efac;
|
||||
}
|
||||
|
||||
.pos-network-pill.offline {
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
border: 1.5px solid #f59e0b;
|
||||
animation: offlinePulse 1.8s infinite;
|
||||
}
|
||||
|
||||
@keyframes offlinePulse {
|
||||
0%, 100% { opacity: 1; transform: scale(1); }
|
||||
50% { opacity: 0.88; transform: scale(1.02); }
|
||||
}
|
||||
|
||||
.pos-offline-banner {
|
||||
background: linear-gradient(135deg, #d97706, #b45309);
|
||||
color: #ffffff;
|
||||
padding: 10px 16px;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 700;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
box-shadow: 0 2px 8px rgba(180, 83, 9, 0.25);
|
||||
animation: slideDown 0.25s ease-out;
|
||||
}
|
||||
|
||||
/* Modal y Alertas de Eliminación de Cuenta */
|
||||
.danger-zone-box {
|
||||
background: #fff1f2;
|
||||
border: 1.5px solid #fecdd3;
|
||||
border-radius: 12px;
|
||||
padding: 14px;
|
||||
color: #9f1239;
|
||||
}
|
||||
|
||||
body.dark-mode .danger-zone-box {
|
||||
background: rgba(244, 63, 94, 0.1);
|
||||
border-color: rgba(244, 63, 94, 0.3);
|
||||
color: #fda4af;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Eliminación de Cuenta y Datos | SiboPay</title>
|
||||
<link rel="icon" type="image/png" href="/img/sibopay-emblem.png">
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
||||
<meta name="theme-color" content="#0284c7">
|
||||
|
||||
<!-- Google Fonts: Plus Jakarta Sans -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
|
||||
|
||||
<!-- Tailwind CSS CDN -->
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ['Plus Jakarta Sans', 'system-ui', '-apple-system', 'sans-serif'],
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
|
||||
background-color: #f8fafc;
|
||||
color: #334155;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
.paper-sheet {
|
||||
background: #ffffff;
|
||||
box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="min-h-screen py-10 px-4 sm:px-6 lg:px-8 flex flex-col justify-between">
|
||||
|
||||
<!-- CONTENEDOR PRINCIPAL -->
|
||||
<main class="max-w-3xl mx-auto w-full">
|
||||
|
||||
<!-- CABECERA DE MARCA -->
|
||||
<header class="text-center mb-8">
|
||||
<a href="/" class="inline-flex items-center gap-3 group">
|
||||
<div class="w-12 h-12 rounded-xl bg-sky-50 border border-sky-100 flex items-center justify-center p-2 shadow-sm transition-transform group-hover:scale-105">
|
||||
<img src="/img/sibopay-emblem.png" alt="SiboPay" class="w-full h-full object-contain">
|
||||
</div>
|
||||
<div class="text-left">
|
||||
<span class="text-2xl font-black tracking-tight text-slate-900 block leading-tight">Sibo<span class="text-sky-600">Pay</span></span>
|
||||
<span class="text-xs font-bold text-slate-500 uppercase tracking-wider block">Privacidad y Protección de Datos</span>
|
||||
</div>
|
||||
</a>
|
||||
<h1 class="text-2xl sm:text-3xl font-black text-slate-900 mt-6 tracking-tight">
|
||||
Eliminación de Cuenta y Supresión de Datos
|
||||
</h1>
|
||||
<p class="text-sm sm:text-base text-slate-600 mt-2 max-w-xl mx-auto">
|
||||
Transparencia y control absoluto sobre tu información conforme a las políticas de privacidad y requisitos de Google Play Store y Apple App Store.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<!-- TARJETA INFORMATIVA PRINCIPAL -->
|
||||
<div class="paper-sheet p-6 sm:p-10 space-y-8">
|
||||
|
||||
<!-- SECCIÓN 1: CÓMO ELIMINAR DIRECTAMENTE DESDE LA APP -->
|
||||
<section class="border-b border-slate-100 pb-8">
|
||||
<div class="flex items-center gap-3 mb-4">
|
||||
<div class="w-8 h-8 rounded-lg bg-sky-100 text-sky-700 flex items-center justify-center font-black text-sm">
|
||||
1
|
||||
</div>
|
||||
<h2 class="text-lg font-black text-slate-900">
|
||||
¿Cómo eliminar tu cuenta desde la app móvil SiboPay?
|
||||
</h2>
|
||||
</div>
|
||||
<p class="text-sm text-slate-600 leading-relaxed mb-4">
|
||||
Si tienes acceso a tu cuenta activa, puedes solicitar la baja inmediata directamente desde tu celular en 3 sencillos pasos:
|
||||
</p>
|
||||
<ol class="space-y-3 text-sm text-slate-700 list-decimal list-inside pl-2">
|
||||
<li class="pl-1">
|
||||
<span class="font-bold text-slate-900">Abre SiboPay</span> e ingresa a tu perfil o panel (Portal de Padres o Estudiante).
|
||||
</li>
|
||||
<li class="pl-1">
|
||||
Toca el botón o icono de <span class="font-bold text-slate-900">⚙️ Mi Cuenta / Ajustes de Privacidad</span>.
|
||||
</li>
|
||||
<li class="pl-1">
|
||||
En la sección inferior, presiona el botón rojo <span class="font-bold text-rose-700">"Eliminar Cuenta y Datos"</span> y confirma tu contraseña de acceso para verificar tu identidad.
|
||||
</li>
|
||||
</ol>
|
||||
<div class="mt-4 p-3.5 bg-sky-50/70 border border-sky-100 rounded-xl text-xs text-sky-800 flex items-start gap-2.5">
|
||||
<svg class="w-4 h-4 text-sky-600 mt-0.5 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
|
||||
<span>El borrado se ejecuta de forma instantánea en nuestros servidores y cerrarás sesión automáticamente en todos tus dispositivos.</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- SECCIÓN 2: FORMULARIO WEB SI DESINSTALASTE LA APP -->
|
||||
<section class="border-b border-slate-100 pb-8">
|
||||
<div class="flex items-center gap-3 mb-4">
|
||||
<div class="w-8 h-8 rounded-lg bg-amber-100 text-amber-800 flex items-center justify-center font-black text-sm">
|
||||
2
|
||||
</div>
|
||||
<h2 class="text-lg font-black text-slate-900">
|
||||
¿Ya desinstalaste la app? Solicita el borrado aquí
|
||||
</h2>
|
||||
</div>
|
||||
<p class="text-sm text-slate-600 leading-relaxed mb-5">
|
||||
Si ya no tienes la aplicación instalada en tu teléfono o no recuerdas tu contraseña, ingresa los datos con los que te registraste y nuestro equipo de seguridad procesará la eliminación:
|
||||
</p>
|
||||
|
||||
<form id="formWebDeletion" onsubmit="enviarSolicitudWeb(event)" class="bg-slate-50 border border-slate-200/80 rounded-2xl p-5 sm:p-6 space-y-4">
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-700 mb-1.5 uppercase tracking-wide">
|
||||
Nombre de Usuario, Correo o Teléfono Registrado:
|
||||
</label>
|
||||
<input type="text" id="delIdentificador" required placeholder="Ej: maria.padre o 8888-8888 o [email protected]" class="w-full px-4 py-2.5 bg-white border border-slate-200 rounded-xl text-sm font-semibold text-slate-900 focus:outline-none focus:ring-2 focus:ring-sky-500/20 focus:border-sky-500">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-700 mb-1.5 uppercase tracking-wide">
|
||||
Motivo de la solicitud (Opcional):
|
||||
</label>
|
||||
<select id="delMotivo" class="w-full px-4 py-2.5 bg-white border border-slate-200 rounded-xl text-sm font-semibold text-slate-900 focus:outline-none focus:ring-2 focus:ring-sky-500/20 focus:border-sky-500">
|
||||
<option value="cambio_institucion">Mi hijo(a) ya no asiste a esta institución</option>
|
||||
<option value="ya_no_uso">Ya no utilizo el servicio de soda escolar</option>
|
||||
<option value="privacidad">Preferencia de privacidad y protección de datos</option>
|
||||
<option value="otro">Otro motivo</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="pt-2">
|
||||
<button type="submit" id="btnSubmitWebDel" class="w-full sm:w-auto px-6 py-3 bg-rose-600 hover:bg-rose-700 text-white font-black text-sm rounded-xl shadow-sm transition-all flex items-center justify-center gap-2">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
|
||||
<span>Solicitar Eliminación Definitiva</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="msgWebResult" class="hidden p-4 rounded-xl text-xs font-bold mt-3"></div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<!-- SECCIÓN 3: POLÍTICA DE RETENCIÓN Y QUÉ DATOS SE SUPRIMEN -->
|
||||
<section class="space-y-4">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-8 h-8 rounded-lg bg-emerald-100 text-emerald-800 flex items-center justify-center font-black text-sm">
|
||||
3
|
||||
</div>
|
||||
<h2 class="text-lg font-black text-slate-900">
|
||||
Detalle de Datos Suprimidos y Retención Legal
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-1">
|
||||
<div class="bg-rose-50/70 border border-rose-100 rounded-xl p-4">
|
||||
<h3 class="text-xs font-black text-rose-800 uppercase tracking-wider mb-2 flex items-center gap-1.5">
|
||||
<span>🗑️</span> Datos que se eliminan de inmediato
|
||||
</h3>
|
||||
<ul class="text-xs text-rose-950/80 space-y-1.5 list-disc list-inside">
|
||||
<li>Nombre completo y credenciales de acceso</li>
|
||||
<li>Contraseña cifrada (hash)</li>
|
||||
<li>Correo electrónico y teléfono personal</li>
|
||||
<li>Vinculación y permisos de supervisión parental</li>
|
||||
<li>Tokens de notificaciones Web Push de tus celulares</li>
|
||||
<li>Preferencias de diseño y personalización</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="bg-slate-50 border border-slate-200/80 rounded-xl p-4">
|
||||
<h3 class="text-xs font-black text-slate-700 uppercase tracking-wider mb-2 flex items-center gap-1.5">
|
||||
<span>⚖️</span> Retención contable y tributaria
|
||||
</h3>
|
||||
<p class="text-xs text-slate-600 leading-relaxed">
|
||||
Conforme a la legislación comercial y tributaria de Costa Rica y normativas de auditoría escolar, los comprobantes de transacciones financieras y recargas previas se conservan de forma disociada y completamente anónima como respaldo contable de la soda concesionaria, sin ningún enlace a tu identidad personal.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- PIE DE PÁGINA -->
|
||||
<footer class="text-center text-xs text-slate-400 mt-8 space-y-2">
|
||||
<p>SiboPay Costa Rica • Sistema de Monedero Digital Escolar y Pagos Rápidos</p>
|
||||
<p>Consultas sobre privacidad y derechos ARCO: <a href="mailto:[email protected]" class="text-sky-600 hover:underline font-bold">[email protected]</a></p>
|
||||
<div class="pt-2">
|
||||
<a href="/legal" class="text-slate-500 hover:text-slate-800 underline mx-2 font-semibold">Términos y Condiciones</a>
|
||||
<span>•</span>
|
||||
<a href="/privacidad" class="text-slate-500 hover:text-slate-800 underline mx-2 font-semibold">Política de Privacidad</a>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
async function enviarSolicitudWeb(e) {
|
||||
e.preventDefault();
|
||||
const btn = document.getElementById('btnSubmitWebDel');
|
||||
const msg = document.getElementById('msgWebResult');
|
||||
const id = document.getElementById('delIdentificador').value.trim();
|
||||
const motivo = document.getElementById('delMotivo').value;
|
||||
|
||||
if (!id) return;
|
||||
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = 'Procesando solicitud...';
|
||||
msg.className = 'hidden';
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/public/solicitar-eliminacion-cuenta', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ identificador: id, motivo: motivo, confirmacion: true })
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
msg.className = 'p-4 rounded-xl text-xs font-bold mt-3 ' + (res.ok ? 'bg-emerald-50 text-emerald-800 border border-emerald-200' : 'bg-rose-50 text-rose-800 border border-rose-200');
|
||||
msg.textContent = data.mensaje || data.error || 'Solicitud procesada correctamente.';
|
||||
|
||||
if (res.ok) {
|
||||
document.getElementById('formWebDeletion').reset();
|
||||
}
|
||||
} catch (err) {
|
||||
msg.className = 'p-4 rounded-xl text-xs font-bold mt-3 bg-rose-50 text-rose-800 border border-rose-200';
|
||||
msg.textContent = 'Error de conexión: ' + err.message;
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<span>Solicitar Eliminación Definitiva</span>';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1234,6 +1234,10 @@
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1-2.5-2.5Z"/></svg>
|
||||
<span>Ver Menú</span>
|
||||
</button>
|
||||
<button type="button" onclick="abrirModalAjustesCuenta()" class="mode-btn" style="background: var(--bg-main); border: 1.5px solid var(--border); font-size: 0.78rem; font-weight: 800; border-radius: 10px; padding: 7px 11px; cursor: pointer; color: var(--text-main); display: inline-flex; align-items: center; gap: 6px;" title="Ajustes de Cuenta y Privacidad">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>
|
||||
<span>Ajustes</span>
|
||||
</button>
|
||||
<button onclick="logout(true)" class="logout-btn" title="Cerrar sesión" style="display: inline-flex; align-items: center; gap: 6px;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" x2="9" y1="12" y2="12"/></svg>
|
||||
<span class="logout-text">Salir</span>
|
||||
@@ -2168,6 +2172,9 @@
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
|
||||
<span>Padres</span>
|
||||
</button>
|
||||
<button id="btnAjustesCuentaEst" onclick="abrirModalAjustesCuenta()" class="theme-toggle-btn" title="Ajustes de Cuenta y Privacidad" style="display: inline-flex; align-items: center; justify-content: center; margin-right: 2px;">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>
|
||||
</button>
|
||||
<button id="btnLogout" onclick="logout(true)" class="logout-btn" title="Cerrar sesión y cambiar de cuenta" style="display: inline-flex; align-items: center; gap: 6px;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" x2="9" y1="12" y2="12"/></svg>
|
||||
<span class="logout-text">Salir</span>
|
||||
@@ -3235,6 +3242,132 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODAL: AJUSTES DE CUENTA, PRIVACIDAD Y EXPERIENCIA SENSORIAL -->
|
||||
<div class="modal-qr-backdrop" id="modalAjustesCuenta" style="display: none; z-index: 10005;" onclick="cerrarModalAjustesCuenta(event)">
|
||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: left; padding: 22px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1.5px solid var(--border); padding-bottom: 12px; margin-bottom: 16px;">
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<div style="width: 38px; height: 38px; border-radius: 10px; background: #e0f2fe; color: #0284c7; display: flex; align-items: center; justify-content: center; flex-shrink: 0;">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h3 style="margin: 0; font-size: 1.12rem; font-weight: 900; color: var(--text-main);">Mi Cuenta y Ajustes</h3>
|
||||
<span id="ajustesCuentaSub" style="font-size: 0.74rem; color: var(--text-muted); font-weight: 600;">Preferencias, privacidad y seguridad</span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" onclick="cerrarModalAjustesCuenta()" style="background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
|
||||
</div>
|
||||
|
||||
<!-- Resumen de Usuario Activo -->
|
||||
<div style="background: var(--bg-main); border: 1.5px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between;">
|
||||
<div>
|
||||
<span style="font-size: 0.70rem; color: var(--text-muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; display: block;">Usuario Activo</span>
|
||||
<strong id="ajustesCuentaNombre" style="font-size: 0.92rem; color: var(--text-main); display: block;">Usuario</strong>
|
||||
<span id="ajustesCuentaRol" style="font-size: 0.74rem; color: #0284c7; font-weight: 700;">Padre / Encargado</span>
|
||||
</div>
|
||||
<span style="font-size: 0.72rem; background: #e0f2fe; color: #0369a1; padding: 4px 10px; border-radius: 20px; font-weight: 800;">Activo</span>
|
||||
</div>
|
||||
|
||||
<!-- Ajustes de Experiencia Sensorial y Táctil -->
|
||||
<div style="margin-bottom: 16px;">
|
||||
<span style="font-size: 0.72rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 8px;">
|
||||
Experiencia Sensorial y Táctil
|
||||
</span>
|
||||
<div style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center;">
|
||||
<div>
|
||||
<strong style="font-size: 0.85rem; color: var(--text-main); display: block;">🔊 Efectos de Sonido</strong>
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted);">Tonos sintetizados para cobros, pagos y escaneos</span>
|
||||
</div>
|
||||
<label class="switch-toggle" style="position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; margin-left: 10px;">
|
||||
<input type="checkbox" id="chkAjustesSound" onchange="toggleSensorySoundUI(this.checked)" style="opacity: 0; width: 0; height: 0;">
|
||||
<span class="switch-slider" style="position: absolute; cursor: pointer; inset: 0; background-color: #cbd5e1; border-radius: 34px; transition: .25s;"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center;">
|
||||
<div>
|
||||
<strong style="font-size: 0.85rem; color: var(--text-main); display: block;">📳 Vibración Háptica</strong>
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted);">Micro-vibración táctil al pulsar botones y escanear QR</span>
|
||||
</div>
|
||||
<label class="switch-toggle" style="position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; margin-left: 10px;">
|
||||
<input type="checkbox" id="chkAjustesHaptic" onchange="toggleSensoryHapticUI(this.checked)" style="opacity: 0; width: 0; height: 0;">
|
||||
<span class="switch-slider" style="position: absolute; cursor: pointer; inset: 0; background-color: #cbd5e1; border-radius: 34px; transition: .25s;"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Enlaces de Políticas y Privacidad -->
|
||||
<div style="margin-bottom: 18px; padding-top: 4px; border-top: 1px solid var(--border);">
|
||||
<div style="display: flex; gap: 8px; justify-content: space-between; margin-top: 8px;">
|
||||
<a href="/privacidad" target="_blank" style="font-size: 0.75rem; color: #0284c7; text-decoration: underline; font-weight: 700;">
|
||||
Política de Privacidad
|
||||
</a>
|
||||
<a href="/legal" target="_blank" style="font-size: 0.75rem; color: #0284c7; text-decoration: underline; font-weight: 700;">
|
||||
Términos de Servicio
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Zona de Peligro: Eliminación de Cuenta -->
|
||||
<div class="danger-zone-box" style="margin-bottom: 12px;">
|
||||
<strong style="display: block; font-size: 0.82rem; font-weight: 900; margin-bottom: 3px;">
|
||||
⚠️ Zona de Peligro: Eliminación de Cuenta
|
||||
</strong>
|
||||
<p style="font-size: 0.72rem; line-height: 1.35; margin: 0 0 10px 0;">
|
||||
Puedes dar de baja tu cuenta y borrar tus datos personales de SiboPay. Esta acción es definitiva e irreversible.
|
||||
</p>
|
||||
<button type="button" onclick="abrirModalConfirmarEliminarCuenta()" class="btn-saas" style="width: 100%; height: 36px; background: #dc2626; color: white; border: 1px solid #b91c1c; font-weight: 800; font-size: 0.82rem; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
||||
<span>Eliminar mi Cuenta y Datos</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Botón de Cerrar Modal -->
|
||||
<div style="display: flex; justify-content: flex-end;">
|
||||
<button type="button" onclick="cerrarModalAjustesCuenta()" class="btn-saas btn-saas-outline" style="height: 36px; padding: 0 18px; font-weight: 700;">
|
||||
Cerrar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODAL: CONFIRMACIÓN ESTRICTA DE ELIMINACIÓN DE CUENTA -->
|
||||
<div class="modal-qr-backdrop" id="modalConfirmarEliminarCuenta" style="display: none; z-index: 10010;" onclick="cerrarModalConfirmarEliminarCuenta(event)">
|
||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left; padding: 22px; border: 2px solid #fecdd3;">
|
||||
<div style="text-align: center; margin-bottom: 14px;">
|
||||
<div style="width: 48px; height: 48px; border-radius: 50%; background: #fee2e2; color: #dc2626; display: flex; align-items: center; justify-content: center; margin: 0 auto 10px;">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
|
||||
</div>
|
||||
<h3 style="margin: 0; font-size: 1.18rem; font-weight: 900; color: #991b1b;">¿Confirmas eliminar tu cuenta?</h3>
|
||||
<p style="font-size: 0.76rem; color: #64748b; margin-top: 4px;">
|
||||
Esta acción no se puede deshacer. Tus accesos, notificaciones y vínculos familiares se borrarán de forma inmediata.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div style="background: #fff1f2; border: 1px solid #fecdd3; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 0.74rem; color: #9f1239; line-height: 1.4;">
|
||||
<strong>Para confirmar el borrado:</strong> Introduce tu contraseña de acceso o escribe la palabra <strong>ELIMINAR</strong> a continuación:
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 16px;">
|
||||
<label style="display: block; font-size: 0.74rem; font-weight: 800; color: var(--text-main); margin-bottom: 4px;">
|
||||
Contraseña o palabra de confirmación:
|
||||
</label>
|
||||
<input type="password" id="inputConfirmarPassEliminar" placeholder="Contraseña o escribe ELIMINAR" style="width: 100%; height: 40px; padding: 0 12px; border: 1.5px solid #cbd5e1; border-radius: 9px; font-size: 0.88rem; box-sizing: border-box; background: var(--bg-main); color: var(--text-main);">
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; justify-content: flex-end;">
|
||||
<button type="button" onclick="cerrarModalConfirmarEliminarCuenta()" class="btn-saas btn-saas-outline" style="height: 38px; padding: 0 16px; font-weight: 700;">
|
||||
Cancelar
|
||||
</button>
|
||||
<button type="button" id="btnEjecutarEliminacionDefinitiva" onclick="confirmarEliminarCuentaDefinitiva()" class="btn-saas" style="height: 38px; padding: 0 18px; background: #dc2626; color: white; border: 1px solid #b91c1c; font-weight: 800;">
|
||||
Sí, Borrar Mi Cuenta
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODAL: CREAR / EDITAR USUARIO (DEVELOPER) -->
|
||||
<div class="modal-qr-backdrop" id="modalDevUser" style="display: none;">
|
||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 500px; text-align: left; padding: 22px;">
|
||||
|
||||
@@ -9653,3 +9653,151 @@ window.closeLoginSheet = closeLoginSheet;
|
||||
window.switchSheetView = switchSheetView;
|
||||
window.openTerminosModal = openTerminosModal;
|
||||
window.closeTerminosModal = closeTerminosModal;
|
||||
|
||||
// ========================================================
|
||||
// AJUSTES DE CUENTA, PRIVACIDAD Y EXPERIENCIA SENSORIAL HÁPTICA
|
||||
// ========================================================
|
||||
function abrirModalAjustesCuenta() {
|
||||
const modal = document.getElementById('modalAjustesCuenta');
|
||||
if (!modal) return;
|
||||
|
||||
const lblNombre = document.getElementById('ajustesCuentaNombre');
|
||||
const lblRol = document.getElementById('ajustesCuentaRol');
|
||||
const chkSound = document.getElementById('chkAjustesSound');
|
||||
const chkHaptic = document.getElementById('chkAjustesHaptic');
|
||||
|
||||
if (currentUser) {
|
||||
if (lblNombre) lblNombre.textContent = currentUser.nombre || currentUser.username || 'Usuario';
|
||||
if (lblRol) {
|
||||
let r = currentUser.rol || 'Usuario';
|
||||
if (r === 'padre') r = 'Padre / Encargado';
|
||||
else if (r === 'estudiante') r = 'Estudiante / Alumno';
|
||||
else if (r === 'cajero') r = 'Cajero de Soda';
|
||||
else if (r === 'admin') r = 'Administrador de Soda';
|
||||
lblRol.textContent = r;
|
||||
}
|
||||
}
|
||||
|
||||
if (chkSound && window.sounds) {
|
||||
chkSound.checked = window.sounds.isSoundEnabled();
|
||||
}
|
||||
if (chkHaptic && window.sounds) {
|
||||
chkHaptic.checked = window.sounds.isHapticEnabled();
|
||||
}
|
||||
|
||||
modal.style.display = 'flex';
|
||||
}
|
||||
window.abrirModalAjustesCuenta = abrirModalAjustesCuenta;
|
||||
|
||||
function cerrarModalAjustesCuenta(e) {
|
||||
if (e && e.target !== e.currentTarget && e.currentTarget !== document) return;
|
||||
const modal = document.getElementById('modalAjustesCuenta');
|
||||
if (modal) modal.style.display = 'none';
|
||||
}
|
||||
window.cerrarModalAjustesCuenta = cerrarModalAjustesCuenta;
|
||||
|
||||
function toggleSensorySoundUI(checked) {
|
||||
if (window.sounds) {
|
||||
window.sounds.toggleSound(checked);
|
||||
}
|
||||
}
|
||||
window.toggleSensorySoundUI = toggleSensorySoundUI;
|
||||
|
||||
function toggleSensoryHapticUI(checked) {
|
||||
if (window.sounds) {
|
||||
window.sounds.toggleHaptics(checked);
|
||||
}
|
||||
}
|
||||
window.toggleSensoryHapticUI = toggleSensoryHapticUI;
|
||||
|
||||
function abrirModalConfirmarEliminarCuenta() {
|
||||
cerrarModalAjustesCuenta();
|
||||
const modal = document.getElementById('modalConfirmarEliminarCuenta');
|
||||
const input = document.getElementById('inputConfirmarPassEliminar');
|
||||
if (input) input.value = '';
|
||||
if (modal) modal.style.display = 'flex';
|
||||
}
|
||||
window.abrirModalConfirmarEliminarCuenta = abrirModalConfirmarEliminarCuenta;
|
||||
|
||||
function cerrarModalConfirmarEliminarCuenta(e) {
|
||||
if (e && e.target !== e.currentTarget && e.currentTarget !== document) return;
|
||||
const modal = document.getElementById('modalConfirmarEliminarCuenta');
|
||||
if (modal) modal.style.display = 'none';
|
||||
}
|
||||
window.cerrarModalConfirmarEliminarCuenta = cerrarModalConfirmarEliminarCuenta;
|
||||
|
||||
async function confirmarEliminarCuentaDefinitiva() {
|
||||
if (!currentUser || !currentUser.id) {
|
||||
alert('No hay una sesión activa para eliminar.');
|
||||
return;
|
||||
}
|
||||
|
||||
const input = document.getElementById('inputConfirmarPassEliminar');
|
||||
const val = input ? input.value.trim() : '';
|
||||
|
||||
if (!val) {
|
||||
alert('Por favor ingresa tu contraseña o la palabra ELIMINAR para verificar tu identidad.');
|
||||
return;
|
||||
}
|
||||
|
||||
const btn = document.getElementById('btnEjecutarEliminacionDefinitiva');
|
||||
if (btn) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Eliminando cuenta...';
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/auth/eliminar-cuenta', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
usuario_id: currentUser.id,
|
||||
password_confirmacion: val,
|
||||
motivo: 'Eliminación voluntaria solicitada por el usuario desde la app'
|
||||
})
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'No se pudo eliminar la cuenta');
|
||||
|
||||
if (window.sounds) {
|
||||
window.sounds.playSuccess();
|
||||
}
|
||||
|
||||
alert('Tu cuenta y datos personales han sido eliminados permanentemente de SiboPay.');
|
||||
|
||||
// Limpieza total de almacenamiento local y caches
|
||||
try {
|
||||
localStorage.removeItem('sibopay_token');
|
||||
localStorage.removeItem('sibopay_user');
|
||||
localStorage.removeItem('recreopay_token');
|
||||
localStorage.removeItem('recreopay_user');
|
||||
sessionStorage.clear();
|
||||
if ('caches' in window) {
|
||||
const keys = await caches.keys();
|
||||
for (const k of keys) await caches.delete(k);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
window.location.href = '/index.html';
|
||||
} catch (err) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
alert('Error al eliminar cuenta: ' + err.message);
|
||||
if (btn) {
|
||||
btn.disabled = false;
|
||||
btn.textContent = 'Sí, Borrar Mi Cuenta';
|
||||
}
|
||||
}
|
||||
}
|
||||
window.confirmarEliminarCuentaDefinitiva = confirmarEliminarCuentaDefinitiva;
|
||||
|
||||
// ========================================================
|
||||
// RETROALIMENTACIÓN HÁPTICA GLOBAL EN DISPOSITIVOS MÓVILES
|
||||
// ========================================================
|
||||
document.addEventListener('pointerdown', (e) => {
|
||||
const btn = e.target.closest('button, .btn-saas, .mode-btn, .login-submit-btn, .pwa-nav-item, .limit-preset-pill, .quick-amount-pill, .theme-toggle-btn');
|
||||
if (btn && !btn.disabled && window.haptics) {
|
||||
window.haptics.tap();
|
||||
}
|
||||
}, { passive: true });
|
||||
|
||||
|
||||
+256
-8
@@ -149,9 +149,26 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
localStorage.setItem('sibopay_pos_autoprint', chkAutoPrint.checked ? '1' : '0');
|
||||
});
|
||||
}
|
||||
|
||||
// Inicializar Resiliencia Offline de la Soda
|
||||
updateNetworkStatusUI();
|
||||
cacheOfflineStudents();
|
||||
|
||||
window.addEventListener('online', () => {
|
||||
updateNetworkStatusUI();
|
||||
const q = getOfflineQueue();
|
||||
if (q.length > 0) {
|
||||
sincronizarVentasOfflineManual();
|
||||
}
|
||||
cacheOfflineStudents();
|
||||
});
|
||||
|
||||
// Cargar catálogo de productos
|
||||
window.addEventListener('offline', () => {
|
||||
updateNetworkStatusUI();
|
||||
});
|
||||
});
|
||||
|
||||
// Cargar catálogo de productos con respaldo offline
|
||||
async function loadCatalog() {
|
||||
try {
|
||||
const url = `/api/productos?escuela_id=${getPosEscuelaId()}`;
|
||||
@@ -160,10 +177,26 @@ async function loadCatalog() {
|
||||
posCategories = data.categorias;
|
||||
posProducts = data.productos;
|
||||
|
||||
// Respaldar catálogo localmente para modo offline
|
||||
try {
|
||||
localStorage.setItem('sibo_pos_offline_catalog', JSON.stringify(data));
|
||||
} catch (e) {}
|
||||
|
||||
renderPosCategories();
|
||||
renderPosProducts(null);
|
||||
} catch (err) {
|
||||
console.error('Error cargando catálogo:', err);
|
||||
console.warn('[Modo Offline] No se pudo conectar al servidor, cargando catálogo desde memoria local:', err.message);
|
||||
try {
|
||||
const cached = localStorage.getItem('sibo_pos_offline_catalog');
|
||||
if (cached) {
|
||||
const data = JSON.parse(cached);
|
||||
posCategories = data.categorias || [];
|
||||
posProducts = data.productos || [];
|
||||
renderPosCategories();
|
||||
renderPosProducts(null);
|
||||
console.log('[Modo Offline] Catálogo cargado exitosamente desde memoria offline.');
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -836,10 +869,17 @@ async function onQrCodeDetected(token) {
|
||||
}
|
||||
|
||||
if (posModalMode === 'identificar' || posCart.length === 0) {
|
||||
try {
|
||||
let data = null;
|
||||
try {
|
||||
const res = await fetch(`/api/estudiantes/qr/${encodeURIComponent(token)}?escuela_id=${getPosEscuelaId()}`);
|
||||
const data = await res.json();
|
||||
data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error);
|
||||
} catch (fetchErr) {
|
||||
data = buscarEstudianteOffline(token);
|
||||
if (!data) throw new Error(fetchErr.message || 'Carné escolar no encontrado');
|
||||
console.log('[Modo Offline] Estudiante identificado desde memoria offline:', data.nombre_completo);
|
||||
}
|
||||
|
||||
scannedStudent = data;
|
||||
renderScannedStudent();
|
||||
@@ -1135,10 +1175,17 @@ async function handlePistolBarcodeScan(rawToken) {
|
||||
|
||||
// Si no hay productos en el carrito, identificar al alumno para mostrador
|
||||
if (posCart.length === 0) {
|
||||
try {
|
||||
let data = null;
|
||||
try {
|
||||
const res = await fetch(`/api/estudiantes/qr/${encodeURIComponent(token)}?escuela_id=${getPosEscuelaId()}`);
|
||||
const data = await res.json();
|
||||
data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error);
|
||||
} catch (fetchErr) {
|
||||
data = buscarEstudianteOffline(token);
|
||||
if (!data) throw new Error(fetchErr.message || 'Carné escolar no encontrado');
|
||||
console.log('[Modo Offline] Estudiante identificado:', data.nombre_completo);
|
||||
}
|
||||
|
||||
scannedStudent = data;
|
||||
renderScannedStudent();
|
||||
@@ -1165,10 +1212,17 @@ async function handlePistolBarcodeScan(rawToken) {
|
||||
document.getElementById('pistolaProcessingName').textContent = 'Identificando estudiante y validando monedero...';
|
||||
|
||||
try {
|
||||
// 1. Buscar estudiante por token o código
|
||||
// 1. Buscar estudiante por token o código (con fallback offline)
|
||||
let student = null;
|
||||
try {
|
||||
const resEst = await fetch(`/api/estudiantes/qr/${encodeURIComponent(token)}?escuela_id=${getPosEscuelaId()}`);
|
||||
const student = await resEst.json();
|
||||
student = await resEst.json();
|
||||
if (!resEst.ok) throw new Error(student.error || 'Carné escolar no encontrado');
|
||||
} catch (fetchErr) {
|
||||
student = buscarEstudianteOffline(token);
|
||||
if (!student) throw new Error(fetchErr.message || 'Carné escolar no encontrado en el sistema ni en memoria offline');
|
||||
console.log('[Modo Offline] Estudiante cargado para cobro desde memoria local:', student.nombre_completo);
|
||||
}
|
||||
|
||||
document.getElementById('pistolaProcessingName').textContent = `Verificando saldo para ${student.nombre_completo}...`;
|
||||
|
||||
@@ -1188,12 +1242,14 @@ async function handlePistolBarcodeScan(rawToken) {
|
||||
throw new Error(`⚠️ SUPERA LÍMITE DIARIO: Le quedan ₡${student.disponible_hoy.toLocaleString('es-CR')} disponibles hoy de su límite diario asignado.`);
|
||||
}
|
||||
|
||||
// 4. Procesar cobro en servidor
|
||||
// 4. Procesar cobro en servidor (o guardar en cola offline si no hay red)
|
||||
const items = posCart.map(item => ({
|
||||
producto_id: item.product.id,
|
||||
cantidad: item.cantidad
|
||||
}));
|
||||
|
||||
let dataCobro = null;
|
||||
try {
|
||||
const resCobro = await fetch('/api/ordenes', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -1206,8 +1262,44 @@ async function handlePistolBarcodeScan(rawToken) {
|
||||
})
|
||||
});
|
||||
|
||||
const dataCobro = await resCobro.json();
|
||||
dataCobro = await resCobro.json();
|
||||
if (!resCobro.ok) throw new Error(dataCobro.error || 'Error al procesar el débito');
|
||||
} catch (errCobro) {
|
||||
if (!navigator.onLine || errCobro.message.includes('fetch') || errCobro.message.includes('NetworkError') || errCobro.message.includes('Failed to fetch')) {
|
||||
const offlineTicketCode = 'OFFLINE-' + Date.now().toString().slice(-6) + '-' + Math.random().toString(36).slice(2, 5).toUpperCase();
|
||||
|
||||
// Descontar saldo localmente para evitar sobregiro offline
|
||||
actualizarSaldoEstudianteOffline(student.id, totalCompra);
|
||||
|
||||
const offlineOrderRecord = {
|
||||
offline_id: offlineTicketCode,
|
||||
estudiante_id: student.id,
|
||||
estudiante_nombre: student.nombre_completo,
|
||||
tipo_orden: 'mostrador',
|
||||
momento_entrega: 'inmediato',
|
||||
items,
|
||||
total: totalCompra,
|
||||
escuela_id: getPosEscuelaId(),
|
||||
fecha: new Date().toISOString()
|
||||
};
|
||||
|
||||
const currentQueue = getOfflineQueue();
|
||||
currentQueue.push(offlineOrderRecord);
|
||||
saveOfflineQueue(currentQueue);
|
||||
|
||||
dataCobro = {
|
||||
codigo_orden: offlineTicketCode,
|
||||
financiero: {
|
||||
estudiante: {
|
||||
saldo_nuevo: Math.max(0, (student.saldo_colones || 0) - totalCompra)
|
||||
}
|
||||
}
|
||||
};
|
||||
console.log('[Modo Offline] Venta de mostrador registrada localmente:', offlineTicketCode);
|
||||
} else {
|
||||
throw errCobro;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Éxito: Mostrar pantalla de confirmación
|
||||
document.getElementById('pistolaStateProcessing').style.display = 'none';
|
||||
@@ -2589,5 +2681,161 @@ function imprimirTicketTermico(orderData) {
|
||||
}
|
||||
window.imprimirTicketTermico = imprimirTicketTermico;
|
||||
|
||||
// ========================================================
|
||||
// SISTEMA DE RESILIENCIA OFFLINE DE LA SODA Y CAJA POS
|
||||
// ========================================================
|
||||
async function cacheOfflineStudents() {
|
||||
try {
|
||||
const res = await fetch(`/api/estudiantes?escuela_id=${getPosEscuelaId()}`);
|
||||
if (!res.ok) return;
|
||||
const list = await res.json();
|
||||
if (Array.isArray(list) && list.length > 0) {
|
||||
localStorage.setItem('sibo_pos_offline_students', JSON.stringify(list));
|
||||
console.log(`[Modo Offline] ${list.length} estudiantes respaldados en memoria local para ventas sin conexión.`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Modo Offline] No se pudieron sincronizar estudiantes para cache offline:', e.message);
|
||||
}
|
||||
}
|
||||
window.cacheOfflineStudents = cacheOfflineStudents;
|
||||
|
||||
function buscarEstudianteOffline(query) {
|
||||
try {
|
||||
const cached = localStorage.getItem('sibo_pos_offline_students');
|
||||
if (!cached) return null;
|
||||
const students = JSON.parse(cached);
|
||||
const q = String(query || '').trim().toLowerCase();
|
||||
return students.find(s =>
|
||||
(s.qr_token && s.qr_token.toLowerCase() === q) ||
|
||||
(s.codigo_estudiante && s.codigo_estudiante.toLowerCase() === q) ||
|
||||
(String(s.id) === q)
|
||||
) || null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
window.buscarEstudianteOffline = buscarEstudianteOffline;
|
||||
|
||||
function actualizarSaldoEstudianteOffline(estId, montoCobrado) {
|
||||
try {
|
||||
const cached = localStorage.getItem('sibo_pos_offline_students');
|
||||
if (!cached) return;
|
||||
const students = JSON.parse(cached);
|
||||
const idx = students.findIndex(s => s.id === estId);
|
||||
if (idx !== -1) {
|
||||
students[idx].saldo_colones = Math.max(0, (students[idx].saldo_colones || 0) - montoCobrado);
|
||||
students[idx].disponible_hoy = Math.max(0, (students[idx].disponible_hoy || 0) - montoCobrado);
|
||||
localStorage.setItem('sibo_pos_offline_students', JSON.stringify(students));
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
window.actualizarSaldoEstudianteOffline = actualizarSaldoEstudianteOffline;
|
||||
|
||||
function getOfflineQueue() {
|
||||
try {
|
||||
const q = localStorage.getItem('sibo_pos_offline_queue');
|
||||
return q ? JSON.parse(q) : [];
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
window.getOfflineQueue = getOfflineQueue;
|
||||
|
||||
function saveOfflineQueue(queue) {
|
||||
try {
|
||||
localStorage.setItem('sibo_pos_offline_queue', JSON.stringify(queue));
|
||||
updateNetworkStatusUI();
|
||||
} catch (e) {}
|
||||
}
|
||||
window.saveOfflineQueue = saveOfflineQueue;
|
||||
|
||||
function updateNetworkStatusUI() {
|
||||
const badge = document.getElementById('posNetworkStatusBadge');
|
||||
const banner = document.getElementById('posOfflineQueueBanner');
|
||||
const lblCount = document.getElementById('lblPosOfflineCount');
|
||||
const queue = getOfflineQueue();
|
||||
const isOnline = navigator.onLine;
|
||||
|
||||
if (badge) {
|
||||
if (isOnline) {
|
||||
badge.className = 'pos-network-pill online';
|
||||
badge.innerHTML = '<span style="width: 8px; height: 8px; border-radius: 50%; background: #16a34a; display: inline-block;"></span> <span>En Línea</span>';
|
||||
} else {
|
||||
badge.className = 'pos-network-pill offline';
|
||||
badge.innerHTML = '<span style="width: 8px; height: 8px; border-radius: 50%; background: #d97706; display: inline-block;"></span> <span>Modo Offline</span>';
|
||||
}
|
||||
}
|
||||
|
||||
if (banner) {
|
||||
if (queue.length > 0) {
|
||||
banner.style.display = 'flex';
|
||||
if (lblCount) {
|
||||
lblCount.textContent = `${queue.length} venta(s) guardada(s) localmente esperando conexión.`;
|
||||
}
|
||||
} else {
|
||||
banner.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
window.updateNetworkStatusUI = updateNetworkStatusUI;
|
||||
|
||||
async function sincronizarVentasOfflineManual() {
|
||||
const queue = getOfflineQueue();
|
||||
if (queue.length === 0) {
|
||||
alert('No hay ventas offline pendientes de sincronizar.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!navigator.onLine) {
|
||||
alert('La terminal no detecta conexión a internet en este momento.');
|
||||
return;
|
||||
}
|
||||
|
||||
const btn = document.getElementById('btnSyncOfflinePos');
|
||||
if (btn) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = '🔄 Sincronizando...';
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/ordenes/sincronizar-offline', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
ordenes: queue,
|
||||
escuela_id: getPosEscuelaId()
|
||||
})
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Error al sincronizar ventas offline');
|
||||
|
||||
// Limpiar cola local
|
||||
localStorage.removeItem('sibo_pos_offline_queue');
|
||||
updateNetworkStatusUI();
|
||||
|
||||
// Refrescar catálogo y estudiantes del servidor
|
||||
await loadCatalog();
|
||||
await cacheOfflineStudents();
|
||||
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
alert(`✅ ¡Sincronización Exitosa!\n\nSe han registrado ${data.sincronizadas} venta(s) offline en la base de datos de la soda.`);
|
||||
} catch (err) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
alert(`Error al sincronizar ventas offline: ${err.message}`);
|
||||
} finally {
|
||||
if (btn) {
|
||||
btn.disabled = false;
|
||||
btn.textContent = '🔄 Sincronizar Ahora';
|
||||
}
|
||||
}
|
||||
}
|
||||
window.sincronizarVentasOfflineManual = sincronizarVentasOfflineManual;
|
||||
|
||||
// Retroalimentación háptica táctil en mostrador POS
|
||||
document.addEventListener('pointerdown', (e) => {
|
||||
const btn = e.target.closest('button, .btn-saas, .pos-mobile-nav-btn, .pos-tab-btn, .pos-cat-pill, .product-card, .pos-qty-btn');
|
||||
if (btn && !btn.disabled && window.haptics) {
|
||||
window.haptics.tap();
|
||||
}
|
||||
}, { passive: true });
|
||||
|
||||
+258
-20
@@ -1,32 +1,270 @@
|
||||
// ========================================================
|
||||
// SISTEMA DE SONIDOS SIBOPAY - COMPLETAMENTE DESACTIVADO
|
||||
// Todos los efectos de sonido y alertas auditivas han sido removidos a solicitud.
|
||||
// SISTEMA SENSORIAL SIBOPAY: AUDIO SINTETIZADO Y HÁPTICO MÓVIL
|
||||
// Sonidos sintetizados mediante Web Audio API (cero descargas, cero latencia)
|
||||
// y vibración háptica táctil en dispositivos móviles (navigator.vibrate)
|
||||
// ========================================================
|
||||
class SoundEffects {
|
||||
|
||||
class SensorySystem {
|
||||
constructor() {
|
||||
this.ctx = null;
|
||||
this.enabled = false;
|
||||
this.soundEnabled = localStorage.getItem('sibopay_sound_enabled') !== 'false';
|
||||
this.hapticEnabled = localStorage.getItem('sibopay_haptic_enabled') !== 'false';
|
||||
this.masterVolume = 0.22; // Nivel suave y agradable, no intrusivo
|
||||
this._initOnGesture = this._initOnGesture.bind(this);
|
||||
|
||||
// Escuchar interacción del usuario para desbloquear AudioContext en móviles (política de navegadores)
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('pointerdown', this._initOnGesture, { once: true, passive: true });
|
||||
window.addEventListener('keydown', this._initOnGesture, { once: true, passive: true });
|
||||
}
|
||||
}
|
||||
|
||||
init() {}
|
||||
playSuccess() {}
|
||||
playCoin() {}
|
||||
playScanChirp() {}
|
||||
playError() {}
|
||||
playTap() {}
|
||||
playBeep() {}
|
||||
playNotice() {}
|
||||
playTrash() {}
|
||||
_initOnGesture() {
|
||||
this._getAudioContext();
|
||||
}
|
||||
|
||||
const silentInstance = new SoundEffects();
|
||||
_getAudioContext() {
|
||||
if (!this.ctx && (typeof window !== 'undefined')) {
|
||||
const AudioCtx = window.AudioContext || window.webkitAudioContext;
|
||||
if (AudioCtx) {
|
||||
try {
|
||||
this.ctx = new AudioCtx();
|
||||
} catch (e) {
|
||||
console.warn('[SensorySystem] No se pudo inicializar AudioContext:', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.ctx && this.ctx.state === 'suspended') {
|
||||
this.ctx.resume().catch(() => {});
|
||||
}
|
||||
return this.ctx;
|
||||
}
|
||||
|
||||
// Proxy de seguridad para asegurar que cualquier llamada desconocida sea silenciosa y segura
|
||||
window.sounds = new Proxy(silentInstance, {
|
||||
get(target, prop) {
|
||||
if (prop in target) {
|
||||
return target[prop];
|
||||
// ==========================================
|
||||
// RETROALIMENTACIÓN HÁPTICA (VIBRACIÓN TÁCTIL)
|
||||
// ==========================================
|
||||
vibrate(pattern) {
|
||||
if (!this.hapticEnabled) return;
|
||||
try {
|
||||
if (typeof navigator !== 'undefined' && 'vibrate' in navigator) {
|
||||
navigator.vibrate(pattern);
|
||||
}
|
||||
return function() {};
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
hapticTap() {
|
||||
this.vibrate(10); // Micro-vibración sutil de 10ms
|
||||
}
|
||||
|
||||
hapticSuccess() {
|
||||
this.vibrate([30, 40, 45]); // Doble pulso de confirmación
|
||||
}
|
||||
|
||||
hapticScan() {
|
||||
this.vibrate(22); // Pulso nítido de detección
|
||||
}
|
||||
|
||||
hapticWarning() {
|
||||
this.vibrate([40, 50, 40]);
|
||||
}
|
||||
|
||||
hapticError() {
|
||||
this.vibrate([70, 50, 70]); // Pulso más marcado de advertencia/error
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// SÍNTESIS DE AUDIO (WEB AUDIO API)
|
||||
// ==========================================
|
||||
|
||||
// Campana suave de éxito (arpegio de 3 notas: Do - Mi - Sol)
|
||||
playSuccess() {
|
||||
this.hapticSuccess();
|
||||
if (!this.soundEnabled) return;
|
||||
const ctx = this._getAudioContext();
|
||||
if (!ctx) return;
|
||||
|
||||
try {
|
||||
const now = ctx.currentTime;
|
||||
const notes = [523.25, 659.25, 783.99]; // C5, E5, G5
|
||||
notes.forEach((freq, index) => {
|
||||
const osc = ctx.createOscillator();
|
||||
const gain = ctx.createGain();
|
||||
osc.type = 'sine';
|
||||
osc.frequency.setValueAtTime(freq, now + index * 0.08);
|
||||
|
||||
gain.gain.setValueAtTime(0, now + index * 0.08);
|
||||
gain.gain.linearRampToValueAtTime(this.masterVolume, now + index * 0.08 + 0.02);
|
||||
gain.gain.exponentialRampToValueAtTime(0.0001, now + index * 0.08 + 0.35);
|
||||
|
||||
osc.connect(gain);
|
||||
gain.connect(ctx.destination);
|
||||
|
||||
osc.start(now + index * 0.08);
|
||||
osc.stop(now + index * 0.08 + 0.36);
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Sonido de moneda / pago registrado (doble tintineo metálico)
|
||||
playCoin() {
|
||||
this.hapticSuccess();
|
||||
if (!this.soundEnabled) return;
|
||||
const ctx = this._getAudioContext();
|
||||
if (!ctx) return;
|
||||
|
||||
try {
|
||||
const now = ctx.currentTime;
|
||||
const tones = [987.77, 1318.51]; // B5 -> E6
|
||||
tones.forEach((freq, index) => {
|
||||
const osc = ctx.createOscillator();
|
||||
const gain = ctx.createGain();
|
||||
osc.type = 'triangle';
|
||||
osc.frequency.setValueAtTime(freq, now + index * 0.09);
|
||||
|
||||
gain.gain.setValueAtTime(0, now + index * 0.09);
|
||||
gain.gain.linearRampToValueAtTime(this.masterVolume * 0.9, now + index * 0.09 + 0.015);
|
||||
gain.gain.exponentialRampToValueAtTime(0.0001, now + index * 0.09 + 0.28);
|
||||
|
||||
osc.connect(gain);
|
||||
gain.connect(ctx.destination);
|
||||
|
||||
osc.start(now + index * 0.09);
|
||||
osc.stop(now + index * 0.09 + 0.30);
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Chirp nítido de escáner QR o código de barras
|
||||
playScanChirp() {
|
||||
this.hapticScan();
|
||||
if (!this.soundEnabled) return;
|
||||
const ctx = this._getAudioContext();
|
||||
if (!ctx) return;
|
||||
|
||||
try {
|
||||
const now = ctx.currentTime;
|
||||
const osc = ctx.createOscillator();
|
||||
const gain = ctx.createGain();
|
||||
|
||||
osc.type = 'sine';
|
||||
osc.frequency.setValueAtTime(1400, now);
|
||||
osc.frequency.exponentialRampToValueAtTime(1900, now + 0.04);
|
||||
|
||||
gain.gain.setValueAtTime(this.masterVolume * 0.8, now);
|
||||
gain.gain.exponentialRampToValueAtTime(0.0001, now + 0.05);
|
||||
|
||||
osc.connect(gain);
|
||||
gain.connect(ctx.destination);
|
||||
|
||||
osc.start(now);
|
||||
osc.stop(now + 0.05);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Tap acústico sutil para botones numéricos o selección
|
||||
playTap() {
|
||||
this.hapticTap();
|
||||
if (!this.soundEnabled) return;
|
||||
const ctx = this._getAudioContext();
|
||||
if (!ctx) return;
|
||||
|
||||
try {
|
||||
const now = ctx.currentTime;
|
||||
const osc = ctx.createOscillator();
|
||||
const gain = ctx.createGain();
|
||||
|
||||
osc.type = 'sine';
|
||||
osc.frequency.setValueAtTime(440, now);
|
||||
osc.frequency.exponentialRampToValueAtTime(220, now + 0.025);
|
||||
|
||||
gain.gain.setValueAtTime(this.masterVolume * 0.4, now);
|
||||
gain.gain.exponentialRampToValueAtTime(0.0001, now + 0.03);
|
||||
|
||||
osc.connect(gain);
|
||||
gain.connect(ctx.destination);
|
||||
|
||||
osc.start(now);
|
||||
osc.stop(now + 0.03);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Tono de error o rechazo (dos tonos bajos descendentes)
|
||||
playError() {
|
||||
this.hapticError();
|
||||
if (!this.soundEnabled) return;
|
||||
const ctx = this._getAudioContext();
|
||||
if (!ctx) return;
|
||||
|
||||
try {
|
||||
const now = ctx.currentTime;
|
||||
const tones = [260, 195];
|
||||
tones.forEach((freq, idx) => {
|
||||
const osc = ctx.createOscillator();
|
||||
const gain = ctx.createGain();
|
||||
|
||||
osc.type = 'sawtooth';
|
||||
osc.frequency.setValueAtTime(freq, now + idx * 0.12);
|
||||
|
||||
gain.gain.setValueAtTime(this.masterVolume * 0.6, now + idx * 0.12);
|
||||
gain.gain.exponentialRampToValueAtTime(0.0001, now + idx * 0.12 + 0.14);
|
||||
|
||||
osc.connect(gain);
|
||||
gain.connect(ctx.destination);
|
||||
|
||||
osc.start(now + idx * 0.12);
|
||||
osc.stop(now + idx * 0.12 + 0.15);
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
playBeep() {
|
||||
this.playTap();
|
||||
}
|
||||
|
||||
playNotice() {
|
||||
this.playSuccess();
|
||||
}
|
||||
|
||||
playTrash() {
|
||||
this.playTap();
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// CONFIGURACIÓN DE PREFERENCIAS DE USUARIO
|
||||
// ==========================================
|
||||
toggleSound(enabled) {
|
||||
this.soundEnabled = (typeof enabled === 'boolean') ? enabled : !this.soundEnabled;
|
||||
localStorage.setItem('sibopay_sound_enabled', String(this.soundEnabled));
|
||||
if (this.soundEnabled) this.playTap();
|
||||
return this.soundEnabled;
|
||||
}
|
||||
|
||||
toggleHaptics(enabled) {
|
||||
this.hapticEnabled = (typeof enabled === 'boolean') ? enabled : !this.hapticEnabled;
|
||||
localStorage.setItem('sibopay_haptic_enabled', String(this.hapticEnabled));
|
||||
if (this.hapticEnabled) this.hapticTap();
|
||||
return this.hapticEnabled;
|
||||
}
|
||||
|
||||
isSoundEnabled() {
|
||||
return this.soundEnabled;
|
||||
}
|
||||
|
||||
isHapticEnabled() {
|
||||
return this.hapticEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
// Instancia global compartida
|
||||
const sensoryInstance = new SensorySystem();
|
||||
|
||||
// Exponer como window.sounds y window.haptics para máxima compatibilidad
|
||||
window.sounds = sensoryInstance;
|
||||
window.haptics = {
|
||||
tap: () => sensoryInstance.hapticTap(),
|
||||
success: () => sensoryInstance.hapticSuccess(),
|
||||
scan: () => sensoryInstance.hapticScan(),
|
||||
warning: () => sensoryInstance.hapticWarning(),
|
||||
error: () => sensoryInstance.hapticError(),
|
||||
vibrate: (p) => sensoryInstance.vibrate(p)
|
||||
};
|
||||
|
||||
+17
-3
@@ -131,9 +131,9 @@
|
||||
<span class="saas-dot" style="background: #0284c7;"></span>
|
||||
Pistola QR Conectada
|
||||
</span>
|
||||
<span class="saas-status-badge saas-status-active" title="Conexión en tiempo real activa">
|
||||
<span class="saas-dot"></span>
|
||||
En Línea (SSE)
|
||||
<span id="posNetworkStatusBadge" class="pos-network-pill online" title="Estado de conexión y sincronización con el servidor">
|
||||
<span style="width: 8px; height: 8px; border-radius: 50%; background: #16a34a; display: inline-block;"></span>
|
||||
<span id="posNetworkStatusText">En Línea</span>
|
||||
</span>
|
||||
<button id="btnPosNotificationToggle" onclick="enablePushNotificationsPrompt()" class="btn-saas btn-saas-outline" style="height: 30px; font-size: 0.76rem; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; color: #0284c7; border-color: #bae6fd;" title="Activar notificaciones de recargas en tiempo real">
|
||||
<span>🔔</span> <span id="lblPosNotificationStatus">Notificaciones</span>
|
||||
@@ -155,6 +155,20 @@
|
||||
<span>🖨️ Auto-imprimir ticket</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- BANNER DE RESILIENCIA OFFLINE DE LA SODA -->
|
||||
<div id="posOfflineQueueBanner" class="pos-offline-banner" style="display: none; border-radius: 12px; margin-top: 4px;">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<span style="font-size: 1.15rem;">⚡</span>
|
||||
<div>
|
||||
<strong style="display: block; font-size: 0.82rem; line-height: 1.2;">Modo Offline Activo</strong>
|
||||
<span id="lblPosOfflineCount" style="font-size: 0.72rem; opacity: 0.95;">0 ventas guardadas localmente esperando conexión.</span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" id="btnSyncOfflinePos" onclick="sincronizarVentasOfflineManual()" class="btn-saas" style="height: 30px; padding: 0 12px; background: white; color: #92400e; font-weight: 800; font-size: 0.76rem; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.15); border: none; cursor: pointer;">
|
||||
🔄 Sincronizar Ahora
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TABS DE MODO DE TERMINAL (RESPONSIVE SIN RECORTES) -->
|
||||
|
||||
@@ -394,6 +394,102 @@ app.post('/api/auth/register-padre', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// ELIMINACIÓN DE CUENTA Y SUPRESIÓN DE DATOS (GOOGLE PLAY & APPLE COMPLIANCE)
|
||||
// ==========================================
|
||||
app.post('/api/auth/eliminar-cuenta', (req, res) => {
|
||||
try {
|
||||
const { usuario_id, password_confirmacion, motivo } = req.body;
|
||||
if (!usuario_id) {
|
||||
return res.status(400).json({ error: 'ID de usuario requerido para procesar la baja' });
|
||||
}
|
||||
|
||||
const user = db.prepare('SELECT * FROM usuarios WHERE id = ?').get(usuario_id);
|
||||
if (!user) {
|
||||
return res.status(404).json({ error: 'La cuenta de usuario no existe o ya ha sido eliminada' });
|
||||
}
|
||||
|
||||
// Verificar contraseña si fue enviada (o frase de confirmación ELIMINAR)
|
||||
if (password_confirmacion) {
|
||||
const cleanPass = String(password_confirmacion).trim();
|
||||
if (cleanPass !== user.password_hash && cleanPass.toUpperCase() !== 'ELIMINAR') {
|
||||
return res.status(401).json({ error: 'Contraseña de confirmación incorrecta. Por favor verifícala para proceder con el borrado.' });
|
||||
}
|
||||
}
|
||||
|
||||
// Proceder con el borrado y disociación según el rol
|
||||
if (user.rol === 'padre') {
|
||||
// 1. Desvincular de todos los hijos en tabla de enlace
|
||||
db.prepare('DELETE FROM padres_estudiantes WHERE padre_usuario_id = ?').run(user.id);
|
||||
// 2. Desvincular campo legacy en estudiantes
|
||||
db.prepare('UPDATE estudiantes SET padre_usuario_id = NULL WHERE padre_usuario_id = ?').run(user.id);
|
||||
} else if (user.rol === 'estudiante') {
|
||||
// 3. Desvincular usuario de su ficha de estudiante
|
||||
db.prepare('UPDATE estudiantes SET usuario_id = NULL WHERE usuario_id = ?').run(user.id);
|
||||
}
|
||||
|
||||
// 4. Limpiar tokens de notificaciones push asociados a este usuario
|
||||
try {
|
||||
if (user.id) {
|
||||
db.prepare('DELETE FROM push_subscriptions WHERE usuario_id = ?').run(user.id);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// 5. Eliminar registro del usuario en tabla usuarios
|
||||
db.prepare('DELETE FROM usuarios WHERE id = ?').run(user.id);
|
||||
|
||||
console.log(`[Seguridad] Cuenta eliminada: ID=${user.id}, Usuario=${user.username}, Rol=${user.rol}, Motivo=${motivo || 'No especificado'}`);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
mensaje: 'Tu cuenta y datos personales han sido eliminados de forma definitiva de SiboPay.'
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('[Error eliminar cuenta]:', err);
|
||||
res.status(500).json({ error: 'Error procesando la eliminación: ' + err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Solicitud pública de eliminación de cuenta desde web (Requisito Google Play Console)
|
||||
app.post('/api/public/solicitar-eliminacion-cuenta', (req, res) => {
|
||||
try {
|
||||
const { identificador, motivo, confirmacion } = req.body;
|
||||
if (!identificador) {
|
||||
return res.status(400).json({ error: 'Por favor ingresa tu nombre de usuario, correo electrónico o teléfono registrado.' });
|
||||
}
|
||||
|
||||
const cleanId = String(identificador).trim().toLowerCase();
|
||||
const user = db.prepare(`
|
||||
SELECT id, username, rol, email, telefono FROM usuarios
|
||||
WHERE LOWER(username) = ? OR LOWER(email) = ? OR telefono = ?
|
||||
`).get(cleanId, cleanId, cleanId);
|
||||
|
||||
if (user) {
|
||||
if (confirmacion === true || String(confirmacion).toUpperCase() === 'ELIMINAR') {
|
||||
if (user.rol === 'padre') {
|
||||
db.prepare('DELETE FROM padres_estudiantes WHERE padre_usuario_id = ?').run(user.id);
|
||||
db.prepare('UPDATE estudiantes SET padre_usuario_id = NULL WHERE padre_usuario_id = ?').run(user.id);
|
||||
} else if (user.rol === 'estudiante') {
|
||||
db.prepare('UPDATE estudiantes SET usuario_id = NULL WHERE usuario_id = ?').run(user.id);
|
||||
}
|
||||
db.prepare('DELETE FROM usuarios WHERE id = ?').run(user.id);
|
||||
|
||||
return res.json({
|
||||
success: true,
|
||||
mensaje: 'Tu cuenta ha sido localizada y eliminada de forma permanente junto con todos sus datos asociados.'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
mensaje: 'Hemos recibido tu solicitud de supresión de datos. Si los datos coinciden con un usuario activo, se procesará en menos de 24 horas laborables.'
|
||||
});
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Vincular estudiante a la cuenta de padre mediante QR o código de carné
|
||||
app.post('/api/padres/vincular-hijo', (req, res) => {
|
||||
try {
|
||||
@@ -3755,6 +3851,89 @@ app.post('/api/ordenes', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// RESILIENCIA OFFLINE: SINCRONIZACIÓN BATCH DE VENTAS OFFLINE DE LA SODA
|
||||
// ==========================================
|
||||
app.post('/api/ordenes/sincronizar-offline', (req, res) => {
|
||||
try {
|
||||
const { ordenes, escuela_id } = req.body;
|
||||
if (!Array.isArray(ordenes) || ordenes.length === 0) {
|
||||
return res.status(400).json({ error: 'No se enviaron órdenes para sincronizar' });
|
||||
}
|
||||
|
||||
const resultados = [];
|
||||
const errores = [];
|
||||
|
||||
for (const ord of ordenes) {
|
||||
try {
|
||||
const estId = ord.estudiante_id;
|
||||
if (!estId) {
|
||||
errores.push({ offline_id: ord.offline_id, error: 'Falta estudiante_id' });
|
||||
continue;
|
||||
}
|
||||
|
||||
// Idempotencia: Verificar si esta orden offline ya fue procesada antes
|
||||
if (ord.offline_id) {
|
||||
const yaExiste = db.prepare(`
|
||||
SELECT id, codigo_orden FROM ordenes
|
||||
WHERE notas LIKE ? OR codigo_orden = ?
|
||||
`).get(`%${ord.offline_id}%`, ord.offline_id);
|
||||
|
||||
if (yaExiste) {
|
||||
resultados.push({
|
||||
offline_id: ord.offline_id,
|
||||
status: 'ya_procesada',
|
||||
codigo_orden: yaExiste.codigo_orden
|
||||
});
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const itemsProc = (ord.items || []).map(i => ({
|
||||
producto_id: i.producto_id || (i.product && i.product.id),
|
||||
cantidad: i.cantidad || 1
|
||||
}));
|
||||
|
||||
const resultado = crearOrdenCompleta({
|
||||
estudianteId: estId,
|
||||
tipoOrden: ord.tipo_orden || 'mostrador',
|
||||
momentoEntrega: ord.momento_entrega || 'inmediato',
|
||||
notas: `Venta offline sincronizada [Ref: ${ord.offline_id || 'LOCAL'}]`,
|
||||
items: itemsProc
|
||||
});
|
||||
|
||||
// Notificar por SSE a la soda y pantallas
|
||||
broadcastEvent('nueva_orden', resultado);
|
||||
|
||||
resultados.push({
|
||||
offline_id: ord.offline_id,
|
||||
status: 'creada',
|
||||
codigo_orden: resultado.codigo_orden,
|
||||
estudiante_id: estId,
|
||||
total: resultado.total_colones
|
||||
});
|
||||
} catch (errOrd) {
|
||||
console.error(`[Offline Sync] Error procesando orden ${ord.offline_id}:`, errOrd.message);
|
||||
errores.push({
|
||||
offline_id: ord.offline_id,
|
||||
error: errOrd.message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
total_enviadas: ordenes.length,
|
||||
sincronizadas: resultados.length,
|
||||
fallidas: errores.length,
|
||||
resultados,
|
||||
errores
|
||||
});
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: 'Error general en sincronización offline: ' + err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Listar órdenes (con filtro por estado o tipo)
|
||||
app.get('/api/ordenes', (req, res) => {
|
||||
try {
|
||||
@@ -3971,6 +4150,11 @@ app.get(['/legal', '/terminos', '/privacidad', '/terminos-y-condiciones', '/poli
|
||||
res.sendFile(path.join(__dirname, '../public/legal.html'));
|
||||
});
|
||||
|
||||
// Ruta dedicada para Solicitud de Eliminación de Cuenta (Requisito Google Play Console y Apple)
|
||||
app.get(['/eliminar-cuenta', '/borrar-cuenta', '/solicitar-eliminacion', '/delete-account'], (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../public/eliminar-cuenta.html'));
|
||||
});
|
||||
|
||||
// Iniciar servidor
|
||||
app.listen(PORT, () => {
|
||||
console.log(`🚀 Servidor SiboPay iniciado en http://localhost:${PORT}`);
|
||||
|
||||
Reference in New Issue
Block a user