fix: optimizar buscador inteligente en carga manual de dinero y soporte de recarga rapida
This commit is contained in:
+12
-11
@@ -1739,8 +1739,9 @@ body.dark-mode .parent-child-card.selected {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.admin-search-input {
|
.admin-search-input {
|
||||||
flex: 1;
|
width: 100%;
|
||||||
padding: 11px 14px;
|
display: block;
|
||||||
|
padding: 11px 36px 11px 14px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
border: 1.5px solid var(--border, #cbd5e1);
|
border: 1.5px solid var(--border, #cbd5e1);
|
||||||
font-size: 0.95rem;
|
font-size: 0.95rem;
|
||||||
@@ -1748,13 +1749,13 @@ body.dark-mode .parent-child-card.selected {
|
|||||||
background: var(--card-bg, #ffffff);
|
background: var(--card-bg, #ffffff);
|
||||||
color: var(--text-main, #0f172a);
|
color: var(--text-main, #0f172a);
|
||||||
outline: none;
|
outline: none;
|
||||||
transition: border 0.15s;
|
transition: border 0.15s, box-shadow 0.15s;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-search-input:focus {
|
.admin-search-input:focus {
|
||||||
border-color: #0284c7;
|
border-color: #0284c7;
|
||||||
box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
|
box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-scan-btn {
|
.admin-scan-btn {
|
||||||
@@ -1784,13 +1785,13 @@ body.dark-mode .parent-child-card.selected {
|
|||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
background: var(--card-bg, #ffffff);
|
background: var(--card-bg, #ffffff);
|
||||||
border: 1.5px solid #0284c7;
|
border: 2px solid #0284c7;
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
max-height: 250px;
|
max-height: 290px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
z-index: 50;
|
z-index: 100;
|
||||||
box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
|
box-shadow: 0 14px 35px rgba(0, 0, 0, 0.22);
|
||||||
margin-top: 4px;
|
margin-top: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-search-item {
|
.admin-search-item {
|
||||||
@@ -1807,11 +1808,11 @@ body.dark-mode .parent-child-card.selected {
|
|||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-search-item:hover, .admin-search-item:active {
|
.admin-search-item:hover, .admin-search-item:active, .admin-search-item.selected {
|
||||||
background: #f0f9ff;
|
background: #f0f9ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .admin-search-item:hover {
|
body.dark-mode .admin-search-item:hover, body.dark-mode .admin-search-item.selected {
|
||||||
background: rgba(2, 132, 199, 0.15);
|
background: rgba(2, 132, 199, 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+46
-22
@@ -10,7 +10,7 @@
|
|||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||||
<meta name="apple-mobile-web-app-title" content="RecreoPay">
|
<meta name="apple-mobile-web-app-title" content="RecreoPay">
|
||||||
<meta name="mobile-web-app-capable" content="yes">
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
<link rel="stylesheet" href="/css/styles.css?v=8.1">
|
<link rel="stylesheet" href="/css/styles.css?v=8.3">
|
||||||
<style>
|
<style>
|
||||||
/* Transiciones suaves */
|
/* Transiciones suaves */
|
||||||
.fade-enter { animation: fadeIn 0.2s ease-in-out; }
|
.fade-enter { animation: fadeIn 0.2s ease-in-out; }
|
||||||
@@ -123,6 +123,9 @@
|
|||||||
<button onclick="toggleTheme()" class="theme-toggle-btn" title="Alternar Modo Oscuro / Modo Claro">
|
<button onclick="toggleTheme()" class="theme-toggle-btn" title="Alternar Modo Oscuro / Modo Claro">
|
||||||
🌙
|
🌙
|
||||||
</button>
|
</button>
|
||||||
|
<button onclick="switchAdminTab('recarga')" style="padding: 8px 14px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 10px; font-size: 0.82rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);" title="Cargar dinero a un estudiante">
|
||||||
|
<span>💵</span> Cargar Dinero
|
||||||
|
</button>
|
||||||
<a href="/pos.html" target="_blank" class="admin-action-btn-caja" title="Abrir Caja / Terminal POS">
|
<a href="/pos.html" target="_blank" class="admin-action-btn-caja" title="Abrir Caja / Terminal POS">
|
||||||
📟 Ir a Caja
|
📟 Ir a Caja
|
||||||
</a>
|
</a>
|
||||||
@@ -166,7 +169,7 @@
|
|||||||
🪪 Estudiantes, Carnés y Bloqueos
|
🪪 Estudiantes, Carnés y Bloqueos
|
||||||
</button>
|
</button>
|
||||||
<button class="admin-tab-btn" id="btnTabAdminRecarga" onclick="switchAdminTab('recarga')">
|
<button class="admin-tab-btn" id="btnTabAdminRecarga" onclick="switchAdminTab('recarga')">
|
||||||
💵 Cargar Dinero Manual en Caja
|
💵 Cargar Dinero Manual (Buscador y QR)
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -196,9 +199,12 @@
|
|||||||
Bloquea tarjetas perdidas, crea nuevos alumnos o genera carnés con código QR.
|
Bloquea tarjetas perdidas, crea nuevos alumnos o genera carnés con código QR.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<button onclick="openNewStudentModal()" style="padding: 9px 16px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 12px; font-size: 0.85rem; font-weight: 900; cursor: pointer; display: flex; align-items: center; gap: 6px;">
|
<div style="display: flex; gap: 8px; align-items: center; flex-wrap: wrap;">
|
||||||
<span>➕</span> Nuevo Estudiante
|
<input type="text" id="adminSearchStudentsTab2" placeholder="🔍 Filtrar alumnos..." oninput="filterAdminStudentsTab2(this.value)" style="padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--border); font-size: 0.85rem; width: 190px;">
|
||||||
</button>
|
<button onclick="openNewStudentModal()" style="padding: 9px 16px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 12px; font-size: 0.85rem; font-weight: 900; cursor: pointer; display: flex; align-items: center; gap: 6px;">
|
||||||
|
<span>➕</span> Nuevo Estudiante
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="adminStudentsList">
|
<div id="adminStudentsList">
|
||||||
@@ -210,49 +216,67 @@
|
|||||||
<div id="adminTabContentRecarga" class="admin-card" style="display: none; max-width: 550px; margin: 0 auto;">
|
<div id="adminTabContentRecarga" class="admin-card" style="display: none; max-width: 550px; margin: 0 auto;">
|
||||||
<div style="text-align: center; margin-bottom: 18px;">
|
<div style="text-align: center; margin-bottom: 18px;">
|
||||||
<span style="font-size: 2.2rem;">💵</span>
|
<span style="font-size: 2.2rem;">💵</span>
|
||||||
<h3 style="margin: 6px 0 2px 0; font-size: 1.2rem; font-weight: 900; color: var(--text-main);">Carga Manual de Dinero</h3>
|
<h3 style="margin: 6px 0 2px 0; font-size: 1.25rem; font-weight: 900; color: var(--text-main);">Carga Manual de Dinero</h3>
|
||||||
<p style="margin: 0; font-size: 0.78rem; color: var(--text-muted);">
|
<p style="margin: 0; font-size: 0.78rem; color: var(--text-muted);">
|
||||||
Recarga de monedero estudiantil por pago en efectivo en la soda o ajuste escolar
|
Recarga de monedero estudiantil por pago en efectivo en la soda o ajuste escolar
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- BUSCADOR INTELIGENTE Y BOTÓN ESCANEAR QR -->
|
<!-- BUSCADOR INTELIGENTE Y BOTÓN ESCANEAR QR -->
|
||||||
<div style="margin-bottom: 14px;">
|
<div style="background: rgba(2, 132, 199, 0.05); border: 2px solid #0284c7; border-radius: 16px; padding: 14px; margin-bottom: 16px; box-shadow: 0 3px 12px rgba(2, 132, 199, 0.08);">
|
||||||
<label style="display: block; font-size: 0.8rem; font-weight: 800; color: var(--text-main); margin-bottom: 6px;">
|
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 6px;">
|
||||||
Buscar Estudiante por Nombre, Apellidos o Carné:
|
<label for="inputAdminSearchStudent" style="font-size: 0.88rem; font-weight: 900; color: var(--text-main); display: flex; align-items: center; gap: 6px; margin: 0;">
|
||||||
</label>
|
<span style="font-size: 1.1rem;">🔍</span>
|
||||||
<div class="admin-search-container">
|
<span>Buscador Inteligente de Estudiante:</span>
|
||||||
<div class="admin-search-input-wrap">
|
</label>
|
||||||
<div style="position: relative; flex: 1;">
|
<span style="font-size: 0.68rem; font-weight: 800; background: #0284c7; color: white; padding: 2px 8px; border-radius: 6px;">
|
||||||
<input type="text" id="inputAdminSearchStudent" class="admin-search-input" placeholder="🔍 Escribe para buscar (ej: Mateo, EST-2026, Alvarado)..." oninput="onAdminSearchStudent(this.value)" autocomplete="off">
|
⚡ Búsqueda en vivo
|
||||||
<button type="button" id="btnClearAdminSearch" onclick="clearAdminSearchStudent()" style="display: none; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 1rem; color: #94a3b8; cursor: pointer;">✕</button>
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-search-container" style="position: relative;">
|
||||||
|
<div class="admin-search-input-wrap" style="display: flex; gap: 8px; align-items: center;">
|
||||||
|
<div style="position: relative; flex: 1; width: 100%;">
|
||||||
|
<input type="text" id="inputAdminSearchStudent" class="admin-search-input" placeholder="🔍 Escribe para buscar (ej: Mateo, EST-2026, Alvarado)..." oninput="onAdminSearchStudent(this.value)" onfocus="onAdminSearchFocus()" autocomplete="off" style="width: 100%; box-sizing: border-box; padding: 11px 36px 11px 14px; font-size: 0.95rem; font-weight: 700; border-radius: 12px; border: 2px solid #cbd5e1; outline: none; background: var(--card-bg, #ffffff); color: var(--text-main);">
|
||||||
|
<button type="button" id="btnClearAdminSearch" onclick="clearAdminSearchStudent()" style="display: none; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: #e2e8f0; border: none; border-radius: 50%; width: 22px; height: 22px; font-size: 0.75rem; font-weight: 900; color: #475569; cursor: pointer; align-items: center; justify-content: center;" title="Borrar búsqueda">✕</button>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" onclick="openAdminScanQrModal()" class="admin-scan-btn" title="Escanear carné físico o código QR con la cámara">
|
<button type="button" onclick="openAdminScanQrModal()" class="admin-scan-btn" title="Escanear carné físico o código QR con la cámara" style="flex-shrink: 0; padding: 11px 14px; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; border-radius: 12px; font-size: 0.85rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap;">
|
||||||
<span>📷</span>
|
<span>📷</span>
|
||||||
<span>Escanear QR</span>
|
<span>Escanear QR</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="adminSearchResultsDropdown" class="admin-search-dropdown" style="display: none;"></div>
|
<div id="adminSearchResultsDropdown" class="admin-search-dropdown" style="display: none;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="font-size: 0.72rem; color: var(--text-muted); margin-top: 6px;">
|
||||||
|
💡 <em>Toca el buscador para ver alumnos o escribe nombre, apellidos o carné para filtrar al instante.</em>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- FICHA DEL ESTUDIANTE SELECCIONADO -->
|
<!-- FICHA DEL ESTUDIANTE SELECCIONADO -->
|
||||||
|
<div style="margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center;">
|
||||||
|
<span style="font-size: 0.75rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;">
|
||||||
|
Estudiante seleccionado:
|
||||||
|
</span>
|
||||||
|
<button type="button" onclick="focusAdminSearch()" style="background: none; border: none; color: #0284c7; font-size: 0.74rem; font-weight: 800; cursor: pointer; text-decoration: underline;">
|
||||||
|
🔍 Cambiar / Buscar otro
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div id="adminSelectedStudentBanner" class="selected-student-banner" style="display: none;">
|
<div id="adminSelectedStudentBanner" class="selected-student-banner" style="display: none;">
|
||||||
<div style="display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;">
|
<div style="display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;">
|
||||||
<img id="adminSelectedAvatar" src="" style="width: 44px; height: 44px; border-radius: 50%; border: 2px solid #0284c7; background: white; flex-shrink: 0; object-fit: cover;">
|
<img id="adminSelectedAvatar" src="" style="width: 46px; height: 46px; border-radius: 50%; border: 2.5px solid #0284c7; background: white; flex-shrink: 0; object-fit: cover;">
|
||||||
<div style="min-width: 0;">
|
<div style="min-width: 0;">
|
||||||
<div style="display: flex; align-items: center; gap: 6px; flex-wrap: wrap;">
|
<div style="display: flex; align-items: center; gap: 6px; flex-wrap: wrap;">
|
||||||
<strong id="adminSelectedName" style="font-size: 0.95rem; color: var(--text-main); word-break: break-word;">Selecciona un alumno</strong>
|
<strong id="adminSelectedName" style="font-size: 0.98rem; color: var(--text-main); word-break: break-word;">Selecciona un alumno</strong>
|
||||||
<span id="adminSelectedStatusBadge" style="font-size: 0.65rem; font-weight: 800; background: #dcfce7; color: #166534; padding: 2px 6px; border-radius: 4px;">ACTIVA</span>
|
<span id="adminSelectedStatusBadge" style="font-size: 0.65rem; font-weight: 800; background: #dcfce7; color: #166534; padding: 2px 6px; border-radius: 4px;">ACTIVA</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="adminSelectedMeta" style="font-size: 0.74rem; color: var(--text-muted); margin-top: 2px;">
|
<div id="adminSelectedMeta" style="font-size: 0.75rem; color: var(--text-muted); margin-top: 2px;">
|
||||||
Grado y Sección • Cód: EST-2026-000
|
Grado y Sección • Cód: EST-2026-000
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align: right; flex-shrink: 0;">
|
<div style="text-align: right; flex-shrink: 0;">
|
||||||
<div style="font-size: 0.68rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase;">Saldo Actual</div>
|
<div style="font-size: 0.68rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase;">Saldo Actual</div>
|
||||||
<div id="adminSelectedBalance" style="font-size: 1.15rem; font-weight: 900; color: #10b981;">₡0</div>
|
<div id="adminSelectedBalance" style="font-size: 1.2rem; font-weight: 900; color: #10b981;">₡0</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -1070,8 +1094,8 @@
|
|||||||
</button>
|
</button>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<script src="/js/sounds.js?v=8.1"></script>
|
<script src="/js/sounds.js?v=8.3"></script>
|
||||||
<script src="/js/jsQR.js"></script>
|
<script src="/js/jsQR.js"></script>
|
||||||
<script src="/js/app.js?v=8.1"></script>
|
<script src="/js/app.js?v=8.3"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+130
-33
@@ -2090,7 +2090,10 @@ function renderAdminStudents(list) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="display: flex; gap: 8px; align-items: center; justify-content: flex-end; border-top: 1px dashed var(--border); padding-top: 8px; width: 100%;">
|
<div style="display: flex; gap: 8px; align-items: center; justify-content: flex-end; border-top: 1px dashed var(--border); padding-top: 8px; width: 100%; flex-wrap: wrap;">
|
||||||
|
<button type="button" onclick="quickGoToRecarga(${s.id})" style="padding: 7px 12px; background: #10b981; color: white; border: none; border-radius: 8px; font-size: 0.76rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 4px;" title="Cargar dinero en caja a este estudiante">
|
||||||
|
💵 Cargar Dinero
|
||||||
|
</button>
|
||||||
<a href="/carnet.html?id=${s.id}" target="_blank" style="padding: 7px 12px; background: #e0f2fe; color: #0369a1; border-radius: 8px; font-size: 0.76rem; font-weight: 800; text-decoration: none;" title="Ver e Imprimir Carné Físico">
|
<a href="/carnet.html?id=${s.id}" target="_blank" style="padding: 7px 12px; background: #e0f2fe; color: #0369a1; border-radius: 8px; font-size: 0.76rem; font-weight: 800; text-decoration: none;" title="Ver e Imprimir Carné Físico">
|
||||||
🖨️ Carné
|
🖨️ Carné
|
||||||
</a>
|
</a>
|
||||||
@@ -2195,20 +2198,33 @@ function setupAdminSmartSearch() {
|
|||||||
if (students && students.length > 0) {
|
if (students && students.length > 0) {
|
||||||
populateAdminRecargaStudents(students);
|
populateAdminRecargaStudents(students);
|
||||||
if (!adminSelectedStudent) {
|
if (!adminSelectedStudent) {
|
||||||
selectAdminStudent(students[0].id);
|
// Pre-seleccionar pero NO rellenar el input de búsqueda para que el placeholder sea visible
|
||||||
|
selectAdminStudent(students[0].id, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateAdminRecargaStudents(list) {
|
function populateAdminRecargaStudents(list) {
|
||||||
const sel = document.getElementById('adminRecargaStudentSelect');
|
const sel = document.getElementById('adminRecargaStudentSelect');
|
||||||
if (!sel) return;
|
if (sel) {
|
||||||
sel.innerHTML = (list || []).map(s => `
|
sel.innerHTML = (list || []).map(s => `
|
||||||
<option value="${s.id}">${s.nombre_completo} (Saldo actual: ₡${(s.saldo_colones || 0).toLocaleString('es-CR')})</option>
|
<option value="${s.id}">${s.nombre_completo} (Saldo actual: ₡${(s.saldo_colones || 0).toLocaleString('es-CR')})</option>
|
||||||
`).join('');
|
`).join('');
|
||||||
|
}
|
||||||
|
|
||||||
if (list && list.length > 0 && !adminSelectedStudent) {
|
if (list && list.length > 0 && !adminSelectedStudent) {
|
||||||
selectAdminStudent(list[0].id);
|
selectAdminStudent(list[0].id, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAdminSearchFocus() {
|
||||||
|
const input = document.getElementById('inputAdminSearchStudent');
|
||||||
|
const q = (input ? input.value : '').trim();
|
||||||
|
if (q.length > 0) {
|
||||||
|
onAdminSearchStudent(q);
|
||||||
|
} else {
|
||||||
|
// Al hacer clic o focus, mostrar la lista de estudiantes disponibles de inmediato
|
||||||
|
renderAdminSearchDropdown(students || []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2217,12 +2233,11 @@ function onAdminSearchStudent(query) {
|
|||||||
const dropdown = document.getElementById('adminSearchResultsDropdown');
|
const dropdown = document.getElementById('adminSearchResultsDropdown');
|
||||||
const btnClear = document.getElementById('btnClearAdminSearch');
|
const btnClear = document.getElementById('btnClearAdminSearch');
|
||||||
|
|
||||||
if (btnClear) btnClear.style.display = q.length > 0 ? 'block' : 'none';
|
if (btnClear) btnClear.style.display = q.length > 0 ? 'flex' : 'none';
|
||||||
if (!dropdown) return;
|
if (!dropdown) return;
|
||||||
|
|
||||||
if (q.length === 0) {
|
if (q.length === 0) {
|
||||||
dropdown.style.display = 'none';
|
renderAdminSearchDropdown(students || []);
|
||||||
dropdown.innerHTML = '';
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2235,27 +2250,49 @@ function onAdminSearchStudent(query) {
|
|||||||
|
|
||||||
if (results.length === 0) {
|
if (results.length === 0) {
|
||||||
dropdown.innerHTML = `
|
dropdown.innerHTML = `
|
||||||
<div style="padding: 12px; text-align: center; color: var(--text-muted); font-size: 0.8rem;">
|
<div style="padding: 16px 12px; text-align: center; color: var(--text-muted); font-size: 0.85rem;">
|
||||||
No se encontró ningún estudiante con "<strong>${query}</strong>"
|
❌ No se encontró ningún estudiante con "<strong>${query}</strong>"
|
||||||
|
<div style="margin-top: 6px; font-size: 0.74rem;">Intenta con el primer nombre, apellidos o carné (ej: EST-2026-001)</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
dropdown.style.display = 'block';
|
dropdown.style.display = 'block';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dropdown.innerHTML = results.map(s => `
|
renderAdminSearchDropdown(results, q);
|
||||||
<div class="admin-search-item" onclick="selectAdminStudent(${s.id})">
|
}
|
||||||
<img src="${s.foto_url || '/img/avatar_default.png'}" style="width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1.5px solid #0284c7; flex-shrink: 0;">
|
|
||||||
<div style="min-width: 0; flex: 1;">
|
function renderAdminSearchDropdown(list, query = '') {
|
||||||
<strong style="font-size: 0.88rem; color: var(--text-main); display: block; word-break: break-word;">${s.nombre_completo}</strong>
|
const dropdown = document.getElementById('adminSearchResultsDropdown');
|
||||||
<span style="font-size: 0.72rem; color: var(--text-muted);">${s.grado} - Sec. ${s.seccion} • Cód: ${s.codigo_estudiante}</span>
|
if (!dropdown) return;
|
||||||
</div>
|
|
||||||
<div style="text-align: right; flex-shrink: 0;">
|
const displayList = (list || []).slice(0, 12);
|
||||||
<span style="font-size: 0.65rem; color: var(--text-muted); display: block; text-transform: uppercase;">Saldo</span>
|
dropdown.innerHTML = `
|
||||||
<strong style="font-size: 0.95rem; color: #10b981;">₡${(s.saldo_colones || 0).toLocaleString('es-CR')}</strong>
|
<div style="padding: 6px 12px; background: #f8fafc; border-bottom: 1px solid var(--border); font-size: 0.72rem; font-weight: 800; color: var(--text-muted); display: flex; justify-content: space-between; align-items: center;">
|
||||||
</div>
|
<span>${query ? `🔍 Resultados para "${query}" (${list.length})` : `👥 Estudiantes Registrados (${list.length})`}:</span>
|
||||||
|
<span style="color: #0284c7;">${displayList.length < list.length ? `Mostrando primeros ${displayList.length}` : 'Todos'}</span>
|
||||||
</div>
|
</div>
|
||||||
`).join('');
|
${displayList.map(s => {
|
||||||
|
const isSelected = adminSelectedStudent && adminSelectedStudent.id === s.id;
|
||||||
|
return `
|
||||||
|
<div class="admin-search-item ${isSelected ? 'selected' : ''}" onclick="selectAdminStudent(${s.id}, true)">
|
||||||
|
<img src="${s.foto_url || '/img/avatar_default.png'}" style="width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid ${isSelected ? '#0284c7' : '#cbd5e1'}; flex-shrink: 0;">
|
||||||
|
<div style="min-width: 0; flex: 1;">
|
||||||
|
<div style="display: flex; align-items: center; gap: 6px;">
|
||||||
|
<strong style="font-size: 0.9rem; color: var(--text-main); display: block; word-break: break-word;">${s.nombre_completo}</strong>
|
||||||
|
${isSelected ? '<span style="font-size: 0.62rem; font-weight: 900; background: #0284c7; color: white; padding: 1px 5px; border-radius: 4px;">ACTUAL</span>' : ''}
|
||||||
|
${s.tarjeta_bloqueada ? '<span style="font-size: 0.62rem; font-weight: 900; background: #fee2e2; color: #dc2626; padding: 1px 5px; border-radius: 4px;">BLOQUEADA</span>' : ''}
|
||||||
|
</div>
|
||||||
|
<span style="font-size: 0.73rem; color: var(--text-muted);">${s.grado} - Sec. ${s.seccion} • Cód: <strong style="color: #0284c7;">${s.codigo_estudiante}</strong></span>
|
||||||
|
</div>
|
||||||
|
<div style="text-align: right; flex-shrink: 0;">
|
||||||
|
<span style="font-size: 0.65rem; color: var(--text-muted); display: block; text-transform: uppercase;">Saldo</span>
|
||||||
|
<strong style="font-size: 0.95rem; color: #10b981;">₡${(s.saldo_colones || 0).toLocaleString('es-CR')}</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}).join('')}
|
||||||
|
`;
|
||||||
dropdown.style.display = 'block';
|
dropdown.style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2263,7 +2300,10 @@ function clearAdminSearchStudent() {
|
|||||||
const input = document.getElementById('inputAdminSearchStudent');
|
const input = document.getElementById('inputAdminSearchStudent');
|
||||||
const btnClear = document.getElementById('btnClearAdminSearch');
|
const btnClear = document.getElementById('btnClearAdminSearch');
|
||||||
const dropdown = document.getElementById('adminSearchResultsDropdown');
|
const dropdown = document.getElementById('adminSearchResultsDropdown');
|
||||||
if (input) input.value = '';
|
if (input) {
|
||||||
|
input.value = '';
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
if (btnClear) btnClear.style.display = 'none';
|
if (btnClear) btnClear.style.display = 'none';
|
||||||
if (dropdown) {
|
if (dropdown) {
|
||||||
dropdown.style.display = 'none';
|
dropdown.style.display = 'none';
|
||||||
@@ -2271,11 +2311,47 @@ function clearAdminSearchStudent() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAdminSelectChange(studentId) {
|
function focusAdminSearch() {
|
||||||
selectAdminStudent(parseInt(studentId, 10));
|
const input = document.getElementById('inputAdminSearchStudent');
|
||||||
|
if (input) {
|
||||||
|
input.value = '';
|
||||||
|
input.focus();
|
||||||
|
input.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
onAdminSearchFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAdminStudent(studentId) {
|
function quickGoToRecarga(studentId) {
|
||||||
|
switchAdminTab('recarga');
|
||||||
|
selectAdminStudent(studentId, true);
|
||||||
|
const montoInput = document.getElementById('adminRecargaMonto');
|
||||||
|
if (montoInput) {
|
||||||
|
setTimeout(() => {
|
||||||
|
montoInput.focus();
|
||||||
|
montoInput.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
}, 120);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterAdminStudentsTab2(query) {
|
||||||
|
const q = (query || '').toLowerCase().trim();
|
||||||
|
if (!q) {
|
||||||
|
renderAdminStudents(students);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const filtered = (students || []).filter(s => {
|
||||||
|
return (s.nombre_completo || '').toLowerCase().includes(q) ||
|
||||||
|
(s.codigo_estudiante || '').toLowerCase().includes(q) ||
|
||||||
|
`${s.grado || ''} ${s.seccion || ''}`.toLowerCase().includes(q);
|
||||||
|
});
|
||||||
|
renderAdminStudents(filtered);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAdminSelectChange(studentId) {
|
||||||
|
selectAdminStudent(parseInt(studentId, 10), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectAdminStudent(studentId, updateSearchInput = false) {
|
||||||
const id = parseInt(studentId, 10);
|
const id = parseInt(studentId, 10);
|
||||||
const student = (students || []).find(s => s.id === id);
|
const student = (students || []).find(s => s.id === id);
|
||||||
if (!student) return;
|
if (!student) return;
|
||||||
@@ -2293,6 +2369,7 @@ function selectAdminStudent(studentId) {
|
|||||||
const balance = document.getElementById('adminSelectedBalance');
|
const balance = document.getElementById('adminSelectedBalance');
|
||||||
const searchInput = document.getElementById('inputAdminSearchStudent');
|
const searchInput = document.getElementById('inputAdminSearchStudent');
|
||||||
const dropdown = document.getElementById('adminSearchResultsDropdown');
|
const dropdown = document.getElementById('adminSearchResultsDropdown');
|
||||||
|
const btnClear = document.getElementById('btnClearAdminSearch');
|
||||||
|
|
||||||
if (banner) banner.style.display = 'flex';
|
if (banner) banner.style.display = 'flex';
|
||||||
if (avatar) avatar.src = student.foto_url || '/img/avatar_default.png';
|
if (avatar) avatar.src = student.foto_url || '/img/avatar_default.png';
|
||||||
@@ -2311,13 +2388,33 @@ function selectAdminStudent(studentId) {
|
|||||||
if (meta) meta.textContent = `${student.grado} - Sección ${student.seccion} • Cód: ${student.codigo_estudiante}`;
|
if (meta) meta.textContent = `${student.grado} - Sección ${student.seccion} • Cód: ${student.codigo_estudiante}`;
|
||||||
if (balance) balance.textContent = `₡${(student.saldo_colones || 0).toLocaleString('es-CR')}`;
|
if (balance) balance.textContent = `₡${(student.saldo_colones || 0).toLocaleString('es-CR')}`;
|
||||||
|
|
||||||
if (searchInput) searchInput.value = student.nombre_completo;
|
if (searchInput) {
|
||||||
|
if (updateSearchInput) {
|
||||||
|
searchInput.value = student.nombre_completo;
|
||||||
|
if (btnClear) btnClear.style.display = 'flex';
|
||||||
|
} else {
|
||||||
|
// Mantener vacío para que el placeholder "🔍 Escribe para buscar..." sea completamente visible
|
||||||
|
searchInput.value = '';
|
||||||
|
if (btnClear) btnClear.style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
if (dropdown) dropdown.style.display = 'none';
|
if (dropdown) dropdown.style.display = 'none';
|
||||||
|
|
||||||
const montoInput = document.getElementById('adminRecargaMonto');
|
if (updateSearchInput) {
|
||||||
if (montoInput) montoInput.focus();
|
const montoInput = document.getElementById('adminRecargaMonto');
|
||||||
|
if (montoInput) montoInput.focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cierre automático del dropdown al hacer clic fuera del buscador
|
||||||
|
document.addEventListener('click', (e) => {
|
||||||
|
const container = document.querySelector('.admin-search-container');
|
||||||
|
const dropdown = document.getElementById('adminSearchResultsDropdown');
|
||||||
|
if (container && dropdown && !container.contains(e.target)) {
|
||||||
|
dropdown.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ESCANEO QR CON CÁMARA EN MOSTRADOR DE SODA (ADMIN)
|
// ESCANEO QR CON CÁMARA EN MOSTRADOR DE SODA (ADMIN)
|
||||||
function openAdminScanQrModal() {
|
function openAdminScanQrModal() {
|
||||||
const modal = document.getElementById('modalAdminScanQr');
|
const modal = document.getElementById('modalAdminScanQr');
|
||||||
@@ -2398,7 +2495,7 @@ async function handleAdminQrDetected(token) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (student) {
|
if (student) {
|
||||||
selectAdminStudent(student.id);
|
selectAdminStudent(student.id, true);
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
if (window.sounds) window.sounds.playSuccess();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2415,7 +2512,7 @@ async function handleAdminQrDetected(token) {
|
|||||||
else students.push(student);
|
else students.push(student);
|
||||||
|
|
||||||
populateAdminRecargaStudents(students);
|
populateAdminRecargaStudents(students);
|
||||||
selectAdminStudent(student.id);
|
selectAdminStudent(student.id, true);
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
if (window.sounds) window.sounds.playSuccess();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (window.sounds) window.sounds.playError();
|
if (window.sounds) window.sounds.playError();
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
// RecreoPay PWA Service Worker v8.2 - Pistola QR POS & Cobro Rápido
|
// RecreoPay PWA Service Worker v8.3 - Buscador Inteligente Carga Manual
|
||||||
const CACHE_NAME = 'recreopay-v8.2';
|
const CACHE_NAME = 'recreopay-v8.3';
|
||||||
const STATIC_ASSETS = [
|
const STATIC_ASSETS = [
|
||||||
'/',
|
'/',
|
||||||
'/index.html',
|
'/index.html',
|
||||||
|
|||||||
Reference in New Issue
Block a user