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

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

{% block content %}

<div class="row">
  <div class="col-sm-4 col-md-3 col-content-left">
    <div class="content-left">
      <div class="content-left-top">
        <div class="line line-big">{{ negatives|length }}</div>
        <div class="line line-bigsub">compte{{ negatives|length|pluralize }} en négatif</div>
        <div class="block">
          <div class="line"><b>Total:</b> {{ negatives_sum|floatformat:2 }}€</div>
        </div>
        <div class="block">
          <div class="line"><b>Découvert autorisé par défaut</b></div>
          <div class="line">Montant: {{ settings.overdraft_amount }}€</div>
          <div class="line">Pendant: {{ settings.overdraft_duration }}</div>
        </div>
      </div>
      {% if perms.kfet.change_settings %}
        <div class="buttons">
          <a class="btn btn-primary btn-lg" href="{% url 'kfet.settings' %}">Modifier les valeurs par défaut</a>
        </div>
      {% endif %}
    </div>
  </div>
  <div class="col-sm-8 col-md-9 col-content-right">
    {% include 'kfet/base_messages.html' %}
    <div class="content-right">
      <div class="content-right-block">
        <h2>Liste des comptes en négatifs</h2>
        <div class="table-responsive">
          <table class="table table-condensed">
            <thead>
              <tr>
                <td></td>
                <td>Tri</td>
                <td>Nom</td>
                <td>Balance</td>
                <td>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 %}">
                      <span class="glyphicon glyphicon-cog"></span>
                    </a>
                  </td>
                  <td>{{ neg.account.trigramme }}</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>
      </div>
    </div>
  </div>
</div>

{% endblock %}
