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

{% block title %}Commandes{% endblock %}
{% block content-header-title %}Commandes{% 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">{{ orders|length }}</div>
        <div class="line line-bigsub">commande{{ orders|length|pluralize }}</div>
      </div>
      <div class="buttons">
      </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>Fournisseurs</h2>
        <div class="table-responsive">
          <table class="table table-condensed">
            <thead>
              <tr>
                <td></td>
                <td></td>
                <td>Nom</td>
                <td>Mail</td>
                <td>Tél.</td>
                <td>Adresse</td>
                <td>Commentaire</td>
            <tbody>
              {% for supplier in suppliers %}
                <tr>
                  <td class="no-padding">
                    <a href="{% url 'kfet.order.new' supplier.pk %}" class="btn btn-primary">
                      Passer une commande
                    </a>
                  </td>
                  <td class="text-center">
                    <a href="{% url 'kfet.order.supplier.update' supplier.pk %}">
                      <span class="glyphicon glyphicon-cog"></span>
                    </a>
                  </td>
                  <td>{{ supplier.name }}</td>
                  <td>{{ supplier.email }}</td>
                  <td>{{ supplier.phone }}</td>
                  <td>{{ supplier.address }}</td>
                  <td>{{ supplier.comment }}</td>
                </tr>
              {% endfor %}
            </tbody>
          </table>
        </div>
      </div>
      <div class="content-right-block">
        <h2>Liste des commandes</h2>
        <div class="table-responsive">
          <table class="table table-condensed">
            <thead>
              <tr>
                <td></td>
                <td></td>
                <td>Date</td>
                <td>Fournisseur</td>
                <td>Inventaire</td>
              </tr>
            </thead>
            <tbody>
              {% for order in orders %}
                <tr>
                  <td class="no-padding">
                    {% if not order.inventory %}
                      <a href="{% url 'kfet.order.to_inventory' order.pk %}" class="btn btn-primary">
                        Générer inventaire
                      </a>
                    {% endif %}
                  </td>
                  <td>
                    <a href="{% url 'kfet.order.read' order.pk %}">
                      <span class="glyphicon glyphicon-cog"></span>
                    </a>
                  </td>
                  <td>{{ order.at }}</td>
                  <td>{{ order.supplier }}</td>
                  <td>
                    {% if order.inventory %}
                      <a href="{% url 'kfet.inventory.read' order.inventory.pk %}">
                        #{{ order.inventory.pk }}
                      </a>
                    {% endif %}
                  </td>
                </tr>
              {% endfor %}
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>

{% endblock %}
