{% 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 naloděných pasažérů</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 %}
          <form action="/people/update/" method="POST" class="people_form">
          {%csrf_token%}
          <table class="table-list">
              <tr>
                  <th><input type="checkbox" id="check_all"/></th>
                  <th>Jméno</th>
                  <th>Příjmení</th>
                  <th>Email</th>
                  <th>PSČ</th>
                  <th>Město</th>
                  <th>Kraj</th>
                  <th>Uživatel chce</th>
                  <th>Dovednosti</th>
                  <th>Akce</th>
              </tr>
              {% for p in people %}
              <tr>
                  <td><input type="checkbox" name="r[]" value="{{p.id}}"/></td>
                  <td>{{p.first_name}}</td>
                  <td>{{p.last_name}}</td>
                  <td>{{p.email}}</td>
                  <td>{{p.postcode|default_if_none:'-'}}</td>
                  <td>{{p.city|default_if_none:'-'}}</td>
                  <td>{{p.get_district_display}}</td>
                  <td>{{p.get_kind_display}}</td>
                  <td>{{p.interestedIn|default_if_none:'-'}}</td>
                  <td>
                      <a href="{% url 'nalodeni:person_detail' p.id%}">detail</a>,
                      <a href="{% url 'nalodeni:person_edit' p.id%}">upravit</a>
                  </td>
              </tr>
              {% endfor %}
          </table>
          {% if newOnly %}
          <button name="setStatus" value="reg" class="button">Nastavit stav 'registrovaný'</button>
          {% else %}
          <button name="setStatus" value="new" class="button">Nastavit stav 'nový'</button>
          {% endif %}
          </form>
          {%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%}
