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

{% block title %}Comptes - Négatifs{% endblock %}
{% block header-title %}Comptes en négatif{% endblock %}

{% block fixed %}

<aside>
  <div class="heading">
    {{ negatives|length }}
    <span class="sub">compte{{ negatives|length|pluralize }} en négatif</span>
  </div>
  <div class="text">
    <b>Total:</b> {{ negatives_sum|floatformat:2 }}€
  </div>
  <div class="text">
    <b>Plafond par défaut</b>
    <ul class="list-unstyled">
      <li>Montant: {{ kfet_config.overdraft_amount }}€</li>
      <li>Pendant: {{ kfet_config.overdraft_duration }}</li>
    </ul>
  </div>
</aside>

{% if perms.kfet.change_settings %}
<div class="buttons">
  <div class="full">
    <button type="button" class="btn btn-primary" href="{% url 'kfet.settings' %}">Modifier les valeurs par défaut</a>
  </div>
</div>
{% endif %}

{% endblock %}

{% block main %}

<div class="table-responsive">
  <table class="table table-hover table-condensed">
    <thead>
      <tr>
        <td class="text-center">Tri.</td>
        <td>Nom</td>
        <td class="text-right">Balance</td>
        <td class="text-right">Réelle</td>
        <td>Début</td>
        <td>Découvert autorisé</td>
        <td>Jusqu'au</td>
        <td>Balance offset</td>
      </tr>
    </thead>
    <tbody>
      {% for neg in negatives %}
      <tr>
        <td class="text-center">
          <a href="{% url 'kfet.account.update' neg.account.trigramme %}">
            {{ neg.account.trigramme }}
          </a>
        </td>
        <td>{{ neg.account.name }}</td>
        <td class="text-right">{{ neg.account.balance|floatformat:2 }}€</td>
        <td class="text-right">
          {% if neg.balance_offset %}
            {{ neg.account.real_balance|floatformat:2 }}€
          {% endif %}
        </td>
        <td>{{ neg.start|date:'d/m/Y H:i:s'}}</td>
        <td>{{ neg.authz_overdraft_amount|default_if_none:'' }}</td>
        <td>{{ neg.authz_overdrafy_until|default_if_none:'' }}</td>
        <td>{{ neg.balance_offset|default_if_none:'' }}</td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</div>

{% endblock %}
