{% extends "base.html" %}
{% block title %}Platform Report{% endblock %}
{% block content %}
<h2>📊 Platform Wise Sales Report</h2>
<form method="get" class="row g-2 mb-3"><div class="col-md-3"><input type="date" class="form-control" name="start_date" value="{{ start_date }}"></div><div class="col-md-3"><input type="date" class="form-control" name="end_date" value="{{ end_date }}"></div><div class="col-md-2"><button class="btn btn-primary w-100">View</button></div></form>
<div class="row g-3 mb-3"><div class="col-md-4"><div class="card p-3"><b>Revenue</b><h3>LKR {{ '%.2f'|format(totals.revenue or 0) }}</h3></div></div><div class="col-md-4"><div class="card p-3"><b>Cost</b><h3>LKR {{ '%.2f'|format(totals.cost or 0) }}</h3></div></div><div class="col-md-4"><div class="card p-3"><b>Gross Profit</b><h3>LKR {{ '%.2f'|format(totals.gross_profit or 0) }}</h3></div></div></div>
<table class="table table-bordered table-striped"><thead><tr><th>Platform</th><th>Orders</th><th>Qty</th><th>Sales Total</th><th>Cash Received</th><th>Cost</th><th>Gross Profit</th></tr></thead><tbody>{% for r in rows %}<tr><td>{{ r.platform }}</td><td>{{ r.order_count }}</td><td>{{ r.total_qty }}</td><td>{{ '%.2f'|format(r.sales_total or 0) }}</td><td>{{ '%.2f'|format(r.cash_total or 0) }}</td><td>{{ '%.2f'|format(r.cost_total or 0) }}</td><td>{{ '%.2f'|format(r.gross_profit or 0) }}</td></tr>{% else %}<tr><td colspan="7" class="text-center">No data.</td></tr>{% endfor %}</tbody></table>
{% endblock %}
