{% extends "base.html" %}

{% block title %}Submit Registration{% endblock %}

{% block addscripts %}
  <script type="text/javascript">

  $(document).ready(function(){
    if (!$('#id_accommodation_required').is(':checked')) {
      $('#id_accommodation_days').attr('disabled', 'disabled');
      $('#id_sex').attr('disabled', 'disabled');
    }
    $('#id_accommodation_required').change(function() {
      if (!$('#id_accommodation_required').is(':checked')) {
        $('#id_accommodation_days').attr('disabled', 'disabled');
        $('#id_sex').attr('disabled', 'disabled');
      } else {
        $('#id_accommodation_days').removeAttr('disabled');
        $('#id_sex').removeAttr('disabled');
      }
    });
  });


  </script>
{% endblock addscripts %}

{% block content %}
    {% block formheading %}
      <h1>Submit Registration</h1>
    {% endblock formheading %}

    {% block overreg %}
    {% if over_reg %}
    <div class="notice">
      We have already reached the total number of registrations for the
      conference. If you would like to be put on a waiting list in the event that
      someone can't make it to the conference, please register below and we
      will be in contact if a registration spot comes available. <strong>N.B. Do not
      pay the admission fee.</strong>
    </div>
    {% endif %}
    {% endblock overreg %}

    <form action=
    {% block url_select_login %}
      "{% url scipycon_submit_registration params.scope %}"
    {% endblock url_select_login %}
        method="post">
    {% if not user.is_authenticated %}
      <fieldset>
        <legend>Have you already registered for the conference?</legend>
        <table class="scipycon-default">
          {{ login_form }}
        </table>

        <input type="hidden" name="action" value="login" />

        <button class="button left" type="submit">Login</button>
      </fieldset>

    </form>
    {% endif %}

    <p></p>

    {% if not user.is_authenticated %}
    <br />
    <form action=
    {% block url_select_reg %}
      "{% url scipycon_submit_registration params.scope %}"
    {% endblock url_select_reg %}
        enctype="multipart/form-data" method="post">
      <fieldset>
        <legend>Registrant Details</legend>
        <table class="scipycon-default required">
          {{ registrant_form }}
        </table>

        <input type="hidden" name="action" value="register" />
      </fieldset>
    {% endif %}
    <br />

    {% if registration_form.errors %}
      <div class="errors">Please correct the errors below</div>
    {% endif %}

      <fieldset>
        <legend>Details</legend>
        <strong>SciPy.in has a registration fee and nominal charges for
        accommodation of out station students and teachers. Please
        make sure you read the details before you register.
        <a href="{% url scipycon_fees params.scope %}">Click here</a>
        for details.</strong>
        <table class="scipycon-default required">
          {% for field in registration_form.personal_fields %}
            <tr class="{% cycle odd,even %}">
              <th>{{ field.label_tag }}</th>
              <td>{{ field.errors }}{{ field }}<br />{{ field.help_text }}</td>
            </tr>
          {% endfor %}

          {% for field in registration_form.other_fields %}
            <tr class="{% cycle odd,even %}">
              <th>{{ field.label_tag }}</th>
              <td>{{ field.errors }}{{ field }}<br />{{ field.help_text }}</td>
            </tr>
          {% endfor %}
        </table>
      </fieldset>
      <br />

      <fieldset>
        <legend>Occupation</legend>
        <table class="scipycon-default required">
          {% for field in registration_form.occupation_fields %}
            <tr class="{% cycle odd,even %}">
              <th>{{ field.label_tag }}</th>
              <td>
                {{ field.errors }}{{ field }}<br />{{ field.help_text }}
              </td>
            </tr>
          {% endfor %}
        </table>
      </fieldset>

      <fieldset>
        <legend>Demographics</legend>
        <table class="scipycon-default">
          {% for field in registration_form.demographic_fields %}
            <tr class="{% cycle odd,even %}">
              <th>{{ field.label_tag }}</th>
              <td>
                {{ field.errors }}{{ field }}<br />{{ field.help_text }}
              </td>
            </tr>
          {% endfor %}
        </table>
      </fieldset>

      <fieldset>
        <legend>Accommodation</legend>
        <table class="scipycon-default">
          {{ acco_form }}
        </table>
      </fieldset>

      <fieldset>
        <legend>Others</legend>
        <table class="scipycon-default">
          {{ wifi_form }}
        </table>

        <button class="button left" type="submit">Submit Registration</button>
      </fieldset>

      {% block formextras %}{% endblock formextras %}
    </form>
    {% if message %}
    <script type="text/javascript">
        $.jGrowl("{{ message }}");
    </script>
    {% endif %}
{% endblock content %}
