{% extends "gestion/base.html" %}
{% load i18n %}
{% load static %}
{% get_current_language as current_language %}
{% load autotranslate %}
{% block titre %}{{ instru.type }}{% endblock %}

{% block content %}
<div id="main">
        <section class="wrapper style1">
        <div class="inner">
    <h3>{% blocktrans with type=instru.type etat=instru.etat statut=instru.statut%} {{type}} en {{etat}} : {{statut}} {% endblocktrans%}</h3>
    <div class="row">

      <div class="7u 12u$(small)">
    <p>{% trans "Propriétaire : "%} {% if instru.owner %}{{instru.owner}} {% else %}-{% endif %}<br>
      {% trans "Statut : "%} {{instru.statut}} <br>
      {% ifequal instru.statut 'Prêté' %}
      {% trans "Utilisateur : "%} {% if instru.user %}{{instru.user}} {% else %}-{% endif %}<br>
      {% endifequal %}
      {% trans "Marque : "%} {% if instru.marque %}{{instru.marque}} {% else %}-{% endif %} <br>
      {% trans "Modele : "%} {% if instru.model %}{{instru.model}} {% else %}-{% endif %}<br>
      {% trans "Numéro de série : "%} {% if instru.serial %}{{instru.serial}}{% else %}-{% endif %} <br>
      {% trans "Prix : "%} {% if instru.prix %}{{instru.prix}} {% else %}-{% endif %}<br>
      {% trans "Acheté·e en" %}{% if instru.annee %}{{annee}}{% else %}-{% endif %}
      </p>
      {% if infos or infos_en %}

        <h1>{% trans "Infos utiles :" %}</h1>

       <div class="box">{% autotranslate current_language infos infos_en %}</div>


      {% endif %}
    {% if suppression %}
        <p>{{ suppression }}</p>
    {% endif %}
  {% if not user.profile.is_chef or not user.profile.is_chef_instru %}
    </div>
      <div class="5u 12u$(small)">
        {% endif %}
<h4>{% blocktrans count counter=reparations|length %}Réparation :{% plural %}Réparations {% endblocktrans %}</h4>
<div class="table-wrapper">
  <table class="default">
    <thead>
      <tr>
        <th>{% trans "Date" %}</th>
        <th>{% trans "Description" %}</th>
        <th>{% trans "Prix" %}</th>
        <th>{% trans "lieu" %}</th>
      </tr>
    </thead>
      <tbody>
          {% for rep in reparations %}
          <tr>

            <td>  {{ rep.date }} </td>
            <td> {% ifequal current_language "fr" %}
                  {{ rep.description  }}
                  {% else %}
                    {% if instru.description_en %}
                      {{ rep.description_en  }}
                    {% else %}
                      {{ rep.description  }}
                    {% endif %}
              {% endifequal %} </td>
            <td> {{ rep.prix }} </td>
            <td> {{ rep.lieux }} </td>
            {%if user.profile.is_chef or user.profile.is_chef_instru %}
            <td>
              <a href="{% url "instruments:update_rep" rep.id %}" class="button small">{% trans "Modifier" %}</a>
              <a href="{% url "instruments:delete_rep" rep.id %}" class="button small">{% trans "Supprimer" %}</a>
      </td>
            {% endif %}
          </tr>
          {% endfor %}

      </tbody>
  </table>
</div>
<p>
  <a class='button ' href="{% url "instruments:liste" %}">Retour aux instruments</a>
{% if user.profile.is_chef or user.profile.is_chef_instru %}
    <a class='button ' href="{% url "instruments:ajouter_rep" instru.id %}">Ajouter une réparation</a>
    {% endif %}
    </p>
</div>

    {% if user.profile.is_chef or user.profile.is_chef_instru %}

      <div class="5u 12u$(small)">
      <div class="info_part">
        <form action="{% url "instruments:fiche_instru" instru.id %}" id="chef-edit-form" method="post">
            {% csrf_token %}
            {{ form.as_p }}
            <input type="submit" value="Enregister" />
        </form>
    {% endif %}


    </div>
    </section>
    </div>
{% endblock %}
