{% extends "newbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}

{% block title %}Workouts{% endblock %}

{% block main %}

<script>
  function toggle(source) {
  checkboxes = document.querySelectorAll("input[name='plannedsessions']");
  for(var i=0, n=checkboxes.length;i<n;i++) {
       checkboxes[i].checked = source.checked;
  }
 }
</script>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
  $(function() {
  
  // Get the form fields and hidden div
  var modality = $("#id_modality");
  var hidden = $("#id_waterboattype");

  
  // Hide the fields.
  // Use JS to do this in case the user doesn't have JS 
  // enabled.

  hidden.hide();


  
  // Setup an event listener for when the state of the 
  // checkbox changes.
  modality.change(function() {
    // Check to see if the checkbox is checked.
    // If it is, show the fields and populate the input.
  // If not, hide the fields.
    var Value = modality.val();
    if (Value=='water') {
  // Show the hidden fields.
  hidden.show();
  } else {
  // Make sure that the hidden fields are indeed
  // hidden.
  hidden.hide();
      
      // You may also want to clear the value of the 
      // hidden fields here. Just in case somebody 
      // shows the fields, enters data to them and then 
      // unticks the checkbox.
      //
      // This would do the job:
      //
      // $("#hidden_field").val("");
    }
  });


  });



</script>

{% if team %}
<h1>Clone Multiple Sessions for {{ team.name }}</h1>
{% else %}
<h1>Clone Multiple Sessions for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
{% endif %}

<ul class="main-content">
  <li class="grid_2">
    <p>
      <form enctype="multipart/form-data" method="get">
        <table>
          {{ dateform.as_table }}
        </table>
	<table>
	  {{ teamform.as_table }}
	</table>
        <input type="Submit" value="Set Date Range">
      </form>
    </p>
  </li>
  <li class="grid_2">
    <p><a href="/rowers/sessions/?startdate={{ timeperiod|previousperiodstart }}&enddate={{ timeperiod|previousperiodend}}">Back by
        {{ timeperiod|timedeltadays }} days</a>
    </p>
    <p><a href="/rowers/sessions/?startdate={{ timeperiod|nextperiodstart }}&enddate={{ timeperiod|nextperiodend}}">Forward by
        {{ timeperiod|timedeltadays }} days</a>
    </p>
  </li>

  <li class="grid_4">
    <form enctype="multipart/form-data" method="post">
    

      {% if plannedsessions %}
      
      
      <table width="100%">
        <tr>
          <td>&nbsp;</td>
          <td>
            <input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
          </td>
        </tr>
        {{ form.as_table }}
      </table>
      
      {% else %}
      <p> No sessions found </p>
      {% endif %}
      <p>Select one or more planned sessions,
        select the date when the new cycle starts below
        and press submit</p>
      {% csrf_token %}
      <table>
        {{ dateshiftform.as_table }}
      </table>
      <p>
        <input name='workoutselectform' type="submit" value="Submit">
      </p>
      <p>You can use the date and search forms above to search through all
      sessions.</p>
    </form>
  </li>
</ul>


{% endblock %}

{% block sidebar %}
{% include 'menu_plan.html' %}
{% endblock %}
