Red de Cuidado Hefzibá
Gestión de Miembros

Grupo 1

Cuidador 1

0
Miembros
0
Presentes
0%
Asistencia
📅 Toca para cambiar fecha
✅ Asistencia guardada exitosamente
Control de Asistencia

⚠️ Confirmar Eliminación

¿Está seguro de eliminar a este miembro?

`; const win = window.open('', '_blank'); if (win) { win.document.write(html); win.document.close(); } else showToast('⚠️ Activa ventanas emergentes para ver el reporte'); } function backupData() { const backup = { version: '2.0', exportDate: new Date().toISOString(), groups, attendanceHistory, reportsData }; downloadContent(JSON.stringify(backup, null, 2), `hefziba_respaldo_${getDateKey(new Date())}.json`, 'application/json'); showToast('✅ Respaldo descargado exitosamente'); } function restoreData() { const input = document.createElement('input'); input.type = 'file'; input.accept = '.json'; input.addEventListener('change', e => { const file = e.target.files[0]; if (!file) return; const reader = new FileReader(); reader.onload = ev => { try { const data = JSON.parse(ev.target.result); if (!data.groups) throw new Error('Archivo inválido'); if (!confirm('¿Restaurar datos? Esto reemplazará los datos actuales.')) return; groups = data.groups; attendanceHistory = data.attendanceHistory || {}; reportsData = data.reportsData || {}; // Asegurar 20 grupos for (let i = 1; i <= 20; i++) if (!groups[i]) groups[i] = []; saveGroupsData(); saveAttendanceHistory(); saveReportsDataFn(); loadAttendanceForDate(); loadMembersTab(); if (currentUser.role === 'admin') buildAdminGroupSelect(); showToast('✅ Datos restaurados exitosamente'); } catch { alert('❌ Archivo de respaldo inválido'); } }; reader.readAsText(file); }); input.click(); } function downloadContent(content, filename, type) { const blob = new Blob([content], { type }); const url = URL.createObjectURL(blob); const a = Object.assign(document.createElement('a'), { href: url, download: filename }); a.click(); URL.revokeObjectURL(url); } // ===================================================================== // CONTACTO // ===================================================================== function callMember(phone) { window.open(`tel:${phone}`, '_self'); } function openMaps(address) { window.open(`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(address)}`, '_blank'); } function textMember(phone, name) { const msg = `Hola ${name}! Te extrañamos en la iglesia. ¿Cómo estás? Que Dios te bendiga.`; window.open(`sms:${phone}?body=${encodeURIComponent(msg)}`, '_self'); } // ===================================================================== // UI HELPERS // ===================================================================== function showToast(msg) { const toast = document.getElementById('toast'); toast.textContent = msg; toast.classList.add('show'); setTimeout(() => toast.classList.remove('show'), 3200); } // ===================================================================== // INICIALIZACIÓN // ===================================================================== document.addEventListener('DOMContentLoaded', () => { initializeData(); }); document.addEventListener('keydown', e => { if (e.key === 'Enter' && document.getElementById('loginScreen').style.display !== 'none') login(); if (e.key === 'Escape') { closeMemberModal(); cancelDelete(); } }); window.addEventListener('click', e => { if (e.target === document.getElementById('memberModal')) closeMemberModal(); if (e.target === document.getElementById('deleteModal')) cancelDelete(); });