Files
fruehstuecksapp/views/dashboard.ejs

94 lines
3.8 KiB
Plaintext

<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard - Frühstückskonten Verwaltung</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<div class="container">
<header>
<h1>Frühstückskonten Verwaltung</h1>
<% if (typeof user !== 'undefined' && user) { %>
<nav>
<span>Angemeldet als: <strong><%= user.username %></strong> (<%= user.role %>) |
<a href="/dashboard">Dashboard</a> |
<a href="/accounts">Konten</a>
<% if (user.role === 'admin') { %>
| <a href="/items">Artikel</a>
| <a href="/users">Benutzer</a>
<% } %>
| <a href="/logout">Abmelden</a>
</span>
</nav>
<% } %>
</header>
<main>
<h2>Dashboard</h2>
<div class="dashboard-stats">
<div class="stat-card">
<h3>Konten</h3>
<p class="stat-value"><%= typeof stats !== 'undefined' ? stats.count : 0 %></p>
</div>
<div class="stat-card">
<h3>Gesamtguthaben</h3>
<p class="stat-value"><%= typeof stats !== 'undefined' ? (stats.total_balance || 0).toFixed(2) : '0.00' %> €</p>
</div>
</div>
<h3>Letzte Transaktionen</h3>
<table class="transaction-table">
<thead>
<tr>
<th>Datum</th>
<th>Konto</th>
<th>Typ</th>
<th>Betrag</th>
<th>Beschreibung</th>
<th>Artikel</th>
<th>Durchgeführt von</th>
</tr>
</thead>
<tbody>
<% if (typeof transactions !== 'undefined' && transactions.length > 0) { %>
<% transactions.forEach(function(transaction) { %>
<tr>
<td><%= new Date(transaction.created_at).toLocaleString('de-DE') %></td>
<td><%= transaction.account_name %></td>
<td class="type-<%= transaction.type %>">
<%= transaction.type === 'deposit' ? 'Einzahlung' : 'Abbuchung' %>
</td>
<td class="amount-<%= transaction.type %>">
<%= transaction.amount.toFixed(2) %> €
</td>
<td><%= transaction.description %></td>
<td><%= transaction.item_name || '-' %></td>
<td><%= transaction.created_by_name || 'System' %></td>
</tr>
<% }); %>
<% } else { %>
<tr>
<td colspan="7">Keine Transaktionen vorhanden</td>
</tr>
<% } %>
</tbody>
</table>
<div class="actions">
<a href="/accounts/new" class="btn">Neues Konto anlegen</a>
<% if (typeof isAdmin !== 'undefined' && isAdmin) { %>
<a href="/items/new" class="btn">Neuen Artikel anlegen</a>
<% } %>
</div>
</main>
<footer>
<p>&copy; 2024 Frühstückskonten Verwaltung</p>
</footer>
</div>
</body>
</html>