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

{% block title %}Articles{% endblock %}
{% block content-header-title %}Articles{% 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">{{ articles|length }}</div>
        <div class="line line-bigsub">article{{ articles|length|pluralize }}</div>
      </div>
      <div class="buttons">
        <a class="btn btn-primary btn-lg" href="{% url 'kfet.article.create' %}">
          Nouvel article
        </a>
        <a class="btn btn-primary btn-lg" href="{% url 'kfet.category' %}">
          Catégories
        </a>
      </div>
    </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 articles</h2>
        <div class="table-responsive">
          <table class="table table-condensed">
            <thead>
              <tr>
                <td></td>
                <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="7">{{ article.category.name }}</td>
                  </tr>
                {% endifchanged %}
                <tr>
                  <td class="text-center">
                    <a href="{% url 'kfet.article.read' article.pk %}">
                      <span class="glyphicon glyphicon-cog"></span>
                    </a>
                  </td>
                  <td>{{ article.name }}</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>
    </div>
  </div>
</div>

{% endblock %}
