{% extends 'pirati_cz.html' %}

{%block head%}
<script>
$(document).ready(function(){
    $("#check_all").on("change", function(){
        if( $(this).prop('checked') ){
            $(".people_form input[type='checkbox']").prop("checked", true);
        } else {
            $(".people_form input[type='checkbox']").prop("checked", false);
        }
    });
});
</script>
{%endblock%}
{%block body%}
<div class="row">
  <div class="medium-12 large-12 columns">
    <section class="o-section o-section--spaceBot">
      <div class="o-section-inner">
        <div class="o-section-block">
          <h2>Seznam EU2019 zájemců o pomoc</h2>
          <form action="#" method="POST">
          {%csrf_token%}
          <div class="medium-4 large-4 columns">
              <select name="dist" onChange="this.form.submit()">{% for d in distAvail%}<option value="{{d.0}}"{%if selDist == d.0%} selected="selected"{%endif%}>{{d.1}}</option>{%endfor%}</select>
          </div>
          <div class="medium-4 large-4 columns">
          </div>
          <div class="medium-4 large-4 columns">
              <input type="submit" name="doCsvExport" value="CSV export" class="button" style="border: 0px; float:right;"/>
          </div>
          </form>
          <br/>
          {% if people|length > 0 %}
          {%csrf_token%}
          <table class="table-list">
              <tr>
                  <th>Vytvořeno</th>
                  <th>E-mail</th>
                  <th>Kraj</th>
                  <th>PSČ</th>
                  <th>Chci info</th>
                  <th>Chci rozdávat</th>
                  <th>Chci se zapojit</th>
                  <th>Poznámka</th>
              </tr>
              {% for p in people %}
              <tr>
                  <td>{{p.createdStamp}}</td>
                  <td>{{p.email}}</td>
                  <td>{{p.get_district_display}}</td>
                  <td>{{p.postcode|default_if_none:'-'}}</td>
                  <td>{%if p.want_info%}ano{%else%}ne{%endif%}</td>
                  <td>{%if p.want_campaign%}ano{%else%}ne{%endif%}</td>
                  <td>{%if p.want_be_active%}ano{%else%}ne{%endif%}</td>
                  <td>{{p.note|default_if_none:'-'}}</td>
              </tr>
              {% endfor %}
          </table>
          {%else%}
          <em>Žádné položky</em>
          {%endif%}
        </div>
      </div>
    </section>
  </div>
</div>

<div class="row">
  <div class="medium-12 large-12 columns">
    <section class="o-section o-section--spaceBot">
      <div class="o-section-inner">
      &nbsp;
      </div>
    </section>
  </div>
</div>


{%endblock%}
