Files
yolkbook/nginx/html/budget.html
derekc aa12648228 Add multi-user auth, admin panel, and timezone support; rename to Yolkbook
- Rename app from Eggtracker to Yolkbook throughout
- Add JWT-based authentication (python-jose, passlib/bcrypt)
- Add users table; all data tables gain user_id FK for full data isolation
- Super admin credentials sourced from ADMIN_USERNAME/ADMIN_PASSWORD env vars,
  synced on every startup; orphaned rows auto-assigned to admin post-migration
- Login page with self-registration; JWT stored in localStorage (30-day expiry)
- Admin panel (/admin): list users, reset passwords, disable/enable, delete,
  and impersonate (Login As) with Return to Admin banner
- Settings modal (gear icon in nav): timezone selector and change password
- Timezone stored per-user; stats date windows computed in user's timezone;
  date input setToday() respects user timezone via Intl API
- migrate_v2.sql for existing single-user installs
- Auto-migration adds timezone column to users on startup
- Updated README with full setup, auth, admin, and migration docs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 23:19:29 -07:00

131 lines
5.9 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Budget — Yolkbook</title>
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<nav class="nav">
<a class="nav-brand" href="/">🥚 <span>Yolkbook</span></a>
<ul class="nav-links">
<li><a href="/">Dashboard</a></li>
<li><a href="/log">Log Eggs</a></li>
<li><a href="/history">History</a></li>
<li><a href="/flock">Flock</a></li>
<li><a href="/budget">Budget</a></li>
<li><a href="/summary">Summary</a></li>
</ul>
</nav>
<main class="container">
<h1>Budget &amp; Feed Costs</h1>
<div id="msg" class="message"></div>
<!-- Stats: all-time -->
<h2>All-Time</h2>
<div class="stats-grid" style="margin-bottom: 1rem;">
<div class="stat-card"><div class="label">Total Feed Cost</div><div class="value" id="b-cost-total"></div></div>
<div class="stat-card"><div class="label">Other Costs</div><div class="value" id="b-other-total"></div></div>
<div class="stat-card"><div class="label">Total Eggs</div><div class="value" id="b-eggs-total"></div></div>
<div class="stat-card accent"><div class="label">Cost / Egg</div><div class="value" id="b-cpe"></div></div>
<div class="stat-card accent"><div class="label">Cost / Dozen</div><div class="value" id="b-cpd"></div></div>
</div>
<!-- Stats: last 30 days -->
<h2>Last 30 Days</h2>
<div class="stats-grid" style="margin-bottom: 2rem;">
<div class="stat-card"><div class="label">Feed Cost (30d)</div><div class="value" id="b-cost-30d"></div></div>
<div class="stat-card"><div class="label">Other Costs (30d)</div><div class="value" id="b-other-30d"></div></div>
<div class="stat-card"><div class="label">Eggs (30d)</div><div class="value" id="b-eggs-30d"></div></div>
<div class="stat-card accent"><div class="label">Cost / Egg (30d)</div><div class="value" id="b-cpe-30d"></div></div>
<div class="stat-card accent"><div class="label">Cost / Dozen (30d)</div><div class="value" id="b-cpd-30d"></div></div>
</div>
<!-- Log a feed purchase -->
<div class="card">
<h2>Log Feed Purchase</h2>
<form id="feed-form">
<div class="form-grid">
<div class="form-group">
<label for="date">Date</label>
<input type="date" id="date" required>
</div>
<div class="form-group">
<label for="bags">Number of Bags</label>
<input type="number" id="bags" min="0.01" step="0.01" required placeholder="1">
</div>
<div class="form-group">
<label for="price">Price per Bag ($)</label>
<input type="number" id="price" min="0.01" step="0.01" required placeholder="0.00">
</div>
<div class="form-group">
<label>Total</label>
<input type="text" id="total-display" readonly placeholder="$0.00" style="background:#f7f4ef; color: var(--green); font-weight:600;">
</div>
<div class="form-group span-full">
<label for="notes">Notes (optional)</label>
<textarea id="notes" placeholder="e.g. Brand, store, sale price…"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Save Purchase</button>
</div>
</div>
</form>
</div>
<!-- Log other purchase -->
<div class="card">
<h2>Log Other Purchases</h2>
<form id="other-form">
<div class="form-grid">
<div class="form-group">
<label for="other-date">Date</label>
<input type="date" id="other-date" required>
</div>
<div class="form-group">
<label for="other-total">Total ($)</label>
<input type="number" id="other-total" min="0.01" step="0.01" required placeholder="0.00">
</div>
<div class="form-group span-full">
<label for="other-notes">Note</label>
<textarea id="other-notes" placeholder="e.g. Snacks, Bedding, Shelter Costs…"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Save Purchase</button>
</div>
</div>
</form>
</div>
<!-- Purchase history -->
<h2>Purchase History</h2>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Date</th>
<th>Type</th>
<th>Details</th>
<th>Total</th>
<th>Notes</th>
<th></th>
</tr>
</thead>
<tbody id="purchase-body">
<tr class="empty-row"><td colspan="6">Loading…</td></tr>
</tbody>
<tfoot id="purchase-foot"></tfoot>
</table>
</div>
</main>
<script src="/js/api.js?v=3"></script>
<script src="/js/auth.js?v=3"></script>
<script src="/js/budget.js?v=3"></script>
</body>
</html>