1
0
Fork 0
forked from s3lph/matemat
matemat/templates/statistics.html

114 lines
2.8 KiB
HTML
Raw Normal View History

2018-10-01 21:08:37 +02:00
{% extends "base.html" %}
{% block header %}
<style>
@media all {
svg g text {
display: none;
}
svg g:hover text {
display: block;
}
span.input-replacement {
display: none;
}
}
@media print {
svg g text {
display: block;
}
input {
display: none;
}
span.input-replacement {
display: inline;
}
}
</style>
{{ super() }}
2018-10-01 21:08:37 +02:00
{% endblock %}
{% block main %}
<h1>Sales Statistics</h1>
2018-10-01 21:08:37 +02:00
<section id="statistics-range">
2018-10-01 21:08:37 +02:00
<h2>Time Range</h2>
2018-10-01 21:08:37 +02:00
<form action="/statistics" method="get" accept-charset="utf-8">
<label class="form-label" for="statistics-range-from">From:</label>
<input class="form-control" type="date" id="statistics-range-from" name="fromdate" value="{{fromdate}}" />
<span class="input-replacement">{{fromdate}}</span>
2018-10-01 21:08:37 +02:00
<label class="form-label" for="statistics-range-to">To:</label>
<input class="form-control" type="date" id="statistics-range-to" name="todate" value="{{todate}}" />
<span class="input-replacement">{{todate}}</span>
2018-10-01 21:08:37 +02:00
<input class="btn btn-primary" type="submit" value="Update">
</form>
2018-10-01 21:08:37 +02:00
</section>
2018-10-01 21:08:37 +02:00
<section id="statistics-total">
2018-10-01 21:08:37 +02:00
<h2>Totals</h2>
2018-10-01 21:08:37 +02:00
<ul>
<li>Total products purchased: {{ total_consumption }}</li>
<li>Total income: {{ total_income|chf }}</li>
<li>Total deposited: {{ total_deposits|chf }}</li>
<li>Total accounts balance: {{ total_balance|chf }}</li>
</ul>
2018-10-01 21:08:37 +02:00
</section>
2018-10-01 21:08:37 +02:00
<section>
2018-10-01 21:08:37 +02:00
<h2>Purchases</h2>
2018-10-01 21:08:37 +02:00
<table class="table table-striped">
<thead>
<tr><th>Product</th><th>Income</th><th>Units</th></tr>
</thead>
<tbody>
{% for prod, data in consumptions.items() %}
<tr><td>{{ prod }}</td><td>{{ -data[0]|chf }}</td><td>{{ data[1] }}</td></tr>
{% endfor %}
</tbody>
<tfoot>
<tr><td>Total</td><td>{{ total_income|chf }}</td><td>{{ total_consumption }}</td></tr>
</tfoot>
</table>
2018-10-01 21:08:37 +02:00
{# Really hacky pie chart implementation. #}
<svg width="400" height="400">
{% for s in product_slices %}
<g>
<path d="M 200 200 L {{ s[1]+200 }} {{ s[2]+200 }} A 100 100 0 {{ s[5] }} 1 {{ s[3]+200 }} {{ s[4]+200 }} L 200 200"
fill="{{ loop.cycle('green', 'red', 'blue', 'yellow', 'purple', 'orange') }}"></path>
<text text-anchor="middle"
x="{{ 200 + s[6] }}"
y="{{ 200 + s[7] }}">{{ s[0] }} ({{ s[8] }})</text>
</g>
{% endfor %}
</svg>
2018-10-01 21:08:37 +02:00
</section>
2018-10-01 21:08:37 +02:00
<section id="statistics-balances">
2018-10-01 21:08:37 +02:00
<h2>Account Balances</h2>
2018-10-01 21:08:37 +02:00
<ul>
<li>Total account balances: {{ total_balance|chf }}</li>
<li>Total positive account balances: {{ positive_balance|chf }}</li>
<li>Total negative account balances: {{ negative_balance|chf }}</li>
</ul>
2018-10-01 21:08:37 +02:00
</section>
{{ super() }}
2018-10-01 21:08:37 +02:00
{% endblock %}