feat: configuracion de horarios escolares admin, reporte excel recargas sinpe y remocion enlaces footer
This commit is contained in:
+107
-9
@@ -684,6 +684,10 @@
|
||||
<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>
|
||||
</button>
|
||||
<button class="admin-tab-btn" id="btnTabAdminHorarios" onclick="switchAdminTab('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>
|
||||
<span>Horarios & Recreos</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- TAB 1: INVENTARIO Y STOCK -->
|
||||
@@ -761,6 +765,38 @@
|
||||
<div id="adminSinpeRequestsList" style="display: flex; flex-direction: column; gap: 12px;">
|
||||
<!-- Solicitudes SINPE pendientes cargadas dinámicamente -->
|
||||
</div>
|
||||
|
||||
<!-- BARRA DE EXPORTACIÓN EXCEL DE RECARGAS SINPE -->
|
||||
<div style="margin-top: 16px; padding: 14px; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 12px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; gap: 8px;">
|
||||
<strong style="font-size: 0.86rem; color: #0f172a; display: flex; align-items: center; gap: 6px;">
|
||||
<span>📊 Exportar Reporte de Recargas / Depósitos (Excel)</span>
|
||||
</strong>
|
||||
<button type="button" onclick="descargarReporteRecargasExcel(true)" class="btn-saas btn-saas-outline" style="height: 28px; padding: 0 10px; font-size: 0.74rem; font-weight: 700; color: #0284c7; border-color: #bae6fd; background: #f0f9ff;" title="Descargar todas las recargas registradas sin filtro">
|
||||
⬇️ Todo el Historial
|
||||
</button>
|
||||
</div>
|
||||
<div style="display: flex; gap: 8px; flex-wrap: wrap; align-items: center;">
|
||||
<div style="display: flex; align-items: center; gap: 4px; font-size: 0.76rem; color: #64748b;">
|
||||
<span>Desde:</span>
|
||||
<input type="date" id="inputExportRecargasDesde" style="padding: 5px 8px; font-size: 0.78rem; border-radius: 6px; border: 1px solid #cbd5e1; outline: none; background: white;">
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 4px; font-size: 0.76rem; color: #64748b;">
|
||||
<span>Hasta:</span>
|
||||
<input type="date" id="inputExportRecargasHasta" style="padding: 5px 8px; font-size: 0.78rem; border-radius: 6px; border: 1px solid #cbd5e1; outline: none; background: white;">
|
||||
</div>
|
||||
<select id="selectExportRecargasEstado" style="padding: 5px 8px; font-size: 0.78rem; border-radius: 6px; border: 1px solid #cbd5e1; outline: none; background: white;">
|
||||
<option value="todos">Todos los Estados</option>
|
||||
<option value="aprobado">Solo Aprobadas</option>
|
||||
<option value="pendiente">Solo Pendientes</option>
|
||||
<option value="rechazado">Solo Rechazadas</option>
|
||||
</select>
|
||||
<button type="button" onclick="descargarReporteRecargasExcel(false)" class="btn-saas btn-saas-primary" style="height: 32px; padding: 0 14px; font-size: 0.78rem; font-weight: 800; display: inline-flex; align-items: center; gap: 5px;">
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
|
||||
<span>Descargar Filtrado</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SEPARADOR CON RECARGA EN EFECTIVO -->
|
||||
@@ -949,6 +985,75 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TAB 6: HORARIOS ESCOLARES (RECREOS Y ALMUERZO) -->
|
||||
<div id="adminTabContentHorarios" class="admin-card" style="display: none; max-width: 780px; margin: 0 auto;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
|
||||
<div>
|
||||
<h3 style="margin: 0; font-size: 1.15rem; font-weight: 900; color: var(--text-main);">
|
||||
⏰ Horarios de Recreos y Almuerzo
|
||||
</h3>
|
||||
<p style="margin: 3px 0 0 0; font-size: 0.78rem; color: var(--text-muted);">
|
||||
Configura los turnos específicos de tu escuela. Los pedidos anticipados de estudiantes y padres se agruparán bajo estos horarios.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="background: var(--bg-main); border: 1.5px solid var(--border); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 16px;">
|
||||
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px;">
|
||||
<!-- Primer Recreo -->
|
||||
<div style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.03);">
|
||||
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 10px;">
|
||||
<span style="font-size: 1.3rem;">🔔</span>
|
||||
<div>
|
||||
<strong style="display: block; font-size: 0.90rem; color: var(--text-main);">1er Recreo</strong>
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted);">Turno de la Mañana</span>
|
||||
</div>
|
||||
</div>
|
||||
<label style="display: block; font-size: 0.74rem; font-weight: 700; color: var(--text-muted); margin-bottom: 5px;">Hora de Inicio:</label>
|
||||
<input type="time" id="inputAdminHoraRecreo1" value="09:30" style="width: 100%; padding: 8px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-size: 1.05rem; font-weight: 800; color: var(--text-main); background: var(--bg-main); outline: none; box-sizing: border-box;">
|
||||
</div>
|
||||
|
||||
<!-- Almuerzo -->
|
||||
<div style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.03);">
|
||||
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 10px;">
|
||||
<span style="font-size: 1.3rem;">🍲</span>
|
||||
<div>
|
||||
<strong style="display: block; font-size: 0.90rem; color: var(--text-main);">Almuerzo</strong>
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted);">Comedor / Almuerzo</span>
|
||||
</div>
|
||||
</div>
|
||||
<label style="display: block; font-size: 0.74rem; font-weight: 700; color: var(--text-muted); margin-bottom: 5px;">Hora de Inicio:</label>
|
||||
<input type="time" id="inputAdminHoraAlmuerzo" value="11:45" style="width: 100%; padding: 8px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-size: 1.05rem; font-weight: 800; color: var(--text-main); background: var(--bg-main); outline: none; box-sizing: border-box;">
|
||||
</div>
|
||||
|
||||
<!-- Segundo Recreo -->
|
||||
<div style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.03);">
|
||||
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 10px;">
|
||||
<span style="font-size: 1.3rem;">⏰</span>
|
||||
<div>
|
||||
<strong style="display: block; font-size: 0.90rem; color: var(--text-main);">2do Recreo</strong>
|
||||
<span style="font-size: 0.72rem; color: var(--text-muted);">Turno de la Tarde</span>
|
||||
</div>
|
||||
</div>
|
||||
<label style="display: block; font-size: 0.74rem; font-weight: 700; color: var(--text-muted); margin-bottom: 5px;">Hora de Inicio:</label>
|
||||
<input type="time" id="inputAdminHoraRecreo2" value="13:45" style="width: 100%; padding: 8px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-size: 1.05rem; font-weight: 800; color: var(--text-main); background: var(--bg-main); outline: none; box-sizing: border-box;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="background: #e0f2fe; border: 1.5px solid #bae6fd; border-radius: 10px; padding: 12px 14px; font-size: 0.78rem; color: #0369a1; display: flex; align-items: center; gap: 10px;">
|
||||
<span style="font-size: 1.2rem;">💡</span>
|
||||
<span>Al presionar <strong>Guardar Horarios</strong>, los cambios se aplican automáticamente para padres y estudiantes en el selector de pedidos y para los cajeros en la terminal POS.</span>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px;">
|
||||
<button type="button" onclick="guardarHorariosEscolares()" class="btn-saas btn-saas-primary" style="padding: 10px 24px; font-size: 0.88rem; font-weight: 800; display: inline-flex; align-items: center; gap: 6px; 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>Guardar Horarios</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ========================================== -->
|
||||
@@ -1916,14 +2021,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- ENLACES DE ACCESO RÁPIDO PARA DEMO Y REVISIÓN -->
|
||||
<div style="margin: 30px 16px; padding: 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; font-size: 0.82rem; text-align: center;">
|
||||
<p style="font-weight: 700; margin-bottom: 8px; color: var(--text-main);">Acceso Rápido del Sistema:</p>
|
||||
<div style="display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;">
|
||||
<a href="/pos.html" target="_blank" style="color: #0284c7; font-weight: 700; text-decoration: none; padding: 4px 10px; background: #e0f2fe; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px;"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg> Terminal Soda (Caja & QR)</a>
|
||||
<a href="/carnet.html" target="_blank" style="color: #10b981; font-weight: 700; text-decoration: none; padding: 4px 10px; background: #d1fae5; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px;"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 6 2 18 2 18 9"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect width="12" height="8" x="6" y="14"/></svg> Carnés Físicos para Imprimir</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- MODAL INMERSIVO: CÓDIGO QR PARA PRESENTAR EN LA SODA (DISEÑO SIBOPAY EXACTO) -->
|
||||
@@ -3179,6 +3277,6 @@
|
||||
<script src="/js/sounds.js?v=9.6"></script>
|
||||
<script src="/js/jsQR.js"></script>
|
||||
<script src="/js/food-icons.js?v=1.1"></script>
|
||||
<script src="/js/app.js?v=13.1"></script>
|
||||
<script src="/js/app.js?v=13.2"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+164
-8
@@ -64,6 +64,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
applyCardTheme(getSavedCardTheme());
|
||||
}
|
||||
checkHttpsEnvironment();
|
||||
cargarHorariosPublicos();
|
||||
|
||||
// Registrar Service Worker para PWA
|
||||
if ('serviceWorker' in navigator) {
|
||||
@@ -1312,14 +1313,57 @@ function normalizeMomentoKey(val) {
|
||||
return v;
|
||||
}
|
||||
|
||||
let currentSchoolHorarios = {
|
||||
hora_recreo_1_fmt: '9:30 AM',
|
||||
hora_almuerzo_fmt: '11:45 AM',
|
||||
hora_recreo_2_fmt: '1:45 PM'
|
||||
};
|
||||
|
||||
async function cargarHorariosPublicos() {
|
||||
try {
|
||||
const res = await fetch('/api/escuela/horarios');
|
||||
const data = await res.json();
|
||||
if (data && data.horarios) {
|
||||
currentSchoolHorarios = data.horarios;
|
||||
window.schoolHorarios = data.horarios;
|
||||
actualizarTextosHorariosPreordenes();
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Error cargando horarios escolares:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function actualizarTextosHorariosPreordenes() {
|
||||
const h = window.schoolHorarios || currentSchoolHorarios || {};
|
||||
const r1Text = h.hora_recreo_1_fmt || '9:30 AM';
|
||||
const almText = h.hora_almuerzo_fmt || '11:45 AM';
|
||||
const r2Text = h.hora_recreo_2_fmt || '1:45 PM';
|
||||
|
||||
const select = document.getElementById('momentoEntregaSelect');
|
||||
if (select) {
|
||||
const prev = select.value;
|
||||
select.innerHTML = `
|
||||
<option value="recreo_1">🔔 1er Recreo de la Mañana (${r1Text})</option>
|
||||
<option value="almuerzo">🍲 Hora de Almuerzo (${almText})</option>
|
||||
<option value="recreo_2">⏰ 2do Recreo de la Tarde (${r2Text})</option>
|
||||
`;
|
||||
if (prev) select.value = prev;
|
||||
}
|
||||
}
|
||||
|
||||
function getMomentoBadge(val) {
|
||||
const key = normalizeMomentoKey(val);
|
||||
const h = window.schoolHorarios || currentSchoolHorarios || {};
|
||||
const r1Text = h.hora_recreo_1_fmt || '9:30 AM';
|
||||
const almText = h.hora_almuerzo_fmt || '11:45 AM';
|
||||
const r2Text = h.hora_recreo_2_fmt || '1:45 PM';
|
||||
|
||||
switch (key) {
|
||||
case 'recreo_1':
|
||||
return {
|
||||
key: 'recreo_1',
|
||||
title: '1er Recreo (9:30 AM)',
|
||||
full: '1er Recreo de la Mañana (9:30 AM)',
|
||||
title: `1er Recreo (${r1Text})`,
|
||||
full: `1er Recreo de la Mañana (${r1Text})`,
|
||||
icon: '🔔',
|
||||
bg: '#fffbeb',
|
||||
border: '#f59e0b',
|
||||
@@ -1331,8 +1375,8 @@ function getMomentoBadge(val) {
|
||||
case 'almuerzo':
|
||||
return {
|
||||
key: 'almuerzo',
|
||||
title: 'Almuerzo (11:45 AM)',
|
||||
full: 'Hora de Almuerzo (11:45 AM)',
|
||||
title: `Almuerzo (${almText})`,
|
||||
full: `Hora de Almuerzo (${almText})`,
|
||||
icon: '🍲',
|
||||
bg: '#f0fdf4',
|
||||
border: '#16a34a',
|
||||
@@ -1344,8 +1388,8 @@ function getMomentoBadge(val) {
|
||||
case 'recreo_2':
|
||||
return {
|
||||
key: 'recreo_2',
|
||||
title: '2do Recreo (1:45 PM)',
|
||||
full: '2do Recreo de la Tarde (1:45 PM)',
|
||||
title: `2do Recreo (${r2Text})`,
|
||||
full: `2do Recreo de la Tarde (${r2Text})`,
|
||||
icon: '⏰',
|
||||
bg: '#eef2ff',
|
||||
border: '#6366f1',
|
||||
@@ -1376,7 +1420,7 @@ function getMomentoBadge(val) {
|
||||
bg: '#f8fafc',
|
||||
border: '#0284c7',
|
||||
text: '#0369a1',
|
||||
badgeBg: '#e0f2fe',
|
||||
badgeBg: '#e0e7fe',
|
||||
badgeColor: '#0369a1',
|
||||
badgeBorder: '#bae6fd'
|
||||
};
|
||||
@@ -2649,6 +2693,25 @@ function initStudentSSE() {
|
||||
}
|
||||
} catch (err) {}
|
||||
});
|
||||
|
||||
sse.addEventListener('horarios_actualizados', (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.data);
|
||||
if (data) {
|
||||
currentSchoolHorarios = data;
|
||||
window.schoolHorarios = data;
|
||||
actualizarTextosHorariosPreordenes();
|
||||
if (currentUser && currentUser.rol === 'admin') {
|
||||
const inpR1 = document.getElementById('inputAdminHoraRecreo1');
|
||||
const inpAlm = document.getElementById('inputAdminHoraAlmuerzo');
|
||||
const inpR2 = document.getElementById('inputAdminHoraRecreo2');
|
||||
if (inpR1) inpR1.value = currentSchoolHorarios.hora_recreo_1 || '09:30';
|
||||
if (inpAlm) inpAlm.value = currentSchoolHorarios.hora_almuerzo || '11:45';
|
||||
if (inpR2) inpR2.value = currentSchoolHorarios.hora_recreo_2 || '13:45';
|
||||
}
|
||||
}
|
||||
} catch (err) {}
|
||||
});
|
||||
}
|
||||
|
||||
// Sincronización en segundo plano: al volver a la pestaña/desbloquear el teléfono
|
||||
@@ -4541,7 +4604,7 @@ async function confirmLinkValidatedChild() {
|
||||
// ==========================================
|
||||
|
||||
function switchAdminTab(tabName) {
|
||||
const tabs = ['inventario', 'estudiantes', 'recarga', 'movimientos', 'personal'];
|
||||
const tabs = ['inventario', 'estudiantes', 'recarga', 'movimientos', 'personal', 'horarios'];
|
||||
tabs.forEach(t => {
|
||||
const btn = document.getElementById(`btnTabAdmin${t.charAt(0).toUpperCase() + t.slice(1)}`);
|
||||
const content = document.getElementById(`adminTabContent${t.charAt(0).toUpperCase() + t.slice(1)}`);
|
||||
@@ -4558,11 +4621,101 @@ function switchAdminTab(tabName) {
|
||||
if (!adminSelectedStudent) {
|
||||
clearAdminSelectedStudent();
|
||||
}
|
||||
} else if (tabName === 'horarios') {
|
||||
cargarHorariosAdmin();
|
||||
}
|
||||
|
||||
if (window.sounds) window.sounds.playTap();
|
||||
}
|
||||
|
||||
async function cargarHorariosAdmin() {
|
||||
try {
|
||||
const res = await fetch('/api/escuela/horarios');
|
||||
const data = await res.json();
|
||||
if (data && data.horarios) {
|
||||
currentSchoolHorarios = data.horarios;
|
||||
window.schoolHorarios = data.horarios;
|
||||
|
||||
const inpR1 = document.getElementById('inputAdminHoraRecreo1');
|
||||
const inpAlm = document.getElementById('inputAdminHoraAlmuerzo');
|
||||
const inpR2 = document.getElementById('inputAdminHoraRecreo2');
|
||||
|
||||
if (inpR1) inpR1.value = currentSchoolHorarios.hora_recreo_1 || '09:30';
|
||||
if (inpAlm) inpAlm.value = currentSchoolHorarios.hora_almuerzo || '11:45';
|
||||
if (inpR2) inpR2.value = currentSchoolHorarios.hora_recreo_2 || '13:45';
|
||||
|
||||
actualizarTextosHorariosPreordenes();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error cargando horarios admin:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function guardarHorariosEscolares() {
|
||||
const inpR1 = document.getElementById('inputAdminHoraRecreo1');
|
||||
const inpAlm = document.getElementById('inputAdminHoraAlmuerzo');
|
||||
const inpR2 = document.getElementById('inputAdminHoraRecreo2');
|
||||
|
||||
const hora1 = inpR1 ? inpR1.value : '09:30';
|
||||
const alm = inpAlm ? inpAlm.value : '11:45';
|
||||
const hora2 = inpR2 ? inpR2.value : '13:45';
|
||||
|
||||
if (!hora1 || !alm || !hora2) {
|
||||
alert('Por favor especifica las horas de los 3 turnos (1er Recreo, Almuerzo y 2do Recreo)');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/admin/escuela/horarios', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
escuela_id: 1,
|
||||
hora_recreo_1: hora1,
|
||||
hora_almuerzo: alm,
|
||||
hora_recreo_2: hora2
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.success && data.horarios) {
|
||||
currentSchoolHorarios = data.horarios;
|
||||
window.schoolHorarios = data.horarios;
|
||||
actualizarTextosHorariosPreordenes();
|
||||
if (window.sounds) window.sounds.playCoin();
|
||||
alert(`✅ Horarios escolares guardados con éxito:\n• 1er Recreo: ${data.horarios.hora_recreo_1_fmt}\n• Almuerzo: ${data.horarios.hora_almuerzo_fmt}\n• 2do Recreo: ${data.horarios.hora_recreo_2_fmt}`);
|
||||
} else {
|
||||
alert('Error guardando horarios: ' + (data.error || 'Ocurrió un error inesperado'));
|
||||
}
|
||||
} catch (err) {
|
||||
alert('Error al comunicarse con el servidor: ' + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
function descargarReporteRecargasExcel(descargarTodo = false) {
|
||||
let url = '/api/admin/export/recargas.csv';
|
||||
if (!descargarTodo) {
|
||||
const desde = document.getElementById('inputExportRecargasDesde')?.value || '';
|
||||
const hasta = document.getElementById('inputExportRecargasHasta')?.value || '';
|
||||
const estado = document.getElementById('selectExportRecargasEstado')?.value || 'todos';
|
||||
|
||||
const params = new URLSearchParams();
|
||||
if (desde) params.append('desde', desde);
|
||||
if (hasta) params.append('hasta', hasta);
|
||||
if (estado && estado !== 'todos') params.append('estado', estado);
|
||||
|
||||
const qs = params.toString();
|
||||
if (qs) url += '?' + qs;
|
||||
}
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.target = '_blank';
|
||||
link.download = '';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
async function loadAdminData() {
|
||||
try {
|
||||
// 1. Cargar resumen y métricas
|
||||
@@ -4597,6 +4750,9 @@ async function loadAdminData() {
|
||||
|
||||
// 5. Cargar solicitudes SINPE pendientes para badge y sección
|
||||
loadAdminSinpeRequests();
|
||||
|
||||
// 6. Cargar horarios escolares para la pestaña de configuración
|
||||
cargarHorariosAdmin();
|
||||
} catch (err) {
|
||||
console.error('Error cargando datos de administración:', err);
|
||||
}
|
||||
|
||||
+57
-6
@@ -101,6 +101,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
await loadCatalog();
|
||||
await loadPreOrders();
|
||||
await loadSinpeRequests();
|
||||
await cargarHorariosPos();
|
||||
// La cámara se activa bajo demanda al cobrar o identificar, NO al entrar
|
||||
initSSE();
|
||||
initPistolScanner();
|
||||
@@ -1322,14 +1323,51 @@ function normalizeMomentoKey(val) {
|
||||
return v;
|
||||
}
|
||||
|
||||
let posSchoolHorarios = {
|
||||
hora_recreo_1_fmt: '9:30 AM',
|
||||
hora_almuerzo_fmt: '11:45 AM',
|
||||
hora_recreo_2_fmt: '1:45 PM'
|
||||
};
|
||||
|
||||
async function cargarHorariosPos() {
|
||||
try {
|
||||
const res = await fetch('/api/escuela/horarios');
|
||||
const data = await res.json();
|
||||
if (data && data.horarios) {
|
||||
posSchoolHorarios = data.horarios;
|
||||
actualizarPillsHorariosPos();
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Error cargando horarios en POS:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function actualizarPillsHorariosPos() {
|
||||
const r1Btn = document.querySelector('#filterPillRecreo_1 span:first-child');
|
||||
const almBtn = document.querySelector('#filterPillAlmuerzo span:first-child');
|
||||
const r2Btn = document.querySelector('#filterPillRecreo_2 span:first-child');
|
||||
|
||||
const r1Text = posSchoolHorarios.hora_recreo_1_fmt || '9:30 AM';
|
||||
const almText = posSchoolHorarios.hora_almuerzo_fmt || '11:45 AM';
|
||||
const r2Text = posSchoolHorarios.hora_recreo_2_fmt || '1:45 PM';
|
||||
|
||||
if (r1Btn) r1Btn.textContent = `🔔 1er Recreo (${r1Text})`;
|
||||
if (almBtn) almBtn.textContent = `🍲 Almuerzo (${almText})`;
|
||||
if (r2Btn) r2Btn.textContent = `⏰ 2do Recreo (${r2Text})`;
|
||||
}
|
||||
|
||||
function getMomentoBadge(val) {
|
||||
const key = normalizeMomentoKey(val);
|
||||
const r1Text = posSchoolHorarios.hora_recreo_1_fmt || '9:30 AM';
|
||||
const almText = posSchoolHorarios.hora_almuerzo_fmt || '11:45 AM';
|
||||
const r2Text = posSchoolHorarios.hora_recreo_2_fmt || '1:45 PM';
|
||||
|
||||
switch (key) {
|
||||
case 'recreo_1':
|
||||
return {
|
||||
key: 'recreo_1',
|
||||
title: '1er Recreo (9:30 AM)',
|
||||
full: '1er Recreo de la Mañana (9:30 AM)',
|
||||
title: `1er Recreo (${r1Text})`,
|
||||
full: `1er Recreo de la Mañana (${r1Text})`,
|
||||
icon: '🔔',
|
||||
bg: '#fffbeb',
|
||||
border: '#f59e0b',
|
||||
@@ -1341,8 +1379,8 @@ function getMomentoBadge(val) {
|
||||
case 'almuerzo':
|
||||
return {
|
||||
key: 'almuerzo',
|
||||
title: 'Almuerzo (11:45 AM)',
|
||||
full: 'Hora de Almuerzo (11:45 AM)',
|
||||
title: `Almuerzo (${almText})`,
|
||||
full: `Hora de Almuerzo (${almText})`,
|
||||
icon: '🍲',
|
||||
bg: '#f0fdf4',
|
||||
border: '#16a34a',
|
||||
@@ -1354,8 +1392,8 @@ function getMomentoBadge(val) {
|
||||
case 'recreo_2':
|
||||
return {
|
||||
key: 'recreo_2',
|
||||
title: '2do Recreo (1:45 PM)',
|
||||
full: '2do Recreo de la Tarde (1:45 PM)',
|
||||
title: `2do Recreo (${r2Text})`,
|
||||
full: `2do Recreo de la Tarde (${r2Text})`,
|
||||
icon: '⏰',
|
||||
bg: '#eef2ff',
|
||||
border: '#6366f1',
|
||||
@@ -1802,6 +1840,19 @@ function initSSE() {
|
||||
loadCatalog();
|
||||
});
|
||||
|
||||
sseSource.addEventListener('horarios_actualizados', (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.data);
|
||||
if (data) {
|
||||
posSchoolHorarios = data;
|
||||
actualizarPillsHorariosPos();
|
||||
renderPreOrdersList();
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Error en SSE horarios_actualizados:', err);
|
||||
}
|
||||
});
|
||||
|
||||
sseSource.addEventListener('cierre_caja_realizado', (e) => {
|
||||
try {
|
||||
const res = JSON.parse(e.data);
|
||||
|
||||
+6
-2
@@ -283,7 +283,11 @@
|
||||
</div>
|
||||
<p style="font-size: 0.78rem; color: #64748b; margin: 3px 0 0 0;">Verifica que el dinero ingresó a la cuenta bancaria de la soda antes de aprobar la recarga.</p>
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: flex; gap: 8px; align-items: center;">
|
||||
<a href="/api/admin/export/recargas.csv" target="_blank" class="btn-saas btn-saas-outline" style="height: 36px; padding: 0 12px; text-decoration: none; font-weight: 700; color: #0284c7; border-color: #bae6fd; background: #f0f9ff; display: inline-flex; align-items: center; gap: 6px;" title="Descargar reporte de todas las recargas SINPE en formato Excel">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
|
||||
<span>Exportar Excel</span>
|
||||
</a>
|
||||
<button onclick="loadSinpeRequests()" class="btn-saas btn-saas-outline" style="height: 36px; padding: 0 12px;">
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M3 21v-5h5"/></svg>
|
||||
<span>Refrescar</span>
|
||||
@@ -581,6 +585,6 @@
|
||||
<script src="/js/sounds.js?v=8.6"></script>
|
||||
<script src="/js/jsQR.js"></script>
|
||||
<script src="/js/food-icons.js?v=1.1"></script>
|
||||
<script src="/js/pos.js?v=13.1"></script>
|
||||
<script src="/js/pos.js?v=13.2"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// SiboPay PWA Service Worker v13.1 - Alta Velocidad & Despacho
|
||||
const CACHE_NAME = 'sibopay-v13.1';
|
||||
// SiboPay PWA Service Worker v13.2 - Alta Velocidad & Despacho
|
||||
const CACHE_NAME = 'sibopay-v13.2';
|
||||
const STATIC_ASSETS = [
|
||||
'/',
|
||||
'/index.html',
|
||||
|
||||
Reference in New Issue
Block a user