`; } // Download as .eml (opens in macOS Mail on double-click) function downloadEml(){ const tasks=scopedTasks(); const html=buildHtmlEmail(tasks); const subj=document.getElementById('ml-subj').value; const to=S.mlRecs.join(', '); const subjEnc='=?UTF-8?B?'+btoa(unescape(encodeURIComponent(subj)))+'?='; const eml=['MIME-Version: 1.0',`To: ${to}`,`Subject: ${subjEnc}`,'Content-Type: text/html; charset=UTF-8','Content-Transfer-Encoding: 8bit','',html].join('\r\n'); const a=document.createElement('a'); a.href=URL.createObjectURL(new Blob([eml],{type:'message/rfc822'})); a.download='lucas-ops-rapor.eml';a.click();URL.revokeObjectURL(a.href); } // Open preview in a new tab function openPreviewTab(){ const w=window.open('','_blank'); w.document.write(buildHtmlEmail(scopedTasks()));w.document.close(); } // Refresh iframe preview function refreshPreview(){ const html=buildHtmlEmail(scopedTasks()); const fr=document.getElementById('ml-preview');if(!fr)return; const doc=fr.contentDocument||fr.contentWindow.document; doc.open();doc.write(html);doc.close(); } // Send all tasks for a specific team member function sendMemberMail(memberId){ const m=memberById(memberId);if(!m)return; S.mlScope='member:'+memberId;S.mlRecs=m.email?[m.email]:[]; document.getElementById('mail-ov').style.display='flex'; document.getElementById('ml-subj').value=`LUCAS OPS — ${m.name} Görev Listesi`; const sel=document.getElementById('ml-sel'); sel.innerHTML=''+S.team.filter(x=>x.email).map(x=>``).join(''); refreshPreview();renderRecs(); } // ─── EXPORT / IMPORT ────────────────────────────────────── function exportData(){ const blob=new Blob([JSON.stringify({tasks:S.tasks,team:S.team,todos:S.todos,depts:S.depts},null,2)],{type:'application/json'}); const a=document.createElement('a');a.href=URL.createObjectURL(blob);a.download='lucas-ops-backup.json';a.click(); } function importData(e){ const f=e.target.files[0];if(!f)return; const r=new FileReader(); r.onload=ev=>{ try{ const d=JSON.parse(ev.target.result); if(!confirm('Mevcut veriler silinecek ve yedek yüklenecek. Devam?'))return; S.tasks=d.tasks||[];S.team=d.team||[];S.todos=d.todos||[];S.depts=d.depts||[]; save();renderAll();updateLoginHint();alert('Veriler başarıyla yüklendi!'); }catch{alert('Geçersiz dosya formatı');} };r.readAsText(f); } // ─── RENDER ALL ─────────────────────────────────────────── function renderAll(){ if(!S.currentUser)return; renderDash();renderTasks();renderTeam();renderTodos();renderDefs(); } // ─── INIT ───────────────────────────────────────────────── load();