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

{% block extra_head %}
<script type="text/javascript" src="{% static 'kfet/js/Chart.bundle.js' %}"></script>
<script type="text/javascript" src="{% static 'kfet/js/statistic.js' %}"></script>
{% endblock %}

{% block title %}Informations sur l'article {{ article }}{% endblock %}
{% block content-header-title %}Article - {{ article.name }}{% 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">{{ article.name }}</div>
        <div class="line line-bigsub">{{ article.category }}</div>
        <div class="block">
          <div class="line">Prix (hors réduc.): {{ article.price }}€</div>
          <div class="line">Stock: {{ article.stock }}</div>
          <div class="line">En vente: {{ article.is_sold | yesno:"Oui,Non" }}</div>
          <div class="line">Affiché: {{ article.hidden | yesno:"Non,Oui" }}</div>
        </div>
      </div>
      <div class="buttons">
        <a class="btn btn-primary btn-lg" href="{% url 'kfet.article.update' article.pk %}">
          Modifier
        </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>Historique</h2>
        <div class="row">
          <div class="col-sm-6">
            <h3>Inventaires</h3>
            <table class="table">
              <thead>
                <tr>
                  <td>Date</td>
                  <td>Stock</td>
                  <td>Erreur</td>
                </tr>
              </thead>
              <tbody>
                {% for inventoryart in inventoryarts %}
                  <tr>
                    <td>{{ inventoryart.inventory.at }}</td>
                    <td>{{ inventoryart.stock_new }}</td>
                    <td>{{ inventoryart.stock_error }}</td>
                  </tr>
                {% endfor %}
              </tbody>
            </table>
          </div>
          <div class="col-sm-6">
            <h3>Prix fournisseurs</h3>
            <table class="table">
              <thead>
                <tr>
                  <td>Date</td>
                  <td>Fournisseur</td>
                  <td>HT</td>
                  <td>TVA</td>
                  <td>Droits</td>
                </tr>
              </thead>
              <tbody>
                {% for supplierart in supplierarts %}
                  <tr>
                    <td>{{ supplierart.at }}</td>
                    <td>{{ supplierart.supplier.name }}</td>
                    <td>{{ supplierart.price_HT }}</td>
                    <td>{{ supplierart.TVA }}</td>
                    <td>{{ supplierart.rights }}</td>
                  </tr>
                {% endfor %}
              </tbody>
            </table>
          </div>
        </div><!-- /row-->
      </div>
      <div class="content-right-block content-right-block-transparent">
        <h2>Statistiques</h2>
        <div class="row">
          <div class="col-sm-12 nopadding">
            <div class="panel-md-margin">
              <h3>Ventes de {{ article.name }}</h3>
              <div id="stat_last"></div>
            </div>
          </div>
        </div><!-- /row -->
      </div>
    </div>
  </div>
</div>

<script type="text/javascript">
$(document).ready(function() {
    var stat_last = new StatsGroup(
        "{% url 'kfet.article.stat.sales.list' article.id %}",
        $("#stat_last"),
    );
});
</script>

{% endblock %}
