feat: inicializacion de RecreoPay - Monedero QR y Pre-ordenes para Soda Escolar CR
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>RecreoPay - Carnés Escolares Físicos con Código QR</title>
|
||||
<link rel="stylesheet" href="/css/styles.css">
|
||||
<style>
|
||||
@page {
|
||||
size: letter portrait;
|
||||
margin: 8mm 10mm;
|
||||
}
|
||||
body {
|
||||
background: #f1f5f9;
|
||||
color: #0f172a;
|
||||
}
|
||||
.print-bar {
|
||||
background: #ffffff;
|
||||
border-bottom: 2px solid #cbd5e1;
|
||||
padding: 14px 24px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
|
||||
}
|
||||
.carnet-grid-print {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 85.6mm);
|
||||
gap: 8mm 12mm;
|
||||
justify-content: center;
|
||||
padding: 15px 0;
|
||||
}
|
||||
.cut-line-wrapper {
|
||||
border: 1px dashed #94a3b8;
|
||||
border-radius: 4mm;
|
||||
padding: 1.5mm;
|
||||
background: white;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
@media print {
|
||||
.print-bar {
|
||||
display: none !important;
|
||||
}
|
||||
body {
|
||||
background: white !important;
|
||||
}
|
||||
.carnet-grid-print {
|
||||
padding: 0 !important;
|
||||
gap: 6mm 10mm !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- BARRA DE ACCIÓN Y CONTROL (NO SE IMPRIME) -->
|
||||
<div class="print-bar no-print">
|
||||
<div style="display: flex; align-items: center; gap: 12px;">
|
||||
<span style="font-size: 1.8rem;">🖨️</span>
|
||||
<div>
|
||||
<h2 style="font-size: 1.15rem; font-weight: 900; color: #0f172a;">Generador de Carnés Físicos RecreoPay</h2>
|
||||
<p style="font-size: 0.78rem; color: #64748b;">Para estudiantes sin teléfono móvil • Tamaño credencial estándar (85.6 × 54 mm)</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; align-items: center; gap: 12px;">
|
||||
<select id="gradeFilter" onchange="filterCards(this.value)" style="padding: 8px 12px; border-radius: 8px; border: 1px solid #cbd5e1; font-weight: 700;">
|
||||
<option value="todos">Todos los Grados</option>
|
||||
<option value="primaria">Solo Primaria (1° a 6°)</option>
|
||||
<option value="secundaria">Solo Secundaria (7° a 11°)</option>
|
||||
</select>
|
||||
|
||||
<button onclick="window.print()" style="padding: 10px 20px; background: #0284c7; color: white; border: none; border-radius: 10px; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);">
|
||||
<span>🖨️ Imprimir Hoja de Carnés (Ctrl + P)</span>
|
||||
</button>
|
||||
|
||||
<a href="/index.html" style="padding: 10px 14px; background: #f1f5f9; color: #334155; text-decoration: none; border-radius: 10px; font-weight: 700;">
|
||||
Volver a la App ↗
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CONTENEDOR DE CARNÉS IMPRIMIBLES -->
|
||||
<main style="max-width: 900px; margin: 0 auto;">
|
||||
<div class="carnet-grid-print" id="carnetsGrid">
|
||||
<!-- Se llena dinámicamente con los carnés de los estudiantes -->
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
let allStudents = [];
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
try {
|
||||
const res = await fetch('/api/estudiantes');
|
||||
allStudents = await res.json();
|
||||
renderCards(allStudents);
|
||||
} catch (e) {
|
||||
console.error('Error cargando estudiantes:', e);
|
||||
}
|
||||
});
|
||||
|
||||
function filterCards(val) {
|
||||
if (val === 'todos') {
|
||||
renderCards(allStudents);
|
||||
} else if (val === 'primaria') {
|
||||
renderCards(allStudents.filter(s => s.edad <= 11));
|
||||
} else if (val === 'secundaria') {
|
||||
renderCards(allStudents.filter(s => s.edad > 11));
|
||||
}
|
||||
}
|
||||
|
||||
function renderCards(studentsList) {
|
||||
const grid = document.getElementById('carnetsGrid');
|
||||
grid.innerHTML = studentsList.map(est => `
|
||||
<div class="cut-line-wrapper">
|
||||
<div class="carnet-card">
|
||||
<!-- ENCABEZADO -->
|
||||
<div class="carnet-header">
|
||||
<span class="carnet-school-name">CENTRO EDUCATIVO • SODA ESCOLAR</span>
|
||||
<span style="font-size: 6.5pt; font-weight: 800; color: #0284c7; background: #e0f2fe; padding: 1px 5px; border-radius: 3px;">
|
||||
RECREOPAY 🇨🇷
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- CUERPO DEL CARNÉ -->
|
||||
<div class="carnet-body">
|
||||
<img class="carnet-photo" src="${est.foto_url}" alt="${est.nombre_completo}">
|
||||
|
||||
<div class="carnet-details">
|
||||
<div class="carnet-name">${est.nombre_completo}</div>
|
||||
<div class="carnet-meta-item"><strong>Cód:</strong> ${est.codigo_estudiante}</div>
|
||||
<div class="carnet-meta-item"><strong>Grado:</strong> ${est.grado} - ${est.seccion}</div>
|
||||
<div class="carnet-meta-item"><strong>Edad:</strong> ${est.edad} años</div>
|
||||
${est.alergias && est.alergias !== 'Ninguna' && est.alergias !== 'Ninguna conocida' ? `
|
||||
<div style="font-size: 6pt; color: #b91c1c; font-weight: 800; margin-top: 1mm;">
|
||||
⚠️ ${est.alergias}
|
||||
</div>
|
||||
` : ''}
|
||||
</div>
|
||||
|
||||
<!-- CÓDIGO QR EN ALTA DEFINICIÓN -->
|
||||
<img class="carnet-qr" src="/api/qr-image/${encodeURIComponent(est.qr_token)}" alt="QR">
|
||||
</div>
|
||||
|
||||
<!-- PIE DE CARNÉ -->
|
||||
<div class="carnet-footer">
|
||||
<span>PIN de Seguridad: <strong>${est.pin_seguridad || '1234'}</strong></span>
|
||||
<span>Encargado: ${est.padre_telefono || 'Escuela'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,781 @@
|
||||
/* ==========================================================================
|
||||
RECREOPAY - SISTEMA DE DISEÑO ADAPTATIVO (KIDS 7-10 & TEENS 11-15 & SODA POS)
|
||||
========================================================================== */
|
||||
|
||||
:root {
|
||||
--primary: #0284c7;
|
||||
--primary-hover: #0369a1;
|
||||
--secondary: #10b981;
|
||||
--accent: #f59e0b;
|
||||
--danger: #ef4444;
|
||||
--bg-main: #f8fafc;
|
||||
--card-bg: #ffffff;
|
||||
--text-main: #0f172a;
|
||||
--text-muted: #64748b;
|
||||
--border: #e2e8f0;
|
||||
--radius: 16px;
|
||||
--shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
|
||||
}
|
||||
|
||||
/* Modo Teens (Estilo Fintech / Dark Mode) */
|
||||
body.mode-teens {
|
||||
--primary: #38bdf8;
|
||||
--primary-hover: #0284c7;
|
||||
--secondary: #34d399;
|
||||
--accent: #fbbf24;
|
||||
--bg-main: #0b1120;
|
||||
--card-bg: #1e293b;
|
||||
--text-main: #f1f5f9;
|
||||
--text-muted: #94a3b8;
|
||||
--border: #334155;
|
||||
--radius: 12px;
|
||||
--shadow: 0 10px 15px -3px rgb(0 0 0 / 0.4);
|
||||
}
|
||||
|
||||
/* Modo Kids (Primaria: Lúdico, Grande, Amigable) */
|
||||
body.mode-kids {
|
||||
--primary: #0284c7;
|
||||
--secondary: #10b981;
|
||||
--accent: #f59e0b;
|
||||
--bg-main: #eff6ff;
|
||||
--card-bg: #ffffff;
|
||||
--text-main: #1e293b;
|
||||
--border: #bfdbfe;
|
||||
--radius: 22px;
|
||||
--shadow: 0 8px 20px -4px rgb(2 132 199 / 0.15);
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--bg-main);
|
||||
color: var(--text-main);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: background-color 0.3s ease, color 0.3s ease;
|
||||
}
|
||||
|
||||
/* Contenedor móvil centrado para PWA */
|
||||
.app-container {
|
||||
max-width: 480px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
padding-bottom: 90px;
|
||||
}
|
||||
|
||||
/* Top App Bar */
|
||||
.top-bar {
|
||||
background: var(--card-bg);
|
||||
padding: 14px 18px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid var(--border);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 40;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.brand-badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 800;
|
||||
color: var(--text-main);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.brand-badge .logo-icon {
|
||||
background: linear-gradient(135deg, #0284c7, #38bdf8);
|
||||
color: white;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
/* Selector de Perfil y Modo */
|
||||
.mode-toggle {
|
||||
display: flex;
|
||||
background: var(--bg-main);
|
||||
border: 1px solid var(--border);
|
||||
padding: 3px;
|
||||
border-radius: 30px;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.mode-btn {
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 5px 12px;
|
||||
border-radius: 20px;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 700;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.mode-btn.active {
|
||||
background: var(--primary);
|
||||
color: #ffffff;
|
||||
box-shadow: 0 2px 6px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
/* Tarjeta de Saldo y Carné Digital */
|
||||
.wallet-card {
|
||||
margin: 16px;
|
||||
background: linear-gradient(135deg, #0369a1, #0284c7);
|
||||
color: white;
|
||||
border-radius: var(--radius);
|
||||
padding: 20px;
|
||||
box-shadow: 0 12px 25px -4px rgba(2, 132, 199, 0.4);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body.mode-teens .wallet-card {
|
||||
background: linear-gradient(135deg, #1e293b, #0f172a);
|
||||
border: 1px solid #334155;
|
||||
box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
body.mode-kids .wallet-card {
|
||||
background: linear-gradient(135deg, #0284c7, #38bdf8);
|
||||
border: 3px solid #7dd3fc;
|
||||
}
|
||||
|
||||
.wallet-card::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: -40px;
|
||||
right: -40px;
|
||||
width: 140px;
|
||||
height: 140px;
|
||||
background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 70%);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.student-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.student-avatar {
|
||||
width: 58px;
|
||||
height: 58px;
|
||||
border-radius: 50%;
|
||||
border: 3px solid rgba(255, 255, 255, 0.8);
|
||||
background: white;
|
||||
object-fit: cover;
|
||||
box-shadow: 0 4px 10px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.student-meta h2 {
|
||||
font-size: 1.15rem;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.student-grade {
|
||||
font-size: 0.85rem;
|
||||
opacity: 0.9;
|
||||
display: inline-block;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.balance-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.2);
|
||||
padding-top: 14px;
|
||||
}
|
||||
|
||||
.balance-col .label {
|
||||
font-size: 0.78rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.balance-col .amount {
|
||||
font-size: 1.85rem;
|
||||
font-weight: 900;
|
||||
letter-spacing: -0.5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.kids-coin-icon {
|
||||
font-size: 1.6rem;
|
||||
animation: bounce 2s infinite ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes bounce {
|
||||
0%, 100% { transform: translateY(0); }
|
||||
50% { transform: translateY(-4px); }
|
||||
}
|
||||
|
||||
.qr-toggle-btn {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border: 1px solid rgba(255, 255, 255, 0.4);
|
||||
color: white;
|
||||
padding: 8px 14px;
|
||||
border-radius: 30px;
|
||||
font-weight: 700;
|
||||
font-size: 0.85rem;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
backdrop-filter: blur(8px);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.qr-toggle-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.35);
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
/* Modal del Código QR Escolar */
|
||||
.modal-qr-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(15, 23, 42, 0.8);
|
||||
backdrop-filter: blur(6px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.modal-qr-card {
|
||||
background: white;
|
||||
border-radius: 24px;
|
||||
padding: 26px 20px;
|
||||
max-width: 340px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
box-shadow: 0 20px 40px rgba(0,0,0,0.3);
|
||||
position: relative;
|
||||
animation: zoomIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
@keyframes zoomIn {
|
||||
from { transform: scale(0.9); opacity: 0; }
|
||||
to { transform: scale(1); opacity: 1; }
|
||||
}
|
||||
|
||||
.qr-code-img {
|
||||
width: 220px;
|
||||
height: 220px;
|
||||
margin: 14px auto;
|
||||
display: block;
|
||||
border-radius: 12px;
|
||||
border: 2px dashed #0284c7;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
/* Banner de Límite Diario / Alerta */
|
||||
.daily-limit-badge {
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--border);
|
||||
margin: 0 16px 16px 16px;
|
||||
padding: 10px 14px;
|
||||
border-radius: var(--radius);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 0.84rem;
|
||||
}
|
||||
|
||||
.daily-limit-badge strong {
|
||||
color: var(--secondary);
|
||||
}
|
||||
|
||||
/* Navegación por Categorías */
|
||||
.category-scroll {
|
||||
display: flex;
|
||||
overflow-x: auto;
|
||||
gap: 8px;
|
||||
padding: 4px 16px 12px 16px;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.category-scroll::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cat-pill {
|
||||
flex-shrink: 0;
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-main);
|
||||
padding: 8px 16px;
|
||||
border-radius: 30px;
|
||||
font-size: 0.86rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
box-shadow: var(--shadow);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.cat-pill.active {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
/* Grilla de Productos */
|
||||
.section-title {
|
||||
padding: 0 16px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 800;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.products-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
body.mode-kids .products-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.product-card {
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 14px;
|
||||
box-shadow: var(--shadow);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
transition: transform 0.15s, box-shadow 0.15s;
|
||||
}
|
||||
|
||||
.product-card:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
body.mode-kids .product-card {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.product-icon-wrap {
|
||||
font-size: 2.8rem;
|
||||
text-align: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
body.mode-kids .product-icon-wrap {
|
||||
font-size: 3.4rem;
|
||||
margin-bottom: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
font-size: 0.95rem;
|
||||
font-weight: 800;
|
||||
line-height: 1.25;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
body.mode-kids .product-name {
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
.product-desc {
|
||||
font-size: 0.76rem;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.3;
|
||||
margin-bottom: 8px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.badge-mep {
|
||||
font-size: 0.68rem;
|
||||
font-weight: 700;
|
||||
background: #dcfce7;
|
||||
color: #166534;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
display: inline-block;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.product-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
body.mode-kids .product-footer {
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 900;
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
border: none;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
font-size: 1.2rem;
|
||||
font-weight: 900;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
|
||||
transition: transform 0.15s;
|
||||
}
|
||||
|
||||
body.mode-kids .add-btn {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
font-size: 1.5rem;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
.add-btn:active {
|
||||
transform: scale(0.9);
|
||||
}
|
||||
|
||||
/* Barra Flotante de Carrito / Pre-orden */
|
||||
.floating-cart-bar {
|
||||
position: fixed;
|
||||
bottom: 16px;
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
max-width: 448px;
|
||||
margin: 0 auto;
|
||||
background: #0f172a;
|
||||
color: white;
|
||||
border-radius: 20px;
|
||||
padding: 12px 18px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-shadow: 0 10px 25px rgba(0,0,0,0.4);
|
||||
z-index: 50;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
body.mode-kids .floating-cart-bar {
|
||||
background: #0284c7;
|
||||
border: 2px solid white;
|
||||
}
|
||||
|
||||
.cart-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.cart-count-badge {
|
||||
background: var(--accent);
|
||||
color: #0f172a;
|
||||
font-weight: 900;
|
||||
padding: 4px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.cart-total-text {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.cart-action-btn {
|
||||
background: var(--secondary);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 12px;
|
||||
font-weight: 800;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
TERMINAL POS SODA (pos.html)
|
||||
========================================================================== */
|
||||
.pos-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 420px;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
background: #0f172a;
|
||||
color: #f8fafc;
|
||||
}
|
||||
|
||||
.pos-catalog-pane {
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.pos-tabs {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
border-bottom: 2px solid #334155;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
.pos-tab-btn {
|
||||
background: #1e293b;
|
||||
border: 1px solid #334155;
|
||||
color: #94a3b8;
|
||||
padding: 10px 18px;
|
||||
border-radius: 10px;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 800;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.pos-tab-btn.active {
|
||||
background: #0284c7;
|
||||
color: white;
|
||||
border-color: #0284c7;
|
||||
}
|
||||
|
||||
.pos-products-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.pos-prod-card {
|
||||
background: #1e293b;
|
||||
border: 1px solid #334155;
|
||||
border-radius: 14px;
|
||||
padding: 16px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
min-height: 140px;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.pos-prod-card:hover {
|
||||
border-color: #38bdf8;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.pos-checkout-pane {
|
||||
background: #1e293b;
|
||||
border-left: 2px solid #334155;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.scanner-feed-card {
|
||||
background: #0f172a;
|
||||
border: 2px dashed #0284c7;
|
||||
border-radius: 16px;
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.camera-preview {
|
||||
width: 100%;
|
||||
height: 180px;
|
||||
background: #000000;
|
||||
border-radius: 10px;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.laser-scan-line {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
height: 2px;
|
||||
background: #ef4444;
|
||||
box-shadow: 0 0 10px #ef4444;
|
||||
animation: scanMove 2s infinite ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes scanMove {
|
||||
0% { top: 20px; opacity: 0.8; }
|
||||
50% { top: 180px; opacity: 1; }
|
||||
100% { top: 20px; opacity: 0.8; }
|
||||
}
|
||||
|
||||
.pos-cart-list {
|
||||
flex-grow: 1;
|
||||
overflow-y: auto;
|
||||
margin: 16px 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.pos-cart-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: #0f172a;
|
||||
padding: 10px 14px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #334155;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
CARNÉ ESCOLAR FÍSICO IMPRIMIBLE (carnet.html)
|
||||
========================================================================== */
|
||||
.carnets-sheet {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 15mm;
|
||||
padding: 10mm;
|
||||
}
|
||||
|
||||
.carnet-card {
|
||||
width: 85.6mm;
|
||||
height: 54mm;
|
||||
border: 1.5px solid #cbd5e1;
|
||||
border-radius: 3.5mm;
|
||||
padding: 3mm 4mm;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
background: white;
|
||||
color: #0f172a;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
.carnet-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 2px solid #0284c7;
|
||||
padding-bottom: 1.5mm;
|
||||
}
|
||||
|
||||
.carnet-school-name {
|
||||
font-size: 7.5pt;
|
||||
font-weight: 800;
|
||||
color: #0284c7;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.carnet-body {
|
||||
display: flex;
|
||||
gap: 3mm;
|
||||
align-items: center;
|
||||
margin: 2mm 0;
|
||||
}
|
||||
|
||||
.carnet-photo {
|
||||
width: 22mm;
|
||||
height: 22mm;
|
||||
border-radius: 2mm;
|
||||
border: 1px solid #cbd5e1;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.carnet-details {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.carnet-name {
|
||||
font-size: 9pt;
|
||||
font-weight: 900;
|
||||
line-height: 1.15;
|
||||
margin-bottom: 1mm;
|
||||
}
|
||||
|
||||
.carnet-meta-item {
|
||||
font-size: 6.8pt;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.carnet-qr {
|
||||
width: 20mm;
|
||||
height: 20mm;
|
||||
border: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.carnet-footer {
|
||||
font-size: 5.5pt;
|
||||
color: #64748b;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
padding-top: 1mm;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
@media print {
|
||||
body {
|
||||
background: white !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
.no-print {
|
||||
display: none !important;
|
||||
}
|
||||
.carnet-card {
|
||||
border: 1px solid #94a3b8;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<title>RecreoPay - Tu Soda Escolar Digital</title>
|
||||
<link rel="manifest" href="/manifest.json">
|
||||
<meta name="theme-color" content="#0284c7">
|
||||
<link rel="stylesheet" href="/css/styles.css">
|
||||
<style>
|
||||
/* Transiciones suaves */
|
||||
.fade-enter { animation: fadeIn 0.2s ease-in-out; }
|
||||
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
|
||||
</style>
|
||||
</head>
|
||||
<body class="mode-kids">
|
||||
|
||||
<div class="app-container">
|
||||
<!-- BARRA SUPERIOR -->
|
||||
<header class="top-bar">
|
||||
<a href="#" class="brand-badge">
|
||||
<div class="logo-icon">🥪</div>
|
||||
<div>
|
||||
<span>Recreo<strong>Pay</strong></span>
|
||||
<span style="font-size: 0.65rem; display: block; color: var(--text-muted); font-weight: 600;">SODA ESCOLAR CR 🇨🇷</span>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<!-- SWITCHER DE MODO (KIDS / TEENS / PADRES) -->
|
||||
<div class="mode-toggle">
|
||||
<button class="mode-btn active" id="btnModeKids" onclick="setAppMode('kids')">🧒 Kids</button>
|
||||
<button class="mode-btn" id="btnModeTeens" onclick="setAppMode('teens')">⚡ Teens</button>
|
||||
<button class="mode-btn" id="btnModePadres" onclick="toggleParentPanel(true)">👨👩👦 Padres</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- SELECTOR RÁPIDO DE ALUMNO DE PRUEBA -->
|
||||
<div style="padding: 10px 16px 0 16px; display: flex; align-items: center; justify-content: space-between; font-size: 0.8rem;">
|
||||
<span style="color: var(--text-muted); font-weight: 700;">Estudiante Activo:</span>
|
||||
<select id="studentSelector" onchange="onStudentChange(this.value)" style="padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text-main); font-weight: 700;">
|
||||
<!-- Se llena dinámicamente -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- TARJETA DIGITAL DE MONEDERO Y SALDO -->
|
||||
<section class="wallet-card">
|
||||
<div class="student-info">
|
||||
<img id="walletAvatar" class="student-avatar" src="" alt="Avatar">
|
||||
<div class="student-meta">
|
||||
<h2 id="walletName">Cargando...</h2>
|
||||
<span id="walletGrade" class="student-grade">Grado y Sección</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="balance-row">
|
||||
<div class="balance-col">
|
||||
<div class="label" id="balanceLabel">💰 Mis Colones Disponibles</div>
|
||||
<div class="amount">
|
||||
<span id="walletBalance">₡0</span>
|
||||
<span class="kids-coin-icon" id="kidsCoinIcon">🪙</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="qr-toggle-btn" onclick="openQrModal()">
|
||||
<span>📱</span>
|
||||
<span id="qrBtnText">Ver mi QR</span>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- BANNER DE LÍMITE DIARIO Y SALUD -->
|
||||
<div class="daily-limit-badge" id="dailyLimitBadge">
|
||||
<div>
|
||||
<span>Límite diario fijado: </span>
|
||||
<strong id="dailyLimitText">₡0</strong>
|
||||
</div>
|
||||
<div style="font-size: 0.76rem; color: var(--text-muted);" id="dailyAvailableText">
|
||||
Disponible hoy: ₡0
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ALERGIAS (SI TIENE) -->
|
||||
<div id="allergyWarning" style="display:none; margin: 0 16px 12px 16px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 8px 12px; font-size: 0.8rem; color: #92400e; align-items: center; gap: 6px;">
|
||||
⚠️ <strong>Atención médica:</strong> <span id="allergyText"></span>
|
||||
</div>
|
||||
|
||||
<!-- BARRA DE CATEGORÍAS -->
|
||||
<div class="category-scroll" id="categoriesBar">
|
||||
<!-- Se llena dinámicamente -->
|
||||
</div>
|
||||
|
||||
<!-- TÍTULO DE SECCIÓN Y FILTRO MEP -->
|
||||
<div class="section-title">
|
||||
<span id="catalogTitle">Menú del Recreo</span>
|
||||
<label style="font-size: 0.75rem; font-weight: 600; color: #166534; display: flex; align-items: center; gap: 4px; cursor: pointer;">
|
||||
<input type="checkbox" id="chkFilterMep" onchange="renderProducts()">
|
||||
<span>Solo Saludables MEP 🌿</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- GRILLA DE PRODUCTOS -->
|
||||
<div class="products-grid" id="productsGrid">
|
||||
<!-- Se llena con productos de la soda -->
|
||||
</div>
|
||||
|
||||
<!-- BARRA FLOTANTE DE PRE-ORDEN / CARRITO -->
|
||||
<div class="floating-cart-bar" id="floatingCart" style="display: none;" onclick="openCartModal()">
|
||||
<div class="cart-summary">
|
||||
<span class="cart-count-badge" id="cartCountBadge">0</span>
|
||||
<div class="cart-total-text" id="cartTotalText">₡0</div>
|
||||
</div>
|
||||
<button class="cart-action-btn">Pedir para el Recreo 🛒</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;">📟 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;">🖨️ Carnés Físicos para Imprimir</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODAL: CÓDIGO QR PARA PRESENTAR EN LA SODA -->
|
||||
<div class="modal-qr-backdrop" id="modalQr" style="display: none;" onclick="closeQrModal(event)">
|
||||
<div class="modal-qr-card" onclick="event.stopPropagation()">
|
||||
<h3 style="color: #0f172a; font-size: 1.2rem; font-weight: 800;">Mi Carné QR RecreoPay</h3>
|
||||
<p style="font-size: 0.8rem; color: #64748b; margin-top: 4px;">Muéstralo en la ventanilla de la soda para pagar al instante</p>
|
||||
|
||||
<img id="qrDisplayImg" class="qr-code-img" src="" alt="Código QR">
|
||||
|
||||
<div style="background: #f1f5f9; padding: 8px 12px; border-radius: 8px; font-family: monospace; font-size: 0.9rem; font-weight: 800; color: #0284c7;" id="qrTokenDisplay">
|
||||
CODIGO-QR
|
||||
</div>
|
||||
|
||||
<p style="font-size: 0.75rem; color: #94a3b8; margin-top: 10px;">
|
||||
💡 Si no tienes tu celular en la escuela, puedes usar tu carné físico impreso con este mismo código.
|
||||
</p>
|
||||
|
||||
<button onclick="closeQrModal()" style="margin-top: 14px; width: 100%; padding: 10px; background: #0f172a; color: white; border: none; border-radius: 12px; font-weight: 700; cursor: pointer;">
|
||||
Cerrar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODAL: CARRITO Y PRE-ORDEN -->
|
||||
<div class="modal-qr-backdrop" id="modalCart" style="display: none;" onclick="closeCartModal(event)">
|
||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 12px;">
|
||||
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800;">Mi Pre-Orden Escolar</h3>
|
||||
<button onclick="closeCartModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 14px;">
|
||||
<label style="display: block; font-size: 0.8rem; font-weight: 700; color: #334155; margin-bottom: 4px;">
|
||||
¿Para cuál recreo deseas tu orden?
|
||||
</label>
|
||||
<select id="momentoEntregaSelect" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #cbd5e1; font-weight: 600;">
|
||||
<option value="recreo_1">🔔 1er Recreo de la Mañana (9:30 AM)</option>
|
||||
<option value="almuerzo">🍲 Hora de Almuerzo (11:45 AM)</option>
|
||||
<option value="recreo_2">🍎 2do Recreo de la Tarde (1:45 PM)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- LISTA DE PRODUCTOS EN EL CARRITO -->
|
||||
<div id="cartItemsList" style="max-height: 220px; overflow-y: auto; margin-bottom: 14px;">
|
||||
<!-- Se llena dinámicamente -->
|
||||
</div>
|
||||
|
||||
<div style="border-top: 1px solid #e2e8f0; padding-top: 10px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center;">
|
||||
<span style="font-weight: 800; color: #334155;">Total a Rebajar de Saldo:</span>
|
||||
<span id="modalCartTotal" style="font-size: 1.3rem; font-weight: 900; color: #0284c7;">₡0</span>
|
||||
</div>
|
||||
|
||||
<button id="btnConfirmarOrden" onclick="submitPreOrder()" style="width: 100%; padding: 12px; background: #10b981; color: white; border: none; border-radius: 12px; font-weight: 800; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;">
|
||||
<span>✅ Confirmar y Pagar Pre-Orden</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODAL: PANEL DE PADRES (RECARGA SINPE Y LÍMITES) -->
|
||||
<div class="modal-qr-backdrop" id="modalPadres" style="display: none;" onclick="toggleParentPanel(false, event)">
|
||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: left;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 14px;">
|
||||
<div>
|
||||
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800;">Portal de Padres RecreoPay</h3>
|
||||
<span style="font-size: 0.75rem; color: #64748b;">Control de meriendas, nutrición y recargas SINPE</span>
|
||||
</div>
|
||||
<button onclick="toggleParentPanel(false)" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
|
||||
</div>
|
||||
|
||||
<!-- RECARGA SINPE MÓVIL -->
|
||||
<div style="background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; padding: 14px; margin-bottom: 16px;">
|
||||
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
|
||||
<span style="font-size: 1.4rem;">📱</span>
|
||||
<div>
|
||||
<strong style="color: #166534; font-size: 0.95rem;">Recarga por SINPE Móvil</strong>
|
||||
<p style="font-size: 0.75rem; color: #15803d;">Número de la Soda: <strong>8888-SODA (7632)</strong></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px;">
|
||||
<button onclick="quickSinpeRecharge(2000)" style="padding: 8px; background: white; border: 1px solid #86efac; border-radius: 8px; font-weight: 700; color: #166534; cursor: pointer;">+ ₡2.000</button>
|
||||
<button onclick="quickSinpeRecharge(5000)" style="padding: 8px; background: white; border: 1px solid #86efac; border-radius: 8px; font-weight: 700; color: #166534; cursor: pointer;">+ ₡5.000</button>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 6px;">
|
||||
<input type="number" id="inputCustomSinpe" placeholder="Otro monto (₡)" style="flex: 1; padding: 8px; border-radius: 8px; border: 1px solid #cbd5e1; font-weight: 600;">
|
||||
<button onclick="customSinpeRecharge()" style="padding: 8px 14px; background: #166534; color: white; border: none; border-radius: 8px; font-weight: 700; cursor: pointer;">Recargar</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CONFIGURACIÓN DE LÍMITE DIARIO -->
|
||||
<div style="background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px; margin-bottom: 16px;">
|
||||
<label style="display: block; font-size: 0.85rem; font-weight: 800; color: #1e293b; margin-bottom: 6px;">
|
||||
Límite de Gasto Máximo Diario: <span id="lblParentDailyLimit" style="color: #0284c7; font-weight: 900;">₡3.000</span>
|
||||
</label>
|
||||
<input type="range" id="rangeDailyLimit" min="1000" max="6000" step="500" value="3000" oninput="onDailyLimitSlider(this.value)" style="width: 100%;">
|
||||
<div style="display: flex; justify-content: space-between; font-size: 0.72rem; color: #64748b; margin-top: 4px;">
|
||||
<span>₡1.000 / día</span>
|
||||
<span>₡3.500</span>
|
||||
<span>₡6.000 / día</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- HISTORIAL RECIENTE -->
|
||||
<h4 style="font-size: 0.85rem; font-weight: 800; color: #1e293b; margin-bottom: 8px;">Consumos Recientes</h4>
|
||||
<div id="parentHistoryList" style="max-height: 140px; overflow-y: auto; font-size: 0.78rem;">
|
||||
<!-- Se llena dinámicamente -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/js/sounds.js"></script>
|
||||
<script src="/js/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,449 @@
|
||||
// RECREOPAY - LÓGICA DE CLIENTE PWA (ESTUDIANTES Y PADRES)
|
||||
|
||||
let students = [];
|
||||
let currentStudent = null;
|
||||
let categories = [];
|
||||
let products = [];
|
||||
let activeCategoryId = null;
|
||||
let cart = [];
|
||||
let currentAppMode = 'kids';
|
||||
|
||||
// Inicialización al cargar la página
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
// Registrar Service Worker para PWA si está soportado
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('/sw.js').catch(err => console.log('SW error:', err));
|
||||
}
|
||||
|
||||
await loadInitialData();
|
||||
});
|
||||
|
||||
async function loadInitialData() {
|
||||
try {
|
||||
// 1. Cargar estudiantes
|
||||
const resEst = await fetch('/api/estudiantes');
|
||||
students = await resEst.json();
|
||||
|
||||
populateStudentSelector();
|
||||
|
||||
// Seleccionar por defecto el primer estudiante (Mateo, 8 años -> Modo Kids)
|
||||
if (students.length > 0) {
|
||||
await selectStudent(students[0].id);
|
||||
}
|
||||
|
||||
// 2. Cargar productos y categorías
|
||||
const resProd = await fetch('/api/productos');
|
||||
const dataProd = await resProd.json();
|
||||
categories = dataProd.categorias;
|
||||
products = dataProd.productos;
|
||||
|
||||
renderCategories();
|
||||
renderProducts();
|
||||
} catch (error) {
|
||||
console.error('Error cargando datos iniciales:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function populateStudentSelector() {
|
||||
const sel = document.getElementById('studentSelector');
|
||||
sel.innerHTML = students.map(s => `
|
||||
<option value="${s.id}">
|
||||
${s.nombre_completo} (${s.edad} años - ${s.grado})
|
||||
</option>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
async function onStudentChange(studentId) {
|
||||
await selectStudent(studentId);
|
||||
}
|
||||
|
||||
async function selectStudent(studentId) {
|
||||
try {
|
||||
const res = await fetch(`/api/estudiantes/${studentId}`);
|
||||
currentStudent = await res.json();
|
||||
|
||||
// Adaptar modo automáticamente por edad (7-10 Kids, 11-15 Teens)
|
||||
if (currentStudent.edad <= 10) {
|
||||
setAppMode('kids', false);
|
||||
} else {
|
||||
setAppMode('teens', false);
|
||||
}
|
||||
|
||||
updateStudentUI();
|
||||
} catch (e) {
|
||||
console.error('Error seleccionando estudiante:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function updateStudentUI() {
|
||||
if (!currentStudent) return;
|
||||
|
||||
// Actualizar avatar, nombre y grado
|
||||
document.getElementById('walletAvatar').src = currentStudent.foto_url || 'https://api.dicebear.com/7.x/bottts/svg?seed=est';
|
||||
document.getElementById('walletName').textContent = currentStudent.nombre_completo;
|
||||
document.getElementById('walletGrade').textContent = `${currentStudent.grado} • Sección ${currentStudent.seccion} • Cód: ${currentStudent.codigo_estudiante}`;
|
||||
|
||||
// Saldo en colones
|
||||
document.getElementById('walletBalance').textContent = `₡${currentStudent.saldo_colones.toLocaleString('es-CR')}`;
|
||||
|
||||
// Límite diario
|
||||
document.getElementById('dailyLimitText').textContent = `₡${currentStudent.limite_diario_colones.toLocaleString('es-CR')}`;
|
||||
document.getElementById('dailyAvailableText').textContent = `Disponible hoy: ₡${currentStudent.disponible_hoy.toLocaleString('es-CR')}`;
|
||||
|
||||
// Alergias
|
||||
const allergyBox = document.getElementById('allergyWarning');
|
||||
if (currentStudent.alergias && currentStudent.alergias !== 'Ninguna' && currentStudent.alergias !== 'Ninguna conocida') {
|
||||
allergyBox.style.display = 'flex';
|
||||
document.getElementById('allergyText').textContent = currentStudent.alergias;
|
||||
} else {
|
||||
allergyBox.style.display = 'none';
|
||||
}
|
||||
|
||||
// QR Modal info
|
||||
document.getElementById('qrDisplayImg').src = `/api/qr-image/${encodeURIComponent(currentStudent.qr_token)}`;
|
||||
document.getElementById('qrTokenDisplay').textContent = currentStudent.qr_token;
|
||||
|
||||
// Panel de Padres sliders y valores
|
||||
document.getElementById('lblParentDailyLimit').textContent = `₡${currentStudent.limite_diario_colones.toLocaleString('es-CR')}`;
|
||||
document.getElementById('rangeDailyLimit').value = currentStudent.limite_diario_colones;
|
||||
renderParentHistory();
|
||||
}
|
||||
|
||||
function setAppMode(mode, playSound = true) {
|
||||
currentAppMode = mode;
|
||||
document.body.classList.remove('mode-kids', 'mode-teens');
|
||||
|
||||
document.getElementById('btnModeKids').classList.remove('active');
|
||||
document.getElementById('btnModeTeens').classList.remove('active');
|
||||
|
||||
if (mode === 'kids') {
|
||||
document.body.classList.add('mode-kids');
|
||||
document.getElementById('btnModeKids').classList.add('active');
|
||||
document.getElementById('balanceLabel').textContent = '💰 Mis Colones para el Recreo';
|
||||
document.getElementById('kidsCoinIcon').style.display = 'inline-block';
|
||||
document.getElementById('qrBtnText').textContent = 'Tocar para mi QR 📱';
|
||||
} else {
|
||||
document.body.classList.add('mode-teens');
|
||||
document.getElementById('btnModeTeens').classList.add('active');
|
||||
document.getElementById('balanceLabel').textContent = 'SALDO DISPONIBLE';
|
||||
document.getElementById('kidsCoinIcon').style.display = 'none';
|
||||
document.getElementById('qrBtnText').textContent = 'QR de Pago';
|
||||
}
|
||||
|
||||
if (playSound && window.sounds) {
|
||||
window.sounds.playCoin();
|
||||
}
|
||||
}
|
||||
|
||||
// Renderizado de Categorías
|
||||
function renderCategories() {
|
||||
const bar = document.getElementById('categoriesBar');
|
||||
let html = `
|
||||
<button class="cat-pill ${activeCategoryId === null ? 'active' : ''}" onclick="selectCategory(null)">
|
||||
<span>✨</span> Todos
|
||||
</button>
|
||||
`;
|
||||
|
||||
for (const cat of categories) {
|
||||
html += `
|
||||
<button class="cat-pill ${activeCategoryId === cat.id ? 'active' : ''}" onclick="selectCategory(${cat.id})">
|
||||
<span>${cat.icono}</span> ${cat.nombre}
|
||||
</button>
|
||||
`;
|
||||
}
|
||||
bar.innerHTML = html;
|
||||
}
|
||||
|
||||
function selectCategory(catId) {
|
||||
activeCategoryId = catId;
|
||||
renderCategories();
|
||||
renderProducts();
|
||||
}
|
||||
|
||||
// Renderizado de Productos del Menú
|
||||
function renderProducts() {
|
||||
const grid = document.getElementById('productsGrid');
|
||||
const filterMepOnly = document.getElementById('chkFilterMep').checked;
|
||||
|
||||
let filtered = products;
|
||||
|
||||
if (activeCategoryId !== null) {
|
||||
filtered = filtered.filter(p => p.categoria_id === activeCategoryId);
|
||||
}
|
||||
|
||||
if (filterMepOnly) {
|
||||
filtered = filtered.filter(p => p.cumple_mep === 1);
|
||||
}
|
||||
|
||||
if (filtered.length === 0) {
|
||||
grid.innerHTML = `
|
||||
<div style="grid-column: 1 / -1; text-align: center; padding: 30px; color: var(--text-muted);">
|
||||
<p style="font-size: 2rem;">🥪</p>
|
||||
<p>No hay productos en esta categoría por ahora.</p>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
grid.innerHTML = filtered.map(prod => `
|
||||
<div class="product-card">
|
||||
<div class="product-icon-wrap">${prod.icono || '🥪'}</div>
|
||||
<div>
|
||||
${prod.cumple_mep ? '<span class="badge-mep">🌿 MEP Saludable</span>' : ''}
|
||||
<h4 class="product-name">${prod.nombre}</h4>
|
||||
<p class="product-desc">${prod.descripcion || ''}</p>
|
||||
${prod.alergenos ? `<div style="font-size: 0.68rem; color: #dc2626; margin-bottom: 4px;">⚠️ Contiene: ${prod.alergenos}</div>` : ''}
|
||||
</div>
|
||||
<div class="product-footer">
|
||||
<span class="product-price">₡${prod.precio_colones.toLocaleString('es-CR')}</span>
|
||||
<button class="add-btn" onclick="addToCart(${prod.id})" title="Agregar a mi pre-orden">
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// CARRITO Y PRE-ÓRDENES
|
||||
// ==========================================
|
||||
|
||||
function addToCart(productId) {
|
||||
const prod = products.find(p => p.id === productId);
|
||||
if (!prod) return;
|
||||
|
||||
const existing = cart.find(item => item.product.id === productId);
|
||||
if (existing) {
|
||||
existing.cantidad++;
|
||||
} else {
|
||||
cart.push({ product: prod, cantidad: 1 });
|
||||
}
|
||||
|
||||
if (window.sounds) {
|
||||
window.sounds.playCoin();
|
||||
}
|
||||
|
||||
updateCartBar();
|
||||
}
|
||||
|
||||
function updateCartBar() {
|
||||
const bar = document.getElementById('floatingCart');
|
||||
const countBadge = document.getElementById('cartCountBadge');
|
||||
const totalText = document.getElementById('cartTotalText');
|
||||
|
||||
const totalCount = cart.reduce((sum, item) => sum + item.cantidad, 0);
|
||||
const totalColones = cart.reduce((sum, item) => sum + (item.product.precio_colones * item.cantidad), 0);
|
||||
|
||||
if (totalCount > 0) {
|
||||
bar.style.display = 'flex';
|
||||
countBadge.textContent = `${totalCount} ${totalCount === 1 ? 'ítem' : 'ítems'}`;
|
||||
totalText.textContent = `₡${totalColones.toLocaleString('es-CR')}`;
|
||||
} else {
|
||||
bar.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function openCartModal() {
|
||||
renderCartModalItems();
|
||||
document.getElementById('modalCart').style.display = 'flex';
|
||||
}
|
||||
|
||||
function closeCartModal(e) {
|
||||
if (e && e.target !== e.currentTarget) return;
|
||||
document.getElementById('modalCart').style.display = 'none';
|
||||
}
|
||||
|
||||
function renderCartModalItems() {
|
||||
const list = document.getElementById('cartItemsList');
|
||||
const totalEl = document.getElementById('modalCartTotal');
|
||||
|
||||
if (cart.length === 0) {
|
||||
list.innerHTML = '<p style="text-align: center; color: #94a3b8; padding: 20px;">El carrito está vacío</p>';
|
||||
totalEl.textContent = '₡0';
|
||||
return;
|
||||
}
|
||||
|
||||
let total = 0;
|
||||
list.innerHTML = cart.map((item, idx) => {
|
||||
const subtotal = item.product.precio_colones * item.cantidad;
|
||||
total += subtotal;
|
||||
return `
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f1f5f9;">
|
||||
<div>
|
||||
<strong style="font-size: 0.9rem; color: #0f172a;">${item.product.icono} ${item.product.nombre}</strong>
|
||||
<div style="font-size: 0.75rem; color: #64748b;">₡${item.product.precio_colones.toLocaleString('es-CR')} c/u</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<button onclick="changeCartQty(${idx}, -1)" style="width: 28px; height: 28px; border-radius: 6px; border: 1px solid #cbd5e1; background: white; font-weight: 800; cursor: pointer;">-</button>
|
||||
<span style="font-weight: 800; font-size: 0.9rem; min-width: 16px; text-align: center;">${item.cantidad}</span>
|
||||
<button onclick="changeCartQty(${idx}, 1)" style="width: 28px; height: 28px; border-radius: 6px; border: 1px solid #cbd5e1; background: white; font-weight: 800; cursor: pointer;">+</button>
|
||||
<span style="font-weight: 900; font-size: 0.95rem; color: #0284c7; min-width: 65px; text-align: right;">₡${subtotal.toLocaleString('es-CR')}</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
totalEl.textContent = `₡${total.toLocaleString('es-CR')}`;
|
||||
}
|
||||
|
||||
function changeCartQty(index, delta) {
|
||||
cart[index].cantidad += delta;
|
||||
if (cart[index].cantidad <= 0) {
|
||||
cart.splice(index, 1);
|
||||
}
|
||||
renderCartModalItems();
|
||||
updateCartBar();
|
||||
}
|
||||
|
||||
async function submitPreOrder() {
|
||||
if (!currentStudent) return;
|
||||
if (cart.length === 0) return alert('Agrega al menos un producto a tu pre-orden');
|
||||
|
||||
const momento = document.getElementById('momentoEntregaSelect').value;
|
||||
const items = cart.map(item => ({
|
||||
producto_id: item.product.id,
|
||||
cantidad: item.cantidad
|
||||
}));
|
||||
|
||||
const btn = document.getElementById('btnConfirmarOrden');
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Procesando en la soda...';
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/ordenes', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
estudiante_id: currentStudent.id,
|
||||
tipo_orden: 'preorden',
|
||||
momento_entrega: momento,
|
||||
items
|
||||
})
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (!res.ok) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
throw new Error(data.error || 'Error procesando pre-orden');
|
||||
}
|
||||
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
|
||||
alert(`🎉 ¡Pre-Orden confirmada con éxito!\nCódigo de entrega: ${data.codigo_orden}\nRebajada de tu monedero: ₡${data.total_colones.toLocaleString('es-CR')}\n\nPodrás retirarla en la fila rápida de la soda durante el recreo presentando tu QR.`);
|
||||
|
||||
// Limpiar carrito y recargar datos del estudiante
|
||||
cart = [];
|
||||
updateCartBar();
|
||||
closeCartModal();
|
||||
await selectStudent(currentStudent.id);
|
||||
} catch (err) {
|
||||
alert(`❌ No se pudo procesar: ${err.message}`);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = '✅ Confirmar y Pagar Pre-Orden';
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// MODAL QR ESCOLAR
|
||||
// ==========================================
|
||||
|
||||
function openQrModal() {
|
||||
if (window.sounds) window.sounds.playScanChirp();
|
||||
document.getElementById('modalQr').style.display = 'flex';
|
||||
}
|
||||
|
||||
function closeQrModal(e) {
|
||||
if (e && e.target !== e.currentTarget) return;
|
||||
document.getElementById('modalQr').style.display = 'none';
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// PANEL DE PADRES Y RECARGAS SINPE
|
||||
// ==========================================
|
||||
|
||||
function toggleParentPanel(show, e) {
|
||||
if (e && e.target !== e.currentTarget) return;
|
||||
document.getElementById('modalPadres').style.display = show ? 'flex' : 'none';
|
||||
}
|
||||
|
||||
async function quickSinpeRecharge(monto) {
|
||||
await doSinpeRecharge(monto);
|
||||
}
|
||||
|
||||
async function customSinpeRecharge() {
|
||||
const val = parseInt(document.getElementById('inputCustomSinpe').value, 10);
|
||||
if (!val || val <= 0) return alert('Ingresa un monto válido en colones');
|
||||
await doSinpeRecharge(val);
|
||||
document.getElementById('inputCustomSinpe').value = '';
|
||||
}
|
||||
|
||||
async function doSinpeRecharge(monto) {
|
||||
if (!currentStudent) return;
|
||||
const comprobante = `SINPE-${Math.floor(100000 + Math.random() * 900000)}`;
|
||||
|
||||
try {
|
||||
const res = await fetch(`/api/estudiantes/${currentStudent.id}/recarga`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
monto,
|
||||
comprobante,
|
||||
descripcion: `Recarga SINPE Móvil desde portal de padres`
|
||||
})
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error);
|
||||
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
alert(`✅ ¡Recarga SINPE exitosa!\nSe acreditaron ₡${monto.toLocaleString('es-CR')} al monedero de ${currentStudent.nombre_completo}.\nComprobante: ${comprobante}`);
|
||||
|
||||
await selectStudent(currentStudent.id);
|
||||
} catch (err) {
|
||||
alert(`Error en recarga: ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function onDailyLimitSlider(val) {
|
||||
document.getElementById('lblParentDailyLimit').textContent = `₡${parseInt(val, 10).toLocaleString('es-CR')}`;
|
||||
if (!currentStudent) return;
|
||||
|
||||
try {
|
||||
await fetch(`/api/estudiantes/${currentStudent.id}/limite`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ limite_diario_colones: parseInt(val, 10) })
|
||||
});
|
||||
// Actualizar UI sutilmente
|
||||
currentStudent.limite_diario_colones = parseInt(val, 10);
|
||||
document.getElementById('dailyLimitText').textContent = `₡${currentStudent.limite_diario_colones.toLocaleString('es-CR')}`;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function renderParentHistory() {
|
||||
const container = document.getElementById('parentHistoryList');
|
||||
if (!currentStudent || !currentStudent.transacciones || currentStudent.transacciones.length === 0) {
|
||||
container.innerHTML = '<p style="color: #94a3b8;">Sin movimientos recientes</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
container.innerHTML = currentStudent.transacciones.map(t => {
|
||||
const esPositivo = t.monto_colones > 0;
|
||||
const color = esPositivo ? '#166534' : '#0f172a';
|
||||
const signo = esPositivo ? '+' : '';
|
||||
const fecha = new Date(t.fecha).toLocaleDateString('es-CR', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' });
|
||||
|
||||
return `
|
||||
<div style="display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f1f5f9;">
|
||||
<div>
|
||||
<div style="font-weight: 700; color: ${color};">${t.descripcion || t.tipo}</div>
|
||||
<div style="font-size: 0.7rem; color: #94a3b8;">${fecha}</div>
|
||||
</div>
|
||||
<div style="font-weight: 800; color: ${esPositivo ? '#10b981' : '#ef4444'};">
|
||||
${signo}₡${Math.abs(t.monto_colones).toLocaleString('es-CR')}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
}
|
||||
@@ -0,0 +1,428 @@
|
||||
// RECREOPAY - LÓGICA DE LA TERMINAL DE LA SODA (POS & ESCÁNER)
|
||||
|
||||
let posProducts = [];
|
||||
let posCategories = [];
|
||||
let posCart = [];
|
||||
let scannedStudent = null;
|
||||
let currentTab = 'mostrador';
|
||||
let sseSource = null;
|
||||
let videoStream = null;
|
||||
let isScanningActive = true;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
await loadCatalog();
|
||||
await loadPreOrders();
|
||||
initCamera();
|
||||
initSSE();
|
||||
});
|
||||
|
||||
// Cargar catálogo de productos
|
||||
async function loadCatalog() {
|
||||
try {
|
||||
const res = await fetch('/api/productos');
|
||||
const data = await res.json();
|
||||
posCategories = data.categorias;
|
||||
posProducts = data.productos;
|
||||
|
||||
renderPosCategories();
|
||||
renderPosProducts(null);
|
||||
} catch (err) {
|
||||
console.error('Error cargando catálogo:', err);
|
||||
}
|
||||
}
|
||||
|
||||
function renderPosCategories() {
|
||||
const bar = document.getElementById('posCategoriesBar');
|
||||
bar.innerHTML = `
|
||||
<button class="pos-tab-btn active" style="padding: 6px 12px; font-size: 0.8rem;" onclick="filterPosCat(null, this)">Todos</button>
|
||||
${posCategories.map(c => `
|
||||
<button class="pos-tab-btn" style="padding: 6px 12px; font-size: 0.8rem;" onclick="filterPosCat(${c.id}, this)">
|
||||
${c.icono} ${c.nombre}
|
||||
</button>
|
||||
`).join('')}
|
||||
`;
|
||||
}
|
||||
|
||||
function filterPosCat(catId, btn) {
|
||||
document.querySelectorAll('#posCategoriesBar .pos-tab-btn').forEach(b => b.classList.remove('active'));
|
||||
if (btn) btn.classList.add('active');
|
||||
renderPosProducts(catId);
|
||||
}
|
||||
|
||||
function renderPosProducts(catId) {
|
||||
const grid = document.getElementById('posProductsGrid');
|
||||
let list = posProducts;
|
||||
if (catId !== null) {
|
||||
list = list.filter(p => p.categoria_id === catId);
|
||||
}
|
||||
|
||||
grid.innerHTML = list.map(prod => `
|
||||
<div class="pos-prod-card" onclick="addToPosCart(${prod.id})">
|
||||
<div style="font-size: 2.2rem; text-align: center;">${prod.icono || '🥪'}</div>
|
||||
<div>
|
||||
<div style="font-size: 0.88rem; font-weight: 800; color: #ffffff; line-height: 1.2;">${prod.nombre}</div>
|
||||
${prod.cumple_mep ? '<span style="font-size: 0.65rem; color: #34d399;">🌿 MEP Saludable</span>' : ''}
|
||||
</div>
|
||||
<div style="font-size: 1.1rem; font-weight: 900; color: #38bdf8; margin-top: 6px;">
|
||||
₡${prod.precio_colones.toLocaleString('es-CR')}
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
// Carrito de mostrador
|
||||
function addToPosCart(prodId) {
|
||||
const prod = posProducts.find(p => p.id === prodId);
|
||||
if (!prod) return;
|
||||
|
||||
const existing = posCart.find(i => i.product.id === prodId);
|
||||
if (existing) {
|
||||
existing.cantidad++;
|
||||
} else {
|
||||
posCart.push({ product: prod, cantidad: 1 });
|
||||
}
|
||||
|
||||
if (window.sounds) window.sounds.playCoin();
|
||||
updatePosCartUI();
|
||||
}
|
||||
|
||||
function updatePosCartUI() {
|
||||
const list = document.getElementById('posCartList');
|
||||
const totalEl = document.getElementById('posCartTotal');
|
||||
|
||||
if (posCart.length === 0) {
|
||||
list.innerHTML = '<p style="text-align: center; color: #64748b; padding: 20px; font-size: 0.85rem;">Toca productos del menú para cobrar</p>';
|
||||
totalEl.textContent = '₡0';
|
||||
return;
|
||||
}
|
||||
|
||||
let total = 0;
|
||||
list.innerHTML = posCart.map((item, idx) => {
|
||||
const subtotal = item.product.precio_colones * item.cantidad;
|
||||
total += subtotal;
|
||||
return `
|
||||
<div class="pos-cart-item">
|
||||
<div style="flex: 1;">
|
||||
<strong style="color: #f8fafc; font-size: 0.85rem;">${item.product.icono} ${item.product.nombre}</strong>
|
||||
<div style="font-size: 0.75rem; color: #94a3b8;">₡${item.product.precio_colones.toLocaleString('es-CR')} c/u</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<button onclick="changePosQty(${idx}, -1)" style="width: 24px; height: 24px; background: #334155; color: white; border: none; border-radius: 4px; font-weight: 800; cursor: pointer;">-</button>
|
||||
<span style="font-weight: 800; min-width: 14px; text-align: center; color: #ffffff;">${item.cantidad}</span>
|
||||
<button onclick="changePosQty(${idx}, 1)" style="width: 24px; height: 24px; background: #334155; color: white; border: none; border-radius: 4px; font-weight: 800; cursor: pointer;">+</button>
|
||||
<span style="font-weight: 900; color: #38bdf8; min-width: 55px; text-align: right;">₡${subtotal.toLocaleString('es-CR')}</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
totalEl.textContent = `₡${total.toLocaleString('es-CR')}`;
|
||||
}
|
||||
|
||||
function changePosQty(idx, delta) {
|
||||
posCart[idx].cantidad += delta;
|
||||
if (posCart[idx].cantidad <= 0) {
|
||||
posCart.splice(idx, 1);
|
||||
}
|
||||
updatePosCartUI();
|
||||
}
|
||||
|
||||
function clearPosCart() {
|
||||
posCart = [];
|
||||
updatePosCartUI();
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// ESCÁNER Y LECTURA DE QR
|
||||
// ==========================================
|
||||
|
||||
async function initCamera() {
|
||||
const video = document.getElementById('scannerVideo');
|
||||
const status = document.getElementById('cameraStatus');
|
||||
|
||||
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
||||
try {
|
||||
videoStream = await navigator.mediaDevices.getUserMedia({
|
||||
video: { facingMode: 'environment', width: { ideal: 640 } }
|
||||
});
|
||||
video.srcObject = videoStream;
|
||||
status.textContent = '🟢 Cámara conectada';
|
||||
startQrDetection(video);
|
||||
} catch (err) {
|
||||
status.textContent = '⚪ Modo simulación QR activo';
|
||||
}
|
||||
} else {
|
||||
status.textContent = '⚪ Modo simulación QR activo';
|
||||
}
|
||||
}
|
||||
|
||||
// Detección nativa por BarcodeDetector si el navegador lo soporta (Chrome/Edge Android)
|
||||
function startQrDetection(video) {
|
||||
if ('BarcodeDetector' in window) {
|
||||
const detector = new window.BarcodeDetector({ formats: ['qr_code'] });
|
||||
const interval = setInterval(async () => {
|
||||
if (!isScanningActive) return;
|
||||
try {
|
||||
const barcodes = await detector.detect(video);
|
||||
if (barcodes.length > 0) {
|
||||
const rawValue = barcodes[0].rawValue;
|
||||
onQrCodeDetected(rawValue);
|
||||
}
|
||||
} catch (e) {}
|
||||
}, 400);
|
||||
}
|
||||
}
|
||||
|
||||
function simulateScan(qrToken) {
|
||||
onQrCodeDetected(qrToken);
|
||||
}
|
||||
|
||||
async function onQrCodeDetected(token) {
|
||||
if (window.sounds) window.sounds.playScanChirp();
|
||||
|
||||
// Si estamos en la pestaña de fila rápida de pre-órdenes, despachamos de inmediato
|
||||
if (currentTab === 'preordenes') {
|
||||
await dispatchPreOrderExpress(token);
|
||||
return;
|
||||
}
|
||||
|
||||
// Si estamos en mostrador, identificamos al estudiante
|
||||
try {
|
||||
const res = await fetch(`/api/estudiantes/qr/${encodeURIComponent(token)}`);
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error);
|
||||
|
||||
scannedStudent = data;
|
||||
renderScannedStudent();
|
||||
|
||||
// Si tiene pre-órdenes listas, alertar a la cajera
|
||||
if (data.preordenes_pendientes && data.preordenes_pendientes.length > 0) {
|
||||
if (confirm(`🔔 ¡Atención! ${data.nombre_completo} tiene ${data.preordenes_pendientes.length} pre-orden lista para retirar. ¿Deseas verla y entregarla ahora?`)) {
|
||||
switchPosTab('preordenes');
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
alert(`QR no reconocido: ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
function renderScannedStudent() {
|
||||
if (!scannedStudent) {
|
||||
document.getElementById('studentScannedCard').style.display = 'none';
|
||||
document.getElementById('scannedAllergyAlert').style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('scannedAvatar').src = scannedStudent.foto_url;
|
||||
document.getElementById('scannedName').textContent = scannedStudent.nombre_completo;
|
||||
document.getElementById('scannedGrade').textContent = `${scannedStudent.grado} • Sección ${scannedStudent.seccion} • Cód: ${scannedStudent.codigo_estudiante}`;
|
||||
document.getElementById('scannedBalance').textContent = `₡${scannedStudent.saldo_colones.toLocaleString('es-CR')}`;
|
||||
document.getElementById('scannedAvailable').textContent = `₡${scannedStudent.disponible_hoy.toLocaleString('es-CR')}`;
|
||||
document.getElementById('studentScannedCard').style.display = 'flex';
|
||||
|
||||
// Alerta médica en mostrador
|
||||
const alertBox = document.getElementById('scannedAllergyAlert');
|
||||
if (scannedStudent.alergias && scannedStudent.alergias !== 'Ninguna' && scannedStudent.alergias !== 'Ninguna conocida') {
|
||||
alertBox.style.display = 'block';
|
||||
document.getElementById('scannedAllergyText').textContent = scannedStudent.alergias;
|
||||
} else {
|
||||
alertBox.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function clearScannedStudent() {
|
||||
scannedStudent = null;
|
||||
renderScannedStudent();
|
||||
}
|
||||
|
||||
// Ejecutar cobro en mostrador
|
||||
async function executePosDebit() {
|
||||
if (!scannedStudent) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
return alert('⚠️ Primero escanea el carné o celular del estudiante (puedes usar los botones de prueba rápida en la cámara).');
|
||||
}
|
||||
|
||||
if (posCart.length === 0) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
return alert('⚠️ Selecciona al menos un producto en el mostrador para cobrar.');
|
||||
}
|
||||
|
||||
const items = posCart.map(item => ({
|
||||
producto_id: item.product.id,
|
||||
cantidad: item.cantidad
|
||||
}));
|
||||
|
||||
const btn = document.getElementById('btnCobrarPos');
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Procesando débito...';
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/ordenes', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
estudiante_id: scannedStudent.id,
|
||||
tipo_orden: 'mostrador',
|
||||
momento_entrega: 'inmediato',
|
||||
items
|
||||
})
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (!res.ok) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
throw new Error(data.error);
|
||||
}
|
||||
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
|
||||
alert(`✅ ¡COBRO EXITOSO!\nTicket: ${data.codigo_orden}\nEstudiante: ${scannedStudent.nombre_completo}\nMonto: ₡${data.total_colones.toLocaleString('es-CR')}\nNuevo Saldo: ₡${data.financiero.estudiante.saldo_nuevo.toLocaleString('es-CR')}`);
|
||||
|
||||
// Limpiar caja y refrescar
|
||||
clearPosCart();
|
||||
clearScannedStudent();
|
||||
} catch (err) {
|
||||
alert(`❌ Fallo en la transacción: ${err.message}`);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<span>📱</span> COBRAR CON QR DE ALUMNO';
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// FILA RÁPIDA DE PRE-ÓRDENES
|
||||
// ==========================================
|
||||
|
||||
function switchPosTab(tab) {
|
||||
currentTab = tab;
|
||||
document.getElementById('tabBtnMostrador').classList.toggle('active', tab === 'mostrador');
|
||||
document.getElementById('tabBtnPreordenes').classList.toggle('active', tab === 'preordenes');
|
||||
|
||||
document.getElementById('viewPosMostrador').style.display = tab === 'mostrador' ? 'block' : 'none';
|
||||
document.getElementById('viewPosPreordenes').style.display = tab === 'preordenes' ? 'block' : 'none';
|
||||
|
||||
if (tab === 'preordenes') {
|
||||
loadPreOrders();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadPreOrders() {
|
||||
try {
|
||||
const res = await fetch('/api/ordenes?tipo=preorden');
|
||||
const orders = await res.json();
|
||||
|
||||
const pendingCount = orders.filter(o => o.estado !== 'entregado' && o.estado !== 'cancelado').length;
|
||||
document.getElementById('badgePreordenesCount').textContent = pendingCount;
|
||||
|
||||
const list = document.getElementById('preOrdersList');
|
||||
if (orders.length === 0) {
|
||||
list.innerHTML = '<p style="text-align: center; color: #64748b; padding: 30px;">No hay pre-órdenes registradas para hoy.</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
list.innerHTML = orders.map(ord => {
|
||||
const hora = new Date(ord.creado_en).toLocaleTimeString('es-CR', { hour: '2-digit', minute: '2-digit' });
|
||||
const itemsList = ord.items.map(i => `${i.cantidad}x ${i.icono || '🥪'} ${i.nombre}`).join(', ');
|
||||
|
||||
return `
|
||||
<div style="background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 14px; display: flex; justify-content: space-between; align-items: center;">
|
||||
<div style="display: flex; gap: 12px; align-items: center;">
|
||||
<img src="${ord.foto_url}" style="width: 44px; height: 44px; border-radius: 50%; border: 2px solid #38bdf8;">
|
||||
<div>
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<strong style="color: #ffffff; font-size: 0.95rem;">${ord.estudiante_nombre}</strong>
|
||||
<span style="font-size: 0.75rem; color: #94a3b8;">${ord.grado} - ${ord.seccion}</span>
|
||||
<span class="status-pill status-${ord.estado}">${ord.estado}</span>
|
||||
</div>
|
||||
<div style="font-size: 0.8rem; color: #38bdf8; margin: 2px 0;">📦 ${itemsList}</div>
|
||||
<div style="font-size: 0.72rem; color: #94a3b8;">Ticket: ${ord.codigo_orden} • Pedido a las ${hora} • Total: ₡${ord.total_colones.toLocaleString('es-CR')}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px;">
|
||||
${ord.estado === 'pendiente' ? `
|
||||
<button onclick="updateOrderStatus(${ord.id}, 'en_preparacion')" style="padding: 6px 12px; background: #3b82f6; color: white; border: none; border-radius: 8px; font-weight: 700; cursor: pointer;">
|
||||
👨🍳 Preparar
|
||||
</button>
|
||||
` : ''}
|
||||
${ord.estado === 'en_preparacion' ? `
|
||||
<button onclick="updateOrderStatus(${ord.id}, 'listo')" style="padding: 6px 12px; background: #10b981; color: white; border: none; border-radius: 8px; font-weight: 700; cursor: pointer;">
|
||||
🛍️ Listo en Bolsa
|
||||
</button>
|
||||
` : ''}
|
||||
${ord.estado === 'listo' ? `
|
||||
<button onclick="updateOrderStatus(${ord.id}, 'entregado')" style="padding: 6px 14px; background: #059669; color: white; border: none; border-radius: 8px; font-weight: 800; cursor: pointer;">
|
||||
✅ Entregar
|
||||
</button>
|
||||
` : ''}
|
||||
${ord.estado === 'entregado' ? `
|
||||
<span style="font-size: 0.78rem; color: #34d399; font-weight: 800;">✓ Entregado</span>
|
||||
` : ''}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
} catch (err) {
|
||||
console.error('Error cargando pre-órdenes:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function updateOrderStatus(orderId, nuevoEstado) {
|
||||
try {
|
||||
const res = await fetch(`/api/ordenes/${orderId}/estado`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ estado: nuevoEstado })
|
||||
});
|
||||
if (!res.ok) throw new Error('Error actualizando orden');
|
||||
if (window.sounds) window.sounds.playCoin();
|
||||
loadPreOrders();
|
||||
} catch (e) {
|
||||
alert(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Despacho Express en 3 segundos mediante escaneo de QR
|
||||
async function dispatchPreOrderExpress(qrToken) {
|
||||
try {
|
||||
const res = await fetch('/api/ordenes/despachar-qr', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ qr_token: qrToken })
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (!res.ok) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
throw new Error(data.error);
|
||||
}
|
||||
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
|
||||
alert(`🎉 ¡ENTREGA EXPRESS EXITOSA!\n${data.mensaje}\nAlumno: ${data.estudiante.nombre_completo}\nGrado: ${data.estudiante.grado}\nProductos a entregar:\n${data.orden.items.map(i => `• ${i.cantidad}x ${i.nombre}`).join('\n')}`);
|
||||
|
||||
loadPreOrders();
|
||||
} catch (err) {
|
||||
alert(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// SSE (SERVER-SENT EVENTS EN TIEMPO REAL)
|
||||
// ==========================================
|
||||
|
||||
function initSSE() {
|
||||
sseSource = new EventSource('/api/events');
|
||||
|
||||
sseSource.addEventListener('nueva_orden', (e) => {
|
||||
const orden = JSON.parse(e.data);
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
// Notificación sonora y visual
|
||||
loadPreOrders();
|
||||
});
|
||||
|
||||
sseSource.addEventListener('orden_actualizada', () => {
|
||||
loadPreOrders();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
// Sintetizador Web Audio API para feedback sonoro en tiempo real sin dependencias externas
|
||||
class SoundEffects {
|
||||
constructor() {
|
||||
this.ctx = null;
|
||||
}
|
||||
|
||||
init() {
|
||||
if (!this.ctx) {
|
||||
const AudioCtx = window.AudioContext || window.webkitAudioContext;
|
||||
this.ctx = new AudioCtx();
|
||||
}
|
||||
if (this.ctx.state === 'suspended') {
|
||||
this.ctx.resume();
|
||||
}
|
||||
}
|
||||
|
||||
// Sonido de escaneo exitoso / cobro completado (Tono alegre ascendente)
|
||||
playSuccess() {
|
||||
try {
|
||||
this.init();
|
||||
const now = this.ctx.currentTime;
|
||||
const osc1 = this.ctx.createOscillator();
|
||||
const osc2 = this.ctx.createOscillator();
|
||||
const gain = this.ctx.createGain();
|
||||
|
||||
osc1.type = 'triangle';
|
||||
osc2.type = 'sine';
|
||||
|
||||
// Acorde alegre de confirmación: C5 -> E5 -> G5
|
||||
osc1.frequency.setValueAtTime(523.25, now);
|
||||
osc1.frequency.exponentialRampToValueAtTime(659.25, now + 0.1);
|
||||
osc1.frequency.exponentialRampToValueAtTime(783.99, now + 0.2);
|
||||
|
||||
osc2.frequency.setValueAtTime(261.63, now);
|
||||
osc2.frequency.setValueAtTime(329.63, now + 0.1);
|
||||
osc2.frequency.setValueAtTime(392.00, now + 0.2);
|
||||
|
||||
gain.gain.setValueAtTime(0.2, now);
|
||||
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.35);
|
||||
|
||||
osc1.connect(gain);
|
||||
osc2.connect(gain);
|
||||
gain.connect(this.ctx.destination);
|
||||
|
||||
osc1.start(now);
|
||||
osc2.start(now);
|
||||
osc1.stop(now + 0.35);
|
||||
osc2.stop(now + 0.35);
|
||||
} catch (e) {
|
||||
console.warn('Audio no disponible:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// Sonido de moneda para Modo Kids
|
||||
playCoin() {
|
||||
try {
|
||||
this.init();
|
||||
const now = this.ctx.currentTime;
|
||||
const osc = this.ctx.createOscillator();
|
||||
const gain = this.ctx.createGain();
|
||||
|
||||
osc.type = 'sine';
|
||||
osc.frequency.setValueAtTime(987.77, now); // B5
|
||||
osc.frequency.setValueAtTime(1318.51, now + 0.08); // E6
|
||||
|
||||
gain.gain.setValueAtTime(0.25, now);
|
||||
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.3);
|
||||
|
||||
osc.connect(gain);
|
||||
gain.connect(this.ctx.destination);
|
||||
|
||||
osc.start(now);
|
||||
osc.stop(now + 0.3);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Chirp de escáner láser de código de barras
|
||||
playScanChirp() {
|
||||
try {
|
||||
this.init();
|
||||
const now = this.ctx.currentTime;
|
||||
const osc = this.ctx.createOscillator();
|
||||
const gain = this.ctx.createGain();
|
||||
|
||||
osc.type = 'square';
|
||||
osc.frequency.setValueAtTime(2000, now);
|
||||
osc.frequency.exponentialRampToValueAtTime(1200, now + 0.06);
|
||||
|
||||
gain.gain.setValueAtTime(0.15, now);
|
||||
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.07);
|
||||
|
||||
osc.connect(gain);
|
||||
gain.connect(this.ctx.destination);
|
||||
|
||||
osc.start(now);
|
||||
osc.stop(now + 0.07);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Sonido de error / límite superado (Tono grave de advertencia)
|
||||
playError() {
|
||||
try {
|
||||
this.init();
|
||||
const now = this.ctx.currentTime;
|
||||
const osc = this.ctx.createOscillator();
|
||||
const gain = this.ctx.createGain();
|
||||
|
||||
osc.type = 'sawtooth';
|
||||
osc.frequency.setValueAtTime(220, now);
|
||||
osc.frequency.setValueAtTime(180, now + 0.15);
|
||||
|
||||
gain.gain.setValueAtTime(0.2, now);
|
||||
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.35);
|
||||
|
||||
osc.connect(gain);
|
||||
gain.connect(this.ctx.destination);
|
||||
|
||||
osc.start(now);
|
||||
osc.stop(now + 0.35);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
window.sounds = new SoundEffects();
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "RecreoPay - Soda Escolar Costa Rica",
|
||||
"short_name": "RecreoPay",
|
||||
"start_url": "/index.html",
|
||||
"display": "standalone",
|
||||
"background_color": "#0f172a",
|
||||
"theme_color": "#0284c7",
|
||||
"description": "Monedero Digital y Pre-órdenes para Sodas Escolares en Costa Rica",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/icons/icon-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/icons/icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
}
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>RecreoPay POS - Terminal de Mostrador y Despacho</title>
|
||||
<link rel="stylesheet" href="/css/styles.css">
|
||||
<style>
|
||||
/* Estilos específicos de terminal de alta velocidad */
|
||||
.student-badge-scanned {
|
||||
background: #0f172a;
|
||||
border: 2px solid #38bdf8;
|
||||
border-radius: 14px;
|
||||
padding: 12px;
|
||||
margin-bottom: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.status-pill {
|
||||
font-size: 0.72rem;
|
||||
font-weight: 800;
|
||||
padding: 3px 8px;
|
||||
border-radius: 6px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.status-pendiente { background: #fef3c7; color: #92400e; }
|
||||
.status-en_preparacion { background: #e0e7ff; color: #3730a3; }
|
||||
.status-listo { background: #dcfce7; color: #166534; }
|
||||
.status-entregado { background: #f1f5f9; color: #64748b; }
|
||||
</style>
|
||||
</head>
|
||||
<body style="background: #0b1120; color: #f8fafc;">
|
||||
|
||||
<div class="pos-layout">
|
||||
<!-- PANEL IZQUIERDO: CATÁLOGO TÁCTIL Y COLA DE PRE-ÓRDENES -->
|
||||
<div class="pos-catalog-pane">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #334155; padding-bottom: 12px;">
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<span style="font-size: 1.8rem;">🥪</span>
|
||||
<div>
|
||||
<h1 style="font-size: 1.25rem; font-weight: 900; color: #ffffff;">RecreoPay <span style="color: #38bdf8;">Terminal Soda</span></h1>
|
||||
<span style="font-size: 0.78rem; color: #94a3b8;">Soda Escolar • Ventana de Atención Rápida</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; align-items: center; gap: 12px;">
|
||||
<span style="display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; background: #064e3b; color: #34d399; padding: 4px 10px; border-radius: 20px; font-weight: 700;">
|
||||
<span style="width: 8px; height: 8px; background: #34d399; border-radius: 50%; display: inline-block;"></span>
|
||||
En Línea (SSE Activo)
|
||||
</span>
|
||||
<a href="/index.html" target="_blank" style="color: #38bdf8; font-size: 0.8rem; font-weight: 700; text-decoration: none; border: 1px solid #38bdf8; padding: 4px 10px; border-radius: 8px;">
|
||||
Ver PWA Estudiante ↗
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TABS DE MODO DE TERMINAL -->
|
||||
<div class="pos-tabs">
|
||||
<button class="pos-tab-btn active" id="tabBtnMostrador" onclick="switchPosTab('mostrador')">
|
||||
<span>🛒</span> Venta de Mostrador
|
||||
</button>
|
||||
<button class="pos-tab-btn" id="tabBtnPreordenes" onclick="switchPosTab('preordenes')">
|
||||
<span>📦</span> Fila Rápida Pre-Órdenes <span id="badgePreordenesCount" style="background: #ef4444; color: white; padding: 2px 7px; border-radius: 10px; font-size: 0.75rem;">0</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- VISTA 1: CATÁLOGO TÁCTIL DE PRODUCTOS (MOSTRADOR) -->
|
||||
<div id="viewPosMostrador">
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto;" id="posCategoriesBar">
|
||||
<!-- Filtros de categorías -->
|
||||
</div>
|
||||
|
||||
<div class="pos-products-grid" id="posProductsGrid">
|
||||
<!-- Tarjetas táctiles de productos -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- VISTA 2: FILA RÁPIDA DE PRE-ÓRDENES (RETIRO EN RECREO) -->
|
||||
<div id="viewPosPreordenes" style="display: none;">
|
||||
<div style="background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center;">
|
||||
<div>
|
||||
<strong style="color: #38bdf8; font-size: 0.95rem;">⚡ Despacho Exclusivo Recreo</strong>
|
||||
<p style="font-size: 0.78rem; color: #94a3b8;">Los estudiantes con pre-orden retiran en 3 segundos escaneando su QR aquí.</p>
|
||||
</div>
|
||||
<button onclick="loadPreOrders()" style="background: #334155; border: none; color: white; padding: 6px 12px; border-radius: 8px; font-weight: 700; cursor: pointer;">
|
||||
🔄 Refrescar
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="preOrdersList" style="display: flex; flex-direction: column; gap: 10px;">
|
||||
<!-- Lista de pre-órdenes -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PANEL DERECHO: SCANNER QR, IDENTIFICACIÓN Y COBRO -->
|
||||
<div class="pos-checkout-pane">
|
||||
<div>
|
||||
<!-- CÁMARA / ESCÁNER DE CÓDIGO QR -->
|
||||
<div class="scanner-feed-card">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
|
||||
<span style="font-size: 0.85rem; font-weight: 800; color: #38bdf8;">📷 Escáner QR de Alumnos</span>
|
||||
<span style="font-size: 0.72rem; color: #94a3b8;" id="cameraStatus">Cámara lista</span>
|
||||
</div>
|
||||
|
||||
<div style="position: relative; border-radius: 10px; overflow: hidden; background: #000;">
|
||||
<video id="scannerVideo" class="camera-preview" autoplay playsinline muted></video>
|
||||
<div class="laser-scan-line"></div>
|
||||
</div>
|
||||
|
||||
<!-- BOTONES DE PRUEBA RÁPIDA DE QR (SIMULACIÓN DE ESCANEO DE CARNÉ O CELULAR) -->
|
||||
<div style="margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;">
|
||||
<span style="font-size: 0.7rem; color: #94a3b8; width: 100%;">Prueba rápida de escaneo de carné:</span>
|
||||
<button onclick="simulateScan('QR-MATEO-2026-A891')" style="font-size: 0.72rem; padding: 3px 8px; background: #334155; color: white; border: none; border-radius: 6px; cursor: pointer;">🧒 Mateo (8a)</button>
|
||||
<button onclick="simulateScan('QR-SOFIA-2026-B442')" style="font-size: 0.72rem; padding: 3px 8px; background: #334155; color: white; border: none; border-radius: 6px; cursor: pointer;">👧 Sofía (9a)</button>
|
||||
<button onclick="simulateScan('QR-NACHO-2026-D902')" style="font-size: 0.72rem; padding: 3px 8px; background: #334155; color: white; border: none; border-radius: 6px; cursor: pointer;">🧑 Ignacio (14a)</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TARJETA DEL ESTUDIANTE IDENTIFICADO POR QR -->
|
||||
<div id="studentScannedCard" style="display: none; margin-top: 14px;" class="student-badge-scanned">
|
||||
<img id="scannedAvatar" src="" style="width: 46px; height: 46px; border-radius: 50%; border: 2px solid #38bdf8; background: white;">
|
||||
<div style="flex: 1;">
|
||||
<h4 id="scannedName" style="font-size: 0.95rem; font-weight: 800; color: #ffffff;">Nombre del Alumno</h4>
|
||||
<div id="scannedGrade" style="font-size: 0.75rem; color: #94a3b8;">2° Grado • Sección 2-A</div>
|
||||
<div style="display: flex; gap: 10px; margin-top: 4px; font-size: 0.76rem;">
|
||||
<span>Saldo: <strong id="scannedBalance" style="color: #34d399;">₡0</strong></span>
|
||||
<span>Disp. hoy: <strong id="scannedAvailable" style="color: #38bdf8;">₡0</strong></span>
|
||||
</div>
|
||||
</div>
|
||||
<button onclick="clearScannedStudent()" style="background: none; border: none; color: #ef4444; font-size: 1.1rem; cursor: pointer;" title="Desconectar alumno">✕</button>
|
||||
</div>
|
||||
|
||||
<!-- ALERTA DE ALERGIAS AL CAJERO -->
|
||||
<div id="scannedAllergyAlert" style="display: none; background: #7f1d1d; border: 1px solid #ef4444; border-radius: 10px; padding: 8px 12px; margin-top: 10px; font-size: 0.78rem; color: #fecaca;">
|
||||
⚠️ <strong>ALERTA MÉDICA:</strong> <span id="scannedAllergyText"></span>
|
||||
</div>
|
||||
|
||||
<!-- LISTA DE PRODUCTOS SELECCIONADOS EN CAJA -->
|
||||
<div style="margin-top: 14px;">
|
||||
<div style="display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 700; color: #94a3b8; border-bottom: 1px solid #334155; padding-bottom: 6px;">
|
||||
<span>Ítems en Mostrador</span>
|
||||
<button onclick="clearPosCart()" style="background: none; border: none; color: #ef4444; font-size: 0.75rem; cursor: pointer;">Limpiar</button>
|
||||
</div>
|
||||
<div class="pos-cart-list" id="posCartList">
|
||||
<p style="text-align: center; color: #64748b; padding: 20px; font-size: 0.85rem;">Toca productos del menú para cobrar</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BOTÓN DE COBRO Y TOTAL -->
|
||||
<div style="border-top: 2px solid #334155; padding-top: 14px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px;">
|
||||
<span style="font-size: 0.9rem; font-weight: 700; color: #94a3b8;">TOTAL A DEBITAR:</span>
|
||||
<span id="posCartTotal" style="font-size: 1.8rem; font-weight: 900; color: #38bdf8;">₡0</span>
|
||||
</div>
|
||||
|
||||
<button id="btnCobrarPos" onclick="executePosDebit()" style="width: 100%; padding: 14px; background: linear-gradient(135deg, #0284c7, #0369a1); border: none; border-radius: 14px; color: white; font-size: 1.05rem; font-weight: 900; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);">
|
||||
<span>📱</span> COBRAR CON QR DE ALUMNO
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/js/sounds.js"></script>
|
||||
<script src="/js/pos.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,47 @@
|
||||
const CACHE_NAME = 'recreopay-static-v1';
|
||||
const ASSETS_TO_CACHE = [
|
||||
'/',
|
||||
'/index.html',
|
||||
'/pos.html',
|
||||
'/carnet.html',
|
||||
'/css/styles.css',
|
||||
'/js/sounds.js',
|
||||
'/manifest.json'
|
||||
];
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME).then((cache) => {
|
||||
return cache.addAll(ASSETS_TO_CACHE).catch(err => console.log('Cache warn:', err));
|
||||
})
|
||||
);
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
event.waitUntil(
|
||||
caches.keys().then((keys) => {
|
||||
return Promise.all(
|
||||
keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key))
|
||||
);
|
||||
})
|
||||
);
|
||||
self.clients.claim();
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', (event) => {
|
||||
// Let API requests pass through to the network
|
||||
if (event.request.url.includes('/api/')) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.respondWith(
|
||||
caches.match(event.request).then((cachedResponse) => {
|
||||
return cachedResponse || fetch(event.request).catch(() => {
|
||||
if (event.request.mode === 'navigate') {
|
||||
return caches.match('/index.html');
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user