feat(preordenes): registrar y mostrar horario de recreo de entrega en comanda de soda y POS
This commit is contained in:
@@ -1682,6 +1682,87 @@ body.dark-mode .floating-cart-bar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Filtros de Pre-órdenes por Horario / Recreo */
|
||||||
|
.pos-preorder-filter-bar {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
overflow-x: auto;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
scrollbar-width: none;
|
||||||
|
}
|
||||||
|
.pos-preorder-filter-bar::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.pos-filter-pill {
|
||||||
|
padding: 8px 14px;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1.5px solid #cbd5e1;
|
||||||
|
background: #ffffff;
|
||||||
|
color: #334155;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 0.82rem;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
white-space: nowrap;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
}
|
||||||
|
.pos-filter-pill:hover {
|
||||||
|
background: #f8fafc;
|
||||||
|
border-color: #94a3b8;
|
||||||
|
}
|
||||||
|
.pos-filter-pill.active {
|
||||||
|
background: #0284c7;
|
||||||
|
color: #ffffff;
|
||||||
|
border-color: #0284c7;
|
||||||
|
box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
|
||||||
|
}
|
||||||
|
.pos-filter-pill.active .pos-pill-count {
|
||||||
|
background: rgba(255, 255, 255, 0.25);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.pos-pill-count {
|
||||||
|
background: #e2e8f0;
|
||||||
|
color: #475569;
|
||||||
|
padding: 2px 7px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 0.74rem;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
.pos-preorder-badge-banner {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 0.84rem;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
.pos-incoming-preorder-toast {
|
||||||
|
position: fixed;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
z-index: 99999;
|
||||||
|
max-width: 440px;
|
||||||
|
width: calc(100% - 40px);
|
||||||
|
background: #ffffff;
|
||||||
|
border-radius: 14px;
|
||||||
|
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.18), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
|
||||||
|
border: 1.5px solid #0284c7;
|
||||||
|
padding: 12px 16px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
animation: slideInRightToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||||
|
}
|
||||||
|
@keyframes slideInRightToast {
|
||||||
|
from { transform: translateX(100%); opacity: 0; }
|
||||||
|
to { transform: translateX(0); opacity: 1; }
|
||||||
|
}
|
||||||
|
|
||||||
/* Panel Checkout Derecho */
|
/* Panel Checkout Derecho */
|
||||||
.pos-checkout-pane {
|
.pos-checkout-pane {
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
|
|||||||
+11
-7
@@ -1714,15 +1714,19 @@
|
|||||||
<button onclick="closeCartModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
|
<button onclick="closeCartModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="margin-bottom: 14px;">
|
<div style="margin-bottom: 14px; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 12px; padding: 12px;">
|
||||||
<label style="display: block; font-size: 0.8rem; font-weight: 700; color: #334155; margin-bottom: 4px;">
|
<label style="display: block; font-size: 0.82rem; font-weight: 800; color: #0f172a; margin-bottom: 6px; display: flex; align-items: center; gap: 6px;">
|
||||||
¿Para cuál recreo deseas tu orden?
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
|
||||||
|
<span>¿Para cuál recreo deseas tu orden?</span>
|
||||||
</label>
|
</label>
|
||||||
<select id="momentoEntregaSelect" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #cbd5e1; font-weight: 600;">
|
<select id="momentoEntregaSelect" style="width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1.5px solid #cbd5e1; font-weight: 700; font-size: 0.88rem; color: #1e293b; background: white; outline: none; cursor: pointer;">
|
||||||
<option value="recreo_1">1er Recreo de la Mañana (9:30 AM)</option>
|
<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="almuerzo">🍲 Hora de Almuerzo (11:45 AM)</option>
|
||||||
<option value="recreo_2">2do Recreo de la Tarde (1:45 PM)</option>
|
<option value="recreo_2">⏰ 2do Recreo de la Tarde (1:45 PM)</option>
|
||||||
</select>
|
</select>
|
||||||
|
<div style="font-size: 0.72rem; color: #64748b; margin-top: 6px; display: flex; align-items: center; gap: 4px;">
|
||||||
|
<span>⚡</span> <span>La soda preparará tus alimentos frescos para este horario.</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- LISTA DE PRODUCTOS EN EL CARRITO -->
|
<!-- LISTA DE PRODUCTOS EN EL CARRITO -->
|
||||||
|
|||||||
+116
-9
@@ -1199,11 +1199,96 @@ function changeCartQty(index, delta) {
|
|||||||
updateCartBar();
|
updateCartBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeMomentoKey(val) {
|
||||||
|
if (!val) return 'recreo_1';
|
||||||
|
const v = String(val).toLowerCase().trim();
|
||||||
|
if (v === 'recreo_1' || v.includes('1er') || v.includes('9:30')) return 'recreo_1';
|
||||||
|
if (v === 'almuerzo' || v.includes('almuerzo') || v.includes('11:45')) return 'almuerzo';
|
||||||
|
if (v === 'recreo_2' || v.includes('2do') || v.includes('1:45')) return 'recreo_2';
|
||||||
|
if (v === 'inmediato' || v.includes('inmediato')) return 'inmediato';
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMomentoBadge(val) {
|
||||||
|
const key = normalizeMomentoKey(val);
|
||||||
|
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)',
|
||||||
|
icon: '🔔',
|
||||||
|
bg: '#fffbeb',
|
||||||
|
border: '#f59e0b',
|
||||||
|
text: '#b45309',
|
||||||
|
badgeBg: '#fef3c7',
|
||||||
|
badgeColor: '#92400e',
|
||||||
|
badgeBorder: '#fde68a'
|
||||||
|
};
|
||||||
|
case 'almuerzo':
|
||||||
|
return {
|
||||||
|
key: 'almuerzo',
|
||||||
|
title: 'Almuerzo (11:45 AM)',
|
||||||
|
full: 'Hora de Almuerzo (11:45 AM)',
|
||||||
|
icon: '🍲',
|
||||||
|
bg: '#f0fdf4',
|
||||||
|
border: '#16a34a',
|
||||||
|
text: '#15803d',
|
||||||
|
badgeBg: '#dcfce7',
|
||||||
|
badgeColor: '#166534',
|
||||||
|
badgeBorder: '#86efac'
|
||||||
|
};
|
||||||
|
case 'recreo_2':
|
||||||
|
return {
|
||||||
|
key: 'recreo_2',
|
||||||
|
title: '2do Recreo (1:45 PM)',
|
||||||
|
full: '2do Recreo de la Tarde (1:45 PM)',
|
||||||
|
icon: '⏰',
|
||||||
|
bg: '#eef2ff',
|
||||||
|
border: '#6366f1',
|
||||||
|
text: '#4338ca',
|
||||||
|
badgeBg: '#e0e7ff',
|
||||||
|
badgeColor: '#3730a3',
|
||||||
|
badgeBorder: '#c7d2fe'
|
||||||
|
};
|
||||||
|
case 'inmediato':
|
||||||
|
return {
|
||||||
|
key: 'inmediato',
|
||||||
|
title: 'Entrega Inmediata',
|
||||||
|
full: 'Entrega Inmediata en Mostrador',
|
||||||
|
icon: '⚡',
|
||||||
|
bg: '#f8fafc',
|
||||||
|
border: '#64748b',
|
||||||
|
text: '#334155',
|
||||||
|
badgeBg: '#f1f5f9',
|
||||||
|
badgeColor: '#334155',
|
||||||
|
badgeBorder: '#cbd5e1'
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
key: val || 'otro',
|
||||||
|
title: val || 'Pre-orden',
|
||||||
|
full: val || 'Pre-orden de recreo',
|
||||||
|
icon: '🥪',
|
||||||
|
bg: '#f8fafc',
|
||||||
|
border: '#0284c7',
|
||||||
|
text: '#0369a1',
|
||||||
|
badgeBg: '#e0f2fe',
|
||||||
|
badgeColor: '#0369a1',
|
||||||
|
badgeBorder: '#bae6fd'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function submitPreOrder() {
|
async function submitPreOrder() {
|
||||||
if (!currentStudent) return;
|
const targetStudent = (currentUser && currentUser.rol === 'padre' && currentParentChild) ? currentParentChild : currentStudent;
|
||||||
|
if (!targetStudent) return;
|
||||||
if (cart.length === 0) return alert('Agrega al menos un producto a tu pre-orden');
|
if (cart.length === 0) return alert('Agrega al menos un producto a tu pre-orden');
|
||||||
|
|
||||||
const momento = document.getElementById('momentoEntregaSelect').value;
|
const momentoSelect = document.getElementById('momentoEntregaSelect');
|
||||||
|
const momento = momentoSelect ? momentoSelect.value : 'recreo_1';
|
||||||
|
const momentoBadge = getMomentoBadge(momento);
|
||||||
|
|
||||||
const items = cart.map(item => ({
|
const items = cart.map(item => ({
|
||||||
producto_id: item.product.id,
|
producto_id: item.product.id,
|
||||||
cantidad: item.cantidad
|
cantidad: item.cantidad
|
||||||
@@ -1218,7 +1303,7 @@ async function submitPreOrder() {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
estudiante_id: currentStudent.id,
|
estudiante_id: targetStudent.id,
|
||||||
tipo_orden: 'preorden',
|
tipo_orden: 'preorden',
|
||||||
momento_entrega: momento,
|
momento_entrega: momento,
|
||||||
items
|
items
|
||||||
@@ -1233,13 +1318,23 @@ async function submitPreOrder() {
|
|||||||
|
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
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.`);
|
alert(`¡Pre-Orden confirmada con éxito!\n\n📋 Código de retiro: ${data.codigo_orden}\n⏰ Horario: ${momentoBadge.full}\n💰 Total rebajado: ₡${data.total_colones.toLocaleString('es-CR')}\n\nPodrás retirarla en la soda durante el recreo programado presentando tu carné QR.`);
|
||||||
|
|
||||||
// Limpiar carrito y recargar datos del estudiante
|
// Limpiar carrito y recargar datos del estudiante o padre
|
||||||
cart = [];
|
cart = [];
|
||||||
updateCartBar();
|
updateCartBar();
|
||||||
|
const cartBadge = document.getElementById('parentCartBadgeCount');
|
||||||
|
if (cartBadge) cartBadge.textContent = '0';
|
||||||
closeCartModal();
|
closeCartModal();
|
||||||
await selectStudent(currentStudent.id);
|
|
||||||
|
if (currentUser && currentUser.rol === 'padre') {
|
||||||
|
await loadParentDashboard();
|
||||||
|
if (currentParentChild) {
|
||||||
|
await loadActiveChildHistory(currentParentChild.id);
|
||||||
|
}
|
||||||
|
} else if (currentStudent) {
|
||||||
|
await selectStudent(currentStudent.id);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert(`No se pudo procesar: ${err.message}`);
|
alert(`No se pudo procesar: ${err.message}`);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -2918,11 +3013,23 @@ async function loadActiveChildHistory(studentId) {
|
|||||||
? o.items.map(it => `${it.cantidad}x ${it.nombre}`).join(', ')
|
? o.items.map(it => `${it.cantidad}x ${it.nombre}`).join(', ')
|
||||||
: 'Compra en mostrador';
|
: 'Compra en mostrador';
|
||||||
const fecha = o.creado_en ? new Date(o.creado_en).toLocaleDateString('es-CR', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }) : '';
|
const fecha = o.creado_en ? new Date(o.creado_en).toLocaleDateString('es-CR', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }) : '';
|
||||||
|
const isPreorden = o.tipo_orden === 'preorden';
|
||||||
|
const badge = getMomentoBadge(o.momento_entrega);
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border);">
|
<div style="display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border);">
|
||||||
<div style="min-width: 0; flex: 1; padding-right: 8px;">
|
<div style="min-width: 0; flex: 1; padding-right: 8px;">
|
||||||
<div style="font-weight: 800; color: var(--text-main); font-size: 0.82rem; word-break: break-word;">${itemsStr}</div>
|
<div style="font-weight: 800; color: var(--text-main); font-size: 0.84rem; word-break: break-word;">${itemsStr}</div>
|
||||||
<div style="font-size: 0.72rem; color: var(--text-muted); margin-top: 1px;">${fecha} • Estado: <span style="color: #10b981; font-weight: 700;">${o.estado}</span></div>
|
<div style="font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;">
|
||||||
|
<span>${fecha}</span>
|
||||||
|
<span>•</span>
|
||||||
|
<span style="color: ${o.estado === 'entregado' ? '#10b981' : '#f59e0b'}; font-weight: 700;">${o.estado === 'entregado' ? 'Entregado' : 'Pendiente de retiro'}</span>
|
||||||
|
${isPreorden ? `
|
||||||
|
<span style="background: ${badge.badgeBg}; color: ${badge.badgeColor}; border: 1px solid ${badge.badgeBorder}; padding: 1px 7px; border-radius: 6px; font-weight: 800; font-size: 0.7rem;">
|
||||||
|
${badge.icon} ${badge.title}
|
||||||
|
</span>
|
||||||
|
` : ''}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<strong style="color: #0284c7; font-size: 0.88rem; flex-shrink: 0;">-₡${(o.total_colones || 0).toLocaleString('es-CR')}</strong>
|
<strong style="color: #0284c7; font-size: 0.88rem; flex-shrink: 0;">-₡${(o.total_colones || 0).toLocaleString('es-CR')}</strong>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+285
-69
@@ -1271,6 +1271,241 @@ function switchPosTab(tab) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let currentPreOrderFilter = 'todos';
|
||||||
|
let cachedPreOrders = [];
|
||||||
|
|
||||||
|
function normalizeMomentoKey(val) {
|
||||||
|
if (!val) return 'recreo_1';
|
||||||
|
const v = String(val).toLowerCase().trim();
|
||||||
|
if (v === 'recreo_1' || v.includes('1er') || v.includes('9:30')) return 'recreo_1';
|
||||||
|
if (v === 'almuerzo' || v.includes('almuerzo') || v.includes('11:45')) return 'almuerzo';
|
||||||
|
if (v === 'recreo_2' || v.includes('2do') || v.includes('1:45')) return 'recreo_2';
|
||||||
|
if (v === 'inmediato' || v.includes('inmediato')) return 'inmediato';
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMomentoBadge(val) {
|
||||||
|
const key = normalizeMomentoKey(val);
|
||||||
|
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)',
|
||||||
|
icon: '🔔',
|
||||||
|
bg: '#fffbeb',
|
||||||
|
border: '#f59e0b',
|
||||||
|
text: '#b45309',
|
||||||
|
badgeBg: '#fef3c7',
|
||||||
|
badgeColor: '#92400e',
|
||||||
|
badgeBorder: '#fde68a'
|
||||||
|
};
|
||||||
|
case 'almuerzo':
|
||||||
|
return {
|
||||||
|
key: 'almuerzo',
|
||||||
|
title: 'Almuerzo (11:45 AM)',
|
||||||
|
full: 'Hora de Almuerzo (11:45 AM)',
|
||||||
|
icon: '🍲',
|
||||||
|
bg: '#f0fdf4',
|
||||||
|
border: '#16a34a',
|
||||||
|
text: '#15803d',
|
||||||
|
badgeBg: '#dcfce7',
|
||||||
|
badgeColor: '#166534',
|
||||||
|
badgeBorder: '#86efac'
|
||||||
|
};
|
||||||
|
case 'recreo_2':
|
||||||
|
return {
|
||||||
|
key: 'recreo_2',
|
||||||
|
title: '2do Recreo (1:45 PM)',
|
||||||
|
full: '2do Recreo de la Tarde (1:45 PM)',
|
||||||
|
icon: '⏰',
|
||||||
|
bg: '#eef2ff',
|
||||||
|
border: '#6366f1',
|
||||||
|
text: '#4338ca',
|
||||||
|
badgeBg: '#e0e7ff',
|
||||||
|
badgeColor: '#3730a3',
|
||||||
|
badgeBorder: '#c7d2fe'
|
||||||
|
};
|
||||||
|
case 'inmediato':
|
||||||
|
return {
|
||||||
|
key: 'inmediato',
|
||||||
|
title: 'Entrega Inmediata',
|
||||||
|
full: 'Entrega Inmediata en Mostrador',
|
||||||
|
icon: '⚡',
|
||||||
|
bg: '#f8fafc',
|
||||||
|
border: '#64748b',
|
||||||
|
text: '#334155',
|
||||||
|
badgeBg: '#f1f5f9',
|
||||||
|
badgeColor: '#334155',
|
||||||
|
badgeBorder: '#cbd5e1'
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
key: val || 'otro',
|
||||||
|
title: val || 'Pre-orden',
|
||||||
|
full: val || 'Pre-orden de recreo',
|
||||||
|
icon: '🥪',
|
||||||
|
bg: '#f8fafc',
|
||||||
|
border: '#0284c7',
|
||||||
|
text: '#0369a1',
|
||||||
|
badgeBg: '#e0f2fe',
|
||||||
|
badgeColor: '#0369a1',
|
||||||
|
badgeBorder: '#bae6fd'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterPreOrdersByMomento(key) {
|
||||||
|
currentPreOrderFilter = key;
|
||||||
|
renderPreOrdersList();
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPreOrdersList() {
|
||||||
|
const orders = cachedPreOrders || [];
|
||||||
|
|
||||||
|
// Conteo total de pendientes
|
||||||
|
const pendingOrders = orders.filter(o => o.estado !== 'entregado' && o.estado !== 'cancelado');
|
||||||
|
const countTodosPending = pendingOrders.length;
|
||||||
|
|
||||||
|
const badgeCount = document.getElementById('badgePreordenesCount');
|
||||||
|
if (badgeCount) badgeCount.textContent = countTodosPending;
|
||||||
|
|
||||||
|
// Conteo por cada horario de entrega
|
||||||
|
let countR1 = 0, countAlm = 0, countR2 = 0;
|
||||||
|
pendingOrders.forEach(o => {
|
||||||
|
const k = normalizeMomentoKey(o.momento_entrega);
|
||||||
|
if (k === 'recreo_1') countR1++;
|
||||||
|
else if (k === 'almuerzo') countAlm++;
|
||||||
|
else if (k === 'recreo_2') countR2++;
|
||||||
|
});
|
||||||
|
|
||||||
|
const elTodos = document.getElementById('countFilterTodos');
|
||||||
|
const elR1 = document.getElementById('countFilterRecreo1');
|
||||||
|
const elAlm = document.getElementById('countFilterAlmuerzo');
|
||||||
|
const elR2 = document.getElementById('countFilterRecreo2');
|
||||||
|
if (elTodos) elTodos.textContent = countTodosPending;
|
||||||
|
if (elR1) elR1.textContent = countR1;
|
||||||
|
if (elAlm) elAlm.textContent = countAlm;
|
||||||
|
if (elR2) elR2.textContent = countR2;
|
||||||
|
|
||||||
|
// Actualizar clase activa en los botones de filtro
|
||||||
|
const pillMap = {
|
||||||
|
'todos': 'filterPillTodos',
|
||||||
|
'recreo_1': 'filterPillRecreo_1',
|
||||||
|
'almuerzo': 'filterPillAlmuerzo',
|
||||||
|
'recreo_2': 'filterPillRecreo_2'
|
||||||
|
};
|
||||||
|
Object.keys(pillMap).forEach(k => {
|
||||||
|
const btn = document.getElementById(pillMap[k]);
|
||||||
|
if (btn) btn.classList.toggle('active', currentPreOrderFilter === k);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Filtrar según botón seleccionado
|
||||||
|
let filtered = orders;
|
||||||
|
if (currentPreOrderFilter !== 'todos') {
|
||||||
|
filtered = orders.filter(o => normalizeMomentoKey(o.momento_entrega) === currentPreOrderFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
const list = document.getElementById('preOrdersList');
|
||||||
|
if (!list) return;
|
||||||
|
|
||||||
|
if (filtered.length === 0) {
|
||||||
|
const filterNames = {
|
||||||
|
'todos': 'para hoy',
|
||||||
|
'recreo_1': 'para el 1er Recreo (9:30 AM)',
|
||||||
|
'almuerzo': 'para el Almuerzo (11:45 AM)',
|
||||||
|
'recreo_2': 'para el 2do Recreo (1:45 PM)'
|
||||||
|
};
|
||||||
|
list.innerHTML = `
|
||||||
|
<div style="text-align: center; color: #64748b; padding: 40px 20px; background: white; border-radius: 14px; border: 1.5px dashed #cbd5e1; margin-top: 4px;">
|
||||||
|
<span style="font-size: 2.2rem; display: block; margin-bottom: 8px;">🥪</span>
|
||||||
|
<strong style="color: #334155; font-size: 0.95rem; display: block;">No hay pre-órdenes registradas ${filterNames[currentPreOrderFilter] || ''}</strong>
|
||||||
|
<p style="font-size: 0.8rem; margin: 4px 0 0 0; color: #94a3b8;">Las órdenes programadas para este horario aparecerán aquí automáticamente.</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
list.innerHTML = filtered.map(ord => {
|
||||||
|
const hora = new Date(ord.creado_en).toLocaleTimeString('es-CR', { hour: '2-digit', minute: '2-digit' });
|
||||||
|
const items = Array.isArray(ord.items) ? ord.items : [];
|
||||||
|
const itemsList = items.map(i => `${i.cantidad}× ${i.nombre}`).join(' • ');
|
||||||
|
const badge = getMomentoBadge(ord.momento_entrega);
|
||||||
|
|
||||||
|
return `
|
||||||
|
<div class="pos-preorder-card" style="border-left: 6px solid ${badge.border};">
|
||||||
|
<!-- Banner Superior de Horario Programado -->
|
||||||
|
<div class="pos-preorder-badge-banner" style="background: ${badge.bg}; border: 1.5px solid ${badge.badgeBorder}; color: ${badge.text};">
|
||||||
|
<div style="display: flex; align-items: center; gap: 8px;">
|
||||||
|
<span style="font-size: 1.3rem;">${badge.icon}</span>
|
||||||
|
<div>
|
||||||
|
<span style="font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.85; display: block; font-weight: 800;">ALISTAR PARA:</span>
|
||||||
|
<strong style="font-size: 0.96rem; letter-spacing: -0.2px;">${badge.full}</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="display: flex; align-items: center; gap: 6px;">
|
||||||
|
${ord.estado === 'entregado'
|
||||||
|
? '<span class="saas-status-badge saas-status-active" style="padding: 4px 10px; font-weight: 800;"><span class="saas-dot"></span>Entregado</span>'
|
||||||
|
: '<span class="saas-status-badge saas-status-pending" style="padding: 4px 10px; background: #fef08a; color: #854d0e; border: 1px solid #fde047; font-weight: 800;"><span class="saas-dot" style="background: #eab308;"></span>Pendiente Alistar</span>'
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pos-preorder-header" style="margin-top: 2px;">
|
||||||
|
<div class="pos-preorder-student">
|
||||||
|
<div class="pos-preorder-avatar" style="display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 0.9rem; background: linear-gradient(135deg, #0284c7, #0369a1); color: #ffffff;">
|
||||||
|
${getStudentInitials(ord.estudiante_nombre)}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="pos-preorder-name-row">
|
||||||
|
<strong class="pos-preorder-name">${ord.estudiante_nombre}</strong>
|
||||||
|
<span class="pos-preorder-grade">${ord.grado} • ${ord.seccion}</span>
|
||||||
|
</div>
|
||||||
|
<div class="pos-preorder-ticket-info" style="display: flex; align-items: center; gap: 6px; flex-wrap: wrap;">
|
||||||
|
<span>Ticket: <strong>${ord.codigo_orden}</strong></span>
|
||||||
|
<span>•</span>
|
||||||
|
<span>Pedido: ${hora}</span>
|
||||||
|
<span>•</span>
|
||||||
|
<span style="color: ${badge.text}; font-weight: 800;">Retiro: ${badge.title}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
${ord.notas ? `
|
||||||
|
<div style="background: #fef3c7; border: 1px solid #fde68a; color: #92400e; padding: 6px 10px; border-radius: 8px; font-size: 0.78rem; font-weight: 700;">
|
||||||
|
📝 Nota del pedido: ${ord.notas}
|
||||||
|
</div>
|
||||||
|
` : ''}
|
||||||
|
|
||||||
|
<div class="pos-preorder-items-box" style="display: flex; align-items: center; gap: 8px;">
|
||||||
|
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;"><path d="m7.5 4.27 9 5.15"/><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg>
|
||||||
|
<span style="flex: 1; word-break: break-word;">${itemsList}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pos-preorder-footer">
|
||||||
|
<div class="pos-preorder-total">
|
||||||
|
<span class="pos-preorder-total-label">Total Cobrado:</span>
|
||||||
|
<strong class="pos-preorder-total-val">₡${ord.total_colones.toLocaleString('es-CR')}</strong>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
${ord.estado !== 'entregado' ? `
|
||||||
|
<button onclick="updateOrderStatus(${ord.id}, 'entregado')" class="btn-saas pos-btn-entregar" title="Marcar como entregado al estudiante">
|
||||||
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="20 6 9 17 4 12"/></svg>
|
||||||
|
<span>Entregar Pedido</span>
|
||||||
|
</button>
|
||||||
|
` : `
|
||||||
|
<span class="saas-status-badge saas-status-active" style="padding: 6px 12px; font-size: 0.8rem;">
|
||||||
|
<span class="saas-dot"></span>Despachado en Soda
|
||||||
|
</span>
|
||||||
|
`}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}).join('');
|
||||||
|
}
|
||||||
|
|
||||||
async function loadPreOrders() {
|
async function loadPreOrders() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/ordenes?tipo=preorden');
|
const res = await fetch('/api/ordenes?tipo=preorden');
|
||||||
@@ -1281,70 +1516,8 @@ async function loadPreOrders() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pendingCount = orders.filter(o => o.estado !== 'entregado' && o.estado !== 'cancelado').length;
|
cachedPreOrders = orders;
|
||||||
document.getElementById('badgePreordenesCount').textContent = pendingCount;
|
renderPreOrdersList();
|
||||||
|
|
||||||
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 items = Array.isArray(ord.items) ? ord.items : [];
|
|
||||||
const itemsList = items.map(i => `${i.cantidad}× ${i.nombre}`).join(' • ');
|
|
||||||
const avatarUrl = ord.foto_url || 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=150';
|
|
||||||
|
|
||||||
return `
|
|
||||||
<div class="pos-preorder-card">
|
|
||||||
<div class="pos-preorder-header">
|
|
||||||
<div class="pos-preorder-student">
|
|
||||||
<div class="pos-preorder-avatar" style="display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 0.9rem; background: linear-gradient(135deg, #0284c7, #0369a1); color: #ffffff;">
|
|
||||||
${getStudentInitials(ord.estudiante_nombre)}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div class="pos-preorder-name-row">
|
|
||||||
<strong class="pos-preorder-name">${ord.estudiante_nombre}</strong>
|
|
||||||
<span class="pos-preorder-grade">${ord.grado} • ${ord.seccion}</span>
|
|
||||||
</div>
|
|
||||||
<div class="pos-preorder-ticket-info">Ticket: ${ord.codigo_orden} • Pedido a las ${hora}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
${ord.estado === 'entregado'
|
|
||||||
? '<span class="saas-status-badge saas-status-active"><span class="saas-dot"></span>Entregado</span>'
|
|
||||||
: '<span class="saas-status-badge saas-status-pending"><span class="saas-dot"></span>Pendiente</span>'
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="pos-preorder-items-box" style="display: flex; align-items: center; gap: 8px;">
|
|
||||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;"><path d="m7.5 4.27 9 5.15"/><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg>
|
|
||||||
<span style="flex: 1; word-break: break-word;">${itemsList}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="pos-preorder-footer">
|
|
||||||
<div class="pos-preorder-total">
|
|
||||||
<span class="pos-preorder-total-label">Total:</span>
|
|
||||||
<strong class="pos-preorder-total-val">₡${ord.total_colones.toLocaleString('es-CR')}</strong>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
${ord.estado !== 'entregado' ? `
|
|
||||||
<button onclick="updateOrderStatus(${ord.id}, 'entregado')" class="btn-saas pos-btn-entregar">
|
|
||||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="20 6 9 17 4 12"/></svg>
|
|
||||||
<span>Entregado</span>
|
|
||||||
</button>
|
|
||||||
` : `
|
|
||||||
<span class="saas-status-badge saas-status-active" style="padding: 6px 12px; font-size: 0.8rem;">
|
|
||||||
<span class="saas-dot"></span>Despachado
|
|
||||||
</span>
|
|
||||||
`}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}).join('');
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error cargando pre-órdenes:', err);
|
console.error('Error cargando pre-órdenes:', err);
|
||||||
}
|
}
|
||||||
@@ -1382,8 +1555,9 @@ async function dispatchPreOrderExpress(qrToken) {
|
|||||||
|
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
if (window.sounds) window.sounds.playSuccess();
|
||||||
|
|
||||||
|
const badge = getMomentoBadge(data.orden ? data.orden.momento_entrega : '');
|
||||||
const itemsList = (data.orden && Array.isArray(data.orden.items) ? data.orden.items : []).map(i => `• ${i.cantidad}x ${i.nombre}`).join('\n');
|
const itemsList = (data.orden && Array.isArray(data.orden.items) ? data.orden.items : []).map(i => `• ${i.cantidad}x ${i.nombre}`).join('\n');
|
||||||
alert(`¡ENTREGA EXPRESS EXITOSA!\n${data.mensaje}\nAlumno: ${data.estudiante.nombre_completo}\nGrado: ${data.estudiante.grado}\nProductos a entregar:\n${itemsList}`);
|
alert(`¡ENTREGA EXPRESS EXITOSA!\n${data.mensaje}\nAlumno: ${data.estudiante.nombre_completo}\nGrado: ${data.estudiante.grado}\nHorario: ${badge.title}\n\nProductos a entregar:\n${itemsList}`);
|
||||||
|
|
||||||
loadPreOrders();
|
loadPreOrders();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -1391,6 +1565,42 @@ async function dispatchPreOrderExpress(qrToken) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showPreOrderIncomingNotification(orden) {
|
||||||
|
const badge = getMomentoBadge(orden.momento_entrega);
|
||||||
|
const container = document.createElement('div');
|
||||||
|
container.className = 'pos-incoming-preorder-toast';
|
||||||
|
container.style.borderLeft = `6px solid ${badge.border}`;
|
||||||
|
|
||||||
|
container.innerHTML = `
|
||||||
|
<div style="font-size: 1.8rem; flex-shrink: 0;">${badge.icon}</div>
|
||||||
|
<div style="flex: 1; min-width: 0;">
|
||||||
|
<div style="display: flex; align-items: center; gap: 6px;">
|
||||||
|
<strong style="color: #0f172a; font-size: 0.92rem;">¡Nueva Pre-orden Recibida!</strong>
|
||||||
|
<span style="background: ${badge.badgeBg}; color: ${badge.badgeColor}; border: 1px solid ${badge.badgeBorder}; padding: 1px 7px; border-radius: 6px; font-size: 0.72rem; font-weight: 800;">
|
||||||
|
${badge.title}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-size: 0.8rem; color: #475569; margin-top: 2px;">
|
||||||
|
<strong>${orden.estudiante_nombre || 'Estudiante'}</strong> (${orden.grado || ''}) • ₡${(orden.total_colones || 0).toLocaleString('es-CR')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" onclick="switchPosTab('preordenes'); this.closest('.pos-incoming-preorder-toast').remove();" class="btn-saas btn-saas-primary" style="padding: 6px 12px; font-size: 0.78rem; border-radius: 8px; flex-shrink: 0;">
|
||||||
|
Ver
|
||||||
|
</button>
|
||||||
|
<button type="button" onclick="this.closest('.pos-incoming-preorder-toast').remove();" style="background: none; border: none; font-size: 1.1rem; color: #94a3b8; cursor: pointer; padding: 4px;">✕</button>
|
||||||
|
`;
|
||||||
|
|
||||||
|
document.body.appendChild(container);
|
||||||
|
setTimeout(() => {
|
||||||
|
if (container.parentNode) {
|
||||||
|
container.style.opacity = '0';
|
||||||
|
container.style.transform = 'translateX(100%)';
|
||||||
|
container.style.transition = 'all 0.3s ease';
|
||||||
|
setTimeout(() => container.remove(), 300);
|
||||||
|
}
|
||||||
|
}, 6000);
|
||||||
|
}
|
||||||
|
|
||||||
// ==========================================
|
// ==========================================
|
||||||
// SSE (SERVER-SENT EVENTS EN TIEMPO REAL)
|
// SSE (SERVER-SENT EVENTS EN TIEMPO REAL)
|
||||||
// ==========================================
|
// ==========================================
|
||||||
@@ -1399,10 +1609,16 @@ function initSSE() {
|
|||||||
sseSource = new EventSource('/api/events');
|
sseSource = new EventSource('/api/events');
|
||||||
|
|
||||||
sseSource.addEventListener('nueva_orden', (e) => {
|
sseSource.addEventListener('nueva_orden', (e) => {
|
||||||
const orden = JSON.parse(e.data);
|
try {
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
const orden = JSON.parse(e.data);
|
||||||
// Notificación sonora y visual
|
if (window.sounds) window.sounds.playSuccess();
|
||||||
loadPreOrders();
|
loadPreOrders();
|
||||||
|
if (orden && orden.tipo_orden === 'preorden') {
|
||||||
|
showPreOrderIncomingNotification(orden);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('Error en SSE nueva_orden:', err);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
sseSource.addEventListener('orden_actualizada', () => {
|
sseSource.addEventListener('orden_actualizada', () => {
|
||||||
|
|||||||
@@ -207,6 +207,26 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- FILTROS POR RECREO / HORARIO -->
|
||||||
|
<div class="pos-preorder-filter-bar">
|
||||||
|
<button type="button" class="pos-filter-pill active" id="filterPillTodos" onclick="filterPreOrdersByMomento('todos')">
|
||||||
|
<span>📋 Todos los Recreos</span>
|
||||||
|
<span class="pos-pill-count" id="countFilterTodos">0</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="pos-filter-pill" id="filterPillRecreo_1" onclick="filterPreOrdersByMomento('recreo_1')">
|
||||||
|
<span>🔔 1er Recreo (9:30 AM)</span>
|
||||||
|
<span class="pos-pill-count" id="countFilterRecreo1">0</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="pos-filter-pill" id="filterPillAlmuerzo" onclick="filterPreOrdersByMomento('almuerzo')">
|
||||||
|
<span>🍲 Almuerzo (11:45 AM)</span>
|
||||||
|
<span class="pos-pill-count" id="countFilterAlmuerzo">0</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="pos-filter-pill" id="filterPillRecreo_2" onclick="filterPreOrdersByMomento('recreo_2')">
|
||||||
|
<span>⏰ 2do Recreo (1:45 PM)</span>
|
||||||
|
<span class="pos-pill-count" id="countFilterRecreo2">0</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="preOrdersList" style="display: flex; flex-direction: column; gap: 12px;">
|
<div id="preOrdersList" style="display: flex; flex-direction: column; gap: 12px;">
|
||||||
<!-- Lista de pre-órdenes -->
|
<!-- Lista de pre-órdenes -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+29
-2
@@ -341,6 +341,14 @@ function initDatabase() {
|
|||||||
`);
|
`);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
|
// 9.2 Garantizar columnas de ordenes para SQLite
|
||||||
|
try { db.exec('ALTER TABLE ordenes ADD COLUMN cajero_id INTEGER DEFAULT 1'); } catch (e) {}
|
||||||
|
try { db.exec('ALTER TABLE ordenes ADD COLUMN saldo_anterior INTEGER DEFAULT 0'); } catch (e) {}
|
||||||
|
try { db.exec('ALTER TABLE ordenes ADD COLUMN saldo_posterior INTEGER DEFAULT 0'); } catch (e) {}
|
||||||
|
try { db.exec('ALTER TABLE ordenes ADD COLUMN metodo_pago TEXT DEFAULT "monedero_qr"'); } catch (e) {}
|
||||||
|
try { db.exec('ALTER TABLE ordenes ADD COLUMN observaciones TEXT'); } catch (e) {}
|
||||||
|
try { db.exec('ALTER TABLE ordenes ADD COLUMN escuela_id INTEGER DEFAULT 1'); } catch (e) {}
|
||||||
|
|
||||||
// 10. Diseños de Tarjetas Virtuales para Estudiantes
|
// 10. Diseños de Tarjetas Virtuales para Estudiantes
|
||||||
try {
|
try {
|
||||||
db.exec(`
|
db.exec(`
|
||||||
@@ -800,6 +808,18 @@ function recargaSaldoTransaction({ estudianteId, monto, comprobanteSinpe, descri
|
|||||||
return transaction();
|
return transaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Traduce y estandariza el código o texto de momento de entrega a una etiqueta humana amigable
|
||||||
|
*/
|
||||||
|
function formatMomentoLabel(momento) {
|
||||||
|
const m = String(momento || '').toLowerCase().trim();
|
||||||
|
if (m === 'recreo_1' || m.includes('1er') || m.includes('9:30')) return '1er Recreo (9:30 AM)';
|
||||||
|
if (m === 'almuerzo' || m.includes('almuerzo') || m.includes('11:45')) return 'Almuerzo (11:45 AM)';
|
||||||
|
if (m === 'recreo_2' || m.includes('2do') || m.includes('1:45')) return '2do Recreo (1:45 PM)';
|
||||||
|
if (m === 'inmediato' || m.includes('inmediato')) return 'Entrega Inmediata';
|
||||||
|
return momento || '1er Recreo (9:30 AM)';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crea una orden completa (Mostrador o Preorden) con sus ítems
|
* Crea una orden completa (Mostrador o Preorden) con sus ítems
|
||||||
*/
|
*/
|
||||||
@@ -919,13 +939,19 @@ function crearOrdenCompleta({ estudianteId, tipoOrden, momentoEntrega, notas, it
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
orden_id: ordenId,
|
orden_id: ordenId,
|
||||||
|
id: ordenId,
|
||||||
codigo_orden: codigoOrden,
|
codigo_orden: codigoOrden,
|
||||||
estudiante_id: estudianteId,
|
estudiante_id: estudianteId,
|
||||||
|
estudiante_nombre: est.nombre_completo,
|
||||||
|
grado: est.grado,
|
||||||
|
seccion: est.seccion,
|
||||||
tipo_orden: tipoOrden,
|
tipo_orden: tipoOrden,
|
||||||
momento_entrega: momentoEntrega,
|
momento_entrega: momentoVal,
|
||||||
|
momento_entrega_label: formatMomentoLabel(momentoVal),
|
||||||
estado: estadoInicial,
|
estado: estadoInicial,
|
||||||
total_colones: totalColones,
|
total_colones: totalColones,
|
||||||
detalles: detallesParaInsertar,
|
detalles: detallesParaInsertar,
|
||||||
|
items: detallesParaInsertar,
|
||||||
productosActualizados,
|
productosActualizados,
|
||||||
financiero: resultadoDebito
|
financiero: resultadoDebito
|
||||||
};
|
};
|
||||||
@@ -1493,5 +1519,6 @@ module.exports = {
|
|||||||
procesarSolicitudRecargaSinpe,
|
procesarSolicitudRecargaSinpe,
|
||||||
guardarSuscripcionPush,
|
guardarSuscripcionPush,
|
||||||
obtenerSuscripcionesPush,
|
obtenerSuscripcionesPush,
|
||||||
eliminarSuscripcionPush
|
eliminarSuscripcionPush,
|
||||||
|
formatMomentoLabel
|
||||||
};
|
};
|
||||||
|
|||||||
+4
-1
@@ -27,7 +27,8 @@ const {
|
|||||||
procesarSolicitudRecargaSinpe,
|
procesarSolicitudRecargaSinpe,
|
||||||
guardarSuscripcionPush,
|
guardarSuscripcionPush,
|
||||||
obtenerSuscripcionesPush,
|
obtenerSuscripcionesPush,
|
||||||
eliminarSuscripcionPush
|
eliminarSuscripcionPush,
|
||||||
|
formatMomentoLabel
|
||||||
} = require('./db');
|
} = require('./db');
|
||||||
const { checkSinpeEmailsOnce, simularSinpeEmail } = require('./sinpeImapService');
|
const { checkSinpeEmailsOnce, simularSinpeEmail } = require('./sinpeImapService');
|
||||||
const { normalizarCodigoDetalle, parseSinpeEmail } = require('./sinpeParser');
|
const { normalizarCodigoDetalle, parseSinpeEmail } = require('./sinpeParser');
|
||||||
@@ -2473,6 +2474,7 @@ app.get('/api/ordenes', (req, res) => {
|
|||||||
const ordenes = db.prepare(query).all(...params);
|
const ordenes = db.prepare(query).all(...params);
|
||||||
const resultado = ordenes.map(o => ({
|
const resultado = ordenes.map(o => ({
|
||||||
...o,
|
...o,
|
||||||
|
momento_entrega_label: formatMomentoLabel(o.momento_entrega),
|
||||||
items: Array.isArray(o.items_json)
|
items: Array.isArray(o.items_json)
|
||||||
? o.items_json
|
? o.items_json
|
||||||
: (typeof o.items_json === 'string' ? JSON.parse(o.items_json || '[]') : [])
|
: (typeof o.items_json === 'string' ? JSON.parse(o.items_json || '[]') : [])
|
||||||
@@ -2548,6 +2550,7 @@ app.post('/api/ordenes/despachar-qr', (req, res) => {
|
|||||||
id: preorden.id,
|
id: preorden.id,
|
||||||
codigo: preorden.codigo_orden,
|
codigo: preorden.codigo_orden,
|
||||||
momento_entrega: preorden.momento_entrega,
|
momento_entrega: preorden.momento_entrega,
|
||||||
|
momento_entrega_label: formatMomentoLabel(preorden.momento_entrega),
|
||||||
total: preorden.total_colones,
|
total: preorden.total_colones,
|
||||||
items
|
items
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user