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

{% block title %}Inventaire #{{ inventory.pk }}{% endblock %}
{% block header-title %}Inventaire #{{ inventory.pk }}{% endblock %}

{% block fixed %}

<aside>
  <div class="text">
    <ul class="list-unstyled">
      <li><b>Date :</b> {{ inventory.at }}</li>
      <li><b>Par :</b> {{ inventory.by }}</li>
      {% if inventory.order %}
      <li>
        <b>Commande relative :</b>
        <a href="{% url 'kfet.order.read' inventory.order.pk %}">
          #{{ inventory.order.pk }}
        </a>
      </li>
      {% endif %}
    </ul>
  </div>
</aside>

{% endblock %}

{% block main %}

<div class="table-responsive">
  <table
      class="table table-condensed table-hover table-striped sortable"
      {# Initial sort: [(article.name,asc)] #}
      data-sortlist="[[0,0]]">
    <thead>
      <tr>
        <td>Article</td>
        <td>Stock avant</td>
        <td>Stock après</td>
        <td>Erreur</td>
      </tr>
    </thead>
    {% regroup inventoryarts by article.category as category_list %}
    {% for category in category_list %}
      <tbody class="tablesorter-no-sort">
        <tr class="section">
          <td colspan="4">{{ category.grouper.name }}</td>
        </tr>
      </tbody>
      <tbody>
        {% for inventoryart in category.list %}
          <tr>
            <td>
              <a href="{% url "kfet.article.read" inventoryart.article.id %}">
                {{ inventoryart.article.name }}
              </a>
            </td>
            <td>{{ inventoryart.stock_old }}</td>
            <td>{{ inventoryart.stock_new }}</td>
            <td>{{ inventoryart.stock_error }}</td>
          </tr>
        {% endfor %}
      </tbody>
    {% endfor %}
  </table>
</div>

{% endblock %}
