{% extends "base.html" %}
{% load ledger %}

{% block title %}Accounts{% endblock %}

{% block content %}
<h2>Accounts</h2>
<ul class='header-actions-left'>
	<li><a href="{% url account_ledger %}">Complete Ledger</a></li>
{% if perms.ledger.transfer_funds %}
	<li><a href="{% url transfer_funds %}">Transfer Funds</a></li>
{% endif %}
{% if perms.ledger.add_transaction %}
	<li><a href="{% url create_general_entry %}">General Entry</a></li>
{% endif %}
{% if perms.ledger.add_account %}
	<li><a href="{% url create_account %}">Create account</a></li>
{% endif %}
</ul>

<h3>Account Reports</h3>
<form action="{% url account_ledger %}" method="get" accept-charset="utf-8">
	<table id='accounts'>
		<tr>
			<th>&nbsp;</th>
			<th>Name</th>
			<th>Number</th>
			<th>Type</th>
			<th class='ledger number'>Debit Total</th>
			<th class='ledger number'>Credit Total</th>
			<th class='ledger number'>Balance</th>
			<th class='ledger number'>Reconciled</th>
		</tr>
		{% for account in accounts %}
		<tr class='{% cycle 'o' 'e' %}'>
			<td>
				<input type="checkbox" name="accounts" value="{{ account.id }}" id="{{ account.id }}" />
			</td>
			<td><a href="{% url single_account_ledger account_id=account.id %}">{{ account.name }}</a></td>
			<td>{{ account.number }}</td>
			<td>{{ account.type }}</td>
			<td class='ledger number'>${{ account.debit_total|currency }}</td>
			<td class='ledger number'>${{ account.credit_total|currency }}</td>
			<td class='ledger number'>${{ account.balance|currency }}</td>
			<td class='ledger number'>${{ account.reconciled_balance|currency }}</td>
			<td class='ledger links'>
			{#	<a href="{% url graph_account developer=account.id %}" title='View graph of {{ account.name }}'> #}
			{#		<img src='{{ MEDIA_URL }}images/icons/chart_curve.png' alt='Graph of {{ account.name }}' /> #}
			{#	</a> #}
			</td>
		{% if perms.ledger.change_account or perms.ledger.delete_account %}
			<td class='ledger links'>
				{% if perms.ledger.change_account %}
					<a href='{% url edit_account account_id=account.id %}'>Edit</a>
				{% endif %}
				{% if perms.ledger.delete_account %}
					<a href='{% url remove_account account_id=account.id %}'>Remove</a>
				{% endif %}
			</td>
		{% endif %}
		</tr>
		{% endfor %}
	</table>
	<div><input type="submit" name="view_selected" value="View Selected Accounts &rarr;" id="view_selected" /></div>
</form>
{% endblock %}