feat(cards): remove chip icon and add option to set default card theme for new users
This commit is contained in:
@@ -3687,13 +3687,15 @@ body.dark-mode .staff-role-vendedor {
|
||||
.card-chip-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
justify-content: flex-end;
|
||||
min-height: 20px;
|
||||
margin-bottom: 12px;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.card-emv-chip {
|
||||
display: none !important;
|
||||
width: 38px;
|
||||
height: 28px;
|
||||
background: linear-gradient(135deg, #fef08a 0%, #eab308 50%, #ca8a04 100%);
|
||||
|
||||
+10
-9
@@ -361,6 +361,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 16px;">
|
||||
<label style="display: flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 700; color: var(--text-main); cursor: pointer;">
|
||||
<input type="checkbox" id="devCardIsDefault" style="width: 17px; height: 17px; accent-color: #0284c7;">
|
||||
<span>Establecer como tarjeta predeterminada para nuevos usuarios</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" id="btnDevSubmitCard" class="dev-action-btn dev-action-btn-primary" style="width: 100%; padding: 12px; justify-content: center; font-size: 0.95rem; border-radius: 12px; display: inline-flex; align-items: center; gap: 8px;">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg>
|
||||
<span>Guardar y Publicar Diseño</span>
|
||||
@@ -381,10 +388,7 @@
|
||||
<div id="devLiveCardPreviewWrapper" style="position: relative; width: 100%; aspect-ratio: 1.586; border-radius: 18px; overflow: hidden; background: #0f172a; border: 1.5px solid var(--border); box-shadow: 0 10px 25px rgba(0,0,0,0.25);">
|
||||
<img id="devLiveCardBgImg" src="/img/cards/card_robo_lab.jpg" alt="Fondo" style="width: 100%; height: 100%; object-fit: cover; display: block;">
|
||||
<div id="devLiveCardOverlay" class="card-overlay" style="opacity: 1; position: absolute; inset: 0; padding: 16px 18px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<div class="card-emv-chip" style="width: 34px; height: 25px; margin: 0;">
|
||||
<div class="chip-inner-circuit"></div>
|
||||
</div>
|
||||
<div style="display: flex; justify-content: flex-end; align-items: center;">
|
||||
<span id="devLiveCardBrand" style="font-weight: 900; font-size: 0.85rem; letter-spacing: 0.5px; text-transform: uppercase; color: #ffffff; text-shadow: 0 2px 8px rgba(0,0,0,0.8); display: inline-flex; align-items: center; gap: 5px;"><span style="color: #38bdf8; font-size: 0.65rem;">●</span> SIBOPAY</span>
|
||||
</div>
|
||||
<div style="margin-top: auto; margin-bottom: 6px;">
|
||||
@@ -2148,11 +2152,8 @@
|
||||
|
||||
<!-- TARJETA DIGITAL DE MONEDERO Y SALDO (ESTILO UNIFICADO TEENS) -->
|
||||
<section class="wallet-card" id="mainWalletCard">
|
||||
<!-- ELEMENTOS DE TARJETA INTELIGENTE (CHIP Y PAGO SIN CONTACTO, SIN ASTERISCOS) -->
|
||||
<div class="card-chip-container">
|
||||
<div class="card-emv-chip" title="Monedero Electrónico Escolar">
|
||||
<div class="chip-inner-circuit"></div>
|
||||
</div>
|
||||
<!-- ELEMENTOS DE TARJETA INTELIGENTE (PAGO SIN CONTACTO, SIN ASTERISCOS) -->
|
||||
<div class="card-chip-container" style="justify-content: flex-end;">
|
||||
<div class="card-contactless-wave" title="Tecnología QR / Sin Contacto">
|
||||
<span>)</span><span>)</span><span>)</span>
|
||||
</div>
|
||||
|
||||
+57
-11
@@ -7512,10 +7512,12 @@ function getSavedCardTheme() {
|
||||
if (studentTheme && themes.some(t => t.id === studentTheme)) {
|
||||
return studentTheme;
|
||||
}
|
||||
if (currentStudent.card_theme && themes.some(t => t.id === currentStudent.card_theme)) {
|
||||
return currentStudent.card_theme;
|
||||
}
|
||||
const globalTheme = localStorage.getItem('recreopay_card_theme');
|
||||
if (globalTheme && themes.some(t => t.id === globalTheme)) {
|
||||
return globalTheme;
|
||||
}
|
||||
if (currentUser && currentUser.card_theme && themes.some(t => t.id === currentUser.card_theme)) {
|
||||
return currentUser.card_theme;
|
||||
}
|
||||
const defaultTheme = themes.find(t => t.es_predeterminado) || themes[0];
|
||||
return defaultTheme ? defaultTheme.id : 'card_robo_lab';
|
||||
@@ -7601,10 +7603,7 @@ function renderCardDesignsCarousel() {
|
||||
<div class="card-carousel-slide" data-index="${idx}" data-theme="${t.id}">
|
||||
<!-- Vista previa de la tarjeta real (SIN ASTERISCOS) -->
|
||||
<div class="wallet-card has-custom-bg ${contrastClass}" style="margin: 0; cursor: pointer; transition: transform 0.2s; ${bgStyle}" onclick="selectCardTheme('${t.id}')">
|
||||
<div class="card-chip-container">
|
||||
<div class="card-emv-chip">
|
||||
<div class="chip-inner-circuit"></div>
|
||||
</div>
|
||||
<div class="card-chip-container" style="justify-content: flex-end;">
|
||||
<div class="card-contactless-wave"><span>)</span><span>)</span><span>)</span></div>
|
||||
</div>
|
||||
<div class="student-info">
|
||||
@@ -7726,6 +7725,12 @@ function selectCardTheme(themeId) {
|
||||
localStorage.setItem('recreopay_card_theme', themeId);
|
||||
if (currentStudent && currentStudent.id) {
|
||||
localStorage.setItem(`recreopay_card_theme_${currentStudent.id}`, themeId);
|
||||
currentStudent.card_theme = themeId;
|
||||
fetch(`/api/estudiantes/${currentStudent.id}/card-theme`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ card_theme: themeId })
|
||||
}).catch(e => console.warn('No se pudo guardar tema en servidor:', e));
|
||||
}
|
||||
|
||||
applyCardTheme(themeId);
|
||||
@@ -8168,6 +8173,7 @@ async function saveDevCardDesign(e) {
|
||||
const name = document.getElementById('devCardName').value.trim();
|
||||
const categoria = document.getElementById('devCardCategory').value;
|
||||
const estilo_texto = document.getElementById('devCardTextStyle').value;
|
||||
const isDefault = document.getElementById('devCardIsDefault')?.checked ? 1 : 0;
|
||||
const submitBtn = document.getElementById('btnDevSubmitCard');
|
||||
|
||||
if (!devUploadedBase64) {
|
||||
@@ -8186,6 +8192,7 @@ async function saveDevCardDesign(e) {
|
||||
nombre: name,
|
||||
categoria: categoria,
|
||||
estilo_texto: estilo_texto,
|
||||
es_predeterminado: isDefault,
|
||||
image_base64: devUploadedBase64
|
||||
})
|
||||
});
|
||||
@@ -8196,6 +8203,8 @@ async function saveDevCardDesign(e) {
|
||||
// Limpiar formulario
|
||||
devUploadedBase64 = null;
|
||||
document.getElementById('formDevCardDesign').reset();
|
||||
const chkDefault = document.getElementById('devCardIsDefault');
|
||||
if (chkDefault) chkDefault.checked = false;
|
||||
document.getElementById('devUploadPrompt').style.display = 'block';
|
||||
document.getElementById('devUploadSuccess').style.display = 'none';
|
||||
document.getElementById('devLiveCardBgImg').src = '/img/cards/card_robo_lab.jpg';
|
||||
@@ -8205,6 +8214,9 @@ async function saveDevCardDesign(e) {
|
||||
|
||||
await loadDevDisenos();
|
||||
await loadCardDesigns();
|
||||
if (isDefault && typeof applyCardTheme === 'function' && typeof getSavedCardTheme === 'function') {
|
||||
applyCardTheme(getSavedCardTheme());
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error guardando tarjeta:', err);
|
||||
if (window.sounds) window.sounds.playError();
|
||||
@@ -8262,15 +8274,17 @@ function renderDevDisenosGrid(disenos) {
|
||||
`<span style="color: #64748b; font-weight: 700; font-size: 0.72rem; background: #f8fafc; border: 1px solid #e2e8f0; padding: 2px 7px; border-radius: 6px;">Inactivo</span>`;
|
||||
|
||||
const textColorLabel = (d.estilo_texto === 'light') ? 'Texto Oscuro' : 'Texto Blanco';
|
||||
const isDefault = Boolean(d.es_predeterminado);
|
||||
|
||||
return `
|
||||
<div style="background: var(--card-bg, #ffffff); border: 1.5px solid var(--border, #e2e8f0); border-radius: 14px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.04); display: flex; flex-direction: column;">
|
||||
<div style="background: var(--card-bg, #ffffff); border: ${isDefault ? '2px solid #0284c7' : '1.5px solid var(--border, #e2e8f0)'}; border-radius: 14px; overflow: hidden; box-shadow: ${isDefault ? '0 4px 14px rgba(2, 132, 199, 0.18)' : '0 2px 8px rgba(0,0,0,0.04)'}; display: flex; flex-direction: column;">
|
||||
<div style="position: relative; aspect-ratio: 1.586; overflow: hidden; background: #0f172a;">
|
||||
<img src="${escapeHtml(d.imagen_url)}" alt="${escapeHtml(d.nombre)}" style="width: 100%; height: 100%; object-fit: cover; display: block;" onerror="this.src='/img/cards/card_robo_lab.jpg'">
|
||||
<div style="position: absolute; top: 8px; left: 8px; background: rgba(15, 23, 42, 0.75); color: white; font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; backdrop-filter: blur(4px);">
|
||||
${catLabel}
|
||||
</div>
|
||||
<div style="position: absolute; top: 8px; right: 8px;">
|
||||
<div style="position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; align-items: center;">
|
||||
${isDefault ? `<span style="color: #0284c7; font-weight: 800; font-size: 0.72rem; background: #e0f2fe; border: 1px solid #7dd3fc; padding: 2px 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 4px; box-shadow: 0 2px 6px rgba(2,132,199,0.25);">★ Predeterminada</span>` : ''}
|
||||
${statusBadge}
|
||||
</div>
|
||||
</div>
|
||||
@@ -8281,10 +8295,19 @@ function renderDevDisenosGrid(disenos) {
|
||||
</div>
|
||||
<div style="font-size: 0.72rem; color: var(--text-muted); display: flex; align-items: center; gap: 8px;">
|
||||
<span>${textColorLabel}</span>
|
||||
${d.es_predeterminado ? '<span style="color: #0284c7; font-weight: 700; background: #f0f9ff; border: 1px solid #bae6fd; padding: 1px 6px; border-radius: 4px;">Predeterminado</span>' : ''}
|
||||
${isDefault ? '<span style="color: #0284c7; font-weight: 800; background: #f0f9ff; border: 1px solid #bae6fd; padding: 1px 6px; border-radius: 4px;">● Predeterminada</span>' : ''}
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 12px; display: flex; gap: 6px; justify-content: flex-end;">
|
||||
<div style="margin-top: 12px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap;">
|
||||
${isDefault ? `
|
||||
<span class="dev-action-btn" style="padding: 5px 10px; font-size: 0.75rem; background: #f0fdf4; color: #166534; border: 1px solid #86efac; font-weight: 800; display: inline-flex; align-items: center; gap: 4px; cursor: default;" title="Esta tarjeta se asigna a todos los nuevos usuarios">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"><polyline points="20 6 9 17 4 12"/></svg> Predeterminada
|
||||
</span>
|
||||
` : `
|
||||
<button onclick="setDevCardAsDefault(${d.id}, '${escapeHtml(d.nombre)}')" class="dev-action-btn" style="padding: 5px 10px; font-size: 0.75rem; background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; font-weight: 800; display: inline-flex; align-items: center; gap: 4px;" title="Establecer como tarjeta predeterminada para nuevos usuarios">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg> Predeterminada
|
||||
</button>
|
||||
`}
|
||||
<button onclick="toggleDevCardStatus(${d.id}, ${d.activo ? 0 : 1})" class="dev-action-btn" style="padding: 5px 10px; font-size: 0.75rem;">
|
||||
${d.activo ? 'Desactivar' : 'Activar'}
|
||||
</button>
|
||||
@@ -8298,6 +8321,29 @@ function renderDevDisenosGrid(disenos) {
|
||||
}).join('');
|
||||
}
|
||||
|
||||
async function setDevCardAsDefault(id, nombre) {
|
||||
try {
|
||||
const res = await fetch(`/api/developer/disenos-tarjetas/${id}/predeterminada`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Error al cambiar tarjeta predeterminada');
|
||||
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
alert(`¡"${nombre}" es ahora la tarjeta predeterminada!\nTodos los nuevos usuarios creados tendrán este diseño por defecto.`);
|
||||
|
||||
await loadDevDisenos();
|
||||
await loadCardDesigns();
|
||||
if (typeof applyCardTheme === 'function' && typeof getSavedCardTheme === 'function') {
|
||||
applyCardTheme(getSavedCardTheme());
|
||||
}
|
||||
} catch (err) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
alert(`Error: ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleDevCardStatus(id, activo) {
|
||||
try {
|
||||
const res = await fetch(`/api/developer/disenos-tarjetas/${id}/estado`, {
|
||||
|
||||
@@ -381,6 +381,8 @@ function initDatabase() {
|
||||
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) {}
|
||||
try { db.exec('ALTER TABLE estudiantes ADD COLUMN card_theme TEXT'); } catch (e) {}
|
||||
try { db.exec('ALTER TABLE usuarios ADD COLUMN card_theme TEXT'); } catch (e) {}
|
||||
|
||||
// 10. Diseños de Tarjetas Virtuales para Estudiantes
|
||||
try {
|
||||
|
||||
+75
-17
@@ -1505,10 +1505,20 @@ app.delete('/api/admin/personal/:id', (req, res) => {
|
||||
// DEVELOPER MASTER SUITE & DISEÑOS DE TARJETAS
|
||||
// ==========================================
|
||||
|
||||
function getCardThemePredeterminado() {
|
||||
try {
|
||||
const row = db.prepare('SELECT theme_id FROM disenos_tarjetas WHERE es_predeterminado = 1 AND activo = 1 LIMIT 1').get()
|
||||
|| db.prepare('SELECT theme_id FROM disenos_tarjetas WHERE activo = 1 ORDER BY id ASC LIMIT 1').get();
|
||||
return row ? row.theme_id : 'card_robo_lab';
|
||||
} catch (e) {
|
||||
return 'card_robo_lab';
|
||||
}
|
||||
}
|
||||
|
||||
// Endpoint público para obtener diseños de tarjetas activas (utilizado por el carrusel y app de estudiantes)
|
||||
app.get('/api/disenos-tarjetas', (req, res) => {
|
||||
try {
|
||||
const disenos = db.prepare('SELECT * FROM disenos_tarjetas WHERE activo = 1 ORDER BY id ASC').all();
|
||||
const disenos = db.prepare('SELECT * FROM disenos_tarjetas WHERE activo = 1 ORDER BY es_predeterminado DESC, id ASC').all();
|
||||
res.json(disenos);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
@@ -1562,15 +1572,16 @@ app.post('/api/developer/usuarios', (req, res) => {
|
||||
return res.status(400).json({ error: `El nombre de usuario "${cleanUser}" ya se encuentra registrado.` });
|
||||
}
|
||||
|
||||
const defaultTheme = getCardThemePredeterminado();
|
||||
const result = db.prepare(`
|
||||
INSERT INTO usuarios (username, password_hash, rol, nombre, telefono, email, activo, escuela_id)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`).run(cleanUser, cleanPass, cleanRol, String(nombre).trim(), telefono || '', email || '', cleanActivo, escuelaId);
|
||||
INSERT INTO usuarios (username, password_hash, rol, nombre, telefono, email, activo, escuela_id, card_theme)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`).run(cleanUser, cleanPass, cleanRol, String(nombre).trim(), telefono || '', email || '', cleanActivo, escuelaId, defaultTheme);
|
||||
|
||||
res.status(201).json({
|
||||
exito: true,
|
||||
mensaje: `Usuario "${nombre}" (${cleanRol}) creado exitosamente con privilegios.`,
|
||||
usuario: { id: result.lastInsertRowid, username: cleanUser, rol: cleanRol, nombre, activo: cleanActivo, escuela_id: escuelaId }
|
||||
usuario: { id: result.lastInsertRowid, username: cleanUser, rol: cleanRol, nombre, activo: cleanActivo, escuela_id: escuelaId, card_theme: defaultTheme }
|
||||
});
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
@@ -1736,6 +1747,10 @@ app.post('/api/developer/disenos-tarjetas', (req, res) => {
|
||||
const cleanEstilo = estilo_texto === 'light' ? 'light' : 'dark';
|
||||
const cleanPred = es_predeterminado ? 1 : 0;
|
||||
|
||||
if (cleanPred === 1) {
|
||||
db.prepare('UPDATE disenos_tarjetas SET es_predeterminado = 0').run();
|
||||
}
|
||||
|
||||
const result = db.prepare(`
|
||||
INSERT INTO disenos_tarjetas (theme_id, nombre, categoria, imagen_url, estilo_texto, es_predeterminado, activo)
|
||||
VALUES (?, ?, ?, ?, ?, ?, 1)
|
||||
@@ -1754,6 +1769,31 @@ app.post('/api/developer/disenos-tarjetas', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Establecer diseño como predeterminado para todos los nuevos usuarios
|
||||
app.put('/api/developer/disenos-tarjetas/:id/predeterminada', (req, res) => {
|
||||
try {
|
||||
const id = parseInt(req.params.id, 10);
|
||||
const diseno = db.prepare('SELECT * FROM disenos_tarjetas WHERE id = ?').get(id);
|
||||
if (!diseno) return res.status(404).json({ error: 'Diseño no encontrado.' });
|
||||
|
||||
db.transaction(() => {
|
||||
db.prepare('UPDATE disenos_tarjetas SET es_predeterminado = 0').run();
|
||||
db.prepare('UPDATE disenos_tarjetas SET es_predeterminado = 1, activo = 1 WHERE id = ?').run(id);
|
||||
})();
|
||||
|
||||
const actualizado = db.prepare('SELECT * FROM disenos_tarjetas WHERE id = ?').get(id);
|
||||
broadcastEvent('disenos_actualizados', actualizado);
|
||||
|
||||
res.json({
|
||||
exito: true,
|
||||
mensaje: `¡El diseño "${diseno.nombre}" ahora es el diseño predeterminado para todos los nuevos usuarios!`,
|
||||
diseno: actualizado
|
||||
});
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Activar / Desactivar diseño de tarjeta
|
||||
app.put('/api/developer/disenos-tarjetas/:id/estado', (req, res) => {
|
||||
try {
|
||||
@@ -1771,6 +1811,20 @@ app.put('/api/developer/disenos-tarjetas/:id/estado', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Actualizar diseño personalizado de tarjeta de un estudiante
|
||||
app.put('/api/estudiantes/:id/card-theme', (req, res) => {
|
||||
try {
|
||||
const id = parseInt(req.params.id, 10);
|
||||
const { card_theme } = req.body;
|
||||
if (!card_theme) return res.status(400).json({ error: 'card_theme es obligatorio.' });
|
||||
|
||||
db.prepare('UPDATE estudiantes SET card_theme = ? WHERE id = ?').run(String(card_theme).trim(), id);
|
||||
res.json({ exito: true, card_theme: String(card_theme).trim() });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Eliminar diseño de tarjeta
|
||||
app.delete('/api/developer/disenos-tarjetas/:id', (req, res) => {
|
||||
try {
|
||||
@@ -2118,6 +2172,7 @@ app.post('/api/developer/estudiantes/importar-masivo', (req, res) => {
|
||||
|
||||
const maxRow = db.prepare('SELECT MAX(id) as maxId FROM estudiantes').get();
|
||||
let currentSeq = (maxRow && maxRow.maxId ? maxRow.maxId : 0) + 1;
|
||||
const defaultCardTheme = getCardThemePredeterminado();
|
||||
|
||||
let insertados = 0;
|
||||
let omitidos = 0;
|
||||
@@ -2129,8 +2184,8 @@ app.post('/api/developer/estudiantes/importar-masivo', (req, res) => {
|
||||
codigo_estudiante, nombre_completo, edad, grado, seccion,
|
||||
qr_token, pin_seguridad, foto_url, saldo_colones, limite_diario_colones,
|
||||
alergias, padre_nombre, padre_telefono, permitir_transferencias,
|
||||
tarjeta_bloqueada, activo, escuela_id
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, 1, 0, 1, ?)
|
||||
tarjeta_bloqueada, activo, escuela_id, card_theme
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, 1, 0, 1, ?, ?)
|
||||
`);
|
||||
|
||||
const insertTxStmt = db.prepare(`
|
||||
@@ -2140,8 +2195,8 @@ app.post('/api/developer/estudiantes/importar-masivo', (req, res) => {
|
||||
`);
|
||||
|
||||
const insertUserStmt = db.prepare(`
|
||||
INSERT INTO usuarios (username, password_hash, rol, nombre, activo, escuela_id)
|
||||
VALUES (?, ?, 'estudiante', ?, 1, ?)
|
||||
INSERT INTO usuarios (username, password_hash, rol, nombre, activo, escuela_id, card_theme)
|
||||
VALUES (?, ?, 'estudiante', ?, 1, ?, ?)
|
||||
`);
|
||||
|
||||
const processImport = db.transaction(() => {
|
||||
@@ -2195,7 +2250,8 @@ app.post('/api/developer/estudiantes/importar-masivo', (req, res) => {
|
||||
alergias,
|
||||
padreNombre,
|
||||
padreTelefono,
|
||||
escuela_id
|
||||
escuela_id,
|
||||
defaultCardTheme
|
||||
);
|
||||
|
||||
const newEstId = resEst.lastInsertRowid || resEst.id;
|
||||
@@ -2206,7 +2262,7 @@ app.post('/api/developer/estudiantes/importar-masivo', (req, res) => {
|
||||
|
||||
const usernameEst = primerNombre.toLowerCase() + currentSeq;
|
||||
try {
|
||||
const resUser = insertUserStmt.run(usernameEst, pin, cleanNombre, escuela_id);
|
||||
const resUser = insertUserStmt.run(usernameEst, pin, cleanNombre, escuela_id, defaultCardTheme);
|
||||
const userId = resUser.lastInsertRowid || resUser.id;
|
||||
db.prepare('UPDATE estudiantes SET usuario_id = ? WHERE id = ?').run(userId, newEstId);
|
||||
} catch (e) {}
|
||||
@@ -2278,11 +2334,12 @@ app.post('/api/admin/estudiantes', (req, res) => {
|
||||
const limite = parseInt(limite_diario_colones, 10) || 3000;
|
||||
const edadNum = parseInt(edad, 10) || 8;
|
||||
const foto = null;
|
||||
const defaultCardTheme = getCardThemePredeterminado();
|
||||
|
||||
const resEst = db.prepare(`
|
||||
INSERT INTO estudiantes
|
||||
(codigo_estudiante, nombre_completo, edad, grado, seccion, qr_token, pin_seguridad, foto_url, saldo_colones, limite_diario_colones, alergias, padre_nombre, padre_telefono, permitir_transferencias, tarjeta_bloqueada, activo, escuela_id)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 0, 1, ?)
|
||||
(codigo_estudiante, nombre_completo, edad, grado, seccion, qr_token, pin_seguridad, foto_url, saldo_colones, limite_diario_colones, alergias, padre_nombre, padre_telefono, permitir_transferencias, tarjeta_bloqueada, activo, escuela_id, card_theme)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 0, 1, ?, ?)
|
||||
`).run(
|
||||
codigoEstudiante,
|
||||
nombre_completo.trim(),
|
||||
@@ -2297,7 +2354,8 @@ app.post('/api/admin/estudiantes', (req, res) => {
|
||||
alergias || 'Ninguna conocida',
|
||||
padre_nombre || '',
|
||||
padre_telefono || '',
|
||||
escuelaId
|
||||
escuelaId,
|
||||
defaultCardTheme
|
||||
);
|
||||
|
||||
const nuevoId = resEst.lastInsertRowid || resEst.id;
|
||||
@@ -2306,9 +2364,9 @@ app.post('/api/admin/estudiantes', (req, res) => {
|
||||
const usernameEst = primerNombre.toLowerCase() + nextSeq;
|
||||
try {
|
||||
const userRes = db.prepare(`
|
||||
INSERT INTO usuarios (username, password_hash, rol, nombre, email, telefono, activo, escuela_id)
|
||||
VALUES (?, ?, 'estudiante', ?, '', '', 1, ?)
|
||||
`).run(usernameEst, pin, nombre_completo.trim(), escuelaId);
|
||||
INSERT INTO usuarios (username, password_hash, rol, nombre, email, telefono, activo, escuela_id, card_theme)
|
||||
VALUES (?, ?, 'estudiante', ?, '', '', 1, ?, ?)
|
||||
`).run(usernameEst, pin, nombre_completo.trim(), escuelaId, defaultCardTheme);
|
||||
db.prepare('UPDATE estudiantes SET usuario_id = ? WHERE id = ?').run(userRes.lastInsertRowid || userRes.id, nuevoId);
|
||||
} catch (e) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user