{% extends "gestion/base.html" %}
{% load i18n %}
{% load autotranslate %}
{% get_current_language as current_language %}
{% block titre %}{{ event.nom.capitalize }}{% endblock %}
{% block extrahead %}
{% endblock %}
{% block content %}
<div id="main">
        <section class="wrapper style1">
        <div class="inner">

          {% if not user.profile.is_chef and not user.profile.is_chef_event %}
          {% if chef_only %}
          {% trans "Cet événement est encore en construction ! Reviens plus tard." %}
          {% endif %}
          {% endif %}
          {% if user.profile.is_chef_event or user.profile.is_chef or not chef_only%}
            <div class="row">
                  <div class="6u 12u$(small)">

<div id="viewevent">
  <h2>{{ event.nom.capitalize }}</h2>
  <h4>
    {% blocktrans with date=event.date%} Le {{ date }}{% endblocktrans %}
    {% if event.fin %}
        {% blocktrans with debut=event.debut|time:"H:i" fin=event.fin|time:"H:i" %} de {{ debut}} à {{ fin }}{% endblocktrans %}
    {% else %}
      {% blocktrans with debut=event.debut|time:"H:i" %}  à {{ debut }}{% endblocktrans %}
    {% endif %}
  {% blocktrans with lieu=event.lieu %}- {{ lieu }}{% endblocktrans %}
  </h4>

  {% if user.is_authenticated and event.desc_users %}

<div class="box">
  {% autotranslate current_language event.desc_users event.desc_users_en %}

  </div>
  {% endif %}
  {% if user.is_authenticated and not event.desc_users and event.desc_users_en %}
<div class="box">
  <p>{{event.desc_users_en|safe}}</p>
</div>
{% endif %}
</div>
</div>
        <div class="6u 12u$(small)">
{% if user.is_authenticated %}
  <div id="doodle">
    <h4>{% trans "Participants" %}</h4>
    <p>{% blocktrans with nboui=nboui nbpe=nbpe nbnon=nbnon %}<b>{{ nboui }}</b> ont répondu oui, <b>{{ nbpe }}</b> peut-être, et <b>{{ nbnon }}</b> non{% endblocktrans %}</p>
      <div class="table-wrapper">
    <table class="default">
      {% if participants %}
      <thead>
        <tr>
          <th>{% trans "Ernestophoniste" %}</th>
          <th>{% trans "Réponse" %}</th>
          <th>{% trans "Commentaire" %}</th>
        </tr>
      </thead>
      {% endif %}
      <tbody>
      {% for p in participants %}

        <tr>
          {% if p.participant.doodlename %}
            <td>{{ p.participant.doodlename }}</td>
          {% else %}
            <td>{{ p.participant.user.username }}</td>
          {% endif %}
          {% if p.reponse == "oui" %}
            <td  style="background-color:#d0fa98; color:#666160">{% trans "Oui" %}</td><td>{{ p.details }}</td>
          {% elif p.reponse == "pe" %}
            <td  style="background-color:#ffd98c; color:#666160" >{% trans "Peut-être" %}</td><td>{{ p.details }}</td>
          {% elif p.reponse == "non" %}
            <td  style="background-color:#f79583; color:#666160">{% trans "Non" %}</td> <td >{{ p.details }}</td>
            {% endif %}

        </tr>
      {% empty %}
        {% blocktrans%} Pas de réponse pour l'instant{% endblocktrans %}
      {% endfor %}
    </tbody>
    </table>
  </div>
    <p><a href="{% url 'calendrier:reponse' event.id %}" class="button">{% trans "Répondre à l'événement" %}</a>    <div class="event-box" id="single-normal"></div></p>
  </div>
{% endif %}
</div>
        <div class="6u 12u$(small)">
{% if user.profile.is_chef or user.profile.is_chef_event %}
  <table class="table">
    <tr>
      <th>{% trans "Instrument" %}</th>
      <th>{% trans "Oui" %}</th>
      <th>{% trans "Peut-être" %}</th>
    </tr>
    {% for instrument, sure, maybe, namesoui, namespe,namesnon in instrument_count %}
      <tr>

            {% if namesoui or namespe %}
            <td>
          <div class="spoilerDiv" onclick="ouvrirFermerSpoiler(this);" align="center">
              <span class="lienAfficher">	<u style="color:#ffffff">	<a style="cursor:pointer">{{ instrument }}</a> </u></span>
              <div class="spoiler">
                  <div class="contenuSpoiler">
                  <table>
                      <tr>
                          <th>{% trans "Oui" %}</th>
                          <th>{% trans "Peut-être" %}</th>
                      </tr>
                      <td>
                          <ul>
                          {% for name in namesoui %}
                    <li>{{name}}</li>
                    {% endfor %}
                          </ul>
                      </td>
                         <td>
                          <ul>
                          {% for name in namespe %}
                    <li>{{name}}</li>
                    {% endfor %}
                          </ul>
                      </td>

                  </table>
                  </div>
              </div>
          </div>
          </td>
          {% else %}
          <td><div class="spoilerDiv" onclick="ouvrirFermerSpoiler(this);" align="center">
              <span class="lienAfficher">	<u style="color:#610B0B">	<a style="cursor:pointer;color:#610B0B">{{ instrument }}</a> </u></span>
              <div class="spoiler">
                  <div class="contenuSpoiler">
                  <table>
                      <tr>
                          <th>{% trans "Non" %}</th>

                      </tr>
                      <td>
                          <ul>
                          {% for name in namesnon %}
                    <li>{{name}}</li>
                    {% endfor %}
                          </ul>
                      </td>


                  </table>
                  </div>
              </div>
          </div></td>
          {% endif %}

        <td>{{ sure }}</td>
        <td>{{ maybe }}</td>
      </tr>
    {% endfor %}
  </table>
{% endif %}
{% if user.profile.is_chef or user.profile.is_chef_event %}
{% if multi_instrumentistes %}
<h1>{% blocktrans count counter=multi_instrumentistes|length %}Multi-instrumentiste présent :{% plural %}Multi-instrumentistes présents{% endblocktrans %}</h1>

