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

{% 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="{{ participan.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>
      <br>
     <button class="btn btn-default" type="button" onclick="toggle('export-mails')">Afficher/Cacher mails participants</button>
      <pre id="export-mails" style="display:none">
{%for participant in participants %}{{participant.email}}, {%endfor%}
      </pre>
      <br>
      <button class="btn btn-default" type="button" onclick="toggle('export-salle')">Afficher/Cacher liste noms</button>
      <pre id="export-salle" style="display:none">
{% for participant in participants %}{{participant.name}} : {{participant.nb_places}} places
{% endfor %}
      </pre>

  <script type="text/javascript"
          src="{% static "js/jquery.min.js" %}"></script>
  <script type="text/javascript"
          src="{% static "js/joequery-Stupid-Table-Plugin/stupidtable.js" %}"></script>
    <script>
    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 %}