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-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||||
<meta name="apple-mobile-web-app-title" content="SiboPay">
|
<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="/css/styles.css?v=19.9" as="style">
|
||||||
<link rel="preload" href="/js/app.js?v=19.8" as="script">
|
<link rel="preload" href="/js/app.js?v=19.9" as="script">
|
||||||
<link rel="stylesheet" href="/css/styles.css?v=19.8">
|
<link rel="stylesheet" href="/css/styles.css?v=19.9">
|
||||||
<link rel="stylesheet" href="/css/desktop.css?v=2.2">
|
<link rel="stylesheet" href="/css/desktop.css?v=2.2">
|
||||||
<style>
|
<style>
|
||||||
/* Transiciones suaves */
|
/* 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>
|
<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>
|
<span>Terminal & Logs en Vivo</span>
|
||||||
</button>
|
</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>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
@@ -1026,6 +1030,206 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
@@ -1681,6 +1885,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</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 -->
|
<!-- 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 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;">
|
<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;">
|
<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>
|
</div>
|
||||||
<!-- Montos sugeridos rápidos -->
|
<!-- 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(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(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>
|
<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>
|
<span><strong>TARJETA SUSPENDIDA POR LA SODA.</strong> Acércate al mostrador de la soda para reactivar tu cuenta.</span>
|
||||||
</div>
|
</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 -->
|
<!-- 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);">
|
<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;">
|
<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/sounds.js?v=19.4"></script>
|
||||||
<script src="/js/jsQR.js" defer></script>
|
<script src="/js/jsQR.js" defer></script>
|
||||||
<script src="/js/food-icons.js?v=19.4" 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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+285
-1
@@ -65,10 +65,11 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
}
|
}
|
||||||
checkHttpsEnvironment();
|
checkHttpsEnvironment();
|
||||||
cargarHorariosPublicos();
|
cargarHorariosPublicos();
|
||||||
|
cargarConfiguracionesPublicas();
|
||||||
|
|
||||||
// Registrar Service Worker para PWA
|
// Registrar Service Worker para PWA
|
||||||
if ('serviceWorker' in navigator) {
|
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(() => {});
|
reg.update().catch(() => {});
|
||||||
if ('Notification' in window && Notification.permission === 'granted') {
|
if ('Notification' in window && Notification.permission === 'granted') {
|
||||||
subscribeDeviceToWebPush().catch(() => {});
|
subscribeDeviceToWebPush().catch(() => {});
|
||||||
@@ -636,6 +637,12 @@ function switchDevTab(tab) {
|
|||||||
if (btn) btn.classList.add('active');
|
if (btn) btn.classList.add('active');
|
||||||
if (content) content.style.display = 'block';
|
if (content) content.style.display = 'block';
|
||||||
initDevLogsTerminal();
|
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) {}
|
} 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)
|
// Saldo actualizado (débito, recarga, ajuste de límite)
|
||||||
sse.addEventListener('saldo_actualizado', (e) => {
|
sse.addEventListener('saldo_actualizado', (e) => {
|
||||||
try {
|
try {
|
||||||
@@ -12021,4 +12041,268 @@ function abrirCarnetEstudianteDesdeDev() {
|
|||||||
}
|
}
|
||||||
window.abrirCarnetEstudianteDesdeDev = 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
|
// SiboPay PWA Service Worker v19.9 - Ultra Fast Startup & Stale-While-Revalidate
|
||||||
const CACHE_NAME = 'sibopay-v19.8';
|
const CACHE_NAME = 'sibopay-v19.9';
|
||||||
const STATIC_ASSETS = [
|
const STATIC_ASSETS = [
|
||||||
'/',
|
'/',
|
||||||
'/index.html',
|
'/index.html',
|
||||||
@@ -8,10 +8,10 @@ const STATIC_ASSETS = [
|
|||||||
'/pistola.html',
|
'/pistola.html',
|
||||||
'/carnet.html',
|
'/carnet.html',
|
||||||
'/manifest.json',
|
'/manifest.json',
|
||||||
'/css/styles.css?v=19.8',
|
'/css/styles.css?v=19.9',
|
||||||
'/css/desktop.css?v=2.2',
|
'/css/desktop.css?v=2.2',
|
||||||
'/js/dialogs.js?v=19.4',
|
'/js/dialogs.js?v=19.4',
|
||||||
'/js/app.js?v=19.8',
|
'/js/app.js?v=19.9',
|
||||||
'/js/pos.js',
|
'/js/pos.js',
|
||||||
'/js/sounds.js?v=19.4',
|
'/js/sounds.js?v=19.4',
|
||||||
'/js/food-icons.js?v=19.4',
|
'/js/food-icons.js?v=19.4',
|
||||||
|
|||||||
+95
-1
@@ -216,8 +216,23 @@ function initDatabase() {
|
|||||||
`);
|
`);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS configuracion_sistema (
|
||||||
|
clave VARCHAR(80) PRIMARY KEY,
|
||||||
|
valor TEXT NOT NULL,
|
||||||
|
categoria VARCHAR(50) DEFAULT 'general',
|
||||||
|
descripcion TEXT,
|
||||||
|
actualizado_en TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
`);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error creando configuracion_sistema en PostgreSQL:', e);
|
||||||
|
}
|
||||||
|
|
||||||
seedUsuarios();
|
seedUsuarios();
|
||||||
seedDisenosTarjetas();
|
seedDisenosTarjetas();
|
||||||
|
seedConfiguraciones();
|
||||||
migrarTrazabilidadSinpeRechazadas();
|
migrarTrazabilidadSinpeRechazadas();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -461,10 +476,23 @@ function initDatabase() {
|
|||||||
`);
|
`);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS configuracion_sistema (
|
||||||
|
clave TEXT PRIMARY KEY,
|
||||||
|
valor TEXT NOT NULL,
|
||||||
|
categoria TEXT DEFAULT 'general',
|
||||||
|
descripcion TEXT,
|
||||||
|
actualizado_en DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
`);
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
migrarTrazabilidadSinpeRechazadas();
|
migrarTrazabilidadSinpeRechazadas();
|
||||||
seedInitialData();
|
seedInitialData();
|
||||||
seedUsuarios();
|
seedUsuarios();
|
||||||
seedDisenosTarjetas();
|
seedDisenosTarjetas();
|
||||||
|
seedConfiguraciones();
|
||||||
}
|
}
|
||||||
|
|
||||||
function migrarTrazabilidadSinpeRechazadas() {
|
function migrarTrazabilidadSinpeRechazadas() {
|
||||||
@@ -594,6 +622,69 @@ function seedDisenosTarjetas() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// CONFIGURACIÓN DEL SISTEMA Y REGLAS DE NEGOCIO "EN CALIENTE"
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
const DEFAULTS_CONFIG = [
|
||||||
|
{ clave: 'sinpe_monto_minimo', valor: '1000', categoria: 'finanzas', descripcion: 'Monto mínimo permitido para recargas por SINPE Móvil (CRC)' },
|
||||||
|
{ clave: 'sinpe_monto_maximo', valor: '50000', categoria: 'finanzas', descripcion: 'Monto máximo de seguridad por transacción SINPE Móvil (CRC)' },
|
||||||
|
{ clave: 'sinpe_montos_sugeridos', valor: '2000,3000,5000,10000', categoria: 'finanzas', descripcion: 'Botones de montos sugeridos para recarga rápida en la app' },
|
||||||
|
{ clave: 'estudiante_limite_diario_default', valor: '3000', categoria: 'estudiantes', descripcion: 'Límite de gasto diario por defecto asignado a nuevos estudiantes (CRC)' },
|
||||||
|
{ clave: 'estudiante_permitir_transferencias_default', valor: '1', categoria: 'estudiantes', descripcion: 'Permitir transferencias P2P a nuevos estudiantes por defecto (1=Sí, 0=No)' },
|
||||||
|
{ clave: 'preordenes_hora_corte', valor: '17:00', categoria: 'preordenes', descripcion: 'Hora de corte general sugerida para emisión de pre-órdenes (HH:mm)' },
|
||||||
|
{ clave: 'preordenes_anticipacion_minutos', valor: '30', categoria: 'preordenes', descripcion: 'Anticipación mínima en minutos antes del recreo/almuerzo para pre-órdenes' },
|
||||||
|
{ clave: 'preordenes_cancelacion_estudiantes', valor: '1', categoria: 'preordenes', descripcion: 'Permitir que los estudiantes cancelen sus propias pre-órdenes (1=Sí, 0=Solo Padres)' },
|
||||||
|
{ clave: 'soporte_whatsapp', valor: '50688888888', categoria: 'soporte', descripcion: 'Número telefónico oficial de WhatsApp para atención y soporte técnico' },
|
||||||
|
{ clave: 'modo_mantenimiento', valor: '0', categoria: 'sistema', descripcion: 'Modo Mantenimiento global (1=Activado / Bloquea compras, 0=Desactivado)' },
|
||||||
|
{ clave: 'modo_mantenimiento_mensaje', valor: 'Estamos realizando mejoras técnicas en el sistema. Los pedidos y recargas se reanudarán en breve.', categoria: 'sistema', descripcion: 'Mensaje visible en la app para los clientes durante el mantenimiento' }
|
||||||
|
];
|
||||||
|
|
||||||
|
function seedConfiguraciones() {
|
||||||
|
try {
|
||||||
|
for (const c of DEFAULTS_CONFIG) {
|
||||||
|
const exists = db.prepare('SELECT clave FROM configuracion_sistema WHERE clave = ?').get(c.clave);
|
||||||
|
if (!exists) {
|
||||||
|
db.prepare('INSERT INTO configuracion_sistema (clave, valor, categoria, descripcion) VALUES (?, ?, ?, ?)').run(c.clave, c.valor, c.categoria, c.descripcion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error sembrando configuraciones por defecto:', err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function obtenerConfiguraciones() {
|
||||||
|
try {
|
||||||
|
const rows = db.prepare('SELECT clave, valor, categoria, descripcion, actualizado_en FROM configuracion_sistema ORDER BY categoria, clave').all();
|
||||||
|
const configObj = {};
|
||||||
|
rows.forEach(r => {
|
||||||
|
configObj[r.clave] = r.valor;
|
||||||
|
});
|
||||||
|
return { configs: configObj, lista: rows };
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error obteniendo configuraciones:', err.message);
|
||||||
|
return { configs: {}, lista: [] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function guardarConfiguracion(clave, valor) {
|
||||||
|
const cleanVal = String(valor !== undefined && valor !== null ? valor : '');
|
||||||
|
const exists = db.prepare('SELECT clave FROM configuracion_sistema WHERE clave = ?').get(clave);
|
||||||
|
if (exists) {
|
||||||
|
db.prepare("UPDATE configuracion_sistema SET valor = ?, actualizado_en = CURRENT_TIMESTAMP WHERE clave = ?").run(cleanVal, clave);
|
||||||
|
} else {
|
||||||
|
db.prepare('INSERT INTO configuracion_sistema (clave, valor) VALUES (?, ?)').run(clave, cleanVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function guardarConfiguracionesMultiples(updates) {
|
||||||
|
if (!updates || typeof updates !== 'object') return obtenerConfiguraciones();
|
||||||
|
for (const [k, v] of Object.entries(updates)) {
|
||||||
|
guardarConfiguracion(k, v);
|
||||||
|
}
|
||||||
|
return obtenerConfiguraciones();
|
||||||
|
}
|
||||||
|
|
||||||
function seedInitialData() {
|
function seedInitialData() {
|
||||||
const existingProducts = db.prepare('SELECT COUNT(*) as count FROM productos').get();
|
const existingProducts = db.prepare('SELECT COUNT(*) as count FROM productos').get();
|
||||||
if (existingProducts.count > 0) return;
|
if (existingProducts.count > 0) return;
|
||||||
@@ -2556,5 +2647,8 @@ module.exports = {
|
|||||||
buscarSinpeUniversalDev,
|
buscarSinpeUniversalDev,
|
||||||
forzarAprobarSolicitudDev,
|
forzarAprobarSolicitudDev,
|
||||||
rechazarSolicitudDev,
|
rechazarSolicitudDev,
|
||||||
vincularBancoAEstudianteDev
|
vincularBancoAEstudianteDev,
|
||||||
|
obtenerConfiguraciones,
|
||||||
|
guardarConfiguracion,
|
||||||
|
guardarConfiguracionesMultiples
|
||||||
};
|
};
|
||||||
|
|||||||
+141
-2
@@ -39,7 +39,9 @@ const {
|
|||||||
buscarSinpeUniversalDev,
|
buscarSinpeUniversalDev,
|
||||||
forzarAprobarSolicitudDev,
|
forzarAprobarSolicitudDev,
|
||||||
rechazarSolicitudDev,
|
rechazarSolicitudDev,
|
||||||
vincularBancoAEstudianteDev
|
vincularBancoAEstudianteDev,
|
||||||
|
obtenerConfiguraciones,
|
||||||
|
guardarConfiguracionesMultiples
|
||||||
} = require('./db');
|
} = require('./db');
|
||||||
const { checkSinpeEmailsOnce, simularSinpeEmail } = require('./sinpeImapService');
|
const { checkSinpeEmailsOnce, simularSinpeEmail } = require('./sinpeImapService');
|
||||||
const { normalizarCodigoDetalle, parseSinpeEmail } = require('./sinpeParser');
|
const { normalizarCodigoDetalle, parseSinpeEmail } = require('./sinpeParser');
|
||||||
@@ -97,6 +99,24 @@ const compression = require('compression');
|
|||||||
const app = express();
|
const app = express();
|
||||||
const PORT = process.env.PORT || 3030;
|
const PORT = process.env.PORT || 3030;
|
||||||
|
|
||||||
|
// ==========================================
|
||||||
|
// CONFIGURACIÓN GLOBAL EN MEMORIA ("EN CALIENTE")
|
||||||
|
// ==========================================
|
||||||
|
let globalConfig = {};
|
||||||
|
try {
|
||||||
|
const cfgData = obtenerConfiguraciones();
|
||||||
|
globalConfig = cfgData.configs || {};
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Error precargando configuraciones en memoria:', e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfig(key, defaultValue) {
|
||||||
|
if (globalConfig && globalConfig[key] !== undefined && globalConfig[key] !== null) {
|
||||||
|
return globalConfig[key];
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
// ==========================================
|
// ==========================================
|
||||||
// MÓDULO: TERMINAL WEB Y LOGS EN VIVO (DEVELOPER)
|
// MÓDULO: TERMINAL WEB Y LOGS EN VIVO (DEVELOPER)
|
||||||
// ==========================================
|
// ==========================================
|
||||||
@@ -2490,6 +2510,110 @@ app.post('/api/developer/logs/clear', (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ==========================================
|
||||||
|
// CONFIGURACIÓN DEL SISTEMA Y REGLAS EN CALIENTE (DEVELOPER)
|
||||||
|
// ==========================================
|
||||||
|
|
||||||
|
// Endpoint público para que la app conozca las directrices del negocio
|
||||||
|
app.get('/api/configuraciones', (req, res) => {
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
configuraciones: {
|
||||||
|
sinpe_monto_minimo: parseInt(getConfig('sinpe_monto_minimo', 1000), 10),
|
||||||
|
sinpe_monto_maximo: parseInt(getConfig('sinpe_monto_maximo', 50000), 10),
|
||||||
|
sinpe_montos_sugeridos: getConfig('sinpe_montos_sugeridos', '2000,3000,5000,10000'),
|
||||||
|
estudiante_limite_diario_default: parseInt(getConfig('estudiante_limite_diario_default', 3000), 10),
|
||||||
|
estudiante_permitir_transferencias_default: parseInt(getConfig('estudiante_permitir_transferencias_default', 1), 10),
|
||||||
|
preordenes_hora_corte: getConfig('preordenes_hora_corte', '17:00'),
|
||||||
|
preordenes_anticipacion_minutos: parseInt(getConfig('preordenes_anticipacion_minutos', 30), 10),
|
||||||
|
preordenes_cancelacion_estudiantes: parseInt(getConfig('preordenes_cancelacion_estudiantes', 1), 10),
|
||||||
|
soporte_whatsapp: getConfig('soporte_whatsapp', '50688888888'),
|
||||||
|
modo_mantenimiento: parseInt(getConfig('modo_mantenimiento', 0), 10),
|
||||||
|
modo_mantenimiento_mensaje: getConfig('modo_mantenimiento_mensaje', 'Estamos realizando mejoras técnicas en el sistema. Los pedidos y recargas se reanudarán en breve.')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Endpoint administrativo para ver el estado completo
|
||||||
|
app.get('/api/developer/configuraciones', (req, res) => {
|
||||||
|
try {
|
||||||
|
const data = obtenerConfiguraciones();
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
configs: globalConfig,
|
||||||
|
lista: data.lista
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
res.status(500).json({ error: err.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Guardar y aplicar reglas en caliente
|
||||||
|
app.post('/api/developer/configuraciones', (req, res) => {
|
||||||
|
try {
|
||||||
|
const { updates } = req.body;
|
||||||
|
if (!updates || typeof updates !== 'object') {
|
||||||
|
return res.status(400).json({ error: 'Configuraciones inválidas' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const resultado = guardarConfiguracionesMultiples(updates);
|
||||||
|
globalConfig = resultado.configs;
|
||||||
|
|
||||||
|
broadcastEvent('configuracion_actualizada', {
|
||||||
|
configuraciones: globalConfig,
|
||||||
|
actualizado_en: new Date().toISOString()
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`[SISTEMA] ⚙️ Reglas de negocio actualizadas en caliente por developer (${Object.keys(updates).length} parámetros modificados)`);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
mensaje: '¡Reglas de negocio actualizadas en caliente con éxito!',
|
||||||
|
...resultado
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error guardando configuraciones:', err);
|
||||||
|
res.status(500).json({ error: err.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Restablecer reglas a valores de fábrica
|
||||||
|
app.post('/api/developer/configuraciones/reset', (req, res) => {
|
||||||
|
try {
|
||||||
|
const defaultsObj = {
|
||||||
|
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.'
|
||||||
|
};
|
||||||
|
|
||||||
|
const resultado = guardarConfiguracionesMultiples(defaultsObj);
|
||||||
|
globalConfig = resultado.configs;
|
||||||
|
|
||||||
|
broadcastEvent('configuracion_actualizada', {
|
||||||
|
configuraciones: globalConfig,
|
||||||
|
actualizado_en: new Date().toISOString()
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('[SISTEMA] 🔄 Reglas de negocio restablecidas a sus valores por defecto');
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
mensaje: 'Reglas de negocio restablecidas a valores de fábrica',
|
||||||
|
...resultado
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
res.status(500).json({ error: err.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ==========================================
|
// ==========================================
|
||||||
// CARGA MASIVA DE ESTUDIANTES (DEVELOPER)
|
// CARGA MASIVA DE ESTUDIANTES (DEVELOPER)
|
||||||
// ==========================================
|
// ==========================================
|
||||||
@@ -3656,6 +3780,14 @@ app.post('/api/sinpe/solicitar', (req, res) => {
|
|||||||
if (isNaN(montoNum) || montoNum <= 0) {
|
if (isNaN(montoNum) || montoNum <= 0) {
|
||||||
return res.status(400).json({ error: 'Ingresa un monto válido mayor a ₡0' });
|
return res.status(400).json({ error: 'Ingresa un monto válido mayor a ₡0' });
|
||||||
}
|
}
|
||||||
|
const minSinpe = parseInt(getConfig('sinpe_monto_minimo', 1000), 10);
|
||||||
|
const maxSinpe = parseInt(getConfig('sinpe_monto_maximo', 50000), 10);
|
||||||
|
if (montoNum < minSinpe) {
|
||||||
|
return res.status(400).json({ error: `El monto mínimo de recarga SINPE es de ₡${minSinpe.toLocaleString('es-CR')}` });
|
||||||
|
}
|
||||||
|
if (montoNum > maxSinpe) {
|
||||||
|
return res.status(400).json({ error: `El monto máximo de recarga SINPE por transacción es de ₡${maxSinpe.toLocaleString('es-CR')}` });
|
||||||
|
}
|
||||||
const cleanComp = String(comprobante || '').trim();
|
const cleanComp = String(comprobante || '').trim();
|
||||||
const cleanCod = codigo_detalle ? String(codigo_detalle).trim() : null;
|
const cleanCod = codigo_detalle ? String(codigo_detalle).trim() : null;
|
||||||
if (!cleanComp && !cleanCod) {
|
if (!cleanComp && !cleanCod) {
|
||||||
@@ -4474,11 +4606,18 @@ app.post('/api/ordenes/:id/cancelar', (req, res) => {
|
|||||||
return res.status(400).json({ error: `Esta orden ya se encuentra ${ord.estado}.` });
|
return res.status(400).json({ error: `Esta orden ya se encuentra ${ord.estado}.` });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si viene estudiante_id (portal de alumno), verificar pertenencia
|
// Si viene estudiante_id (portal de alumno), verificar pertenencia y permisos
|
||||||
if (estudiante_id && parseInt(estudiante_id, 10) !== ord.estudiante_id) {
|
if (estudiante_id && parseInt(estudiante_id, 10) !== ord.estudiante_id) {
|
||||||
return res.status(403).json({ error: 'No tienes permisos para cancelar una orden de otro estudiante.' });
|
return res.status(403).json({ error: 'No tienes permisos para cancelar una orden de otro estudiante.' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (usuario_rol === 'estudiante') {
|
||||||
|
const allowStudentCancel = parseInt(getConfig('preordenes_cancelacion_estudiantes', 1), 10);
|
||||||
|
if (allowStudentCancel === 0) {
|
||||||
|
return res.status(403).json({ error: 'La política del colegio solo permite a los padres de familia cancelar pre-órdenes.' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let rolMotivo = 'Cancelada por el usuario';
|
let rolMotivo = 'Cancelada por el usuario';
|
||||||
if (usuario_rol === 'estudiante') rolMotivo = 'Cancelada por el alumno';
|
if (usuario_rol === 'estudiante') rolMotivo = 'Cancelada por el alumno';
|
||||||
else if (usuario_rol === 'padre') rolMotivo = 'Cancelada por el padre de familia';
|
else if (usuario_rol === 'padre') rolMotivo = 'Cancelada por el padre de familia';
|
||||||
|
|||||||
Reference in New Issue
Block a user