<table class="table">
  <tr>
    <th>{% trans "Nom" %}</th>
    <th>{% trans "Instrument" %}</th>
    <th>{% trans "Instrument·s bonus" %}</th>
    <th>{% trans "Réponse" %}</th>
  </tr>
  {% for participant in multi_instrumentistes %}
    <tr>
      <td>{% if participant.participant.doodlename %}
        {{participant.participant.doodlename}}
      {% else %}
        {{participant.participant.user.username}}
        {% endif %}

    </td>
      <td>{% if participant.dont_play_main == 'Oui' %}
        {% if participant.instrument == "Autre" %}
          {{participant.instrument_autre}}
        {% else %}
          {{participant.instrument}}
          {% endif %}
        {% elif participant.participant.instru == "Autre" %}
        {{participant.participant.instru_autre}}
        {% else %}
        {{ participant.participant.instru }}
      {% endif %}</td>
      <td>{% if participant.dont_play_main == 'Oui' %}
        {% if participant.participant.instru == "Autre" %}
        {{participant.participant.instru_autre}}
        {% else %}
        {{ participant.participant.instru }}
      {% endif %}<br>{% endif %}
      {% if participant.instrument != participant.participant.instru_bonus %}
      {{ participant.participant.instru_bonus }}
    {% endif %}</td>
      <td>{{participant.reponse}}</td>
    </tr>
  {% endfor %}
</table>
{% endif %}
{% endif %}
</div>
<div class="6u 12u$(small)">
{% if user.is_authenticated %}
  <div id="actions">    {% if user.profile.is_chef or user.profile.is_chef_event  %}
        <p><a href="{% url "calendrier:edit_event" event.id %}" class="button alt">{% trans "Modifier l'événement" %}</a> &nbsp <a href="{% url "calendrier:delete_event" event.id %}" class="button alt">{% trans "Supprimer l'événement" %}</a></p>
      {% endif %}
    <p><a href="{% url 'calendrier:change-doodle-name' event.id %}" class="button">{% trans "Changer mon nom pour le doodle" %}</a> &nbsp <a href="{% url 'calendrier:home' %}" class="button">{% trans "Retour au calendrier" %}</a></p>
  </div>
{% endif %}
</div>
</div>
{% endif %}
</div>
</section>
</div>
{% endblock %}
{% block script %}
<script>
/*================================ Single Event
*/

var startDate,
  endDate;

var tmpstart = new Date('{{ event.date.isoformat }}'+' '+'{{ event.debut.isoformat }}'+':00');
startDate = tmpstart.toString();

{% if event.fin %}
var tmpend = new Date('{{ event.date.isoformat }}'+' '+'{{ event.fin.isoformat }}'+':00');
endDate = tmpend.toString();
{% else %}
var tmpend = new Date('{{ event.date.isoformat }}'+' '+'{{ event.debut.isoformat }}'+':00');
tmpend.setHours(tmpend.getHours() +2)
endDate = tmpend.toString();
{% endif %}
var singleEventArgs = {
  title       : '{{ event.nomcourt}}',
  start       : startDate,
  end         : endDate,
  location    : '{{ event.lieu}}',
  description : ''
};
var singleEvent = new Add2Calendar(singleEventArgs);


// widget 1 - normal
singleEvent.createWidget('#single-normal', function() {
  console.log('#single-normal widget has been created');
});

{% ifequal current_language "fr" %}
singleEvent.setOption({ lang: 'fr' });
{% else %}
singleEvent.setOption({ lang: 'en' });
{% endifequal %}
</script>

{% endblock %}
