{% extends "base.html" %}
{% load arrayutil %}
{% load python %}
{% load humanize %}
{% load ledger %}

{% block javascript %}
<script src="{{ MEDIA_URL }}js/clientside.js" type="text/javascript"></script>
{{ date_form.media|safe }}
{% endblock %}

{% block css %}
    <link charset='UTF-8' rel="stylesheet" type="text/css" media="print" href="{{ MEDIA_URL }}style/print.css" />
{% endblock %}

{% block title %}Account Business Balances{% endblock %}

{% block content %}
<h2 class='skinny'>Filter by Date</h2>
<ul class='header-actions-left'>
	<li><a href='{% url single_account_ledger account.pk %}'>Return to Account</a></li>
</ul>

{% include 'books/ledger/_date_filters.html' %}

<form method="get" action="" id="date-filter">
    <ul id='ledger-date-fieldlist'>
        {{ date_form.as_ul }}
        <li>
            <input type='submit' name='submit' value='Update' id='id_date_form_submit_btn'/>
        </li>
        <li>
            <input type='button' name='clear' value='Clear' id='id_date_form_clear_btn'/>
        </li>
    </ul>
</form>

<table cellspacing="0" cellpadding="0" id='ledger_accounts'>

	<tr>
		<th class='ledger string business'>Business</th>
		<th class='ledger number debit'>Debit</th>
		<th class='ledger number credit'>Credit</th>
		<th class='ledger number total'>Balance</th>
	</tr>

{% for balance in balances|dictsort:"name" %}
   <tr class='{% cycle 'o' 'e' %}'>
        <td class='ledger string business'><a href='{% url view_business balance.id %}'>{{ balance.name }}</a></td>
        <td class='ledger number debit'>{{ balance.debit_total }}</td>
        <td class='ledger number credit'>{{ balance.credit_total }}</td>
        <td class='ledger number total'>{{ balance.balance }}</td>
    </tr>
{% endfor %}
</table>

{% endblock %}
