{% extends 'dashboard/layout.html' %}
{% load currency_filters %}
{% load i18n %}

{% block body_class %}orders{% endblock %}

{% block title %}
{% trans "Order statistics" %} | {{ block.super }}
{% endblock %}

{% block breadcrumbs %}
<ul class="breadcrumb">
    <li>
	<a href="{% url dashboard:index %}">{% trans "Dashboard" %}</a>
        <span class="divider">/</span>
    </li>
    <li>
	<a href="{% url dashboard:order-list %}">{% trans "Orders" %}</a>
        <span class="divider">/</span>
    </li>
	<li class="active"><a href=".">{% trans "Statistics" %}</a></li>
</ul>
{% endblock %}

{% block header %}
<div class="page-header">
	<h1>{{ title }}</h1>
</div>
{% endblock header %}

{% block dashboard_content %}
<div class="well well-info">
    <form method="get" action="{% url dashboard:order-stats %}" class="form-inline">
        <h3 class="app-ico ico_magnify icon">Filter</h3>
        {% include "partials/form_fields_inline.html" with form=form %}
		<button type="submit" class="btn btn-primary">Filter result</button>
		<a href="{% url dashboard:order-stats %}" class="btn">{% trans "Reset" %}</a>
    </form>
</div>
<table class="table table-striped table-bordered">
	<caption>{% trans "Summary" %}</caption>
	<tr>
		<th>{% trans "Total orders" %}</th>
		<td>{{ total_orders }}</td>
	</tr>
	<tr>
		<th>{% trans "Total lines" %}</th>
		<td>{{ total_lines }}</td>
	</tr>
	<tr>
		<th>{% trans "Total revenue" %}</th>
		<td>{{ total_revenue|currency }}</td>
	</tr>
</table>

{% if order_status_breakdown %}
<table class="table table-striped table-bordered">
	<caption>{% trans "Order status breakdown" %}</caption>
	<tr>
		<th>{% trans "Status" %}</th>
		<th>{% trans "Frequency" %}</th>
	</tr>
	{% for dict in order_status_breakdown %}
	<tr>
		<td><a href="{% url dashboard:order-list %}?order_status={{ dict.status }}">{{ dict.status }}</a></td>
		<td>{{ dict.freq }}</td>
	</tr>
	{% endfor %}
</table>
{% endif %}

{% endblock dashboard_content %}
