{% extends "base_title.html" %}
{% load static %}

{% block realcontent %}
    <h2>{{ spectacle }}</h2>
      <table class='table table-striped etat-bda'>
        <thead>
          <tr>
          <th data-sort="string">Nom</th>
          <th data-sort="int">Places</th>
          <th data-sort="string">Adresse Mail</th>
          <th data-sort="string">Payé</th>
          <th data-sort="string">Donné</th>
          </tr>
        </thead> 
        <tbody>
        {% for participant in participants %}
            <tr>
                <td data-sort-value="{{ participant.name}}">{{participant.name}}</td>
                <td data-sort-value="{{participant.nb_places}}">{{participant.nb_places}} place{{participant.nb_places|pluralize}}</td>
                <td data-sort-value="{{participant.email}}">{{participant.email}}</td>
                <td data-sort-value="{{ participant.paid}}" class={%if participant.paid %}"greenratio"{%else%}"redratio"{%endif%}>
                {% if participant.paid %}Oui{% else %}Non{%endif%}
            </td>
            <td data-sort-value="{{participant.given}}" class={%if participant.given == participant.nb_places %}"greenratio"
                            {%elif participant.given == 0%}"redratio"
                            {%else%}"orangeratio"
                            {%endif%}>
                {% if participant.given == participant.nb_places %}Oui
                {% elif participant.given == 0 %}Non
                {% else %}{{participant.given}}/{{participant.nb_places}}
                {%endif%}
            </td>
            </tr>
            {% endfor %}
        </tbody>
      </table>
    <h3><a href="{% url "admin:bda_attribution_add" %}?spectacle={{spectacle.id}}"><span class="glyphicon glyphicon-plus-sign"></span> Ajouter une attribution</a></h3>
    <div>
      <div>
        <button class="btn btn-default" type="button" onclick="toggle('export-mails')">Afficher/Cacher mails participant⋅e⋅s</button>
	<pre id="export-mails" style="display:none">{% spaceless %}
          {% for participant in participants %}{{ participant.email }}, {% endfor %}
	{% endspaceless %}</pre>
      </div>

      <div>
        <button class="btn btn-default" type="button" onclick="toggle('export-salle')">Afficher/Cacher liste noms</button>
	<pre id="export-salle" style="display:none">{% spaceless %}
{% for participant in participants %}{{ participant.name }} : {{ participant.nb_places }} place{{ participant.nb_places|pluralize }}
{% endfor %}
	{% endspaceless %}</pre>
      </div>

      <div>
        <a href="{% url 'bda-rappels' spectacle.id %}">Page d'envoi manuel des mails de rappel</a>
      </div>

    <script type="text/javascript">
    function toggle(id) {
        var pre = document.getElementById(id) ;
        pre.style.display = pre.style.display == "none" ? "block" : "none" ;
    }
    </script>
    <script type="text/javascript">
        $(function(){
        $("table.etat-bda").stupidtable();
        });
    </script>
 
{% endblock %}
