diff --git a/admin.html b/admin.html
new file mode 100644
index 0000000..54cf3b4
--- /dev/null
+++ b/admin.html
@@ -0,0 +1,743 @@
+
+
+
+
@@ -1461,6 +1500,12 @@
+
+
Stammvertreter wählen
+
+
+
+
@@ -1751,6 +1796,151 @@ function extrasKey(name) {
return (name || '').toLowerCase().trim();
}
+// ============================================================
+// STAMMVERTRETER (Profilvorrat für Vertretungen)
+// ============================================================
+function stammvertreterKey() {
+ return activeChapter ? `bni-stammvertreter-${activeChapter.code}` : 'bni-stammvertreter';
+}
+function loadStammvertreter() {
+ try { return JSON.parse(localStorage.getItem(stammvertreterKey()) || '[]'); } catch(e) { return []; }
+}
+function saveStammvertreter(list) {
+ localStorage.setItem(stammvertreterKey(), JSON.stringify(list));
+}
+
+let _svEditingPhotoB64 = null;
+
+function openAddSv() {
+ document.getElementById('sv-modal-id').value = '';
+ document.getElementById('sv-modal-title').textContent = 'Stammvertreter hinzufügen';
+ document.getElementById('sv-modal-name').value = '';
+ document.getElementById('sv-modal-company').value = '';
+ document.getElementById('sv-modal-specialty').value = '';
+ document.getElementById('sv-delete-btn').style.display = 'none';
+ _svEditingPhotoB64 = null;
+ _updateSvPhotoUI(null);
+ openModal('modal-sv');
+}
+
+function openEditSv(svId) {
+ const sv = loadStammvertreter().find(s => s.id === svId);
+ if (!sv) return;
+ document.getElementById('sv-modal-id').value = sv.id;
+ document.getElementById('sv-modal-title').textContent = 'Stammvertreter bearbeiten';
+ document.getElementById('sv-modal-name').value = sv.name;
+ document.getElementById('sv-modal-company').value = sv.company || '';
+ document.getElementById('sv-modal-specialty').value = sv.specialty || '';
+ document.getElementById('sv-delete-btn').style.display = '';
+ _svEditingPhotoB64 = sv.photoB64 || null;
+ _updateSvPhotoUI(_svEditingPhotoB64);
+ openModal('modal-sv');
+}
+
+function _updateSvPhotoUI(b64) {
+ _svEditingPhotoB64 = b64;
+ const thumb = document.getElementById('sv-photo-thumb');
+ const btn = document.getElementById('sv-remove-photo');
+ if (b64) { thumb.src = b64; thumb.style.display = 'block'; btn.style.display = 'inline-flex'; }
+ else { thumb.src = ''; thumb.style.display = 'none'; btn.style.display = 'none'; }
+}
+
+function handleSvPhotoFile(input) {
+ const file = input.files && input.files[0];
+ if (!file) return;
+ resizePhotoToBase64(file).then(b64 => _updateSvPhotoUI(b64)).catch(e => alert(e.message));
+ input.value = '';
+}
+
+function removeSvPhoto() { _updateSvPhotoUI(null); }
+
+function saveStammvertreterModal() {
+ const name = document.getElementById('sv-modal-name').value.trim();
+ if (!name) { alert('Bitte Namen eingeben.'); return; }
+ const list = loadStammvertreter();
+ const existingId = document.getElementById('sv-modal-id').value;
+ const sv = {
+ id: existingId || 'sv-' + Date.now(),
+ name,
+ company: document.getElementById('sv-modal-company').value.trim(),
+ specialty: document.getElementById('sv-modal-specialty').value.trim(),
+ photoB64: _svEditingPhotoB64 || null,
+ };
+ if (existingId) {
+ const idx = list.findIndex(s => s.id === existingId);
+ if (idx >= 0) list[idx] = sv; else list.push(sv);
+ } else {
+ list.push(sv);
+ }
+ saveStammvertreter(list);
+ closeModal('modal-sv');
+ renderStammvertreterSection();
+}
+
+function deleteStammvertreter(svId) {
+ if (!confirm('Stammvertreter löschen?')) return;
+ saveStammvertreter(loadStammvertreter().filter(s => s.id !== svId));
+ closeModal('modal-sv');
+ renderStammvertreterSection();
+}
+
+function renderStammvertreterSection() {
+ const container = document.getElementById('sv-list-container');
+ if (!container) return;
+ const list = loadStammvertreter();
+ if (list.length === 0) {
+ container.innerHTML = `
Noch keine gespeichert. →
Admin öffnen zum Importieren aus anderen Chaptern.
`;
+ return;
+ }
+ container.innerHTML = '';
+ list.forEach(sv => {
+ const photo = sv.photoB64
+ ? `

`
+ : `
${getInitials(sv.name)}
`;
+ const div = document.createElement('div');
+ div.style.cssText = 'display:flex;align-items:center;gap:8px;padding:5px 0;border-bottom:1px solid var(--border);';
+ div.innerHTML = `${photo}
${escHtml(sv.name)}
${escHtml(sv.company||'')}${sv.specialty?' · '+escHtml(sv.specialty):''}
`;
+ container.appendChild(div);
+ });
+}
+
+function renderSvPicker() {
+ const list = loadStammvertreter();
+ const picker = document.getElementById('sub-sv-picker');
+ const container = document.getElementById('sub-sv-list');
+ if (!picker || !container) return;
+ if (list.length === 0) { picker.style.display = 'none'; return; }
+ picker.style.display = '';
+ container.innerHTML = '';
+ list.forEach(sv => {
+ const photoHtml = sv.photoB64
+ ? `

`
+ : `
${getInitials(sv.name)}
`;
+ const card = document.createElement('div');
+ card.style.cssText = 'display:flex;align-items:center;gap:7px;padding:6px 9px;background:#f8f9fa;border:1px solid var(--border);border-radius:8px;cursor:pointer;';
+ card.innerHTML = `${photoHtml}
${escHtml(sv.name)}
${escHtml(sv.company||'')}
`;
+ card.onclick = () => pickStammvertreter(sv.id);
+ container.appendChild(card);
+ });
+}
+
+function pickStammvertreter(svId) {
+ const sv = loadStammvertreter().find(s => s.id === svId);
+ if (!sv) return;
+ document.getElementById('sub-modal-name').value = sv.name;
+ document.getElementById('sub-modal-company').value = sv.company || '';
+ document.getElementById('sub-modal-specialty').value = sv.specialty || '';
+ document.getElementById('sub-modal-photo').value = '';
+ if (sv.photoB64) {
+ const extras = loadExtras();
+ const key = extrasKey(sv.name);
+ if (!extras[key]) extras[key] = {};
+ extras[key].photoB64 = sv.photoB64;
+ saveExtras(extras);
+ }
+ document.getElementById('sub-sv-picker').style.display = 'none';
+}
+
// Resize an image File to base64 JPEG (max maxPx on longest side)
function resizePhotoToBase64(file, maxPx = 400) {
return new Promise((resolve, reject) => {
@@ -2418,6 +2608,7 @@ function renderControl() {
renderSubstituteMemberSelect();
renderInvitedBySelect();
renderAdminPanel();
+ renderStammvertreterSection();
updateNextButton();
syncDot = document.getElementById('sync-dot');
}
@@ -3058,6 +3249,7 @@ function openSubstituteModal(memberId) {
document.getElementById('sub-modal-specialty').value = sub.specialty || '';
document.getElementById('sub-modal-photo').value = sub.photoUrl || '';
document.getElementById('sub-modal-skip-round2').checked = sub.skipRound2 || false;
+ renderSvPicker();
openModal('modal-substitute');
}
@@ -4259,26 +4451,12 @@ function renderAdminPanel() {
Aktives Chapter
${cfg.chapterName || '—'}
-
Version: ${APP_VERSION} · Lizenzprüfung: ${lastChecked}
+
Version: ${APP_VERSION}
+
Lizenzprüfung: ${lastChecked}
-
-
Mitglieder laden
-
-
Letzter Download: ${lastSync}
-
-
Mitglieder hochladen (Admin)
-
-
-
-
-
-
-
Letzter Upload: ${lastUpload}
-
-
+
+
Letzter Download: ${lastSync}
+
⚙ Admin-Panel öffnen
` : `
Kein Chapter aktiviert.
`}