{% extends 'hordak/base.html' %}

{% block page_name %}Accounts{% endblock %}
{% block page_description %}See all accounts at a glance{% endblock %}

{% block content %}
    <table class="table table-striped">
        <thead>
            <tr>
                <th>Name</th>
                <th>Type</th>
                <th>Balance</th>
                <th>Currencies</th>
                <th></th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            {% for account in accounts %}
            <tr>
                <td>
                    <div style="padding-left: {% widthratio account.get_level 1 15 %}px;">
                        {% if account.is_child_node %}↳{% endif %}
                        {{ account.name }}
                    </div>
                </td>
                <td>{{ account.get__type_display }}</td>
                <td>{{ account.balance }}</td>
                <td>{{ account.currencies|join:', ' }}</td>
                <td>
                    {% if account.is_leaf_node %}
                        <a href="{% url 'hordak:accounts_transactions' account.uuid %}" class="btn btn-default btn-xs">Transactions</a>
                    {% endif %}
                </td>
                <td>
                    <a href="{% url 'hordak:accounts_update' account.uuid %}" class="btn btn-default btn-xs">Edit</a>
                </td>
            </tr>
            {% empty %}
                <tr>
                <td colspan="5" class="text-center">No accounts exist</td>
                </tr>
            {% endfor %}
        </tbody>
    </table>

    <p>
        <a href="{% url 'hordak:accounts_create' %}">Create account</a> |
        <a href="{% url 'hordak:transactions_create' %}">Create transaction</a> |
        <a href="{% url 'hordak:transactions_reconcile' %}">Reconcile statements</a>
    </p>
{% endblock %}
