feat(student): autorecarga sinpe y presupuesto personal para alumnos autoadministrados v20.8

This commit is contained in:
unknown
2026-10-13 10:59:58 -06:00
parent 1f0207a5ee
commit c053a74d69
3 changed files with 673 additions and 52 deletions
+195 -8
View File
@@ -3212,14 +3212,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">
<div>
<span>Límite diario fijado: </span>
<strong id="dailyLimitText">₡0</strong>
<!-- 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 id="dailyLimitBadgeTitle">Límite diario fijado: </span>
<strong id="dailyLimitText">₡0</strong>
</div>
<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);" id="dailyAvailableText">
Disponible hoy: ₡0
<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>
@@ -5292,6 +5312,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;">
@@ -5480,6 +5667,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.7"></script>
<script src="/js/app.js?v=20.8"></script>
</body>
</html>