Add admin Sales report page
This commit is contained in:
parent
d02d0b3d25
commit
da917692f0
3 changed files with 87 additions and 1 deletions
13
app.py
13
app.py
|
|
@ -781,6 +781,19 @@ def admin_dashboard():
|
||||||
return render_template('admin/dashboard.html', requests=requests, statuses=STATUS_LABELS, current_status=status_filter, refresh_seconds=get_refresh_seconds())
|
return render_template('admin/dashboard.html', requests=requests, statuses=STATUS_LABELS, current_status=status_filter, refresh_seconds=get_refresh_seconds())
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/admin/sales')
|
||||||
|
def admin_sales():
|
||||||
|
"""
|
||||||
|
Sales report: delivered requests only.
|
||||||
|
Shows customer email, name, chosen version, and Square payment reference.
|
||||||
|
"""
|
||||||
|
redir = require_admin()
|
||||||
|
if redir:
|
||||||
|
return redir
|
||||||
|
sales = list_requests(status='delivered')
|
||||||
|
return render_template('admin/sales.html', sales=sales, statuses=STATUS_LABELS)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/admin/request/<int:rid>', methods=['GET', 'POST'])
|
@app.route('/admin/request/<int:rid>', methods=['GET', 'POST'])
|
||||||
def admin_request(rid):
|
def admin_request(rid):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,9 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<!-- Topbar: Settings link and Log out link -->
|
<!-- Topbar: Sales, Settings, Log out -->
|
||||||
<div class="topbar">
|
<div class="topbar">
|
||||||
|
<a href="{{ url_for('admin_sales') }}">Sales</a>
|
||||||
<a href="{{ url_for('admin_settings') }}" class="settings">Settings</a>
|
<a href="{{ url_for('admin_settings') }}" class="settings">Settings</a>
|
||||||
<a href="{{ url_for('admin_logout') }}" class="logout">Log out</a>
|
<a href="{{ url_for('admin_logout') }}" class="logout">Log out</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
72
templates/admin/sales.html
Normal file
72
templates/admin/sales.html
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Sales Report — Admin</title>
|
||||||
|
<style>
|
||||||
|
body{
|
||||||
|
font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
|
||||||
|
background:#111827;
|
||||||
|
color:#f3f4f6;
|
||||||
|
margin:0;
|
||||||
|
padding:1rem;
|
||||||
|
line-height:1.5;
|
||||||
|
}
|
||||||
|
.container{max-width:1100px;margin:0 auto;}
|
||||||
|
h1{color:#60a5fa;margin-top:0;}
|
||||||
|
a{color:#93c5fd;}
|
||||||
|
table{
|
||||||
|
width:100%;
|
||||||
|
border-collapse:collapse;
|
||||||
|
background:#1f2937;
|
||||||
|
border-radius:.5rem;
|
||||||
|
overflow:hidden;
|
||||||
|
}
|
||||||
|
th,td{padding:.7rem;text-align:left;border-bottom:1px solid #374151;}
|
||||||
|
th{background:#111827;color:#9ca3af;}
|
||||||
|
tr:hover{background:#2d3748;}
|
||||||
|
.topbar{float:right;display:flex;gap:.75rem;align-items:center;}
|
||||||
|
.topbar a{color:#93c5fd;text-decoration:none;}
|
||||||
|
.empty{padding:1rem;color:#9ca3af;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="topbar">
|
||||||
|
<a href="{{ url_for('admin_dashboard') }}">Dashboard</a>
|
||||||
|
<a href="{{ url_for('admin_settings') }}">Settings</a>
|
||||||
|
<a href="{{ url_for('admin_logout') }}" style="color:#f87171">Log out</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1>Sales Report</h1>
|
||||||
|
|
||||||
|
{% if sales %}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Picked</th>
|
||||||
|
<th>Payment Reference</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for s in sales %}
|
||||||
|
<tr>
|
||||||
|
<td>#{{ s.id }}</td>
|
||||||
|
<td>{{ s.name }}</td>
|
||||||
|
<td>{{ s.email }}</td>
|
||||||
|
<td>{% if s.customer_approved == 'both' %}Both Versions{% else %}Version {{ s.customer_approved.upper() }}{% endif %}</td>
|
||||||
|
<td>{{ s.square_payment_ref or '-' }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<p class="empty">No delivered requests yet.</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in a new issue