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

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

{% block fixed %}

<aside>
  <div class="heading">
    {{ checkouts|length }}
    <span class="sub">caisse{{ checkouts|length|pluralize }}</span>
  </div>
</aside>

<div class="buttons">
  <a class="btn btn-primary" href="{% url 'kfet.checkout.create' %}">
    <span class="glyphicon glyphicon-plus"></span>
    <span>Créer une caisse</span>
  </a>
</div>

{% endblock %}

{% block main %}

<div class="table-responsive">
  <table
      class="table table-hover table-condensed sortable"
      {# Initial sort: [(valid_to,desc)] #}
      data-sortlist="[[3,1]]">
    <thead>
      <tr>
        <td>Nom</td>
        <td class="text-right">Balance</td>
        <td class="text-right" data-parser="shortDate">Déb. valid.</td>
        <td class="text-right" data-parser="shortDate">Fin valid.</td>
        <td class="text-right">Protégée</td>
      </tr>
    </thead>
    <tbody>
      {% for checkout in checkouts %}
      <tr>
        <td>
          <a href="{% url 'kfet.checkout.read' checkout.pk %}">
            {{ checkout.name }}
          </a>
        </td>
        <td class="text-right">{{ checkout.balance}}€</td>
        <td class="text-right" title="{{ checkout.valid_from }}">
          {{ checkout.valid_from|date:'d/m/Y H:i' }}
        </td>
        <td class="text-right" title="{{ checkout.valid_to }}">
          {{ checkout.valid_to|date:'d/m/Y H:i' }}
        </td>
        <td class="text-right">{{ checkout.is_protected|yesno }}</td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</div>

{% endblock %}
