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

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

{% block fixed %}

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

<div class="buttons">
  <a class="btn btn-primary" href="{% url 'kfet.article.create' %}">
    <span class="glyphicon glyphicon-plus"></span>
    <span>Nouvel article</span>
  </a>
  <a class="btn btn-primary" href="{% url 'kfet.category' %}">
    Catégories
  </a>
</div>

{% endblock %}

{% block main %}
<div class="table-responsive">
  <table class="table table-hover table-condensed">
    <thead>
      <tr>
        <td>Nom</td>
        <td class="text-right">Prix</td>
        <td class="text-right">Stock</td>
        <td class="text-right">En vente</td>
        <td class="text-right">Affiché</td>
        <td class="text-right">Dernier inventaire</td>
      </tr>
    </thead>
    <tbody>
      {% for article in articles %}
      {% ifchanged article.category %}
      <tr class="section">
        <td colspan="6">{{ article.category.name }}</td>
      </tr>
      {% endifchanged %}
      <tr>
        <td>
          <a href="{% url 'kfet.article.read' article.pk %}">
            {{ article.name }}
          </a>
        </td>
        <td class="text-right">{{ article.price }}€</td>
        <td class="text-right">{{ article.stock }}</td>
        <td class="text-right">{{ article.is_sold | yesno:"En vente,Non vendu"}}</td>
        <td class="text-right">{{ article.hidden | yesno:"Caché,Affiché" }}</td>
        <td class="text-right">{{ article.inventory.0.at }}</td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</div>
</div>

{% endblock %}
