<!-- BEGIN [% component.name %] -->
    [% # PROCESS site/js/jquery.tt # already loaded in html_wrapper %]
    [% # PROCESS dumper.tt dump = restricted %]

    <script type="text/javascript" src="/js/jquery.dateentry.min.js"></script>
	<script type="text/javascript" src="/js/jquery.mousewheel.js"></script>
	<script type="text/javascript" src="/js/form2queryparam.js"></script>
	<script type="text/javascript" src="/js/changeField.js"></script>

    <script type="text/javascript">
    [% IF func_name == 'get_page' %]
      function get_page(constraint_type, fields) {
        window.location = '[% target_url %]?[% query_args _ ';' IF query_args %]'
        + form_to_queryparam('constraint_form', fields,
        { constraint_type: constraint_type });
      }
    [% ELSIF func_name == 'get_chart' %]
      function get_chart (constraint_type, fields) {
        document.getElementById('chart').src
            = '[% target_url %]?'
            + form_to_queryparam('constraint_form', fields,
            { constraint_type: constraint_type });
      }
    [% END %]
    </script>

  <div class="indent">
    <p class="title">Modify constraints:
        [% div_name = 'constraints'; INCLUDE site/snippets/toggleview.tt %]</p>
    <div id="constraints" class="itemhidden">
    <form id="constraint_form">
      <ul>
	  [% UNLESS restricted.no_constraint %]
        <li>no constraint:
          <input type="button" name="all_data" id="all_data"  value="Go"
            onclick="[% func_name %]('all_data',['all_data']); return false" />
        </li>
	  [% END %]

	  [% UNLESS restricted.this_year %]
        <li>this year only:
          <input type="button" name="current_year" id="current_year" value="Go"
            onclick="[% func_name %]('this_year',['current_year']); return false" />
        </li>
	  [% END %]

      [% IF start_date; # don't load unless needed
		  USE date(format = '%Y'); # just need year
		  last_year = (date.format - 1);
		  start_year = start_date.strftime('%Y');

		IF start_year <= last_year %]
		  [% UNLESS restricted.previous_year %]
          <li>a previous year:
            <select name="year_field_select" id="year_field_select"
                onchange="change_year_field()">
              <option value=""></option>
              [% years = [ start_year .. last_year ];
                FOREACH yr IN years.sort.reverse %]
                <option value="[% yr %]">[% yr %]</option>
              [% END %]
            </select>

            <input type="submit" onclick="[% func_name %]('year',['year']);
                return false" value="Go">
            [% site.html.reset %]

            <input type="text" style="color: #fff; border: none;" name="year"
              id="year" size="4" />
          </li>
		  [% END %]

		  [% UNLESS restricted.all_since %]
          <li>all since year:
            <select name="year_since_field_select" id="year_since_field_select"
                onchange="change_year_since_field()">
              <option value=""></option>
              [% years = [ start_year .. last_year ];
                FOREACH yr IN years.sort.reverse %]
                <option value="[% yr %]">[% yr %]</option>
              [% END %]
            </select>

            <input type="submit" onclick="[% func_name %]('year_since',['year']);
                return false" value="Go">
            [% site.html.reset %]
          </li>
		  [% END %]
		[% END %]
	  [% END %]

	  [% UNLESS restricted.days %]
        <li>previous # days:
          <input type="text" name="days" id="days" size="4" />
          <input type="submit" onclick="[% func_name %]('days',['days']);
              return false" value="Go">
          [% site.html.reset %]
        </li>
	  [% END %]

	  [% UNLESS restricted.date_range %]
        <li>date range:
          <input type="text" name="date_from" id="date_from" size="8" /> to
          <input type="text" name="date_to" id="date_to" size="8" />
          <input type="submit" onclick="[% func_name %]('date_range',['date_from','date_to']);
            return false" value="Go">
          [% site.html.reset %]
        </li>
	  [% END %]
      </ul>
    </form>
    </div>
  </div>
<!-- END [% component.name %] -->
