{% 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 {%if show_all %}všech{%else%}nových{%endif%} čekajících registrací <small>(<a href="?show_all={%if show_all %}no{%else%}yes{%endif%}">zobrazit {%if show_all %}pouze nové{%else%}vše{%endif%}</a>)</small></h2>
          {% if people|length > 0 %}
          <form action="#" method="POST" class="people_form">
          {%csrf_token%}
          <table class="table-list">
              <tr>
                  <th><input type="checkbox" id="check_all"/></th>
                  <th>Datum registrace</th>
                  <th>E-mail</th>
                  <th title="Byla odeslána registrační zpráva ?" colspan="2">Registrační zpráva ?</th>
                  <th>PSČ</th>
                  <th>Uživatel chce</th>
                  <th>Poznámka, vzkaz</th>
              </tr>
              {% for p in people %}
              <tr>
                  <td><input type="checkbox" name="r[]" value="{{p.id}}"/></td>
                  <td>{{p.createdStamp | date:'j.n.Y, H:i'}}</td>
                  <td>{{p.email}}</td>
                  <td>{%if p.emailToken %}{%if p.etStamp > tokenValidAfter %}platná{%else%}vypršela{%endif%}{%else%}ne{%endif%}</td>
                  <td>{{p.etStamp | date:'j.n, H:i'}}</td>
                  <td>{{p.postcode|default_if_none:'-'}}</td>
                  <td>{{p.get_kind_display}}</td>
                  <td>{{p.interestedIn|default_if_none:'-'}}</td>
              </tr>
              {% endfor %}
          </table>
          <button name="action" value="token" class="button">Zaslat registrační mail</button>
          <button name="action" value="delete" class="button" onClick="if( !confirm('Opravdu smazat ?') ){ return false;}">Smazat registraci</button>
          </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%}
