Compare commits
5
Commits
798cc33add
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8357c3158 | ||
|
|
b5e421cf25 | ||
|
|
ed7989a280 | ||
|
|
c053a74d69 | ||
|
|
1f0207a5ee |
@@ -2680,6 +2680,53 @@ body.dark-mode .floating-cart-bar {
|
||||
box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
|
||||
}
|
||||
|
||||
/* Envoltorio para alternar visualización de contraseñas */
|
||||
.password-input-wrapper {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.password-input-wrapper input {
|
||||
padding-right: 44px !important;
|
||||
}
|
||||
|
||||
.btn-toggle-password {
|
||||
position: absolute;
|
||||
right: 6px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 8px;
|
||||
cursor: pointer;
|
||||
color: #64748b;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 8px;
|
||||
transition: all 0.15s ease;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.btn-toggle-password:hover,
|
||||
.btn-toggle-password:focus-visible {
|
||||
color: #0284c7;
|
||||
background: rgba(2, 132, 199, 0.1);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
body.dark-mode .btn-toggle-password {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
body.dark-mode .btn-toggle-password:hover,
|
||||
body.dark-mode .btn-toggle-password:focus-visible {
|
||||
color: #38bdf8;
|
||||
background: rgba(56, 189, 248, 0.15);
|
||||
}
|
||||
|
||||
.login-submit-btn {
|
||||
width: 100%;
|
||||
padding: 13px;
|
||||
|
||||
@@ -616,21 +616,24 @@
|
||||
<span class="text-lg font-black text-white">Sibo<span class="text-sky-500">Pay</span></span>
|
||||
<span class="text-[10px] bg-slate-800 text-slate-300 px-2 py-0.5 rounded-full ml-2">Costa Rica 🇨🇷</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-6 font-bold text-slate-300">
|
||||
<div class="flex items-center gap-6 font-bold text-slate-300 flex-wrap justify-center">
|
||||
<a href="#sodas" class="hover:text-white transition">Sodas</a>
|
||||
<a href="#familias" class="hover:text-white transition">Familias</a>
|
||||
<a href="#mep" class="hover:text-white transition">Normativa MEP</a>
|
||||
<button onclick="window.location.href='/app'" class="hover:text-white transition cursor-pointer">Iniciar Sesión</button>
|
||||
<a href="/carnet.html" target="_blank" class="hover:text-white transition">Carnés QR</a>
|
||||
<a href="/eliminar-cuenta" class="hover:text-white transition">Eliminar Cuenta</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col sm:flex-row items-center justify-between gap-4 pt-6 text-[11px] text-slate-500">
|
||||
<p>© 2026 SiboPay Costa Rica. Sistema inteligente de billetera online.</p>
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="flex items-center gap-4 flex-wrap justify-center sm:justify-end">
|
||||
<a href="/terminos" class="hover:text-slate-300 transition underline-offset-2 hover:underline">Términos y Condiciones</a>
|
||||
<span>•</span>
|
||||
<a href="/privacidad" class="hover:text-slate-300 transition underline-offset-2 hover:underline">Política de Privacidad</a>
|
||||
<span>•</span>
|
||||
<a href="/eliminar-cuenta" class="hover:text-slate-300 transition underline-offset-2 hover:underline text-rose-400">Eliminación de Cuenta</a>
|
||||
<span>•</span>
|
||||
<span>SINPE Móvil 🇨🇷</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+328
-19
@@ -11,15 +11,32 @@
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="SiboPay">
|
||||
<link rel="preload" href="/css/styles.css?v=19.9" as="style">
|
||||
<link rel="preload" href="/js/app.js?v=20.5" as="script">
|
||||
<link rel="stylesheet" href="/css/styles.css?v=19.9">
|
||||
<link rel="preload" href="/css/styles.css?v=20.0" as="style">
|
||||
<link rel="preload" href="/js/app.js?v=20.9" as="script">
|
||||
<link rel="stylesheet" href="/css/styles.css?v=20.0">
|
||||
<link rel="stylesheet" href="/css/desktop.css?v=2.2">
|
||||
<style>
|
||||
/* Transiciones suaves */
|
||||
.fade-enter { animation: fadeIn 0.2s ease-in-out; }
|
||||
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
|
||||
</style>
|
||||
<script>
|
||||
function togglePasswordVisibility(inputId, btn) {
|
||||
var input = document.getElementById(inputId);
|
||||
if (!input) return;
|
||||
var isPassword = input.type === 'password';
|
||||
input.type = isPassword ? 'text' : 'password';
|
||||
if (btn) {
|
||||
btn.title = isPassword ? 'Ocultar contraseña' : 'Ver contraseña';
|
||||
btn.setAttribute('aria-label', btn.title);
|
||||
btn.style.color = isPassword ? '#0284c7' : '';
|
||||
btn.innerHTML = isPassword
|
||||
? '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>'
|
||||
: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>';
|
||||
}
|
||||
}
|
||||
window.togglePasswordVisibility = togglePasswordVisibility;
|
||||
</script>
|
||||
</head>
|
||||
<body class="">
|
||||
|
||||
@@ -51,9 +68,11 @@
|
||||
|
||||
<p class="splash-disclaimer">
|
||||
Al iniciar sesión y registrarse, acepta nuestros
|
||||
<a href="/terminos" target="_blank" rel="noopener noreferrer">Términos y Condiciones</a>
|
||||
y nuestra
|
||||
<a href="/privacidad" target="_blank" rel="noopener noreferrer">Política de Privacidad</a>.
|
||||
<a href="/terminos" target="_blank" rel="noopener noreferrer">Términos y Condiciones</a>,
|
||||
nuestra
|
||||
<a href="/privacidad" target="_blank" rel="noopener noreferrer">Política de Privacidad</a>
|
||||
y
|
||||
<a href="/eliminar-cuenta" target="_blank" rel="noopener noreferrer">Eliminación de Cuenta</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -81,7 +100,12 @@
|
||||
|
||||
<div class="login-form-group" style="margin-bottom: 8px;">
|
||||
<label id="lblLoginPass" for="loginPassword">Contraseña o PIN:</label>
|
||||
<div class="password-input-wrapper">
|
||||
<input type="password" id="loginPassword" class="login-input" placeholder="••••••••" required autocomplete="current-password">
|
||||
<button type="button" class="btn-toggle-password" onclick="togglePasswordVisibility('loginPassword', this)" title="Ver contraseña" aria-label="Ver contraseña">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; justify-content: flex-end; margin-top: -2px; margin-bottom: 14px;">
|
||||
@@ -131,9 +155,74 @@
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<!-- CONTENIDO 2: REGISTRO DE CUENTA -->
|
||||
<!-- CONTENIDO 2: MODAL DE SELECCIÓN DE TIPO DE REGISTRO -->
|
||||
<div id="sheetContentRegisterChoose" style="display: none; padding: 4px 0 8px;">
|
||||
<div style="text-align: center; margin-bottom: 18px;">
|
||||
<h4 style="margin: 0 0 6px; font-size: 1.15rem; font-weight: 800; color: #0f172a;">¿Cómo deseas registrarte?</h4>
|
||||
<p style="margin: 0; font-size: 0.82rem; color: #64748b;">Elige tu perfil para continuar con el registro</p>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px;">
|
||||
<!-- BOTÓN 1: PADRE DE FAMILIA -->
|
||||
<button type="button" onclick="selectRegisterType('padre')" style="display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 16px; border: 2px solid #bae6fd; background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); cursor: pointer; text-align: left; transition: all 0.2s ease; box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08); width: 100%;">
|
||||
<div style="width: 48px; height: 48px; border-radius: 12px; background: white; border: 1.5px solid #7dd3fc; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; box-shadow: 0 2px 6px rgba(0,0,0,0.04);">
|
||||
👨👩👧
|
||||
</div>
|
||||
<div style="flex: 1;">
|
||||
<strong style="display: block; font-size: 1rem; font-weight: 800; color: #0369a1; margin-bottom: 2px;">Padre de familia</strong>
|
||||
<span style="display: block; font-size: 0.76rem; color: #475569; line-height: 1.35;">Crea tu cuenta para vincular a tus hijos y recargarles saldo en SINPE Móvil.</span>
|
||||
</div>
|
||||
<div style="color: #0284c7; font-weight: 800; font-size: 1.3rem;">›</div>
|
||||
</button>
|
||||
|
||||
<!-- BOTÓN 2: ALUMNO GENERAL -->
|
||||
<button type="button" onclick="selectRegisterType('alumno')" style="display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 16px; border: 2px solid #e2e8f0; background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%); cursor: pointer; text-align: left; transition: all 0.2s ease; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); width: 100%;">
|
||||
<div style="width: 48px; height: 48px; border-radius: 12px; background: #f1f5f9; border: 1.5px solid #cbd5e1; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0;">
|
||||
🎓
|
||||
</div>
|
||||
<div style="flex: 1;">
|
||||
<strong style="display: block; font-size: 1rem; font-weight: 800; color: #1e293b; margin-bottom: 2px;">Alumno general</strong>
|
||||
<span style="display: block; font-size: 0.76rem; color: #64748b; line-height: 1.35;">Para estudiantes y compras personales en la soda estudiantil.</span>
|
||||
</div>
|
||||
<div style="color: #94a3b8; font-weight: 800; font-size: 1.3rem;">›</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div style="text-align: center; border-top: 1px solid #f1f5f9; padding-top: 14px;">
|
||||
<p style="font-size: 0.82rem; color: #64748b; margin: 0;">
|
||||
¿Ya tienes cuenta registrada?
|
||||
<button type="button" onclick="switchSheetView('login')" style="background: none; border: none; color: #0284c7; font-weight: 800; cursor: pointer; text-decoration: underline; font-size: 0.82rem; padding: 0;">Inicia sesión aquí</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CONTENIDO 2.1: FORMULARIO DE REGISTRO (PADRE O ALUMNO) -->
|
||||
<div id="sheetContentRegister" style="display: none;">
|
||||
<!-- BANNER PADRE (visible solo para rol padre) -->
|
||||
<div id="bannerPadreRegister" style="background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); border: 1.5px solid #bae6fd; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px;">
|
||||
<div style="width: 36px; height: 36px; border-radius: 10px; background: white; border: 1px solid #bae6fd; display: flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 4px;">
|
||||
<img src="/img/sibopay-emblem.png" alt="SiboPay" style="width: 100%; height: 100%; object-fit: contain;">
|
||||
</div>
|
||||
<div>
|
||||
<strong style="color: #0369a1; font-size: 0.86rem; display: block; font-weight: 800;">Registro de Padres o Encargados</strong>
|
||||
<span style="font-size: 0.72rem; color: #475569; display: block;">Crea tu cuenta para vincular a tus hijos y recargarles saldo con SINPE móvil.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BANNER ALUMNO (visible solo para rol alumno) -->
|
||||
<div id="bannerAlumnoRegister" style="display: none; background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%); border: 1.5px solid #e2e8f0; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; align-items: center; gap: 10px;">
|
||||
<div style="width: 36px; height: 36px; border-radius: 10px; background: white; border: 1px solid #cbd5e1; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1.25rem;">
|
||||
🎓
|
||||
</div>
|
||||
<div>
|
||||
<strong style="color: #1e293b; font-size: 0.86rem; display: block; font-weight: 800;">Registro de Alumno General</strong>
|
||||
<span style="font-size: 0.72rem; color: #64748b; display: block;">Crea tu cuenta personal para acceder a tu carné y monedero digital.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form id="formRegisterPadre" onsubmit="handleRegisterPadreSubmit(event)">
|
||||
<input type="hidden" id="regTargetRol" value="padre">
|
||||
|
||||
<div class="login-form-group">
|
||||
<label for="regNombre">Nombre y Apellidos:</label>
|
||||
<input type="text" id="regNombre" class="login-input" placeholder="Ej: Carlos Alvarado Castro" required autocomplete="name">
|
||||
@@ -161,22 +250,25 @@
|
||||
|
||||
<div class="login-form-group">
|
||||
<label for="regPassword">Contraseña:</label>
|
||||
<div class="password-input-wrapper">
|
||||
<input type="password" id="regPassword" class="login-input" placeholder="Mínimo 6 caracteres" minlength="6" required autocomplete="new-password">
|
||||
<button type="button" class="btn-toggle-password" onclick="togglePasswordVisibility('regPassword', this)" title="Ver contraseña" aria-label="Ver contraseña">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="registerErrorMsg" style="display: none; background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; padding: 8px 12px; border-radius: 10px; font-size: 0.8rem; font-weight: 700; margin-bottom: 12px; text-align: center;"></div>
|
||||
|
||||
<button type="submit" id="btnRegisterSubmit" class="login-submit-btn" style="display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 48px; border-radius: 12px; font-weight: 800; font-size: 1rem; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; cursor: pointer; box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="7" r="3.5"/><path d="M3 20v-1.5A4.5 4.5 0 0 1 7.5 14h3A4.5 4.5 0 0 1 15 18.5V20"/><circle cx="17.5" cy="7.5" r="2.5"/><path d="M15 14a3.5 3.5 0 0 1 5.5 3v3"/></svg>
|
||||
<span>Crear Cuenta y Entrar</span>
|
||||
<span id="lblBtnRegisterSubmit">Crear Cuenta y Entrar</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div style="text-align: center; margin-top: 14px;">
|
||||
<p style="font-size: 0.82rem; color: #64748b; margin: 0;">
|
||||
¿Ya tienes cuenta registrada?
|
||||
<button type="button" onclick="switchSheetView('login')" style="background: none; border: none; color: #0284c7; font-weight: 800; cursor: pointer; text-decoration: underline; font-size: 0.82rem; padding: 0;">Inicia sesión aquí</button>
|
||||
</p>
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 0.82rem;">
|
||||
<button type="button" onclick="switchSheetView('register-choose')" style="background: none; border: none; color: #0284c7; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0;">← Cambiar tipo de cuenta</button>
|
||||
<button type="button" onclick="switchSheetView('login')" style="background: none; border: none; color: #64748b; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0;">Iniciar sesión</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -219,12 +311,22 @@
|
||||
|
||||
<div class="login-form-group">
|
||||
<label for="forgotNewPass">Nueva Contraseña:</label>
|
||||
<div class="password-input-wrapper">
|
||||
<input type="password" id="forgotNewPass" class="login-input" placeholder="Mínimo 6 caracteres" minlength="6" required autocomplete="new-password">
|
||||
<button type="button" class="btn-toggle-password" onclick="togglePasswordVisibility('forgotNewPass', this)" title="Ver contraseña" aria-label="Ver contraseña">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="login-form-group">
|
||||
<label for="forgotConfirmPass">Confirmar Nueva Contraseña:</label>
|
||||
<div class="password-input-wrapper">
|
||||
<input type="password" id="forgotConfirmPass" class="login-input" placeholder="Repite la contraseña" minlength="6" required autocomplete="new-password">
|
||||
<button type="button" class="btn-toggle-password" onclick="togglePasswordVisibility('forgotConfirmPass', this)" title="Ver contraseña" aria-label="Ver contraseña">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="forgotMsgStep2" style="display: none; padding: 9px 12px; border-radius: 10px; font-size: 0.82rem; font-weight: 700; margin-bottom: 12px; text-align: center;"></div>
|
||||
@@ -3149,14 +3251,34 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- BANNER DE LÍMITE DIARIO Y DISPONIBILIDAD (SÓLO LECTURA INFORMATIVA PARA EL ESTUDIANTE) -->
|
||||
<div class="daily-limit-badge" id="dailyLimitBadge" style="cursor: default;" title="Límite diario establecido por tus padres">
|
||||
<!-- ACCIONES RÁPIDAS DEL MONEDERO DEL ESTUDIANTE (AUTORECARGA SINPE Y PRESUPUESTO) -->
|
||||
<div class="wallet-student-quick-actions" id="walletStudentQuickActions" style="display: flex; gap: 8px; margin: 0 auto 12px auto; max-width: 440px; width: calc(100% - 24px); box-sizing: border-box;">
|
||||
<button type="button" class="btn-wallet-quick-action" id="btnStudentSinpeRecharge" onclick="abrirModalRecargaSinpeEstudiante()" style="flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 12px; background: linear-gradient(135deg, #0284c7, #0369a1); border: none; border-radius: 12px; color: #ffffff; font-weight: 800; font-size: 0.8rem; cursor: pointer; box-shadow: 0 4px 12px rgba(2, 132, 199, 0.22); transition: transform 0.15s ease;">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><line x1="12" x2="12.01" y1="18" y2="18"/></svg>
|
||||
<span>Recargar SINPE</span>
|
||||
</button>
|
||||
<button type="button" class="btn-wallet-quick-action" id="btnStudentPresupuesto" onclick="abrirModalPresupuestoPersonal()" style="flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 12px; background: var(--card-bg, #ffffff); border: 1.5px solid var(--border, #cbd5e1); border-radius: 12px; color: var(--text-main, #0f172a); font-weight: 800; font-size: 0.8rem; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); transition: transform 0.15s ease;">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m10 15 5-3-5-3v6Z"/></svg>
|
||||
<span id="btnStudentPresupuestoLabel">Mi Presupuesto</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- BANNER DE LÍMITE DIARIO Y DISPONIBILIDAD (INTERACTIVO PARA ESTUDIANTES) -->
|
||||
<div class="daily-limit-badge" id="dailyLimitBadge" style="cursor: pointer; flex-direction: column; align-items: stretch; gap: 5px; margin: 0 auto 14px auto; max-width: 440px; width: calc(100% - 24px); box-sizing: border-box;" onclick="handleDailyLimitBadgeClick()" title="Toca para ver o ajustar tu presupuesto">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
|
||||
<div>
|
||||
<span>Límite diario fijado: </span>
|
||||
<span id="dailyLimitBadgeTitle">Límite diario fijado: </span>
|
||||
<strong id="dailyLimitText">₡0</strong>
|
||||
</div>
|
||||
<div style="font-size: 0.76rem; color: var(--text-muted);" id="dailyAvailableText">
|
||||
Disponible hoy: ₡0
|
||||
<span id="dailyLimitEditHint" style="font-size: 0.72rem; color: #0284c7; font-weight: 800; background: #e0f2fe; padding: 2px 8px; border-radius: 6px; display: none;">🎯 Ajustar</span>
|
||||
</div>
|
||||
<div style="font-size: 0.76rem; color: var(--text-muted); display: flex; justify-content: space-between; align-items: center; width: 100%;">
|
||||
<span id="dailyAvailableText">Disponible hoy: ₡0</span>
|
||||
<span id="dailyGastadoText" style="font-size: 0.72rem; color: #64748b;">Gastado hoy: ₡0</span>
|
||||
</div>
|
||||
<!-- Barra de progreso visual del presupuesto para el estudiante -->
|
||||
<div id="studentBudgetProgressBarContainer" style="display: none; width: 100%; height: 6px; background: #e2e8f0; border-radius: 6px; overflow: hidden; margin-top: 2px;">
|
||||
<div id="studentBudgetProgressBar" style="width: 0%; height: 100%; background: #10b981; border-radius: 6px; transition: width 0.3s ease, background 0.3s ease;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3857,7 +3979,12 @@
|
||||
|
||||
<div style="margin-bottom: 10px;">
|
||||
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;" id="lblStaffPassword">Contraseña de Acceso *:</label>
|
||||
<div class="password-input-wrapper">
|
||||
<input type="password" id="adminStaffPassword" placeholder="••••••••" style="width: 100%; padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
|
||||
<button type="button" class="btn-toggle-password" onclick="togglePasswordVisibility('adminStaffPassword', this)" title="Ver contraseña" aria-label="Ver contraseña">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<small id="hintStaffPassword" style="display: none; font-size: 0.7rem; color: var(--text-muted); margin-top: 3px;">Deja en blanco para conservar la contraseña actual.</small>
|
||||
</div>
|
||||
|
||||
@@ -4301,7 +4428,12 @@
|
||||
<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>
|
||||
<div class="password-input-wrapper">
|
||||
<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);">
|
||||
<button type="button" class="btn-toggle-password" onclick="togglePasswordVisibility('inputConfirmarPassEliminar', this)" title="Ver contraseña" aria-label="Ver contraseña">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; justify-content: flex-end;">
|
||||
@@ -4519,7 +4651,12 @@
|
||||
|
||||
<div id="devPasswordRow" style="margin-bottom: 12px;">
|
||||
<label id="devPasswordLabel" style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Contraseña:</label>
|
||||
<div class="password-input-wrapper">
|
||||
<input type="password" id="devInputPassword" placeholder="Contraseña de acceso" style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;">
|
||||
<button type="button" class="btn-toggle-password" onclick="togglePasswordVisibility('devInputPassword', this)" title="Ver contraseña" aria-label="Ver contraseña">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<small id="devPasswordHelp" style="font-size: 0.72rem; color: var(--text-muted); display: none;">Dejar en blanco si no deseas cambiar la contraseña actual.</small>
|
||||
</div>
|
||||
|
||||
@@ -4567,7 +4704,12 @@
|
||||
|
||||
<div style="margin-bottom: 16px;">
|
||||
<label style="font-size: 0.82rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 6px;">Nueva Contraseña:</label>
|
||||
<div class="password-input-wrapper">
|
||||
<input type="password" id="devInputNewPassword" required minlength="4" placeholder="Mínimo 4 caracteres" style="width: 100%; padding: 11px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box; font-size: 0.95rem;">
|
||||
<button type="button" class="btn-toggle-password" onclick="togglePasswordVisibility('devInputNewPassword', this)" title="Ver contraseña" aria-label="Ver contraseña">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; justify-content: flex-end; gap: 10px; border-top: 1.5px solid var(--border); padding-top: 14px;">
|
||||
@@ -5229,6 +5371,173 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODAL: AUTORECARGA DE SALDO CON SINPE MÓVIL PARA ESTUDIANTES -->
|
||||
<div class="modal-qr-backdrop modal-sinpe-backdrop" id="modalRecargaSinpeEstudiante" style="display: none;" onclick="handleModalRecargaSinpeEstudianteBackdrop(event)">
|
||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; width: 92%; padding: 22px 20px; border-radius: 22px; box-shadow: 0 20px 40px rgba(0,0,0,0.25); text-align: left; background: var(--card-bg, #ffffff); max-height: 90vh; overflow-y: auto; box-sizing: border-box;">
|
||||
|
||||
<!-- Encabezado con Botón Cerrar -->
|
||||
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; border-bottom: 1.5px solid var(--border, #e2e8f0); padding-bottom: 10px;">
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<div style="width: 40px; height: 40px; border-radius: 12px; background: #e0f2fe; display: flex; align-items: center; justify-content: center; font-size: 1.25rem;">
|
||||
📲
|
||||
</div>
|
||||
<div>
|
||||
<h3 style="margin: 0; font-size: 1.1rem; font-weight: 800; color: var(--text-main, #0f172a);">Recargar con SINPE</h3>
|
||||
<span style="font-size: 0.74rem; color: var(--text-muted, #64748b);">Acredita saldo a tu monedero escolar</span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" onclick="cerrarModalRecargaSinpeEstudiante()" style="background: none; border: none; font-size: 1.4rem; color: #94a3b8; cursor: pointer; padding: 4px; line-height: 1;" title="Cerrar">✕</button>
|
||||
</div>
|
||||
|
||||
<!-- Banner si SINPE suspendido en la escuela -->
|
||||
<div id="studentSinpeSuspendedBanner" style="display: none; background: #fef2f2; border: 1.5px solid #fecaca; border-radius: 12px; padding: 10px 12px; font-size: 0.8rem; color: #991b1b; margin-bottom: 12px;">
|
||||
⚠️ <span id="studentSinpeSuspendedMsg">Las recargas SINPE se encuentran temporalmente en pausa técnica.</span>
|
||||
</div>
|
||||
|
||||
<div id="studentSinpeFormContainer">
|
||||
<!-- PASO 1: DATOS BANCARIOS DE LA SODA -->
|
||||
<div style="background: linear-gradient(135deg, #0284c7, #0369a1); border-radius: 16px; padding: 14px 16px; color: #ffffff; margin-bottom: 14px; box-shadow: 0 4px 14px rgba(2, 132, 199, 0.25);">
|
||||
<div style="font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.8px; opacity: 0.88; margin-bottom: 4px;">Envía tu SINPE Móvil al número:</div>
|
||||
|
||||
<div style="display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px;">
|
||||
<div style="font-size: 1.45rem; font-weight: 900; letter-spacing: 1px;" id="studentSinpeNumeroDisplay">8888-8888</div>
|
||||
<button type="button" id="btnCopiarTelSinpeEstudiante" onclick="copiarTelefonoSinpeEstudiante()" style="background: rgba(255,255,255,0.22); border: 1px solid rgba(255,255,255,0.35); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 0.75rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 5px; backdrop-filter: blur(4px);">
|
||||
<span id="lblCopiarTelSinpeEstudiante">📋 Copiar</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div style="border-top: 1px solid rgba(255,255,255,0.2); padding-top: 8px; display: flex; flex-direction: column; gap: 3px; font-size: 0.75rem; opacity: 0.95;">
|
||||
<div>Titular: <strong id="studentSinpeTitularDisplay">Soda Escolar</strong></div>
|
||||
<div>Escuela: <span id="studentSinpeEscuelaDisplay">Centro Educativo</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PASO 2: CÓDIGO DE DETALLE PARA EL BANCO -->
|
||||
<div style="background: #f8fafc; border: 1.5px dashed #cbd5e1; border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between;">
|
||||
<div>
|
||||
<span style="font-size: 0.7rem; color: #64748b; font-weight: 700; text-transform: uppercase; display: block;">Código de Detalle (Motivo SINPE):</span>
|
||||
<strong id="studentSinpeCodigoDisplay" style="font-family: monospace; font-size: 1.05rem; color: #0284c7; letter-spacing: 1px;">SIBO-CARGANDO</strong>
|
||||
</div>
|
||||
<button type="button" id="btnCopiarCodSinpeEstudiante" onclick="copiarCodigoSinpeEstudiante()" style="background: #e0f2fe; border: 1px solid #bae6fd; color: #0284c7; padding: 6px 10px; border-radius: 8px; font-size: 0.74rem; font-weight: 800; cursor: pointer;">
|
||||
<span id="lblCopiarCodSinpeEstudiante">Copiar</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- PASO 3: MONTO A RECARGAR -->
|
||||
<div style="margin-bottom: 12px;">
|
||||
<label style="display: block; font-size: 0.78rem; font-weight: 700; color: var(--text-main, #334155); margin-bottom: 6px;">
|
||||
1. ¿Cuánto transferiste? (Monto en Colones)
|
||||
</label>
|
||||
|
||||
<!-- Botones rápidos de monto -->
|
||||
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px;">
|
||||
<button type="button" class="btn-monto-quick" onclick="setStudentSinpeMonto(1000)" style="padding: 7px 4px; border-radius: 8px; border: 1.5px solid var(--border, #cbd5e1); background: var(--bg-main, #ffffff); font-size: 0.78rem; font-weight: 800; color: var(--text-main, #334155); cursor: pointer;">₡1.000</button>
|
||||
<button type="button" class="btn-monto-quick" onclick="setStudentSinpeMonto(2000)" style="padding: 7px 4px; border-radius: 8px; border: 1.5px solid var(--border, #cbd5e1); background: var(--bg-main, #ffffff); font-size: 0.78rem; font-weight: 800; color: var(--text-main, #334155); cursor: pointer;">₡2.000</button>
|
||||
<button type="button" class="btn-monto-quick" onclick="setStudentSinpeMonto(3000)" style="padding: 7px 4px; border-radius: 8px; border: 1.5px solid var(--border, #cbd5e1); background: var(--bg-main, #ffffff); font-size: 0.78rem; font-weight: 800; color: var(--text-main, #334155); cursor: pointer;">₡3.000</button>
|
||||
<button type="button" class="btn-monto-quick" onclick="setStudentSinpeMonto(5000)" style="padding: 7px 4px; border-radius: 8px; border: 1.5px solid var(--border, #cbd5e1); background: var(--bg-main, #ffffff); font-size: 0.78rem; font-weight: 800; color: var(--text-main, #334155); cursor: pointer;">₡5.000</button>
|
||||
</div>
|
||||
|
||||
<input type="number" id="inputStudentSinpeMonto" min="500" step="500" placeholder="Escribe el monto en colones (ej. 2500)" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border, #cbd5e1); background: var(--bg-main, #ffffff); color: var(--text-main, #0f172a); font-size: 0.92rem; font-weight: 700; box-sizing: border-box;">
|
||||
</div>
|
||||
|
||||
<!-- PASO 4: NÚMERO DE COMPROBANTE -->
|
||||
<div style="margin-bottom: 16px;">
|
||||
<label style="display: block; font-size: 0.78rem; font-weight: 700; color: var(--text-main, #334155); margin-bottom: 6px;">
|
||||
2. Número de Comprobante / Referencia Bancaria
|
||||
</label>
|
||||
<input type="text" id="inputStudentSinpeComprobante" placeholder="Ej. 123456789 (del SMS o app del banco)" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border, #cbd5e1); background: var(--bg-main, #ffffff); color: var(--text-main, #0f172a); font-size: 0.92rem; font-weight: 700; box-sizing: border-box;">
|
||||
<span style="display: block; font-size: 0.7rem; color: #64748b; margin-top: 4px;">Asegúrate de ingresar el número que te brindó tu banco al completar el SINPE.</span>
|
||||
</div>
|
||||
|
||||
<!-- BOTÓN PRINCIPAL DE ENVÍO -->
|
||||
<button type="button" id="btnEnviarRecargaSinpeEstudiante" onclick="enviarRecargaSinpeEstudiante()" class="btn-saas btn-saas-primary" style="width: 100%; height: 44px; font-size: 0.92rem; font-weight: 800; border-radius: 12px; justify-content: center; cursor: pointer;">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>
|
||||
<span id="btnEnviarRecargaSinpeEstudianteTxt">Validar y Recargar Saldo</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODAL: PRESUPUESTO PERSONAL / CONTROL DE GASTOS PARA ESTUDIANTES -->
|
||||
<div class="modal-qr-backdrop modal-sinpe-backdrop" id="modalPresupuestoEstudiante" style="display: none;" onclick="handleModalPresupuestoEstudianteBackdrop(event)">
|
||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; width: 92%; padding: 22px 20px; border-radius: 22px; box-shadow: 0 20px 40px rgba(0,0,0,0.25); text-align: left; background: var(--card-bg, #ffffff); max-height: 90vh; overflow-y: auto; box-sizing: border-box;">
|
||||
|
||||
<!-- Encabezado con Botón Cerrar -->
|
||||
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; border-bottom: 1.5px solid var(--border, #e2e8f0); padding-bottom: 10px;">
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<div style="width: 40px; height: 40px; border-radius: 12px; background: #fef3c7; display: flex; align-items: center; justify-content: center; font-size: 1.25rem;">
|
||||
🎯
|
||||
</div>
|
||||
<div>
|
||||
<h3 style="margin: 0; font-size: 1.1rem; font-weight: 800; color: var(--text-main, #0f172a);">Mi Presupuesto Diario</h3>
|
||||
<span style="font-size: 0.74rem; color: var(--text-muted, #64748b);">Controla tus gastos diarios del recreo</span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" onclick="cerrarModalPresupuestoEstudiante()" style="background: none; border: none; font-size: 1.4rem; color: #94a3b8; cursor: pointer; padding: 4px; line-height: 1;" title="Cerrar">✕</button>
|
||||
</div>
|
||||
|
||||
<!-- TARJETA RESUMEN DE PROGRESO DE HOY -->
|
||||
<div style="background: var(--bg-main, #f8fafc); border: 1.5px solid var(--border, #e2e8f0); border-radius: 16px; padding: 14px 16px; margin-bottom: 14px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
|
||||
<span style="font-size: 0.76rem; font-weight: 700; color: var(--text-muted, #64748b); text-transform: uppercase;">Consumo de hoy:</span>
|
||||
<strong id="modalPresupuestoPorcentaje" style="font-size: 0.88rem; color: #10b981; font-weight: 800;">0%</strong>
|
||||
</div>
|
||||
|
||||
<!-- Barra de progreso visual -->
|
||||
<div style="width: 100%; height: 10px; background: #e2e8f0; border-radius: 10px; overflow: hidden; margin-bottom: 10px;">
|
||||
<div id="modalPresupuestoBar" style="width: 0%; height: 100%; background: #10b981; border-radius: 10px; transition: width 0.3s ease, background 0.3s ease;"></div>
|
||||
</div>
|
||||
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 0.8rem;">
|
||||
<div style="background: var(--card-bg, #ffffff); padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border, #e2e8f0);">
|
||||
<span style="display: block; font-size: 0.7rem; color: var(--text-muted, #64748b);">Gastado hoy</span>
|
||||
<strong id="modalPresupuestoGastado" style="font-size: 0.95rem; color: var(--text-main, #334155);">₡0</strong>
|
||||
</div>
|
||||
<div style="background: var(--card-bg, #ffffff); padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border, #e2e8f0);">
|
||||
<span style="display: block; font-size: 0.7rem; color: var(--text-muted, #64748b);">Disponible hoy</span>
|
||||
<strong id="modalPresupuestoDisponible" style="font-size: 0.95rem; color: #0284c7;">₡0</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SECCIÓN DE CONFIGURACIÓN DE META DIARIA -->
|
||||
<div id="studentPresupuestoEditorSection">
|
||||
<label style="display: block; font-size: 0.78rem; font-weight: 700; color: var(--text-main, #334155); margin-bottom: 6px;">
|
||||
Fija o ajusta tu meta diaria de consumo:
|
||||
</label>
|
||||
|
||||
<!-- Botones rápidos de presupuesto -->
|
||||
<div id="studentPresupuestoQuickButtons" style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px;">
|
||||
<button type="button" class="btn-budget-quick" onclick="setStudentBudgetMonto(1500)" style="padding: 7px 4px; border-radius: 8px; border: 1.5px solid var(--border, #cbd5e1); background: var(--bg-main, #ffffff); font-size: 0.78rem; font-weight: 800; color: var(--text-main, #334155); cursor: pointer;">₡1.500</button>
|
||||
<button type="button" class="btn-budget-quick" onclick="setStudentBudgetMonto(2000)" style="padding: 7px 4px; border-radius: 8px; border: 1.5px solid var(--border, #cbd5e1); background: var(--bg-main, #ffffff); font-size: 0.78rem; font-weight: 800; color: var(--text-main, #334155); cursor: pointer;">₡2.000</button>
|
||||
<button type="button" class="btn-budget-quick" onclick="setStudentBudgetMonto(3000)" style="padding: 7px 4px; border-radius: 8px; border: 1.5px solid var(--border, #cbd5e1); background: var(--bg-main, #ffffff); font-size: 0.78rem; font-weight: 800; color: var(--text-main, #334155); cursor: pointer;">₡3.000</button>
|
||||
<button type="button" class="btn-budget-quick" onclick="setStudentBudgetMonto(5000)" style="padding: 7px 4px; border-radius: 8px; border: 1.5px solid var(--border, #cbd5e1); background: var(--bg-main, #ffffff); font-size: 0.78rem; font-weight: 800; color: var(--text-main, #334155); cursor: pointer;">₡5.000</button>
|
||||
</div>
|
||||
|
||||
<div style="position: relative; margin-bottom: 12px;">
|
||||
<input type="number" id="inputStudentPresupuestoMonto" min="500" step="500" placeholder="Escribe tu límite diario en colones..." style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border, #cbd5e1); background: var(--bg-main, #ffffff); color: var(--text-main, #0f172a); font-size: 0.95rem; font-weight: 700; box-sizing: border-box;">
|
||||
</div>
|
||||
|
||||
<!-- MENSAJE EDUCATIVO -->
|
||||
<div style="background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 12px; padding: 10px 12px; font-size: 0.74rem; color: #065f46; line-height: 1.4; margin-bottom: 14px;">
|
||||
💡 <strong>Tip financiero:</strong> Fijar un presupuesto voluntario te ayuda a no gastar todo tu saldo en un solo recreo y asegurar tus meriendas toda la semana escolar.
|
||||
</div>
|
||||
|
||||
<!-- AVISO SI ES CONTROLADO POR PADRES -->
|
||||
<div id="modalPresupuestoParentLockedNotice" style="display: none; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px; padding: 10px 12px; font-size: 0.75rem; color: #1e40af; margin-bottom: 14px;">
|
||||
ℹ️ <strong>Control Parental:</strong> Este límite fue establecido por tu encargado de familia. Si necesitas modificarlo, coordina con él o ella para que lo actualice desde su portal.
|
||||
</div>
|
||||
|
||||
<!-- BOTÓN GUARDAR -->
|
||||
<button type="button" id="btnGuardarPresupuestoEstudiante" onclick="guardarPresupuestoPersonalEstudiante()" class="btn-saas btn-saas-primary" style="width: 100%; height: 44px; font-size: 0.92rem; font-weight: 800; border-radius: 12px; justify-content: center; cursor: pointer;">
|
||||
Guardar Presupuesto
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODAL: RECHAZAR RECARGA SINPE CON MOTIVO Y TRAZABILIDAD -->
|
||||
<div class="modal-qr-backdrop" id="modalRechazarSinpe" style="display: none; z-index: 99999;">
|
||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: left; padding: 22px; border-radius: 18px;">
|
||||
@@ -5417,6 +5726,6 @@
|
||||
<script src="/js/sounds.js?v=19.4"></script>
|
||||
<script src="/js/jsQR.js" defer></script>
|
||||
<script src="/js/food-icons.js?v=19.4" defer></script>
|
||||
<script src="/js/app.js?v=20.6"></script>
|
||||
<script src="/js/app.js?v=20.9"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+522
-34
@@ -331,17 +331,21 @@ function closeLoginSheet(e) {
|
||||
|
||||
function switchSheetView(view) {
|
||||
const loginContent = document.getElementById('sheetContentLogin');
|
||||
const registerChooseContent = document.getElementById('sheetContentRegisterChoose');
|
||||
const registerContent = document.getElementById('sheetContentRegister');
|
||||
const forgotContent = document.getElementById('sheetContentForgot');
|
||||
const title = document.getElementById('bottomSheetTitle');
|
||||
|
||||
if (loginContent) loginContent.style.display = 'none';
|
||||
if (registerChooseContent) registerChooseContent.style.display = 'none';
|
||||
if (registerContent) registerContent.style.display = 'none';
|
||||
if (forgotContent) forgotContent.style.display = 'none';
|
||||
|
||||
if (view === 'register') {
|
||||
if (registerContent) registerContent.style.display = 'block';
|
||||
if (view === 'register' || view === 'register-choose') {
|
||||
if (registerChooseContent) registerChooseContent.style.display = 'block';
|
||||
if (title) title.textContent = 'Crear Cuenta';
|
||||
} else if (view === 'register-form') {
|
||||
if (registerContent) registerContent.style.display = 'block';
|
||||
} else if (view === 'forgot') {
|
||||
if (forgotContent) forgotContent.style.display = 'block';
|
||||
if (title) title.textContent = 'Restablecer Contraseña';
|
||||
@@ -359,6 +363,30 @@ function switchSheetView(view) {
|
||||
}
|
||||
}
|
||||
|
||||
function selectRegisterType(type) {
|
||||
const bannerPadre = document.getElementById('bannerPadreRegister');
|
||||
const bannerAlumno = document.getElementById('bannerAlumnoRegister');
|
||||
const rolInput = document.getElementById('regTargetRol');
|
||||
const title = document.getElementById('bottomSheetTitle');
|
||||
const btnLabel = document.getElementById('lblBtnRegisterSubmit');
|
||||
|
||||
if (rolInput) rolInput.value = type;
|
||||
|
||||
if (type === 'padre') {
|
||||
if (bannerPadre) bannerPadre.style.display = 'flex';
|
||||
if (bannerAlumno) bannerAlumno.style.display = 'none';
|
||||
if (title) title.textContent = 'Registro de Padres';
|
||||
if (btnLabel) btnLabel.textContent = 'Crear Cuenta de Padre y Entrar';
|
||||
} else {
|
||||
if (bannerPadre) bannerPadre.style.display = 'none';
|
||||
if (bannerAlumno) bannerAlumno.style.display = 'flex';
|
||||
if (title) title.textContent = 'Registro de Alumno';
|
||||
if (btnLabel) btnLabel.textContent = 'Crear Cuenta de Alumno y Entrar';
|
||||
}
|
||||
|
||||
switchSheetView('register-form');
|
||||
}
|
||||
|
||||
function openTerminosModal() {
|
||||
window.open('/terminos', '_blank');
|
||||
}
|
||||
@@ -428,6 +456,8 @@ async function handleRegisterPadreSubmit(event) {
|
||||
const email = emailInput ? emailInput.value.trim() : '';
|
||||
const username = document.getElementById('regUsername').value.trim();
|
||||
const password = document.getElementById('regPassword').value.trim();
|
||||
const rolInput = document.getElementById('regTargetRol');
|
||||
const rol = (rolInput && rolInput.value === 'alumno') ? 'estudiante' : 'padre';
|
||||
const errorMsg = document.getElementById('registerErrorMsg');
|
||||
const btnSubmit = document.getElementById('btnRegisterSubmit');
|
||||
|
||||
@@ -456,7 +486,7 @@ async function handleRegisterPadreSubmit(event) {
|
||||
const res = await fetch('/api/auth/register-padre', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ nombre, fecha_nacimiento, telefono, email, username, password })
|
||||
body: JSON.stringify({ nombre, fecha_nacimiento, telefono, email, username, password, rol })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Error al registrar la cuenta');
|
||||
@@ -465,15 +495,23 @@ async function handleRegisterPadreSubmit(event) {
|
||||
...data.user,
|
||||
hijos: []
|
||||
};
|
||||
if (data.estudiante) {
|
||||
currentStudent = data.estudiante;
|
||||
safeSetItem('recreopay_estudiante', JSON.stringify(data.estudiante));
|
||||
}
|
||||
try {
|
||||
safeSetItem('sibopay_user', JSON.stringify(currentUser));
|
||||
safeSetItem('recreopay_user', JSON.stringify(currentUser));
|
||||
} catch (_) {}
|
||||
|
||||
const welcomeMsg = (data.user.rol === 'padre')
|
||||
? `Hola ${data.user.nombre}, tu cuenta de padre fue creada exitosamente.\n\nYa puedes vincular a tus hijos y recargarles saldo con SINPE Móvil.`
|
||||
: `Hola ${data.user.nombre}, tu cuenta de estudiante fue creada exitosamente.\n\nYa puedes acceder a tu carné digital y tus compras en la soda.`;
|
||||
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
await showAppAlert({
|
||||
title: '¡Bienvenido(a) a SiboPay!',
|
||||
message: `Hola ${data.user.nombre}, tu cuenta fue creada exitosamente.\n\nYa puedes acceder a todos los servicios y monedero digital SiboPay.`,
|
||||
message: welcomeMsg,
|
||||
type: 'success',
|
||||
confirmText: 'Entrar a mi Panel'
|
||||
});
|
||||
@@ -639,6 +677,22 @@ function quickFillLogin(username, password) {
|
||||
handleLoginSubmit();
|
||||
}
|
||||
|
||||
function togglePasswordVisibility(inputId, btn) {
|
||||
const input = document.getElementById(inputId);
|
||||
if (!input) return;
|
||||
const isPassword = input.type === 'password';
|
||||
input.type = isPassword ? 'text' : 'password';
|
||||
if (btn) {
|
||||
btn.title = isPassword ? 'Ocultar contraseña' : 'Ver contraseña';
|
||||
btn.setAttribute('aria-label', btn.title);
|
||||
btn.style.color = isPassword ? '#0284c7' : '';
|
||||
btn.innerHTML = isPassword
|
||||
? '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>'
|
||||
: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>';
|
||||
}
|
||||
}
|
||||
window.togglePasswordVisibility = togglePasswordVisibility;
|
||||
|
||||
async function handleLoginSubmit(event) {
|
||||
if (event) event.preventDefault();
|
||||
const username = document.getElementById('loginUsername').value.trim();
|
||||
@@ -1129,6 +1183,45 @@ function updateStudentUI() {
|
||||
? currentStudent.disponible_hoy
|
||||
: Math.max(0, limiteDiario - gastadoHoy - saldoRetenido);
|
||||
|
||||
const isSelfManaged = !currentStudent.padre_usuario_id;
|
||||
const badgeTitleEl = document.getElementById('dailyLimitBadgeTitle');
|
||||
const editHintEl = document.getElementById('dailyLimitEditHint');
|
||||
const badgeEl = document.getElementById('dailyLimitBadge');
|
||||
const gastadoEl = document.getElementById('dailyGastadoText');
|
||||
const progressContainer = document.getElementById('studentBudgetProgressBarContainer');
|
||||
const progressBar = document.getElementById('studentBudgetProgressBar');
|
||||
const btnPresupuestoLabel = document.getElementById('btnStudentPresupuestoLabel');
|
||||
|
||||
if (badgeTitleEl) {
|
||||
badgeTitleEl.textContent = isSelfManaged ? 'Mi Presupuesto Diario: ' : 'Límite diario fijado: ';
|
||||
}
|
||||
if (btnPresupuestoLabel) {
|
||||
btnPresupuestoLabel.textContent = isSelfManaged ? 'Mi Presupuesto' : 'Ver Presupuesto';
|
||||
}
|
||||
if (editHintEl) {
|
||||
editHintEl.style.display = isSelfManaged ? 'inline-block' : 'none';
|
||||
}
|
||||
if (badgeEl) {
|
||||
badgeEl.title = isSelfManaged ? 'Toca para ajustar tu meta diaria de gasto' : 'Límite diario establecido por tus padres';
|
||||
}
|
||||
if (gastadoEl) {
|
||||
gastadoEl.textContent = `Gastado hoy: ₡${gastadoHoy.toLocaleString('es-CR')}`;
|
||||
}
|
||||
|
||||
// Barra de progreso del presupuesto
|
||||
if (progressContainer && progressBar) {
|
||||
progressContainer.style.display = 'block';
|
||||
const pct = limiteDiario > 0 ? Math.min(100, Math.round((gastadoHoy / limiteDiario) * 100)) : 0;
|
||||
progressBar.style.width = `${pct}%`;
|
||||
if (pct >= 100) {
|
||||
progressBar.style.background = '#ef4444';
|
||||
} else if (pct >= 70) {
|
||||
progressBar.style.background = '#f59e0b';
|
||||
} else {
|
||||
progressBar.style.background = '#10b981';
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('dailyLimitText').textContent = `₡${limiteDiario.toLocaleString('es-CR')}`;
|
||||
document.getElementById('dailyAvailableText').textContent = `Disponible hoy: ₡${disponibleHoy.toLocaleString('es-CR')}`;
|
||||
|
||||
@@ -1144,7 +1237,9 @@ function updateStudentUI() {
|
||||
if (msgEl) {
|
||||
msgEl.textContent = tienePreordenes
|
||||
? 'Has alcanzado tu límite diario de consumo. Tu código QR solo podrá ser escaneado en la soda para retirar tu Pre-Orden.'
|
||||
: `Has alcanzado tu límite diario de ₡${limiteDiario.toLocaleString('es-CR')} asignado por tus padres. La generación del código QR para compras está bloqueada hasta mañana.`;
|
||||
: (isSelfManaged
|
||||
? `Has consumido tu presupuesto diario de ₡${limiteDiario.toLocaleString('es-CR')}. Si necesitas realizar más compras hoy, puedes ajustar tu presupuesto personal tocando "Mi Presupuesto".`
|
||||
: `Has alcanzado tu límite diario de ₡${limiteDiario.toLocaleString('es-CR')} asignado por tus padres. La generación del código QR para compras está bloqueada hasta mañana.`);
|
||||
}
|
||||
} else {
|
||||
bannerLimitBlocked.style.display = 'none';
|
||||
@@ -1999,6 +2094,25 @@ async function submitPreOrder() {
|
||||
cantidad: item.cantidad
|
||||
}));
|
||||
|
||||
// Verificación preventiva de presupuesto personal para alumnos autoadministrados
|
||||
const totalCart = cart.reduce((acc, it) => acc + (it.product.precio_colones * it.cantidad), 0);
|
||||
const limiteDiario = targetStudent.limite_diario_colones || 0;
|
||||
const gastadoHoy = targetStudent.gastado_hoy || 0;
|
||||
const retenido = targetStudent.saldo_retenido || 0;
|
||||
const disponibleHoy = Math.max(0, limiteDiario - gastadoHoy - retenido);
|
||||
|
||||
if (limiteDiario > 0 && totalCart > disponibleHoy) {
|
||||
const isSelfManaged = !targetStudent.padre_usuario_id;
|
||||
if (isSelfManaged && (!currentUser || currentUser.rol === 'estudiante')) {
|
||||
const respAjustar = confirm(`⚠️ Aviso de Presupuesto Personal:\n\nEste pedido suma ₡${totalCart.toLocaleString('es-CR')} y tu presupuesto disponible para hoy es de ₡${disponibleHoy.toLocaleString('es-CR')}.\n\nComo estudiante independiente, ¿deseas ajustar tu presupuesto diario personal antes de realizar este pedido?`);
|
||||
if (respAjustar) {
|
||||
closeCartModal();
|
||||
abrirModalPresupuestoPersonal();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const btn = document.getElementById('btnConfirmarOrden');
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Procesando en la soda...';
|
||||
@@ -2585,10 +2699,11 @@ function toggleParentPanel(show, e) {
|
||||
}
|
||||
|
||||
function openDailyLimitEditor() {
|
||||
// SEGURIDAD: Los estudiantes no pueden modificar su límite diario
|
||||
if (!currentUser || currentUser.rol === 'estudiante') {
|
||||
if (currentUser && currentUser.rol === 'estudiante') {
|
||||
abrirModalPresupuestoPersonal();
|
||||
return;
|
||||
}
|
||||
if (!currentUser) return;
|
||||
toggleParentPanel(true);
|
||||
setTimeout(() => {
|
||||
const input = document.getElementById('inputCustomDailyLimit');
|
||||
@@ -5228,19 +5343,32 @@ async function executeParentSinpeRecharge() {
|
||||
`;
|
||||
}
|
||||
|
||||
currentSinpePollingData = {
|
||||
await ejecutarSondeoValidacionSinpe({
|
||||
studentId: currentParentChild.id,
|
||||
studentName: currentParentChild.nombre_completo,
|
||||
monto,
|
||||
codigo,
|
||||
comprobante
|
||||
comprobante,
|
||||
isStudentMode: false,
|
||||
btn
|
||||
});
|
||||
}
|
||||
|
||||
async function ejecutarSondeoValidacionSinpe({ studentId, studentName, monto, codigo, comprobante, isStudentMode, btn }) {
|
||||
currentSinpePollingData = {
|
||||
studentId,
|
||||
studentName,
|
||||
monto,
|
||||
codigo,
|
||||
comprobante,
|
||||
isStudentMode: Boolean(isStudentMode)
|
||||
};
|
||||
|
||||
// Abrir modal con estado LOADING (sin barra ni contador de segundos)
|
||||
showSinpeModal('loading', {
|
||||
studentName: currentParentChild.nombre_completo,
|
||||
monto: monto,
|
||||
codigo: codigo
|
||||
studentName,
|
||||
monto,
|
||||
codigo
|
||||
});
|
||||
|
||||
const pollIntervalMs = 3000; // Consulta cada 3 segundos
|
||||
@@ -5282,8 +5410,8 @@ async function executeParentSinpeRecharge() {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
estudiante_id: currentParentChild.id,
|
||||
padre_usuario_id: currentUser ? currentUser.id : null,
|
||||
estudiante_id: studentId,
|
||||
padre_usuario_id: currentUser && currentUser.rol === 'padre' ? currentUser.id : null,
|
||||
monto,
|
||||
codigo,
|
||||
comprobante: comprobante || null
|
||||
@@ -5321,28 +5449,47 @@ async function executeParentSinpeRecharge() {
|
||||
if (verifiedData && verifiedData.verificado) {
|
||||
if (window.sounds) window.sounds.playCoin();
|
||||
|
||||
const baseSaldo = (currentParentChild && currentParentChild.id === studentId)
|
||||
? (currentParentChild.saldo_colones || 0)
|
||||
: ((currentStudent && currentStudent.id === studentId) ? (currentStudent.saldo_colones || 0) : 0);
|
||||
|
||||
const nuevoSaldo = typeof verifiedData.saldo_nuevo === 'number'
|
||||
? verifiedData.saldo_nuevo
|
||||
: (currentParentChild.saldo_colones + monto);
|
||||
: (baseSaldo + monto);
|
||||
|
||||
if (currentParentChild && currentParentChild.id === studentId) {
|
||||
currentParentChild.saldo_colones = nuevoSaldo;
|
||||
renderActiveChildDetails(currentParentChild);
|
||||
}
|
||||
if (currentStudent && currentStudent.id === studentId) {
|
||||
currentStudent.saldo_colones = nuevoSaldo;
|
||||
updateStudentUI();
|
||||
}
|
||||
|
||||
if (inputMonto) inputMonto.value = '';
|
||||
if (inputComp) inputComp.value = '';
|
||||
const inputParentMonto = document.getElementById('inputParentSinpeMonto');
|
||||
const inputParentComp = document.getElementById('inputParentSinpeComprobante');
|
||||
if (inputParentMonto) inputParentMonto.value = '';
|
||||
if (inputParentComp) inputParentComp.value = '';
|
||||
|
||||
const inputStudentMonto = document.getElementById('inputStudentSinpeMonto');
|
||||
const inputStudentComp = document.getElementById('inputStudentSinpeComprobante');
|
||||
if (inputStudentMonto) inputStudentMonto.value = '';
|
||||
if (inputStudentComp) inputStudentComp.value = '';
|
||||
|
||||
showSinpeModal('success', {
|
||||
studentName: currentParentChild.nombre_completo,
|
||||
monto: monto,
|
||||
studentName,
|
||||
monto,
|
||||
banco: verifiedData.banco || 'Bancario',
|
||||
comprobante: verifiedData.comprobante || verifiedData.codigo || codigo,
|
||||
codigo: codigo,
|
||||
nuevoSaldo: nuevoSaldo
|
||||
codigo,
|
||||
nuevoSaldo
|
||||
});
|
||||
|
||||
if (currentParentChild && currentParentChild.id === studentId) {
|
||||
await loadParentSinpeRequests(currentParentChild.id);
|
||||
clearSinpeSession();
|
||||
obtenerNuevoCodigoSinpe();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5364,9 +5511,9 @@ async function executeParentSinpeRecharge() {
|
||||
// ============================================
|
||||
if (window.sounds) window.sounds.playTap();
|
||||
showSinpeModal('timeout', {
|
||||
studentName: currentParentChild.nombre_completo,
|
||||
monto: monto,
|
||||
codigo: codigo
|
||||
studentName,
|
||||
monto,
|
||||
codigo
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
@@ -5380,12 +5527,17 @@ async function executeParentSinpeRecharge() {
|
||||
} finally {
|
||||
if (btn) {
|
||||
btn.disabled = false;
|
||||
if (isStudentMode) {
|
||||
const btnTxt = document.getElementById('btnEnviarRecargaSinpeEstudianteTxt');
|
||||
if (btnTxt) btnTxt.textContent = 'Validar y Recargar Saldo';
|
||||
} else {
|
||||
btn.innerHTML = `
|
||||
<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>
|
||||
<span id="btnParentValidarSinpeText">Validar SINPE</span>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function retrySinpeWaitMore() {
|
||||
@@ -5467,22 +5619,36 @@ async function retrySinpeWaitMore() {
|
||||
|
||||
if (verifiedData && verifiedData.verificado) {
|
||||
if (window.sounds) window.sounds.playCoin();
|
||||
|
||||
const baseSaldo = (currentParentChild && currentParentChild.id === studentId)
|
||||
? (currentParentChild.saldo_colones || 0)
|
||||
: ((currentStudent && currentStudent.id === studentId) ? (currentStudent.saldo_colones || 0) : 0);
|
||||
|
||||
const nuevoSaldo = typeof verifiedData.saldo_nuevo === 'number'
|
||||
? verifiedData.saldo_nuevo
|
||||
: ((currentParentChild ? currentParentChild.saldo_colones : 0) + monto);
|
||||
: (baseSaldo + monto);
|
||||
|
||||
if (currentParentChild) {
|
||||
if (currentParentChild && currentParentChild.id === studentId) {
|
||||
currentParentChild.saldo_colones = nuevoSaldo;
|
||||
renderActiveChildDetails(currentParentChild);
|
||||
}
|
||||
if (currentStudent && currentStudent.id === studentId) {
|
||||
currentStudent.saldo_colones = nuevoSaldo;
|
||||
updateStudentUI();
|
||||
}
|
||||
|
||||
const inputMonto = document.getElementById('inputParentSinpeMonto');
|
||||
const inputComp = document.getElementById('inputParentSinpeComprobante');
|
||||
if (inputMonto) inputMonto.value = '';
|
||||
if (inputComp) inputComp.value = '';
|
||||
|
||||
const inputStudentMonto = document.getElementById('inputStudentSinpeMonto');
|
||||
const inputStudentComp = document.getElementById('inputStudentSinpeComprobante');
|
||||
if (inputStudentMonto) inputStudentMonto.value = '';
|
||||
if (inputStudentComp) inputStudentComp.value = '';
|
||||
|
||||
showSinpeModal('success', {
|
||||
studentName: studentName || (currentParentChild ? currentParentChild.nombre_completo : ''),
|
||||
studentName: studentName || (currentParentChild ? currentParentChild.nombre_completo : (currentStudent ? currentStudent.nombre_completo : '')),
|
||||
monto,
|
||||
banco: verifiedData.banco || 'Bancario',
|
||||
comprobante: verifiedData.comprobante || verifiedData.codigo || codigo,
|
||||
@@ -5490,11 +5656,11 @@ async function retrySinpeWaitMore() {
|
||||
nuevoSaldo
|
||||
});
|
||||
|
||||
if (currentParentChild) {
|
||||
if (currentParentChild && currentParentChild.id === studentId) {
|
||||
await loadParentSinpeRequests(currentParentChild.id);
|
||||
}
|
||||
clearSinpeSession();
|
||||
obtenerNuevoCodigoSinpe();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5536,11 +5702,13 @@ async function confirmSinpeSendManualReview() {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
estudiante_id: studentId,
|
||||
padre_usuario_id: currentUser ? currentUser.id : null,
|
||||
padre_usuario_id: currentUser && currentUser.rol === 'padre' ? currentUser.id : null,
|
||||
monto,
|
||||
comprobante: comprobante || `SINPE-${codigo}`,
|
||||
codigo_detalle: codigo,
|
||||
notas: `Portal de Padres - Código: ${codigo}`
|
||||
notas: (currentUser && currentUser.rol === 'padre')
|
||||
? `Portal de Padres - Código: ${codigo}`
|
||||
: `Autorecarga estudiante: ${studentName || ''}`
|
||||
})
|
||||
});
|
||||
} catch (solErr) {
|
||||
@@ -5552,19 +5720,339 @@ async function confirmSinpeSendManualReview() {
|
||||
if (inputMonto) inputMonto.value = '';
|
||||
if (inputComp) inputComp.value = '';
|
||||
|
||||
const inputStudentMonto = document.getElementById('inputStudentSinpeMonto');
|
||||
const inputStudentComp = document.getElementById('inputStudentSinpeComprobante');
|
||||
if (inputStudentMonto) inputStudentMonto.value = '';
|
||||
if (inputStudentComp) inputStudentComp.value = '';
|
||||
|
||||
showSinpeModal('pending', {
|
||||
studentName: studentName || (currentParentChild ? currentParentChild.nombre_completo : ''),
|
||||
studentName: studentName || (currentParentChild ? currentParentChild.nombre_completo : (currentStudent ? currentStudent.nombre_completo : '')),
|
||||
monto,
|
||||
codigo
|
||||
});
|
||||
|
||||
if (currentParentChild) {
|
||||
if (currentParentChild && currentParentChild.id === studentId) {
|
||||
await loadParentSinpeRequests(currentParentChild.id);
|
||||
}
|
||||
clearSinpeSession();
|
||||
obtenerNuevoCodigoSinpe();
|
||||
}
|
||||
if (currentStudent && currentStudent.id === studentId) {
|
||||
updateStudentUI();
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// AUTORECARGA SINPE PARA ESTUDIANTES AUTOADMINISTRADOS
|
||||
// ==========================================
|
||||
let currentStudentSinpeCode = null;
|
||||
|
||||
async function abrirModalRecargaSinpeEstudiante() {
|
||||
if (!currentStudent) return;
|
||||
const modal = document.getElementById('modalRecargaSinpeEstudiante');
|
||||
if (!modal) return;
|
||||
|
||||
const numEl = document.getElementById('studentSinpeNumeroDisplay');
|
||||
const titEl = document.getElementById('studentSinpeTitularDisplay');
|
||||
const escEl = document.getElementById('studentSinpeEscuelaDisplay');
|
||||
const codEl = document.getElementById('studentSinpeCodigoDisplay');
|
||||
const bannerSusp = document.getElementById('studentSinpeSuspendedBanner');
|
||||
const msgSusp = document.getElementById('studentSinpeSuspendedMsg');
|
||||
const formBox = document.getElementById('studentSinpeFormContainer');
|
||||
|
||||
if (codEl) codEl.textContent = 'GENERANDO...';
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/sinpe/generar-codigo', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ estudiante_id: currentStudent.id })
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
if (data.suspended) {
|
||||
if (bannerSusp) bannerSusp.style.display = 'block';
|
||||
if (msgSusp && data.mensaje_suspension) msgSusp.textContent = data.mensaje_suspension;
|
||||
if (formBox) {
|
||||
formBox.style.opacity = '0.4';
|
||||
formBox.style.pointerEvents = 'none';
|
||||
}
|
||||
} else {
|
||||
if (bannerSusp) bannerSusp.style.display = 'none';
|
||||
if (formBox) {
|
||||
formBox.style.opacity = '1';
|
||||
formBox.style.pointerEvents = 'auto';
|
||||
}
|
||||
}
|
||||
|
||||
if (numEl && data.telefono_sinpe) numEl.textContent = data.telefono_sinpe;
|
||||
if (titEl && data.titular_sinpe) titEl.textContent = data.titular_sinpe;
|
||||
if (escEl && data.escuela_nombre) escEl.textContent = data.escuela_nombre;
|
||||
|
||||
currentStudentSinpeCode = data.codigo || `SIBO-${currentStudent.codigo_estudiante || ''}`;
|
||||
if (codEl) codEl.textContent = currentStudentSinpeCode;
|
||||
|
||||
} catch (e) {
|
||||
console.warn('Error cargando datos SINPE para estudiante:', e);
|
||||
currentStudentSinpeCode = `SIBO-${currentStudent.codigo_estudiante || ''}`;
|
||||
if (codEl) codEl.textContent = currentStudentSinpeCode;
|
||||
}
|
||||
|
||||
const inpMonto = document.getElementById('inputStudentSinpeMonto');
|
||||
const inpComp = document.getElementById('inputStudentSinpeComprobante');
|
||||
if (inpMonto) inpMonto.value = '';
|
||||
if (inpComp) inpComp.value = '';
|
||||
|
||||
modal.style.display = 'flex';
|
||||
if (window.sounds) window.sounds.playTap();
|
||||
}
|
||||
|
||||
function cerrarModalRecargaSinpeEstudiante() {
|
||||
const modal = document.getElementById('modalRecargaSinpeEstudiante');
|
||||
if (modal) modal.style.display = 'none';
|
||||
}
|
||||
|
||||
function handleModalRecargaSinpeEstudianteBackdrop(event) {
|
||||
if (event && event.target && event.target.id === 'modalRecargaSinpeEstudiante') {
|
||||
cerrarModalRecargaSinpeEstudiante();
|
||||
}
|
||||
}
|
||||
|
||||
function copiarTelefonoSinpeEstudiante() {
|
||||
const tel = (document.getElementById('studentSinpeNumeroDisplay')?.textContent || '').trim();
|
||||
if (!tel) return;
|
||||
|
||||
const lbl = document.getElementById('lblCopiarTelSinpeEstudiante');
|
||||
const onDone = () => {
|
||||
if (window.sounds) window.sounds.playTap();
|
||||
if (lbl) lbl.textContent = '¡Copiado! ✓';
|
||||
setTimeout(() => { if (lbl) lbl.textContent = '📋 Copiar'; }, 2000);
|
||||
};
|
||||
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(tel.replace(/\D/g, '')).then(onDone).catch(() => fallbackCopyText(tel.replace(/\D/g, ''), onDone));
|
||||
} else {
|
||||
fallbackCopyText(tel.replace(/\D/g, ''), onDone);
|
||||
}
|
||||
}
|
||||
|
||||
function copiarCodigoSinpeEstudiante() {
|
||||
const cod = currentStudentSinpeCode || (document.getElementById('studentSinpeCodigoDisplay')?.textContent || '').trim();
|
||||
if (!cod || cod.includes('GENERANDO')) return;
|
||||
|
||||
const lbl = document.getElementById('lblCopiarCodSinpeEstudiante');
|
||||
const onDone = () => {
|
||||
if (window.sounds) window.sounds.playTap();
|
||||
if (lbl) lbl.textContent = '¡Copiado! ✓';
|
||||
setTimeout(() => { if (lbl) lbl.textContent = 'Copiar'; }, 2000);
|
||||
};
|
||||
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(cod).then(onDone).catch(() => fallbackCopyText(cod, onDone));
|
||||
} else {
|
||||
fallbackCopyText(cod, onDone);
|
||||
}
|
||||
}
|
||||
|
||||
function setStudentSinpeMonto(monto) {
|
||||
const inp = document.getElementById('inputStudentSinpeMonto');
|
||||
if (inp) {
|
||||
inp.value = monto;
|
||||
inp.focus();
|
||||
}
|
||||
if (window.sounds) window.sounds.playCoin();
|
||||
}
|
||||
|
||||
async function enviarRecargaSinpeEstudiante() {
|
||||
if (!currentStudent) return;
|
||||
const bannerSusp = document.getElementById('studentSinpeSuspendedBanner');
|
||||
if (bannerSusp && bannerSusp.style.display !== 'none') {
|
||||
alert('Las recargas por SINPE Móvil se encuentran temporalmente en pausa técnica en esta sede.');
|
||||
return;
|
||||
}
|
||||
|
||||
const inpMonto = document.getElementById('inputStudentSinpeMonto');
|
||||
const inpComp = document.getElementById('inputStudentSinpeComprobante');
|
||||
const monto = parseInt(inpMonto ? inpMonto.value : 0, 10);
|
||||
const comprobante = inpComp ? inpComp.value.trim() : '';
|
||||
const codigo = currentStudentSinpeCode || `SIBO-${currentStudent.codigo_estudiante || ''}`;
|
||||
|
||||
if (isNaN(monto) || monto <= 0) {
|
||||
alert('Por favor ingresa un monto válido mayor a ₡0 para procesar tu recarga SINPE.');
|
||||
if (inpMonto) inpMonto.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!comprobante) {
|
||||
alert('Por favor escribe el número de comprobante o referencia que te brindó el banco.');
|
||||
if (inpComp) inpComp.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
const btn = document.getElementById('btnEnviarRecargaSinpeEstudiante');
|
||||
if (btn) {
|
||||
btn.disabled = true;
|
||||
const btnTxt = document.getElementById('btnEnviarRecargaSinpeEstudianteTxt');
|
||||
if (btnTxt) btnTxt.textContent = 'Validando con el banco...';
|
||||
}
|
||||
|
||||
cerrarModalRecargaSinpeEstudiante();
|
||||
|
||||
await ejecutarSondeoValidacionSinpe({
|
||||
studentId: currentStudent.id,
|
||||
studentName: currentStudent.nombre_completo,
|
||||
monto,
|
||||
codigo,
|
||||
comprobante,
|
||||
isStudentMode: true,
|
||||
btn
|
||||
});
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// PRESUPUESTO PERSONAL / CONTROL DE GASTOS PARA ESTUDIANTES
|
||||
// ==========================================
|
||||
function abrirModalPresupuestoPersonal() {
|
||||
if (!currentStudent) return;
|
||||
const modal = document.getElementById('modalPresupuestoEstudiante');
|
||||
if (!modal) return;
|
||||
|
||||
const limiteDiario = currentStudent.limite_diario_colones || 0;
|
||||
const gastadoHoy = currentStudent.gastado_hoy || 0;
|
||||
const saldoRetenido = currentStudent.saldo_retenido || 0;
|
||||
const disponibleHoy = (typeof currentStudent.disponible_hoy === 'number')
|
||||
? currentStudent.disponible_hoy
|
||||
: Math.max(0, limiteDiario - gastadoHoy - saldoRetenido);
|
||||
|
||||
const pct = limiteDiario > 0 ? Math.min(100, Math.round((gastadoHoy / limiteDiario) * 100)) : 0;
|
||||
|
||||
const gastadoEl = document.getElementById('modalPresupuestoGastado');
|
||||
const dispEl = document.getElementById('modalPresupuestoDisponible');
|
||||
const pctEl = document.getElementById('modalPresupuestoPorcentaje');
|
||||
const barEl = document.getElementById('modalPresupuestoBar');
|
||||
const inputEl = document.getElementById('inputStudentPresupuestoMonto');
|
||||
const lockedNotice = document.getElementById('modalPresupuestoParentLockedNotice');
|
||||
const quickButtons = document.getElementById('studentPresupuestoQuickButtons');
|
||||
const btnGuardar = document.getElementById('btnGuardarPresupuestoEstudiante');
|
||||
|
||||
if (gastadoEl) gastadoEl.textContent = `₡${gastadoHoy.toLocaleString('es-CR')}`;
|
||||
if (dispEl) dispEl.textContent = `₡${disponibleHoy.toLocaleString('es-CR')}`;
|
||||
if (pctEl) pctEl.textContent = `${pct}%`;
|
||||
if (barEl) {
|
||||
barEl.style.width = `${pct}%`;
|
||||
if (pct >= 100) {
|
||||
barEl.style.background = '#ef4444';
|
||||
if (pctEl) pctEl.style.color = '#ef4444';
|
||||
} else if (pct >= 70) {
|
||||
barEl.style.background = '#f59e0b';
|
||||
if (pctEl) pctEl.style.color = '#f59e0b';
|
||||
} else {
|
||||
barEl.style.background = '#10b981';
|
||||
if (pctEl) pctEl.style.color = '#10b981';
|
||||
}
|
||||
}
|
||||
|
||||
if (inputEl) inputEl.value = limiteDiario;
|
||||
|
||||
const isSelfManaged = !currentStudent.padre_usuario_id;
|
||||
if (isSelfManaged) {
|
||||
if (lockedNotice) lockedNotice.style.display = 'none';
|
||||
if (quickButtons) quickButtons.style.display = 'grid';
|
||||
if (btnGuardar) btnGuardar.style.display = 'flex';
|
||||
if (inputEl) inputEl.disabled = false;
|
||||
} else {
|
||||
if (lockedNotice) lockedNotice.style.display = 'block';
|
||||
if (quickButtons) quickButtons.style.display = 'none';
|
||||
if (btnGuardar) btnGuardar.style.display = 'none';
|
||||
if (inputEl) inputEl.disabled = true;
|
||||
}
|
||||
|
||||
modal.style.display = 'flex';
|
||||
if (window.sounds) window.sounds.playTap();
|
||||
}
|
||||
|
||||
function cerrarModalPresupuestoEstudiante() {
|
||||
const modal = document.getElementById('modalPresupuestoEstudiante');
|
||||
if (modal) modal.style.display = 'none';
|
||||
}
|
||||
|
||||
function handleModalPresupuestoEstudianteBackdrop(event) {
|
||||
if (event && event.target && event.target.id === 'modalPresupuestoEstudiante') {
|
||||
cerrarModalPresupuestoEstudiante();
|
||||
}
|
||||
}
|
||||
|
||||
function setStudentBudgetMonto(monto) {
|
||||
const inputEl = document.getElementById('inputStudentPresupuestoMonto');
|
||||
if (inputEl) {
|
||||
inputEl.value = monto;
|
||||
inputEl.focus();
|
||||
}
|
||||
if (window.sounds) window.sounds.playCoin();
|
||||
}
|
||||
|
||||
async function guardarPresupuestoPersonalEstudiante() {
|
||||
if (!currentStudent) return;
|
||||
const inputEl = document.getElementById('inputStudentPresupuestoMonto');
|
||||
const val = parseInt(inputEl ? inputEl.value : 0, 10);
|
||||
|
||||
if (isNaN(val) || val < 500) {
|
||||
alert('Por favor ingresa un presupuesto válido (mínimo ₡500).');
|
||||
if (inputEl) inputEl.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
const btn = document.getElementById('btnGuardarPresupuestoEstudiante');
|
||||
if (btn) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Guardando meta...';
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch(`/api/estudiantes/${currentStudent.id}/limite`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ limite_diario_colones: val })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Error al actualizar presupuesto');
|
||||
|
||||
currentStudent.limite_diario_colones = val;
|
||||
currentStudent.disponible_hoy = Math.max(0, val - (currentStudent.gastado_hoy || 0) - (currentStudent.saldo_retenido || 0));
|
||||
|
||||
updateStudentUI();
|
||||
cerrarModalPresupuestoEstudiante();
|
||||
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
alert(`🎯 ¡Presupuesto Actualizado!\n\nTu meta diaria de gasto ahora es de ₡${val.toLocaleString('es-CR')}.\n\nPodrás monitorear tu barra de consumo en tu monedero escolar.`);
|
||||
} catch (err) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
alert(`No se pudo guardar el presupuesto: ${err.message}`);
|
||||
} finally {
|
||||
if (btn) {
|
||||
btn.disabled = false;
|
||||
btn.textContent = 'Guardar Presupuesto';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleDailyLimitBadgeClick() {
|
||||
abrirModalPresupuestoPersonal();
|
||||
}
|
||||
|
||||
window.abrirModalRecargaSinpeEstudiante = abrirModalRecargaSinpeEstudiante;
|
||||
window.cerrarModalRecargaSinpeEstudiante = cerrarModalRecargaSinpeEstudiante;
|
||||
window.handleModalRecargaSinpeEstudianteBackdrop = handleModalRecargaSinpeEstudianteBackdrop;
|
||||
window.copiarTelefonoSinpeEstudiante = copiarTelefonoSinpeEstudiante;
|
||||
window.copiarCodigoSinpeEstudiante = copiarCodigoSinpeEstudiante;
|
||||
window.setStudentSinpeMonto = setStudentSinpeMonto;
|
||||
window.enviarRecargaSinpeEstudiante = enviarRecargaSinpeEstudiante;
|
||||
window.abrirModalPresupuestoPersonal = abrirModalPresupuestoPersonal;
|
||||
window.cerrarModalPresupuestoEstudiante = cerrarModalPresupuestoEstudiante;
|
||||
window.handleModalPresupuestoEstudianteBackdrop = handleModalPresupuestoEstudianteBackdrop;
|
||||
window.setStudentBudgetMonto = setStudentBudgetMonto;
|
||||
window.guardarPresupuestoPersonalEstudiante = guardarPresupuestoPersonalEstudiante;
|
||||
window.handleDailyLimitBadgeClick = handleDailyLimitBadgeClick;
|
||||
|
||||
async function loadParentSinpeRequests(studentId) {
|
||||
const box = document.getElementById('parentSinpePendingBox');
|
||||
const list = document.getElementById('parentSinpePendingList');
|
||||
|
||||
+4
-2
@@ -345,7 +345,7 @@
|
||||
En conformidad con la Ley N° 8968, los titulares pueden ejercer en todo momento sus derechos de <strong>Acceso, Rectificación, Cancelación y Oposición (ARCO)</strong>.
|
||||
</p>
|
||||
<p>
|
||||
Para actualizar información errónea o solicitar la eliminación total de la cuenta y los registros históricos de un alumno al concluir el ciclo escolar, el tutor legal puede remitir la solicitud a <strong>[email protected]</strong>. Las solicitudes de eliminación se procesan en un plazo no mayor a cinco (5) días hábiles.
|
||||
Para actualizar información errónea o solicitar la eliminación total de la cuenta y los registros históricos de un alumno al concluir el ciclo escolar, el tutor legal puede remitir la solicitud a <strong>[email protected]</strong> o utilizar nuestro canal directo automatizado de <strong><a href="/eliminar-cuenta" class="text-sky-600 font-bold underline hover:text-sky-800">Solicitud Web de Eliminación de Cuenta y Datos</a></strong> (o desde los Ajustes de la App Móvil). Las solicitudes de eliminación se procesan de forma inmediata o en un plazo no mayor a cinco (5) días hábiles.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
@@ -368,12 +368,14 @@
|
||||
<span class="txtRetornoApp">Regresar a la Aplicación SiboPay</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="flex items-center justify-center gap-3 font-medium text-slate-600">
|
||||
<div class="flex items-center justify-center gap-3 font-medium text-slate-600 flex-wrap">
|
||||
<span>SiboPay Costa Rica</span>
|
||||
<span>•</span>
|
||||
<span>Cumplimiento Ley N° 8968</span>
|
||||
<span>•</span>
|
||||
<span>Google Play Data Safety</span>
|
||||
<span>•</span>
|
||||
<a href="/eliminar-cuenta" class="text-rose-600 font-bold hover:underline">Eliminación de Cuenta</a>
|
||||
</div>
|
||||
<p>© 2026 SiboPay. Sistema inteligente de billetera online. Todos los derechos reservados.</p>
|
||||
<p class="text-slate-400">Canal de atención y soporte: <a href="mailto:[email protected]" class="text-slate-600 font-semibold hover:underline">[email protected]</a></p>
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
// SiboPay PWA Service Worker v20.6 - Ultra Fast Startup & Stale-While-Revalidate
|
||||
const CACHE_NAME = 'sibopay-v20.6';
|
||||
// SiboPay PWA Service Worker v20.9 - Ultra Fast Startup & Stale-While-Revalidate
|
||||
const CACHE_NAME = 'sibopay-v20.9';
|
||||
const STATIC_ASSETS = [
|
||||
'/',
|
||||
'/index.html',
|
||||
@@ -8,10 +8,10 @@ const STATIC_ASSETS = [
|
||||
'/pistola.html',
|
||||
'/carnet.html',
|
||||
'/manifest.json',
|
||||
'/css/styles.css?v=19.9',
|
||||
'/css/styles.css?v=20.0',
|
||||
'/css/desktop.css?v=2.2',
|
||||
'/js/dialogs.js?v=19.4',
|
||||
'/js/app.js?v=20.6',
|
||||
'/js/app.js?v=20.9',
|
||||
'/js/pos.js?v=20.5',
|
||||
'/js/sounds.js?v=19.4',
|
||||
'/js/food-icons.js?v=19.4',
|
||||
|
||||
@@ -639,6 +639,23 @@ function seedUsuarios() {
|
||||
db.prepare("INSERT INTO usuarios (username, password_hash, rol, nombre, telefono, email, activo) VALUES ('cajero', 'cajero123', 'cajero', 'Cajero de la Soda', '+506 8888-0000', '[email protected]', 1)").run();
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// Asegurar cuentas para revisión de Google Play Console
|
||||
try {
|
||||
const gTester = db.prepare("SELECT id FROM usuarios WHERE username = 'google_tester'").get();
|
||||
if (!gTester) {
|
||||
const uRes = db.prepare("INSERT INTO usuarios (username, password_hash, rol, nombre, telefono, email, activo, fecha_nacimiento, escuela_id) VALUES ('google_tester', 'SiboPay2026!', 'estudiante', 'Google Play Reviewer', '+506 8888-0001', '[email protected]', 1, '2008-05-15', 1)").run();
|
||||
db.prepare("INSERT INTO estudiantes (usuario_id, codigo_estudiante, nombre_completo, edad, grado, seccion, qr_token, pin_seguridad, foto_url, saldo_colones, limite_diario_colones, alergias, padre_nombre, padre_telefono, padre_usuario_id, permitir_transferencias, tarjeta_bloqueada, activo, escuela_id) VALUES (?, 'EST-GOOGLE-001', 'Google Play Reviewer', 16, 'Secundaria', '10-A', 'QR-GOOGLE-REVIEWER-2026', '1234', NULL, 25000, 50000, 'Ninguna conocida', '', '', NULL, 1, 0, 1, 1)").run(uRes.lastInsertRowid);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
const gPadre = db.prepare("SELECT id FROM usuarios WHERE username = 'google_padre'").get();
|
||||
if (!gPadre) {
|
||||
const pRes = db.prepare("INSERT INTO usuarios (username, password_hash, rol, nombre, telefono, email, activo, fecha_nacimiento, escuela_id) VALUES ('google_padre', 'SiboPay2026!', 'padre', 'Google Reviewer (Padre)', '+506 8888-0002', '[email protected]', 1, '1985-04-20', 1)").run();
|
||||
db.prepare("INSERT INTO padres_estudiantes (padre_usuario_id, estudiante_id) VALUES (?, 1)").run(pRes.lastInsertRowid);
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+24
-5
@@ -534,10 +534,10 @@ app.post('/api/auth/login', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Registro de nuevos usuarios desde la pantalla de bienvenida
|
||||
// Registro de nuevos usuarios (Padres o Alumnos) desde la pantalla de bienvenida
|
||||
app.post('/api/auth/register-padre', (req, res) => {
|
||||
try {
|
||||
const { nombre, telefono, email, username, password, fecha_nacimiento } = req.body;
|
||||
const { nombre, telefono, email, username, password, fecha_nacimiento, rol } = req.body;
|
||||
if (!nombre || !username || !password || !email) {
|
||||
return res.status(400).json({ error: 'Nombre completo, correo electrónico, usuario y contraseña son requeridos' });
|
||||
}
|
||||
@@ -548,6 +548,7 @@ app.post('/api/auth/register-padre', (req, res) => {
|
||||
const cleanTel = telefono ? String(telefono).trim() : '';
|
||||
const cleanEmail = String(email).trim().toLowerCase();
|
||||
const cleanFechaNac = fecha_nacimiento ? String(fecha_nacimiento).trim() : '';
|
||||
const targetRol = (rol === 'estudiante' || rol === 'alumno') ? 'estudiante' : 'padre';
|
||||
|
||||
if (cleanUser.length < 3) {
|
||||
return res.status(400).json({ error: 'El nombre de usuario debe tener al menos 3 caracteres' });
|
||||
@@ -573,23 +574,41 @@ app.post('/api/auth/register-padre', (req, res) => {
|
||||
|
||||
const insert = db.prepare(`
|
||||
INSERT INTO usuarios (username, password_hash, rol, nombre, telefono, email, fecha_nacimiento)
|
||||
VALUES (?, ?, 'padre', ?, ?, ?, ?)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
`);
|
||||
const result = insert.run(cleanUser, cleanPass, cleanNombre, cleanTel, cleanEmail, cleanFechaNac);
|
||||
const result = insert.run(cleanUser, cleanPass, targetRol, cleanNombre, cleanTel, cleanEmail, cleanFechaNac);
|
||||
|
||||
const newUser = {
|
||||
id: result.lastInsertRowid,
|
||||
username: cleanUser,
|
||||
rol: 'padre',
|
||||
rol: targetRol,
|
||||
nombre: cleanNombre,
|
||||
telefono: cleanTel,
|
||||
email: cleanEmail,
|
||||
fecha_nacimiento: cleanFechaNac
|
||||
};
|
||||
|
||||
let estudiante = null;
|
||||
if (targetRol === 'estudiante') {
|
||||
try {
|
||||
const codEst = `EST-${Date.now().toString().slice(-6)}`;
|
||||
const qrToken = `QR-${Date.now()}-${Math.random().toString(36).substring(2, 7).toUpperCase()}`;
|
||||
const resEst = db.prepare(`
|
||||
INSERT INTO estudiantes
|
||||
(usuario_id, codigo_estudiante, nombre_completo, edad, grado, seccion, qr_token, pin_seguridad, foto_url, saldo_colones, limite_diario_colones, alergias, padre_nombre, padre_telefono, permitir_transferencias, tarjeta_bloqueada, activo, escuela_id)
|
||||
VALUES (?, ?, ?, 12, 'General', '1', ?, ?, NULL, 0, 3000, 'Ninguna conocida', '', '', 1, 0, 1, 1)
|
||||
`).run(newUser.id, codEst, cleanNombre, qrToken, cleanPass.slice(0, 4));
|
||||
|
||||
estudiante = db.prepare('SELECT * FROM estudiantes WHERE id = ?').get(resEst.lastInsertRowid);
|
||||
} catch (errEst) {
|
||||
console.warn('[AUTH] Error al crear ficha de estudiante automática:', errEst);
|
||||
}
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
user: newUser,
|
||||
estudiante: estudiante,
|
||||
hijos: []
|
||||
});
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user