diff --git a/backend/static/js/pages/health.js b/backend/static/js/pages/health.js index 00d8bd5..677fd37 100644 --- a/backend/static/js/pages/health.js +++ b/backend/static/js/pages/health.js @@ -245,23 +245,32 @@ window.Page_health = (() => { function _renderTierarzt(entries) { const addBtn = ``; if (!entries.length) return UI.emptyState({ - icon: '🏥', title: 'Noch keine Tierarztbesuche', text: 'Halte alle Tierarztbesuche fest.', action: addBtn + icon: '🩺', title: 'Noch keine Tierarztbesuche', text: 'Halte alle Tierarztbesuche fest.', action: addBtn }); - const items = entries.map(e => ` -
-
-
${_esc(e.bezeichnung)}
-
- ${UI.time.format(e.datum + 'T00:00:00')} - ${e.tierarzt_name ? ` · ${_esc(e.tierarzt_name)}` : ''} - ${e.kosten != null ? ` · ${Number(e.kosten).toFixed(2)} €` : ''} + const items = entries.map(e => { + const praxis = _praxen.find(p => p.id === e.tierarzt_id); + const praxisName = praxis?.name || e.tierarzt_name || ''; + const praxisOrt = praxis ? [praxis.plz, praxis.ort].filter(Boolean).join(' ') : ''; + return ` +
+
+
${_esc(e.bezeichnung)}
+
+ ${UI.time.format(e.datum + 'T00:00:00')} + ${e.kosten != null ? ` · ${Number(e.kosten).toFixed(2)} €` : ''} +
+ ${praxisName ? ` +
+ 🏥 ${_esc(praxisName)}${praxisOrt ? ` · ${_esc(praxisOrt)}` : ''} +
` : ''} + ${e.diagnose ? `
Diagnose: ${_esc(e.diagnose)}
` : ''} + ${e.notiz ? `
${_esc(e.notiz)}
` : ''}
- ${e.diagnose ? `
Diagnose: ${_esc(e.diagnose)}
` : ''} - ${e.notiz ? `
${_esc(e.notiz)}
` : ''}
-
- `).join(''); + `; + }).join(''); return `
${items}
${addBtn}
`; @@ -574,7 +583,16 @@ window.Page_health = (() => { const rows = []; if (e.datum) rows.push(['Datum', UI.time.format(e.datum + 'T00:00:00')]); if (e.naechstes) rows.push(['Nächstes', UI.time.format(e.naechstes + 'T00:00:00')]); - if (e.tierarzt_name) rows.push(['Tierarzt', _esc(e.tierarzt_name)]); + if (e.tierarzt_id) { + const praxis = _praxen.find(p => p.id === e.tierarzt_id); + if (praxis) { + const adresse = [praxis.strasse, [praxis.plz, praxis.ort].filter(Boolean).join(' ')].filter(Boolean).join(', '); + const tel = praxis.telefon ? ` · ${_esc(praxis.telefon)}` : ''; + rows.push(['Praxis', `🏥 ${_esc(praxis.name)}${adresse ? `
${_esc(adresse)}${tel}` : tel}`]); + } + } else if (e.tierarzt_name) { + rows.push(['Tierarzt', _esc(e.tierarzt_name)]); + } if (e.charge_nr) rows.push(['Charge-Nr.', _esc(e.charge_nr)]); if (e.kosten != null) rows.push(['Kosten', `${Number(e.kosten).toFixed(2)} €`]); if (e.diagnose) rows.push(['Diagnose', _esc(e.diagnose)]); @@ -648,17 +666,12 @@ window.Page_health = (() => { const form = document.getElementById('health-form'); setTimeout(() => { form?.querySelector('[name="bezeichnung"]')?.focus(); - // Praxis-Dropdown: Name auto-befüllen - const praxisSelect = document.getElementById('health-praxis-select'); - const nameInput = document.getElementById('health-tierarzt-name-input'); - if (praxisSelect && nameInput) { - praxisSelect.addEventListener('change', () => { - const selected = praxisSelect.options[praxisSelect.selectedIndex]; - if (selected.value) { - nameInput.value = selected.dataset.name || selected.textContent.trim(); - } - }); - } + // "Praxis anlegen" Button im Formular + form?.querySelector('[data-action="goto-praxen"]')?.addEventListener('click', () => { + UI.modal.close(); + _activeTab = 'praxen'; + _renderTab(); + }); }, 150); document.getElementById('health-form-cancel')?.addEventListener('click', UI.modal.close); @@ -743,25 +756,31 @@ window.Page_health = (() => { `; case 'tierarzt': { const aktivePraxen = _praxen.filter(p => p.aktiv); - const praxisDropdown = aktivePraxen.length ? ` -
- - -
` : ''; + const praxisField = aktivePraxen.length + ? `
+ + +
` + : `
+
+ 🏥 Noch keine Praxis angelegt — + +
+ + +
`; return ` - ${praxisDropdown} -
- - -
+ ${praxisField}
@@ -845,7 +864,12 @@ window.Page_health = (() => { if (typ === 'gewicht') p.bezeichnung = `${p.wert} kg`; } if (fd.kosten) p.kosten = parseFloat(fd.kosten.toString().replace(',', '.')); - if (fd.tierarzt_id) p.tierarzt_id = parseInt(fd.tierarzt_id); + if (fd.tierarzt_id) { + p.tierarzt_id = parseInt(fd.tierarzt_id); + // Praxisname auch als tierarzt_name sichern (bleibt lesbar wenn Praxis inaktiv/gelöscht) + const praxis = _praxen.find(x => x.id === p.tierarzt_id); + if (praxis) p.tierarzt_name = praxis.name; + } if (typ === 'medikament') { p.aktiv = 'aktiv' in fd ? 1 : 0; } diff --git a/backend/static/sw.js b/backend/static/sw.js index eb5a0fd..286df93 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -3,7 +3,7 @@ Offline-Cache + Push Notifications ============================================================ */ -const CACHE_VERSION = 'by-v11'; +const CACHE_VERSION = 'by-v12'; const CACHE_STATIC = `${CACHE_VERSION}-static`; // Diese Dateien werden beim Install gecacht (App Shell)