{% extends "sidebar_table_layout.html" %}

{% block sidebar %}
    <div id="table_overflow">
    <table class="balance table">
    {% set balance = g.project.balance %}
    {% for member in g.project.members | sort(attribute='name') if member.activated or balance[member.id]|round(2) != 0 %}
    <tr id="bal-member-{{ member.id }}" action={% if member.activated %}delete{% else %}reactivate{% endif %}>
        <td class="balance-name">{{ member.name }}</td>
        <td class="balance-value {% if balance[member.id]|round(2) > 0 %}positive{% elif balance[member.id]|round(2) < 0 %}negative{% endif %}">
            {% if balance[member.id]|round(2) > 0 %}+{% endif %}{{ "%.2f" | format(balance[member.id]) }}
        </td>
    </tr>
    {% endfor %}
    </table>
    </div>
{% endblock %}


{% block content %}
    <table id="bill_table" class="split_bills table table-striped">
        <thead><tr><th>{{ _("Who?") }}</th><th>{{ _("Paid") }}</th><th>{{ _("Spent") }}</th><th>{{ _("Balance") }}</th></tr></thead>
    <tbody>
    {% for member in members %}
    <tr class="{{ loop.cycle("odd", "even") }}">
            <td>{{ member.name }}</td>
            <td>{{ "%0.2f"|format(paid[member.id]) }}</td>
            <td>{{ "%0.2f"|format(spent[member.id]) }}</td>
            <td>{{ "%0.2f"|format(balance[member.id]) }}</td>
    </tr>
    {% endfor %}
    </tbody>
    </table>

{% endblock %}
