{% 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">{% trans "Statistics" %}</li>  	
</ul>
{% endblock %}

{% block header %}{{ title }}{% endblock %}

{% block dashboard_content %}
<div class="table-header">
    <h3><i class="icon-filter icon-large"></i> {% trans "Filter" %}</h3>
</div>
<div class="well">
    <form method="get" action="{% url dashboard:order-stats %}" class="form-inline">
        {% include "partials/form_fields_inline.html" with form=form %}
		<button type="submit" class="btn btn-primary">{% trans "Filter result" %}</button>
		<a href="{% url dashboard:order-stats %}" class="btn">{% trans "Reset" %}</a>
    </form>
</div>

<table class="table table-striped table-bordered table-hover">
    <caption><i class="icon-shopping-cart icon-large"></i>{% 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 table-hover">
	<caption><i class="icon-shopping-cart icon-large"></i>{% 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 %}
