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

{% block title %}
{{ title }} | {% trans "Accounts" %} | {{ 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 'accounts-list' %}">{% trans "Accounts" %}</a>
        <span class="divider">/</span>
    </li>
	<li class="active">{{ title }}</li>
</ul>
{% endblock %}

{% block headertext %}{{ title }}{% endblock %}

{% block dashboard_content %}

<form class="form-horizontal well" action="." method="get">
	{% include 'partials/form_fields.html' %}
	<button type="submit" class="btn btn-primary">{% trans "Fetch report" %}</button>
</form>

{% if rows %}
<h2>{% trans "Position at" %} {{ report_date }}</h2>
<table class="table">
	<thead>
		<tr>
			<th>{% trans "Account type" %}</th>
			<th>{% trans "Total balance" %}</th>
			<th>{% trans "Num accounts" %}</th>
			<th colspan="4">{% trans "Expiring" %}</th>
		</tr>
		<tr>
			<th></th>
			<th></th>
			<th></th>
            <th>{% trans "&lt; 30 days" %}</th>
            <th>{% trans "30 - 60 days" %}</th>
            <th>{% trans "60 - 90 days" %}</th>
            <th>{% trans "&gt; 90 days" %}</th>
			<th>{% trans "No end date" %}</th>
		</tr>
	</thead>
	<tbody>
		{% for row in rows %}
		<tr>
			<td>{{ row.name }}</td>
			<td>{{ row.total|currency }}</td>
			<td>{{ row.num_accounts }}</td>
			<td>
				{{ row.total_expiring_within_30|currency }}
				({{ row.num_expiring_within_30 }})
			</td>
			<td>
				{{ row.total_expiring_within_60|currency }}
				({{ row.num_expiring_within_60 }})
			</td>
			<td>
				{{ row.total_expiring_within_90|currency }}
				({{ row.num_expiring_within_90 }})
			</td>
			<td>
				{{ row.total_expiring_outside_90|currency }}
				({{ row.num_expiring_outside_90 }})
			</td>
			<td>
				{{ row.total_open_ended|currency }}
				({{ row.num_open_ended }})
			</td>
		</tr>
		{% endfor %}
		<tr>
			<th></th>
			<th>{{ totals.total|currency }}</th>
			<th>{{ totals.num_accounts }}</th>
		</tr>
	</tbody>

</table>
{% endif %}

{% endblock dashboard_content %}
