{% extends "kfet/base_col_2.html" %}

{% block title %}Comptes{% endblock %}
{% block header-title %}Comptes{% endblock %}

{% block fixed %}

<aside>
  <div class="heading">
    {% with n_accounts=accounts|length|add:-1 %}
    {{ n_accounts }}
    <span class="sub">compte{{ n_accounts|pluralize }}</span>
    {% endwith %}
  </div>
</aside>

<div class="buttons">
  <div class="solo full">
  <a class="btn btn-primary" href="{% url 'kfet.account.create' %}">
    <span class="glyphicon glyphicon-plus"></span>
    <span>Créer un compte</span>
  </a>
</div>

  {% if perms.kfet.manage_perms %}
  <a class="btn btn-primary" href="{% url 'kfet.account.group' %}">Permissions</a>
  {% endif %}

  {% if perms.kfet.view_negs %}
  <a class="btn btn-primary" href="{% url 'kfet.account.negative' %}">Négatifs</a>
  {% endif %}
</div>

{% endblock %}

{% block main %}

<section>
  <div class="table-responsive">
    <table
        class="table table-hover table-condensed sortable"
        {# Initial sort: [(trigramme,asc)] #}
        data-sortlist="[[0,0]]">
      <thead>
        <tr>
          <td class="text-center">Tri.</td>
          <td>Nom</td>
          <td class="text-right">Balance</td>
          <td class="text-center" data-sorter="yesno">COF</td>
          <td>Dpt</td>
          <td class="text-center">Promo</td>
        </tr>
      </thead>
      <tbody>
        {% for account in accounts %}
        <tr>
          <td class="text-center">
            <a href="{% url 'kfet.account.read' account.trigramme %}">
              {{ account.trigramme }}
            </a>
          </td>
          <td>{{ account.name }}</td>
          <td class="text-right">{{ account.balance }}€</td>
          <td class="text-center">{{ account.is_cof|yesno }}</td>
          <td>{{ account.departement }}</td>
          <td class="text-center">{{ account.promo|default_if_none:'' }}</td>
        </tr>
        {% endfor %}
        </tbody>
    </table>
  </div>
</section>

{% endblock %}
