feat(admin): permitir al administrador configurar numero y titular SINPE en caliente v20.4
This commit is contained in:
+72
-7
@@ -12,7 +12,7 @@
|
|||||||
<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.9" as="style">
|
<link rel="preload" href="/css/styles.css?v=19.9" as="style">
|
||||||
<link rel="preload" href="/js/app.js?v=20.3" as="script">
|
<link rel="preload" href="/js/app.js?v=20.4" as="script">
|
||||||
<link rel="stylesheet" href="/css/styles.css?v=19.9">
|
<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>
|
||||||
@@ -1340,9 +1340,9 @@
|
|||||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M16 22h2a2 2 0 0 0 2-2V7.5L14.5 2H6a2 2 0 0 0-2 2v3"/><path d="m3 12.5 3 3 6-6"/></svg>
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M16 22h2a2 2 0 0 0 2-2V7.5L14.5 2H6a2 2 0 0 0-2 2v3"/><path d="m3 12.5 3 3 6-6"/></svg>
|
||||||
<span>Movimientos & Reversiones</span>
|
<span>Movimientos & Reversiones</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="admin-tab-btn" id="btnTabAdminHorarios" onclick="switchAdminTab('horarios')" title="Horarios de Recreos y Almuerzos">
|
<button class="admin-tab-btn" id="btnTabAdminHorarios" onclick="switchAdminTab('horarios')" title="Configuración de la Soda, Cuenta SINPE y Horarios">
|
||||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>
|
||||||
<span>Horarios & Recreos</span>
|
<span>Configuración & SINPE</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -1785,8 +1785,73 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- TAB 6: HORARIOS ESCOLARES (RECREOS Y ALMUERZO) -->
|
<!-- TAB 6: CONFIGURACIÓN GENERAL DE LA SODA & HORARIOS -->
|
||||||
<div id="adminTabContentHorarios" class="admin-card" style="display: none; max-width: 780px; margin: 0 auto;">
|
<div id="adminTabContentHorarios" class="admin-card" style="display: none; max-width: 820px; margin: 0 auto;">
|
||||||
|
|
||||||
|
<!-- SECCIÓN 1: CUENTA RECEPTORA DE SINPE MÓVIL DE LA SODA -->
|
||||||
|
<div style="background: var(--bg-main); border: 1.5px solid var(--border); border-radius: 14px; padding: 22px; margin-bottom: 22px; box-shadow: 0 1px 3px rgba(0,0,0,0.03);">
|
||||||
|
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
|
||||||
|
<div>
|
||||||
|
<div style="display: flex; align-items: center; gap: 8px;">
|
||||||
|
<span style="font-size: 1.35rem;">📲</span>
|
||||||
|
<h3 style="margin: 0; font-size: 1.18rem; font-weight: 900; color: var(--text-main);">
|
||||||
|
Cuenta Receptora de SINPE Móvil
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<p style="margin: 4px 0 0 0; font-size: 0.80rem; color: var(--text-muted); max-width: 650px;">
|
||||||
|
Configura el número telefónico y el titular a donde llegarán las transferencias de recarga. Los padres de familia verán esta información de inmediato en su app al solicitar una recarga por SINPE Móvil.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<span style="background: #e0f2fe; color: #0284c7; font-size: 0.74rem; font-weight: 800; padding: 4px 10px; border-radius: 8px; display: inline-flex; align-items: center; gap: 5px;">
|
||||||
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="20 6 9 17 4 12"/></svg>
|
||||||
|
En Caliente
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 14px;">
|
||||||
|
<!-- Teléfono SINPE -->
|
||||||
|
<div style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px;">
|
||||||
|
<label for="inputAdminTelefonoSinpe" style="display: flex; align-items: center; gap: 6px; font-size: 0.80rem; font-weight: 800; color: var(--text-main); margin-bottom: 6px;">
|
||||||
|
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/></svg>
|
||||||
|
Número Celular SINPE Móvil:
|
||||||
|
</label>
|
||||||
|
<input type="tel" id="inputAdminTelefonoSinpe" placeholder="Ej: 8888-8888" oninput="actualizarPreviewAdminSinpe()" style="width: 100%; padding: 10px 14px; border-radius: 9px; border: 1.5px solid var(--border); font-size: 1.05rem; font-weight: 800; color: #0284c7; background: var(--bg-main); outline: none; box-sizing: border-box; letter-spacing: 0.5px;">
|
||||||
|
<span style="display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 4px;">Ingresa 8 dígitos (ej: 8888-8888 o 88888888)</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Titular SINPE -->
|
||||||
|
<div style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px;">
|
||||||
|
<label for="inputAdminTitularSinpe" style="display: flex; align-items: center; gap: 6px; font-size: 0.80rem; font-weight: 800; color: var(--text-main); margin-bottom: 6px;">
|
||||||
|
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#10b981" stroke-width="2"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
|
||||||
|
Nombre del Titular de la Cuenta:
|
||||||
|
</label>
|
||||||
|
<input type="text" id="inputAdminTitularSinpe" placeholder="Ej: Soda Escolar Central S.A." oninput="actualizarPreviewAdminSinpe()" style="width: 100%; padding: 10px 14px; border-radius: 9px; border: 1.5px solid var(--border); font-size: 0.95rem; font-weight: 800; color: var(--text-main); background: var(--bg-main); outline: none; box-sizing: border-box;">
|
||||||
|
<span style="display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 4px;">Nombre físico o comercial asociado al número bancario</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Vista previa de cómo lo verán los padres -->
|
||||||
|
<div style="background: var(--card-bg); border: 1.5px dashed var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;">
|
||||||
|
<div style="display: flex; align-items: center; gap: 10px;">
|
||||||
|
<span style="font-size: 1.15rem;">👀</span>
|
||||||
|
<div style="font-size: 0.80rem; color: var(--text-main); font-weight: 700;">
|
||||||
|
Vista previa para los padres:
|
||||||
|
<span style="color: #0284c7; font-weight: 900;" id="previewAdminSinpeTel">8888-8888</span> — Titular:
|
||||||
|
<span style="color: #10b981; font-weight: 900;" id="previewAdminSinpeTitular">Soda Escolar</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span style="font-size: 0.72rem; color: var(--text-muted); font-weight: 600;">Se actualizará en tiempo real</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display: flex; justify-content: flex-end; gap: 10px;">
|
||||||
|
<button type="button" id="btnGuardarAdminSinpe" onclick="guardarAdminSinpeConfig()" class="btn-saas btn-saas-primary" style="padding: 10px 22px; font-size: 0.88rem; font-weight: 800; display: inline-flex; align-items: center; gap: 7px; box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);">
|
||||||
|
<svg width="15" height="15" 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 id="lblBtnGuardarAdminSinpe">Guardar Datos SINPE Móvil</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- SECCIÓN 2: HORARIOS DE RECREOS Y ALMUERZO -->
|
||||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
|
||||||
<div>
|
<div>
|
||||||
<h3 style="margin: 0; font-size: 1.15rem; font-weight: 900; color: var(--text-main);">
|
<h3 style="margin: 0; font-size: 1.15rem; font-weight: 900; color: var(--text-main);">
|
||||||
@@ -5172,6 +5237,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=20.3"></script>
|
<script src="/js/app.js?v=20.4"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+142
-2
@@ -143,7 +143,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
|
|
||||||
// Registrar Service Worker para PWA
|
// Registrar Service Worker para PWA
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.register('/sw.js?v=20.3').then(reg => {
|
navigator.serviceWorker.register('/sw.js?v=20.4').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(() => {});
|
||||||
@@ -3379,6 +3379,32 @@ function initStudentSSE() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Configuración de datos de cobro SINPE de la escuela actualizada en caliente
|
||||||
|
sse.addEventListener('escuela_sinpe_actualizado', (e) => {
|
||||||
|
try {
|
||||||
|
const data = JSON.parse(e.data);
|
||||||
|
const myEscId = (currentUser && currentUser.escuela_id) || (currentStudent && currentStudent.escuela_id) || (currentParentChild && currentParentChild.escuela_id) || null;
|
||||||
|
if (data.escuela_id && myEscId && Number(data.escuela_id) !== Number(myEscId)) return;
|
||||||
|
|
||||||
|
// Actualizar en caliente la pantalla de recarga de los padres
|
||||||
|
const parentNum = document.getElementById('parentSinpeNumero');
|
||||||
|
if (parentNum && data.telefono_sinpe) parentNum.textContent = data.telefono_sinpe;
|
||||||
|
const parentTit = document.getElementById('parentSinpeTitular');
|
||||||
|
if (parentTit && data.nombre_sinpe) parentTit.textContent = data.nombre_sinpe;
|
||||||
|
|
||||||
|
// Actualizar campos del admin si está en su panel
|
||||||
|
if (currentUser && currentUser.rol === 'admin') {
|
||||||
|
const inpTel = document.getElementById('inputAdminTelefonoSinpe');
|
||||||
|
const inpTitular = document.getElementById('inputAdminTitularSinpe');
|
||||||
|
if (inpTel) inpTel.value = data.telefono_sinpe || '';
|
||||||
|
if (inpTitular) inpTitular.value = data.nombre_sinpe || '';
|
||||||
|
if (typeof actualizarPreviewAdminSinpe === 'function') actualizarPreviewAdminSinpe();
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('Error en SSE escuela_sinpe_actualizado:', 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 {
|
||||||
@@ -6197,6 +6223,40 @@ function switchAdminTab(tabName) {
|
|||||||
async function cargarHorariosAdmin() {
|
async function cargarHorariosAdmin() {
|
||||||
try {
|
try {
|
||||||
const escId = (currentUser && currentUser.escuela_id) || 1;
|
const escId = (currentUser && currentUser.escuela_id) || 1;
|
||||||
|
// 1. Cargar información completa de la escuela (Datos SINPE y Horarios)
|
||||||
|
const resInfo = await fetch(`/api/admin/escuela/info?escuela_id=${escId}`);
|
||||||
|
const dataInfo = await resInfo.json();
|
||||||
|
if (dataInfo && dataInfo.escuela) {
|
||||||
|
const esc = dataInfo.escuela;
|
||||||
|
const inpTel = document.getElementById('inputAdminTelefonoSinpe');
|
||||||
|
const inpTitular = document.getElementById('inputAdminTitularSinpe');
|
||||||
|
if (inpTel) inpTel.value = esc.telefono_sinpe || '8888-8888';
|
||||||
|
if (inpTitular) inpTitular.value = esc.nombre_sinpe || esc.nombre || 'Soda Escolar';
|
||||||
|
actualizarPreviewAdminSinpe();
|
||||||
|
|
||||||
|
currentSchoolHorarios = {
|
||||||
|
hora_recreo_1: esc.hora_recreo_1 || '09:30',
|
||||||
|
hora_almuerzo: esc.hora_almuerzo || '11:45',
|
||||||
|
hora_recreo_2: esc.hora_recreo_2 || '13:45',
|
||||||
|
hora_recreo_1_fmt: esc.hora_recreo_1_fmt || '9:30 AM',
|
||||||
|
hora_almuerzo_fmt: esc.hora_almuerzo_fmt || '11:45 AM',
|
||||||
|
hora_recreo_2_fmt: esc.hora_recreo_2_fmt || '1:45 PM'
|
||||||
|
};
|
||||||
|
window.schoolHorarios = currentSchoolHorarios;
|
||||||
|
|
||||||
|
const inpR1 = document.getElementById('inputAdminHoraRecreo1');
|
||||||
|
const inpAlm = document.getElementById('inputAdminHoraAlmuerzo');
|
||||||
|
const inpR2 = document.getElementById('inputAdminHoraRecreo2');
|
||||||
|
|
||||||
|
if (inpR1) inpR1.value = currentSchoolHorarios.hora_recreo_1;
|
||||||
|
if (inpAlm) inpAlm.value = currentSchoolHorarios.hora_almuerzo;
|
||||||
|
if (inpR2) inpR2.value = currentSchoolHorarios.hora_recreo_2;
|
||||||
|
|
||||||
|
actualizarTextosHorariosPreordenes();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback a solo horarios si fuera necesario
|
||||||
const res = await fetch(`/api/escuela/horarios?escuela_id=${escId}`);
|
const res = await fetch(`/api/escuela/horarios?escuela_id=${escId}`);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (data && data.horarios) {
|
if (data && data.horarios) {
|
||||||
@@ -6214,10 +6274,90 @@ async function cargarHorariosAdmin() {
|
|||||||
actualizarTextosHorariosPreordenes();
|
actualizarTextosHorariosPreordenes();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error cargando horarios admin:', err);
|
console.error('Error cargando configuración admin:', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function actualizarPreviewAdminSinpe() {
|
||||||
|
const inpTel = document.getElementById('inputAdminTelefonoSinpe');
|
||||||
|
const inpTitular = document.getElementById('inputAdminTitularSinpe');
|
||||||
|
const prevTel = document.getElementById('previewAdminSinpeTel');
|
||||||
|
const prevTitular = document.getElementById('previewAdminSinpeTitular');
|
||||||
|
|
||||||
|
const telVal = inpTel ? (inpTel.value.trim() || '8888-8888') : '8888-8888';
|
||||||
|
const titularVal = inpTitular ? (inpTitular.value.trim() || 'Soda Escolar') : 'Soda Escolar';
|
||||||
|
|
||||||
|
if (prevTel) prevTel.textContent = telVal;
|
||||||
|
if (prevTitular) prevTitular.textContent = titularVal;
|
||||||
|
}
|
||||||
|
window.actualizarPreviewAdminSinpe = actualizarPreviewAdminSinpe;
|
||||||
|
|
||||||
|
async function guardarAdminSinpeConfig() {
|
||||||
|
const inpTel = document.getElementById('inputAdminTelefonoSinpe');
|
||||||
|
const inpTitular = document.getElementById('inputAdminTitularSinpe');
|
||||||
|
const btn = document.getElementById('btnGuardarAdminSinpe');
|
||||||
|
const lblBtn = document.getElementById('lblBtnGuardarAdminSinpe');
|
||||||
|
|
||||||
|
let tel = inpTel ? inpTel.value.trim() : '';
|
||||||
|
const titular = inpTitular ? inpTitular.value.trim() : '';
|
||||||
|
|
||||||
|
if (!tel) {
|
||||||
|
alert('Por favor ingresa el número telefónico para SINPE Móvil.');
|
||||||
|
if (inpTel) inpTel.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const digits = tel.replace(/\D/g, '');
|
||||||
|
if (digits.length < 8) {
|
||||||
|
alert('El número de teléfono debe contener al menos 8 dígitos.');
|
||||||
|
if (inpTel) inpTel.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (digits.length === 8 && !tel.includes('-')) {
|
||||||
|
tel = `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
||||||
|
if (inpTel) inpTel.value = tel;
|
||||||
|
actualizarPreviewAdminSinpe();
|
||||||
|
}
|
||||||
|
|
||||||
|
const escId = (currentUser && currentUser.escuela_id) || 1;
|
||||||
|
|
||||||
|
if (btn) btn.disabled = true;
|
||||||
|
if (lblBtn) lblBtn.textContent = 'Guardando en caliente...';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api/admin/escuela/sinpe', {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({
|
||||||
|
escuela_id: escId,
|
||||||
|
telefono_sinpe: tel,
|
||||||
|
nombre_sinpe: titular
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await res.json();
|
||||||
|
if (!res.ok || !data.success) {
|
||||||
|
throw new Error(data.error || 'No se pudieron guardar los datos de SINPE');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.sounds) window.sounds.playCoin();
|
||||||
|
await showAppAlert({
|
||||||
|
title: '¡Datos SINPE Actualizados!',
|
||||||
|
message: `El número de cobro SINPE Móvil de tu soda se actualizó exitosamente en caliente.\n\n• Teléfono: ${data.escuela.telefono_sinpe}\n• Titular: ${data.escuela.nombre_sinpe}\n\nA partir de este momento, todos los padres de familia verán estos nuevos datos de transferencia en su aplicación.`,
|
||||||
|
type: 'success',
|
||||||
|
confirmText: 'Entendido'
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
if (window.sounds) window.sounds.playError();
|
||||||
|
alert('Error al guardar datos SINPE: ' + err.message);
|
||||||
|
} finally {
|
||||||
|
if (btn) btn.disabled = false;
|
||||||
|
if (lblBtn) lblBtn.textContent = 'Guardar Datos SINPE Móvil';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.guardarAdminSinpeConfig = guardarAdminSinpeConfig;
|
||||||
|
|
||||||
async function guardarHorariosEscolares() {
|
async function guardarHorariosEscolares() {
|
||||||
const inpR1 = document.getElementById('inputAdminHoraRecreo1');
|
const inpR1 = document.getElementById('inputAdminHoraRecreo1');
|
||||||
const inpAlm = document.getElementById('inputAdminHoraAlmuerzo');
|
const inpAlm = document.getElementById('inputAdminHoraAlmuerzo');
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
// SiboPay PWA Service Worker v20.3 - Ultra Fast Startup & Stale-While-Revalidate
|
// SiboPay PWA Service Worker v20.4 - Ultra Fast Startup & Stale-While-Revalidate
|
||||||
const CACHE_NAME = 'sibopay-v20.3';
|
const CACHE_NAME = 'sibopay-v20.4';
|
||||||
const STATIC_ASSETS = [
|
const STATIC_ASSETS = [
|
||||||
'/',
|
'/',
|
||||||
'/index.html',
|
'/index.html',
|
||||||
@@ -11,7 +11,7 @@ const STATIC_ASSETS = [
|
|||||||
'/css/styles.css?v=19.9',
|
'/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=20.3',
|
'/js/app.js?v=20.4',
|
||||||
'/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',
|
||||||
|
|||||||
@@ -986,6 +986,68 @@ function obtenerHorariosEscuela(escuelaId = 1) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function obtenerDatosEscuela(escuelaId = 1) {
|
||||||
|
try {
|
||||||
|
const row = db.prepare('SELECT id, codigo, nombre, telefono_sinpe, nombre_sinpe, concesionario, hora_recreo_1, hora_almuerzo, hora_recreo_2, activo FROM escuelas WHERE id = ?').get(escuelaId || 1);
|
||||||
|
if (row) {
|
||||||
|
return {
|
||||||
|
id: row.id,
|
||||||
|
codigo: row.codigo,
|
||||||
|
nombre: row.nombre,
|
||||||
|
telefono_sinpe: row.telefono_sinpe || '8888-8888',
|
||||||
|
nombre_sinpe: row.nombre_sinpe || row.nombre || 'Soda Escolar',
|
||||||
|
concesionario: row.concesionario || '',
|
||||||
|
hora_recreo_1: row.hora_recreo_1 || '09:30',
|
||||||
|
hora_almuerzo: row.hora_almuerzo || '11:45',
|
||||||
|
hora_recreo_2: row.hora_recreo_2 || '13:45',
|
||||||
|
hora_recreo_1_fmt: formatTime12h(row.hora_recreo_1 || '09:30'),
|
||||||
|
hora_almuerzo_fmt: formatTime12h(row.hora_almuerzo || '11:45'),
|
||||||
|
hora_recreo_2_fmt: formatTime12h(row.hora_recreo_2 || '13:45'),
|
||||||
|
activo: row.activo
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error obteniendo datos escuela:', e);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: 1,
|
||||||
|
codigo: 'ESC01',
|
||||||
|
nombre: 'Soda Escolar Central',
|
||||||
|
telefono_sinpe: '8888-8888',
|
||||||
|
nombre_sinpe: 'Soda Escolar Central',
|
||||||
|
concesionario: 'Concesionario Soda Central',
|
||||||
|
hora_recreo_1: '09:30',
|
||||||
|
hora_almuerzo: '11:45',
|
||||||
|
hora_recreo_2: '13:45',
|
||||||
|
hora_recreo_1_fmt: '9:30 AM',
|
||||||
|
hora_almuerzo_fmt: '11:45 AM',
|
||||||
|
hora_recreo_2_fmt: '1:45 PM',
|
||||||
|
activo: 1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function actualizarSinpeEscuela(escuelaId = 1, { telefono_sinpe, nombre_sinpe, concesionario }) {
|
||||||
|
const tel = String(telefono_sinpe || '8888-8888').trim();
|
||||||
|
const nom = String(nombre_sinpe || '').trim();
|
||||||
|
const conce = concesionario !== undefined ? String(concesionario).trim() : null;
|
||||||
|
|
||||||
|
if (conce !== null) {
|
||||||
|
db.prepare(`
|
||||||
|
UPDATE escuelas
|
||||||
|
SET telefono_sinpe = ?, nombre_sinpe = ?, concesionario = ?
|
||||||
|
WHERE id = ?
|
||||||
|
`).run(tel, nom, conce, escuelaId || 1);
|
||||||
|
} else {
|
||||||
|
db.prepare(`
|
||||||
|
UPDATE escuelas
|
||||||
|
SET telefono_sinpe = ?, nombre_sinpe = ?
|
||||||
|
WHERE id = ?
|
||||||
|
`).run(tel, nom, escuelaId || 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return obtenerDatosEscuela(escuelaId || 1);
|
||||||
|
}
|
||||||
|
|
||||||
function actualizarHorariosEscuela(escuelaId = 1, { hora_recreo_1, hora_almuerzo, hora_recreo_2 }) {
|
function actualizarHorariosEscuela(escuelaId = 1, { hora_recreo_1, hora_almuerzo, hora_recreo_2 }) {
|
||||||
const r1 = hora_recreo_1 || '09:30';
|
const r1 = hora_recreo_1 || '09:30';
|
||||||
const alm = hora_almuerzo || '11:45';
|
const alm = hora_almuerzo || '11:45';
|
||||||
@@ -2654,6 +2716,8 @@ module.exports = {
|
|||||||
enriquecerEstudianteFinanzas,
|
enriquecerEstudianteFinanzas,
|
||||||
obtenerHorariosEscuela,
|
obtenerHorariosEscuela,
|
||||||
actualizarHorariosEscuela,
|
actualizarHorariosEscuela,
|
||||||
|
obtenerDatosEscuela,
|
||||||
|
actualizarSinpeEscuela,
|
||||||
formatTime12h,
|
formatTime12h,
|
||||||
buscarSinpeUniversalDev,
|
buscarSinpeUniversalDev,
|
||||||
forzarAprobarSolicitudDev,
|
forzarAprobarSolicitudDev,
|
||||||
|
|||||||
+49
-1
@@ -35,6 +35,8 @@ const {
|
|||||||
enriquecerEstudianteFinanzas,
|
enriquecerEstudianteFinanzas,
|
||||||
obtenerHorariosEscuela,
|
obtenerHorariosEscuela,
|
||||||
actualizarHorariosEscuela,
|
actualizarHorariosEscuela,
|
||||||
|
obtenerDatosEscuela,
|
||||||
|
actualizarSinpeEscuela,
|
||||||
formatTime12h,
|
formatTime12h,
|
||||||
buscarSinpeUniversalDev,
|
buscarSinpeUniversalDev,
|
||||||
forzarAprobarSolicitudDev,
|
forzarAprobarSolicitudDev,
|
||||||
@@ -3558,7 +3560,53 @@ app.put('/api/admin/escuela/horarios', (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ==========================================
|
// Obtener información y configuración completa de la escuela (Admin / Developer)
|
||||||
|
app.get('/api/admin/escuela/info', (req, res) => {
|
||||||
|
try {
|
||||||
|
const escuelaId = req.query.escuela_id ? parseInt(req.query.escuela_id, 10) : 1;
|
||||||
|
const info = obtenerDatosEscuela(escuelaId);
|
||||||
|
res.json({ success: true, escuela: info });
|
||||||
|
} catch (err) {
|
||||||
|
res.status(500).json({ error: err.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Modificar Teléfono y Titular de SINPE Móvil de la Escuela (Admin / Developer)
|
||||||
|
app.put('/api/admin/escuela/sinpe', (req, res) => {
|
||||||
|
try {
|
||||||
|
const { escuela_id, telefono_sinpe, nombre_sinpe, concesionario } = req.body;
|
||||||
|
if (!telefono_sinpe || !String(telefono_sinpe).trim()) {
|
||||||
|
return res.status(400).json({ error: 'El número de teléfono SINPE Móvil es obligatorio' });
|
||||||
|
}
|
||||||
|
const cleanTel = String(telefono_sinpe).trim();
|
||||||
|
const cleanNom = String(nombre_sinpe || '').trim();
|
||||||
|
|
||||||
|
const escuelaId = escuela_id ? parseInt(escuela_id, 10) : 1;
|
||||||
|
const actualizada = actualizarSinpeEscuela(escuelaId, {
|
||||||
|
telefono_sinpe: cleanTel,
|
||||||
|
nombre_sinpe: cleanNom,
|
||||||
|
concesionario
|
||||||
|
});
|
||||||
|
|
||||||
|
// Notificar en tiempo real por SSE para que cualquier pantalla activa actualice los datos en caliente
|
||||||
|
broadcastEvent('escuela_sinpe_actualizado', {
|
||||||
|
escuela_id: escuelaId,
|
||||||
|
telefono_sinpe: cleanTel,
|
||||||
|
nombre_sinpe: cleanNom
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`[SINPE] 📲 Datos de cobro SINPE Móvil actualizados para Escuela #${escuelaId}: Tel ${cleanTel} | Titular "${cleanNom}"`);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: 'Datos de cobro SINPE Móvil actualizados correctamente',
|
||||||
|
escuela: actualizada
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error actualizando SINPE de escuela:', err);
|
||||||
|
res.status(500).json({ error: err.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
// 1. ESTUDIANTES Y QR
|
// 1. ESTUDIANTES Y QR
|
||||||
// ==========================================
|
// ==========================================
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user