diff --git a/public/css/style.css b/public/css/style.css index 0c259a4..1654370 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -1301,3 +1301,45 @@ body:not(.admin-body) > * { background: #fee2e2; border-color: var(--error); } + +/* ---- Rechnungshistorie in Mitglied-Detail ---- */ +.karte-header-sub { + margin-left: auto; + font-size: 0.78rem; + font-weight: 600; + color: var(--text-muted); + background: var(--bg); + padding: 2px 10px; + border-radius: 20px; + border: 1px solid var(--border); +} +.invoice-history-wrap { + max-height: 272px; /* ca. 6 Zeilen */ + overflow-y: auto; + border-radius: 0 0 14px 14px; +} +.invoice-history-table { + width: 100%; + border-collapse: collapse; + font-size: 0.88rem; +} +.invoice-history-table thead th { + position: sticky; + top: 0; + z-index: 1; + padding: 10px 16px; + background: var(--bg); + font-size: 0.75rem; + font-weight: 700; + text-transform: uppercase; + letter-spacing: 0.5px; + color: var(--text-muted); + border-bottom: 1.5px solid var(--border); +} +.invoice-history-table td { + padding: 10px 16px; + border-bottom: 1px solid var(--border); + vertical-align: middle; +} +.invoice-history-row:last-child td { border-bottom: none; } +.invoice-history-row:hover td { background: #f8f8ff; cursor: default; } diff --git a/routes/admin.js b/routes/admin.js index 810e7ba..a988f93 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -175,6 +175,11 @@ router.get('/members/:id', requireAdmin, async (req, res) => { 'SELECT * FROM membership_pauses WHERE membership_id = ? ORDER BY pause_start DESC', [req.params.id] ); + const [invoices] = await db.query(` + SELECT * FROM invoices + WHERE membership_id = ? + ORDER BY period DESC, created_at DESC + `, [req.params.id]); const [tariffs] = await db.query( 'SELECT * FROM tariffs WHERE active = 1 ORDER BY name ASC' ); @@ -183,6 +188,7 @@ router.get('/members/:id', requireAdmin, async (req, res) => { member: rows[0], pauses, tariffs, + invoices, admin: req.session.adminUser, success: req.query.success || null, error: req.query.error || null diff --git a/views/admin/member-detail.ejs b/views/admin/member-detail.ejs index dfadb47..4aa5379 100644 --- a/views/admin/member-detail.ejs +++ b/views/admin/member-detail.ejs @@ -303,6 +303,68 @@ + + +
+
+ ๐Ÿงพ +

Rechnungshistorie

+ <%= invoices.length %> Rechnung(en) +
+
+ <% if (invoices.length === 0) { %> +

Noch keine Rechnungen vorhanden.

+ <% } else { %> +
+ + + + + + + + + + + + + <% invoices.forEach(inv => { %> + + + + + + + + + <% }) %> + +
Nr.PeriodeBetragStatusDatumAktion
PF24-<%= String(inv.id).padStart(6,'0') %><%= inv.period %> + <% if (inv.status === 'cancelled') { %> + + <%= Number(inv.amount).toFixed(2).replace('.', ',') %> โ‚ฌ + + <% } else { %> + <%= Number(inv.amount).toFixed(2).replace('.', ',') %> โ‚ฌ + <% } %> + + + <%= inv.status === 'paid' ? 'โœ… Bezahlt' : inv.status === 'cancelled' ? '๐Ÿšซ Storniert' : '๐Ÿ”ด Offen' %> + + <%= new Date(inv.created_at).toLocaleDateString('de-DE') %> + <% if (inv.status === 'cancelled') { %> + ๐Ÿšซ Storno-PDF + <% } else { %> + ๐Ÿ“„ Rechnung + <% } %> +
+
+ <% } %> +
+
+