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

{% block title %}Nouvelle commande{% endblock %}
{% block content-header-title %}Nouvelle commande {{ supplier.name }}{% endblock %}

{% block content %}

<div class="content-center">
    <div>
<form action="" method="post">
  {% csrf_token %}
  <table class="table text-center">
    <thead>
      <tr>
        <td rowspan="2">Article</td>
        <td colspan="5">Ventes
            <span class='glyphicon glyphicon-question-sign' title="Ventes des 5 dernières semaines" data-placement="bottom"></span>
            </td>
        <td rowspan="2">V. moy.
            <span class='glyphicon glyphicon-question-sign' title="Moyenne des ventes" data-placement="bottom"></span>
            </td>
        <td rowspan="2">E.T.
            <span class='glyphicon glyphicon-question-sign' title="Écart-type des ventes" data-placement="bottom"></span>
            </td>
        <td rowspan="2">Prév.
            <span class='glyphicon glyphicon-question-sign' title="Prévision de ventes" data-placement="bottom"></span>
            </td>
        <td rowspan="2">Stock</td>
        <td rowspan="2">Rec.
            <span class='glyphicon glyphicon-question-sign' title="Quantité conseillée" data-placement="bottom"></span>
            </td>
        <td rowspan="2">Commande</td>
      </tr>
      <tr>
        <td>S1</td>
        <td>S2</td>
        <td>S3</td>
        <td>S4</td>
        <td>S5</td>
      </tr>
    </thead>
    <tbody>
      {% for form in formset %}
        {% ifchanged form.category %}
          <tr class='section'>
              <td> {{ form.category_name }}</td>
              <td colspan="11"></td>
          </tr>
        {% endifchanged %}
        <tr>
          {{ form.article }}
          <td>{{ form.name }}</td>
          <td>{{ form.v_s1 }}</td>
          <td>{{ form.v_s2 }}</td>
          <td>{{ form.v_s3 }}</td>
          <td>{{ form.v_s4 }}</td>
          <td>{{ form.v_s5 }}</td>
          <td>{{ form.v_moy }}</td>
          <td>{{ form.v_et }}</td>
          <td>{{ form.v_prev }}</td>
          <td>{{ form.stock }}</td>
          <td>{{ form.c_rec }}</td>
          <td>{{ form.quantity_ordered | add_class:"form-control" }}</td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
  {{ formset.management_form }}
  {% if not perms.kfet.add_inventory %}
  <div class='auth-form form-horizontal'>
    {% include "kfet/form_authentication_snippet.html" %}
  </div>
  {% endif %}
  <input type="submit" value="Enregistrer" class="btn btn-primary btn-lg btn-block">
</form>
    </div>
</div>

<script type='text/javascript'>
$(document).ready(function () {
    $('.glyphicon-question-sign').tooltip({'html': true}) ;
});
</script>

{% endblock %}
