feat: implementacion del configurador de reglas de negocio en caliente en developer
This commit is contained in:
+227
-5
@@ -11,9 +11,9 @@
|
||||
<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.8" as="style">
|
||||
<link rel="preload" href="/js/app.js?v=19.8" as="script">
|
||||
<link rel="stylesheet" href="/css/styles.css?v=19.8">
|
||||
<link rel="preload" href="/css/styles.css?v=19.9" as="style">
|
||||
<link rel="preload" href="/js/app.js?v=19.9" as="script">
|
||||
<link rel="stylesheet" href="/css/styles.css?v=19.9">
|
||||
<link rel="stylesheet" href="/css/desktop.css?v=2.2">
|
||||
<style>
|
||||
/* Transiciones suaves */
|
||||
@@ -267,6 +267,10 @@
|
||||
<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg>
|
||||
<span>Terminal & Logs en Vivo</span>
|
||||
</button>
|
||||
<button class="dev-tab-btn" id="btnDevTabReglas" onclick="switchDevTab('reglas')">
|
||||
<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="21" x2="4" y2="14"/><line x1="4" y1="10" x2="4" y2="3"/><line x1="12" y1="21" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="3"/><line x1="20" y1="21" x2="20" y2="16"/><line x1="20" y1="12" x2="20" y2="3"/><line x1="1" y1="14" x2="7" y2="14"/><line x1="9" y1="8" x2="15" y2="8"/><line x1="17" y1="16" x2="23" y2="16"/></svg>
|
||||
<span>Reglas "En Caliente"</span>
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -1026,6 +1030,206 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 9. PESTAÑA: CONFIGURADOR DE REGLAS DE NEGOCIO "EN CALIENTE" -->
|
||||
<div id="devTabContentReglas" class="dev-tab-content" style="display: none;">
|
||||
<!-- CABECERA DE LA SECCIÓN -->
|
||||
<div style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 18px; padding: 22px; margin-bottom: 22px; box-shadow: 0 4px 16px rgba(0,0,0,0.04); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px;">
|
||||
<div style="display: flex; align-items: center; gap: 14px;">
|
||||
<div style="width: 48px; height: 48px; border-radius: 14px; background: linear-gradient(135deg, #0284c7, #0369a1); color: #ffffff; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3); flex-shrink: 0;">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="21" x2="4" y2="14"/><line x1="4" y1="10" x2="4" y2="3"/><line x1="12" y1="21" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="3"/><line x1="20" y1="21" x2="20" y2="16"/><line x1="20" y1="12" x2="20" y2="3"/><line x1="1" y1="14" x2="7" y2="14"/><line x1="9" y1="8" x2="15" y2="8"/><line x1="17" y1="16" x2="23" y2="16"/></svg>
|
||||
</div>
|
||||
<div>
|
||||
<h3 style="margin: 0; font-size: 1.25rem; font-weight: 900; color: var(--text-main); display: flex; align-items: center; gap: 8px;">
|
||||
<span>Configurador de Reglas de Negocio "En Caliente"</span>
|
||||
<span style="background: #e0f2fe; color: #0284c7; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; font-weight: 800;">Tiempo Real</span>
|
||||
</h3>
|
||||
<p style="margin: 4px 0 0 0; font-size: 0.83rem; color: var(--text-muted); line-height: 1.4;">
|
||||
Modifica parámetros financieros, topes operativos y políticas del sistema sin reiniciar el servidor ni tocar código.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; align-items: center; gap: 10px; flex-wrap: wrap;">
|
||||
<button type="button" onclick="resetearReglasNegocioDev()" class="dev-action-btn" style="padding: 10px 16px; font-size: 0.84rem; display: inline-flex; align-items: center; gap: 6px;" title="Restablecer todos los parámetros a sus valores recomendados de fábrica">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>
|
||||
<span>Valores de Fábrica</span>
|
||||
</button>
|
||||
<button type="button" onclick="guardarReglasNegocioDev()" class="dev-action-btn dev-action-btn-primary" style="padding: 10px 22px; font-size: 0.88rem; display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg>
|
||||
<span>Guardar y Aplicar en Vivo</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BANNER DE ESTADO DE SINCRONIZACIÓN -->
|
||||
<div id="devReglasSyncAlert" style="display: none; padding: 12px 16px; border-radius: 12px; margin-bottom: 20px; font-size: 0.84rem; font-weight: 700; align-items: center; gap: 10px;"></div>
|
||||
|
||||
<!-- REJILLA DE TARJETAS DE CONFIGURACIÓN -->
|
||||
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px;">
|
||||
|
||||
<!-- CARD 1: FINANZAS Y RECARGAS SINPE -->
|
||||
<div class="dev-card" style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 16px;">
|
||||
<div style="display: flex; align-items: center; gap: 10px; border-bottom: 1.5px solid var(--border); padding-bottom: 12px;">
|
||||
<div style="width: 36px; height: 36px; border-radius: 10px; background: rgba(16, 185, 129, 0.15); color: #10b981; display: flex; align-items: center; justify-content: center; font-size: 1.1rem;">
|
||||
💸
|
||||
</div>
|
||||
<div>
|
||||
<h4 style="margin: 0; font-size: 0.98rem; font-weight: 800; color: var(--text-main);">Finanzas & Recargas SINPE</h4>
|
||||
<span style="font-size: 0.74rem; color: var(--text-muted);">Límites y montos sugeridos para los padres</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style="font-size: 0.76rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 6px;">Monto Mínimo por Recarga (CRC):</label>
|
||||
<div style="position: relative;">
|
||||
<span style="position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 800; color: var(--text-muted);">₡</span>
|
||||
<input type="number" id="cfg_sinpe_monto_minimo" min="100" step="500" style="width: 100%; padding: 10px 12px 10px 30px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-size: 0.95rem; font-weight: 700; box-sizing: border-box;">
|
||||
</div>
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 4px;">Rechaza reportes de recarga por montos inferiores a este valor.</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style="font-size: 0.76rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 6px;">Monto Máximo de Seguridad (CRC):</label>
|
||||
<div style="position: relative;">
|
||||
<span style="position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 800; color: var(--text-muted);">₡</span>
|
||||
<input type="number" id="cfg_sinpe_monto_maximo" min="1000" step="5000" style="width: 100%; padding: 10px 12px 10px 30px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-size: 0.95rem; font-weight: 700; box-sizing: border-box;">
|
||||
</div>
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 4px;">Tope máximo admitido por cada transacción individual.</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style="font-size: 0.76rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 6px;">Botones de Montos Sugeridos Rápidos:</label>
|
||||
<input type="text" id="cfg_sinpe_montos_sugeridos" placeholder="2000, 3000, 5000, 10000" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-size: 0.88rem; font-weight: 700; box-sizing: border-box;">
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 4px;">Separados por coma. Se renderizan como píldoras de 1 toque en la app.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CARD 2: ALUMNOS Y NUEVOS REGISTROS -->
|
||||
<div class="dev-card" style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 16px;">
|
||||
<div style="display: flex; align-items: center; gap: 10px; border-bottom: 1.5px solid var(--border); padding-bottom: 12px;">
|
||||
<div style="width: 36px; height: 36px; border-radius: 10px; background: rgba(2, 132, 199, 0.15); color: #0284c7; display: flex; align-items: center; justify-content: center; font-size: 1.1rem;">
|
||||
🎓
|
||||
</div>
|
||||
<div>
|
||||
<h4 style="margin: 0; font-size: 0.98rem; font-weight: 800; color: var(--text-main);">Alumnos & Nuevas Matrículas</h4>
|
||||
<span style="font-size: 0.74rem; color: var(--text-muted);">Valores iniciales aplicados a nuevos estudiantes</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style="font-size: 0.76rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 6px;">Límite Diario por Defecto (CRC):</label>
|
||||
<div style="position: relative;">
|
||||
<span style="position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 800; color: var(--text-muted);">₡</span>
|
||||
<input type="number" id="cfg_estudiante_limite_diario_default" min="500" step="500" style="width: 100%; padding: 10px 12px 10px 30px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-size: 0.95rem; font-weight: 700; box-sizing: border-box;">
|
||||
</div>
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 4px;">Tope diario de gasto sugerido al registrar o importar alumnos masivamente.</span>
|
||||
</div>
|
||||
|
||||
<div style="padding: 12px 14px; background: var(--bg-main); border: 1.5px solid var(--border); border-radius: 12px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<div>
|
||||
<span style="font-size: 0.85rem; font-weight: 800; color: var(--text-main); display: block;">Transferencias P2P entre alumnos</span>
|
||||
<span style="font-size: 0.73rem; color: var(--text-muted);">Habilitar opción por defecto para nuevas cuentas</span>
|
||||
</div>
|
||||
<label class="switch-saas">
|
||||
<input type="checkbox" id="cfg_estudiante_permitir_transferencias_default">
|
||||
<span class="switch-saas-slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CARD 3: PRE-ÓRDENES Y HORARIOS DE SODA -->
|
||||
<div class="dev-card" style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 16px;">
|
||||
<div style="display: flex; align-items: center; gap: 10px; border-bottom: 1.5px solid var(--border); padding-bottom: 12px;">
|
||||
<div style="width: 36px; height: 36px; border-radius: 10px; background: rgba(249, 115, 22, 0.15); color: #f97316; display: flex; align-items: center; justify-content: center; font-size: 1.1rem;">
|
||||
🥪
|
||||
</div>
|
||||
<div>
|
||||
<h4 style="margin: 0; font-size: 0.98rem; font-weight: 800; color: var(--text-main);">Pre-órdenes & Horarios</h4>
|
||||
<span style="font-size: 0.74rem; color: var(--text-muted);">Horas de corte y políticas de cancelación</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style="font-size: 0.76rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 6px;">Hora de Corte General (HH:mm):</label>
|
||||
<input type="time" id="cfg_preordenes_hora_corte" style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-size: 0.92rem; font-weight: 700; box-sizing: border-box;">
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 4px;">Hora de cierre habitual para realizar pedidos del día siguiente.</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style="font-size: 0.76rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 6px;">Anticipación Mínima (Minutos):</label>
|
||||
<input type="number" id="cfg_preordenes_anticipacion_minutos" min="5" max="240" step="5" style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-size: 0.92rem; font-weight: 700; box-sizing: border-box;">
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 4px;">Minutos antes de cada recreo requeridos para preparar el pedido en cocina.</span>
|
||||
</div>
|
||||
|
||||
<div style="padding: 12px 14px; background: var(--bg-main); border: 1.5px solid var(--border); border-radius: 12px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<div>
|
||||
<span style="font-size: 0.85rem; font-weight: 800; color: var(--text-main); display: block;">Cancelación por Alumnos</span>
|
||||
<span style="font-size: 0.73rem; color: var(--text-muted);">Si se apaga, solo los padres pueden cancelar órdenes</span>
|
||||
</div>
|
||||
<label class="switch-saas">
|
||||
<input type="checkbox" id="cfg_preordenes_cancelacion_estudiantes">
|
||||
<span class="switch-saas-slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CARD 4: CANALES DE ATENCIÓN Y SOPORTE -->
|
||||
<div class="dev-card" style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 16px;">
|
||||
<div style="display: flex; align-items: center; gap: 10px; border-bottom: 1.5px solid var(--border); padding-bottom: 12px;">
|
||||
<div style="width: 36px; height: 36px; border-radius: 10px; background: rgba(34, 197, 94, 0.15); color: #22c55e; display: flex; align-items: center; justify-content: center; font-size: 1.1rem;">
|
||||
📞
|
||||
</div>
|
||||
<div>
|
||||
<h4 style="margin: 0; font-size: 0.98rem; font-weight: 800; color: var(--text-main);">Atención & Soporte Técnico</h4>
|
||||
<span style="font-size: 0.74rem; color: var(--text-muted);">Líneas directas oficiales de asistencia</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style="font-size: 0.76rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 6px;">WhatsApp Oficial de Soporte (con código país):</label>
|
||||
<input type="text" id="cfg_soporte_whatsapp" placeholder="50688888888" oninput="actualizarPreviewWhatsapp(this.value)" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-size: 0.92rem; font-weight: 700; box-sizing: border-box;">
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 4px;">Al cambiarlo aquí, todos los enlaces y botones de ayuda en la app se redirigirán a este número.</span>
|
||||
</div>
|
||||
|
||||
<div style="padding: 10px 12px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; font-size: 0.76rem; color: #166534; line-height: 1.4;">
|
||||
💡 <strong>Enlace en vivo generado:</strong> <span id="cfgWhatsappPreview" style="font-family: monospace; font-weight: 700;">https://wa.me/50688888888</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CARD 5: MODO MANTENIMIENTO / PAUSA OPERATIVA -->
|
||||
<div class="dev-card" style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 16px; grid-column: 1 / -1;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; border-bottom: 1.5px solid var(--border); padding-bottom: 12px;">
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<div style="width: 36px; height: 36px; border-radius: 10px; background: rgba(239, 68, 68, 0.15); color: #ef4444; display: flex; align-items: center; justify-content: center; font-size: 1.1rem;">
|
||||
🛡️
|
||||
</div>
|
||||
<div>
|
||||
<h4 style="margin: 0; font-size: 0.98rem; font-weight: 800; color: var(--text-main);">Pausa de Operaciones & Modo Mantenimiento</h4>
|
||||
<span style="font-size: 0.74rem; color: var(--text-muted);">Pausa temporal de órdenes y aviso institucional a padres</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<span id="cfgMantenimientoStatusTag" style="padding: 4px 10px; border-radius: 8px; font-size: 0.75rem; font-weight: 800; background: #f1f5f9; color: #64748b;">Desactivado</span>
|
||||
<label class="switch-saas">
|
||||
<input type="checkbox" id="cfg_modo_mantenimiento" onchange="toggleMantenimientoUiState(this.checked)">
|
||||
<span class="switch-saas-slider round rose"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style="font-size: 0.76rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 6px;">Mensaje de Aviso al Usuario:</label>
|
||||
<textarea id="cfg_modo_mantenimiento_mensaje" rows="2" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-size: 0.88rem; line-height: 1.4; box-sizing: border-box;"></textarea>
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 4px;">Este texto aparecerá en un banner flotante en la app de los padres y bloqueará la creación de pre-órdenes.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
@@ -1681,6 +1885,15 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- BANNER DE MODO MANTENIMIENTO EN PORTAL DE PADRES -->
|
||||
<div id="parentMaintenanceBanner" style="display: none; background: #fff1f2; border: 1.5px solid #fecdd3; color: #9f1239; padding: 12px 16px; border-radius: 14px; margin-bottom: 16px; font-size: 0.84rem; align-items: center; gap: 10px; box-shadow: 0 4px 12px rgba(225, 29, 72, 0.08);">
|
||||
<span style="font-size: 1.3rem;">🛡️</span>
|
||||
<div style="flex: 1;">
|
||||
<strong style="display: block; font-size: 0.86rem; color: #881337;">Aviso de Pausa Temporal</strong>
|
||||
<span id="parentMaintenanceBannerText">Estamos realizando mejoras técnicas en el sistema. Los pedidos se reanudarán en breve.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BANNER SI NO HAY HIJOS VINCULADOS -->
|
||||
<div id="parentNoChildrenBanner" class="parent-card" style="display: none; text-align: center; border: 2px dashed #0284c7; background: #f0f9ff;">
|
||||
<div style="width: 52px; height: 52px; border-radius: 50%; background: #e0f2fe; color: #0284c7; display: flex; align-items: center; justify-content: center; margin: 0 auto 10px;">
|
||||
@@ -2032,7 +2245,7 @@
|
||||
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputParentSinpeMonto" placeholder="Ej: 3000" style="width: 100%; padding: 10px 12px 10px 30px; border-radius: 10px; border: 1.8px solid #86efac; font-size: 1.1rem; font-weight: 800; color: #166534; background: white; box-sizing: border-box; outline: none;">
|
||||
</div>
|
||||
<!-- Montos sugeridos rápidos -->
|
||||
<div style="display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap;">
|
||||
<div id="parentSinpePresetsContainer" style="display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap;">
|
||||
<button type="button" onclick="setParentSinpeMonto(1000)" style="background: white; border: 1px solid #86efac; color: #166534; font-size: 0.74rem; font-weight: 700; padding: 4px 9px; border-radius: 8px; cursor: pointer;">₡1.000</button>
|
||||
<button type="button" onclick="setParentSinpeMonto(2000)" style="background: white; border: 1px solid #86efac; color: #166534; font-size: 0.74rem; font-weight: 700; padding: 4px 9px; border-radius: 8px; cursor: pointer;">₡2.000</button>
|
||||
<button type="button" onclick="setParentSinpeMonto(3000)" style="background: white; border: 1px solid #86efac; color: #166534; font-size: 0.74rem; font-weight: 700; padding: 4px 9px; border-radius: 8px; cursor: pointer;">₡3.000</button>
|
||||
@@ -2587,6 +2800,15 @@
|
||||
<span><strong>TARJETA SUSPENDIDA POR LA SODA.</strong> Acércate al mostrador de la soda para reactivar tu cuenta.</span>
|
||||
</div>
|
||||
|
||||
<!-- BANNER DE MODO MANTENIMIENTO EN CATÁLOGO / ESTUDIANTES -->
|
||||
<div id="studentMaintenanceBanner" style="display: none; background: #fff1f2; border: 1.5px solid #fecdd3; color: #9f1239; padding: 12px 16px; border-radius: 12px; margin: 10px 16px 0 16px; font-size: 0.84rem; align-items: center; gap: 10px; box-shadow: 0 4px 12px rgba(225, 29, 72, 0.08);">
|
||||
<span style="font-size: 1.3rem;">🛡️</span>
|
||||
<div style="flex: 1;">
|
||||
<strong style="display: block; font-size: 0.86rem; color: #881337;">Aviso de Pausa Temporal</strong>
|
||||
<span id="studentMaintenanceBannerText">Estamos realizando mejoras técnicas en el sistema. Los pedidos se reanudarán en breve.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BANNER DE ADVERTENCIA HTTPS PARA TELÉFONOS MÓVILES -->
|
||||
<div id="bannerHttpsWarning" style="display: none; background: linear-gradient(135deg, #f59e0b, #d97706); color: white; padding: 10px 14px; font-size: 0.78rem; font-weight: 700; text-align: center; border-radius: 12px; margin: 10px 16px 0 16px; box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);">
|
||||
<span style="display: inline-flex; align-items: center; gap: 6px;">
|
||||
@@ -4945,6 +5167,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=19.8"></script>
|
||||
<script src="/js/app.js?v=19.9"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+285
-1
@@ -65,10 +65,11 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
}
|
||||
checkHttpsEnvironment();
|
||||
cargarHorariosPublicos();
|
||||
cargarConfiguracionesPublicas();
|
||||
|
||||
// Registrar Service Worker para PWA
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('/sw.js?v=18.1').then(reg => {
|
||||
navigator.serviceWorker.register('/sw.js?v=19.9').then(reg => {
|
||||
reg.update().catch(() => {});
|
||||
if ('Notification' in window && Notification.permission === 'granted') {
|
||||
subscribeDeviceToWebPush().catch(() => {});
|
||||
@@ -636,6 +637,12 @@ function switchDevTab(tab) {
|
||||
if (btn) btn.classList.add('active');
|
||||
if (content) content.style.display = 'block';
|
||||
initDevLogsTerminal();
|
||||
} else if (tab === 'reglas') {
|
||||
const btn = document.getElementById('btnDevTabReglas');
|
||||
const content = document.getElementById('devTabContentReglas');
|
||||
if (btn) btn.classList.add('active');
|
||||
if (content) content.style.display = 'block';
|
||||
cargarReglasNegocioDev();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3231,6 +3238,19 @@ function initStudentSSE() {
|
||||
} catch (err) {}
|
||||
});
|
||||
|
||||
// Configuración del sistema y reglas de negocio actualizadas en caliente
|
||||
sse.addEventListener('configuracion_actualizada', (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.data);
|
||||
if (data && data.configuraciones) {
|
||||
window.appConfig = data.configuraciones;
|
||||
aplicarConfiguracionPublica(window.appConfig);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Error en SSE configuracion_actualizada:', err);
|
||||
}
|
||||
});
|
||||
|
||||
// Saldo actualizado (débito, recarga, ajuste de límite)
|
||||
sse.addEventListener('saldo_actualizado', (e) => {
|
||||
try {
|
||||
@@ -12021,4 +12041,268 @@ function abrirCarnetEstudianteDesdeDev() {
|
||||
}
|
||||
window.abrirCarnetEstudianteDesdeDev = abrirCarnetEstudianteDesdeDev;
|
||||
|
||||
// ============================================================================
|
||||
// CONFIGURACIONES PÚBLICAS Y REGLAS DE NEGOCIO "EN CALIENTE"
|
||||
// ============================================================================
|
||||
|
||||
window.appConfig = {
|
||||
sinpe_monto_minimo: 1000,
|
||||
sinpe_monto_maximo: 50000,
|
||||
sinpe_montos_sugeridos: '2000,3000,5000,10000',
|
||||
estudiante_limite_diario_default: 3000,
|
||||
estudiante_permitir_transferencias_default: 1,
|
||||
preordenes_hora_corte: '17:00',
|
||||
preordenes_anticipacion_minutos: 30,
|
||||
preordenes_cancelacion_estudiantes: 1,
|
||||
soporte_whatsapp: '50688888888',
|
||||
modo_mantenimiento: 0,
|
||||
modo_mantenimiento_mensaje: 'Estamos realizando mejoras técnicas en el sistema. Los pedidos y recargas se reanudarán en breve.'
|
||||
};
|
||||
|
||||
async function cargarConfiguracionesPublicas() {
|
||||
try {
|
||||
const res = await fetch('/api/configuraciones');
|
||||
if (!res.ok) return;
|
||||
const data = await res.json();
|
||||
if (data && data.configuraciones) {
|
||||
window.appConfig = data.configuraciones;
|
||||
aplicarConfiguracionPublica(window.appConfig);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Error cargando configuraciones públicas:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function aplicarConfiguracionPublica(cfg) {
|
||||
if (!cfg) return;
|
||||
|
||||
// 1. Modo Mantenimiento
|
||||
const enMantenimiento = Number(cfg.modo_mantenimiento) === 1;
|
||||
const msgMantenimiento = cfg.modo_mantenimiento_mensaje || 'Estamos realizando mejoras técnicas en el sistema. Los pedidos se reanudarán en breve.';
|
||||
|
||||
const parentBanner = document.getElementById('parentMaintenanceBanner');
|
||||
const parentText = document.getElementById('parentMaintenanceBannerText');
|
||||
if (parentBanner) {
|
||||
parentBanner.style.display = enMantenimiento ? 'flex' : 'none';
|
||||
if (parentText) parentText.textContent = msgMantenimiento;
|
||||
}
|
||||
|
||||
const studentBanner = document.getElementById('studentMaintenanceBanner');
|
||||
const studentText = document.getElementById('studentMaintenanceBannerText');
|
||||
if (studentBanner) {
|
||||
studentBanner.style.display = enMantenimiento ? 'flex' : 'none';
|
||||
if (studentText) studentText.textContent = msgMantenimiento;
|
||||
}
|
||||
|
||||
// 2. Presets de SINPE sugeridos para el padre
|
||||
const presetsContainer = document.getElementById('parentSinpePresetsContainer');
|
||||
if (presetsContainer && cfg.sinpe_montos_sugeridos) {
|
||||
const montos = String(cfg.sinpe_montos_sugeridos)
|
||||
.split(',')
|
||||
.map(m => parseInt(m.trim(), 10))
|
||||
.filter(m => !isNaN(m) && m > 0);
|
||||
|
||||
if (montos.length > 0) {
|
||||
presetsContainer.innerHTML = montos.map(m => `
|
||||
<button type="button" onclick="setParentSinpeMonto(${m})" style="background: white; border: 1px solid #86efac; color: #166534; font-size: 0.74rem; font-weight: 700; padding: 4px 9px; border-radius: 8px; cursor: pointer;">₡${m.toLocaleString('es-CR')}</button>
|
||||
`).join('');
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Monto placeholder y min en SINPE del padre
|
||||
const inputSinpe = document.getElementById('inputParentSinpeMonto');
|
||||
if (inputSinpe && cfg.sinpe_monto_minimo) {
|
||||
inputSinpe.min = cfg.sinpe_monto_minimo;
|
||||
}
|
||||
|
||||
// 4. Enlaces dinámicos de WhatsApp
|
||||
if (cfg.soporte_whatsapp) {
|
||||
const cleanTel = String(cfg.soporte_whatsapp).replace(/[^0-9]/g, '');
|
||||
const waUrl = `https://wa.me/${cleanTel}`;
|
||||
document.querySelectorAll('.link-soporte-whatsapp').forEach(a => {
|
||||
a.href = waUrl;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// CONFIGURADOR DE REGLAS DE NEGOCIO "EN CALIENTE" (DEVELOPER)
|
||||
// ==========================================
|
||||
|
||||
async function cargarReglasNegocioDev() {
|
||||
try {
|
||||
const res = await fetch('/api/developer/configuraciones');
|
||||
if (!res.ok) throw new Error('Error al consultar configuraciones');
|
||||
const data = await res.json();
|
||||
const cfg = data.configs || {};
|
||||
|
||||
const elMinSinpe = document.getElementById('cfg_sinpe_monto_minimo');
|
||||
if (elMinSinpe) elMinSinpe.value = cfg.sinpe_monto_minimo || 1000;
|
||||
|
||||
const elMaxSinpe = document.getElementById('cfg_sinpe_monto_maximo');
|
||||
if (elMaxSinpe) elMaxSinpe.value = cfg.sinpe_monto_maximo || 50000;
|
||||
|
||||
const elSugeridos = document.getElementById('cfg_sinpe_montos_sugeridos');
|
||||
if (elSugeridos) elSugeridos.value = cfg.sinpe_montos_sugeridos || '2000, 3000, 5000, 10000';
|
||||
|
||||
const elLimiteEst = document.getElementById('cfg_estudiante_limite_diario_default');
|
||||
if (elLimiteEst) elLimiteEst.value = cfg.estudiante_limite_diario_default || 3000;
|
||||
|
||||
const elTransfEst = document.getElementById('cfg_estudiante_permitir_transferencias_default');
|
||||
if (elTransfEst) elTransfEst.checked = String(cfg.estudiante_permitir_transferencias_default) === '1';
|
||||
|
||||
const elCorte = document.getElementById('cfg_preordenes_hora_corte');
|
||||
if (elCorte) elCorte.value = cfg.preordenes_hora_corte || '17:00';
|
||||
|
||||
const elAnticipacion = document.getElementById('cfg_preordenes_anticipacion_minutos');
|
||||
if (elAnticipacion) elAnticipacion.value = cfg.preordenes_anticipacion_minutos || 30;
|
||||
|
||||
const elCancelEst = document.getElementById('cfg_preordenes_cancelacion_estudiantes');
|
||||
if (elCancelEst) elCancelEst.checked = String(cfg.preordenes_cancelacion_estudiantes) !== '0';
|
||||
|
||||
const elWhatsapp = document.getElementById('cfg_soporte_whatsapp');
|
||||
if (elWhatsapp) {
|
||||
elWhatsapp.value = cfg.soporte_whatsapp || '50688888888';
|
||||
actualizarPreviewWhatsapp(elWhatsapp.value);
|
||||
}
|
||||
|
||||
const elMantenimiento = document.getElementById('cfg_modo_mantenimiento');
|
||||
const isMantenimiento = String(cfg.modo_mantenimiento) === '1';
|
||||
if (elMantenimiento) {
|
||||
elMantenimiento.checked = isMantenimiento;
|
||||
toggleMantenimientoUiState(isMantenimiento);
|
||||
}
|
||||
|
||||
const elMsgMantenimiento = document.getElementById('cfg_modo_mantenimiento_mensaje');
|
||||
if (elMsgMantenimiento) {
|
||||
elMsgMantenimiento.value = cfg.modo_mantenimiento_mensaje || 'Estamos realizando mejoras técnicas en el sistema. Los pedidos y recargas se reanudarán en breve.';
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error cargando reglas de negocio dev:', err);
|
||||
mostrarAlertaReglasDev(`Error cargando configuraciones: ${err.message}`, false);
|
||||
}
|
||||
}
|
||||
|
||||
function actualizarPreviewWhatsapp(val) {
|
||||
const preview = document.getElementById('cfgWhatsappPreview');
|
||||
if (!preview) return;
|
||||
const clean = String(val || '').replace(/[^0-9]/g, '');
|
||||
preview.textContent = clean ? `https://wa.me/${clean}` : 'https://wa.me/...';
|
||||
}
|
||||
|
||||
function toggleMantenimientoUiState(activo) {
|
||||
const tag = document.getElementById('cfgMantenimientoStatusTag');
|
||||
if (!tag) return;
|
||||
if (activo) {
|
||||
tag.style.background = '#fee2e2';
|
||||
tag.style.color = '#b91c1c';
|
||||
tag.textContent = '⚠️ ACTIVO - Pausa Operativa';
|
||||
} else {
|
||||
tag.style.background = '#f1f5f9';
|
||||
tag.style.color = '#64748b';
|
||||
tag.textContent = 'Desactivado';
|
||||
}
|
||||
}
|
||||
|
||||
async function guardarReglasNegocioDev() {
|
||||
try {
|
||||
const minSinpe = parseInt(document.getElementById('cfg_sinpe_monto_minimo')?.value || 1000, 10);
|
||||
const maxSinpe = parseInt(document.getElementById('cfg_sinpe_monto_maximo')?.value || 50000, 10);
|
||||
const sugeridos = (document.getElementById('cfg_sinpe_montos_sugeridos')?.value || '2000, 3000, 5000, 10000').trim();
|
||||
const limiteEst = parseInt(document.getElementById('cfg_estudiante_limite_diario_default')?.value || 3000, 10);
|
||||
const transfEst = document.getElementById('cfg_estudiante_permitir_transferencias_default')?.checked ? '1' : '0';
|
||||
const horaCorte = (document.getElementById('cfg_preordenes_hora_corte')?.value || '17:00').trim();
|
||||
const anticipacion = parseInt(document.getElementById('cfg_preordenes_anticipacion_minutos')?.value || 30, 10);
|
||||
const cancelEst = document.getElementById('cfg_preordenes_cancelacion_estudiantes')?.checked ? '1' : '0';
|
||||
const whatsapp = (document.getElementById('cfg_soporte_whatsapp')?.value || '50688888888').trim();
|
||||
const mantenimiento = document.getElementById('cfg_modo_mantenimiento')?.checked ? '1' : '0';
|
||||
const msgMantenimiento = (document.getElementById('cfg_modo_mantenimiento_mensaje')?.value || '').trim();
|
||||
|
||||
if (minSinpe <= 0) return alert('El monto mínimo de SINPE debe ser mayor a 0');
|
||||
if (maxSinpe < minSinpe) return alert('El monto máximo de SINPE debe ser mayor o igual al monto mínimo');
|
||||
|
||||
const updates = {
|
||||
sinpe_monto_minimo: String(minSinpe),
|
||||
sinpe_monto_maximo: String(maxSinpe),
|
||||
sinpe_montos_sugeridos: sugeridos,
|
||||
estudiante_limite_diario_default: String(limiteEst),
|
||||
estudiante_permitir_transferencias_default: transfEst,
|
||||
preordenes_hora_corte: horaCorte,
|
||||
preordenes_anticipacion_minutos: String(anticipacion),
|
||||
preordenes_cancelacion_estudiantes: cancelEst,
|
||||
soporte_whatsapp: whatsapp,
|
||||
modo_mantenimiento: mantenimiento,
|
||||
modo_mantenimiento_mensaje: msgMantenimiento
|
||||
};
|
||||
|
||||
const res = await fetch('/api/developer/configuraciones', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ updates })
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Error al guardar reglas de negocio');
|
||||
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
mostrarAlertaReglasDev('✅ ¡Reglas de negocio actualizadas y aplicadas en caliente con éxito!', true);
|
||||
|
||||
// Actualizar configuración en la ventana actual
|
||||
if (data.configs) {
|
||||
window.appConfig = data.configs;
|
||||
aplicarConfiguracionPublica(window.appConfig);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error guardando reglas de negocio dev:', err);
|
||||
if (window.sounds) window.sounds.playError();
|
||||
mostrarAlertaReglasDev(`❌ Error al aplicar cambios: ${err.message}`, false);
|
||||
}
|
||||
}
|
||||
|
||||
async function resetearReglasNegocioDev() {
|
||||
if (!confirm('¿Deseas restablecer todas las reglas de negocio a sus valores de fábrica recomendados?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/developer/configuraciones/reset', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Error al restablecer');
|
||||
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
mostrarAlertaReglasDev('🔄 Valores de fábrica restablecidos correctamente.', true);
|
||||
await cargarReglasNegocioDev();
|
||||
} catch (err) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
mostrarAlertaReglasDev(`❌ Error: ${err.message}`, false);
|
||||
}
|
||||
}
|
||||
|
||||
function mostrarAlertaReglasDev(mensaje, esExito) {
|
||||
const alertEl = document.getElementById('devReglasSyncAlert');
|
||||
if (!alertEl) return;
|
||||
alertEl.style.display = 'flex';
|
||||
alertEl.style.background = esExito ? '#ecfdf5' : '#fef2f2';
|
||||
alertEl.style.color = esExito ? '#065f46' : '#991b1b';
|
||||
alertEl.style.border = `1.5px solid ${esExito ? '#a7f3d0' : '#fecaca'}`;
|
||||
alertEl.innerHTML = `<span>${mensaje}</span>`;
|
||||
|
||||
setTimeout(() => {
|
||||
alertEl.style.display = 'none';
|
||||
}, 4500);
|
||||
}
|
||||
|
||||
window.cargarConfiguracionesPublicas = cargarConfiguracionesPublicas;
|
||||
window.aplicarConfiguracionPublica = aplicarConfiguracionPublica;
|
||||
window.cargarReglasNegocioDev = cargarReglasNegocioDev;
|
||||
window.guardarReglasNegocioDev = guardarReglasNegocioDev;
|
||||
window.resetearReglasNegocioDev = resetearReglasNegocioDev;
|
||||
window.actualizarPreviewWhatsapp = actualizarPreviewWhatsapp;
|
||||
window.toggleMantenimientoUiState = toggleMantenimientoUiState;
|
||||
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
// SiboPay PWA Service Worker v19.8 - Ultra Fast Startup & Stale-While-Revalidate
|
||||
const CACHE_NAME = 'sibopay-v19.8';
|
||||
// SiboPay PWA Service Worker v19.9 - Ultra Fast Startup & Stale-While-Revalidate
|
||||
const CACHE_NAME = 'sibopay-v19.9';
|
||||
const STATIC_ASSETS = [
|
||||
'/',
|
||||
'/index.html',
|
||||
@@ -8,10 +8,10 @@ const STATIC_ASSETS = [
|
||||
'/pistola.html',
|
||||
'/carnet.html',
|
||||
'/manifest.json',
|
||||
'/css/styles.css?v=19.8',
|
||||
'/css/styles.css?v=19.9',
|
||||
'/css/desktop.css?v=2.2',
|
||||
'/js/dialogs.js?v=19.4',
|
||||
'/js/app.js?v=19.8',
|
||||
'/js/app.js?v=19.9',
|
||||
'/js/pos.js',
|
||||
'/js/sounds.js?v=19.4',
|
||||
'/js/food-icons.js?v=19.4',
|
||||
|
||||
Reference in New Issue
Block a user