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

{% block title %}Change Rower {% endblock %}

{% block content %}
<div class="grid_12 alpha">
  <div class="grid_8 alpha">
    <h1>User Settings for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
    <p><a href="http://analytics.rowsandall.com/2017/11/02/rowsandall-settings-page-tutorial/">Need help? Click to read the tutorial</a></p>
  </div>
  <div class="grid_2 suffix_2 omega dropdown">
    <button class="grid_2 alpha button green small dropbtn">
      {{ rower.user.first_name }} {{ rower.user.last_name }}
    </button>
    <div class="dropdown-content">
      {% for rower in user|team_rowers %}
      <a class="button green small" href="/rowers/rower/edit/{{ rower.id }}">{{ rower.user.first_name }} {{ rower.user.last_name }}</a>
      {% endfor %}
    </div>
  </div>
  <div class="grid_6 alpha">
    <p>
      <h2>Heart Rate Zones</h2>
      <p>Set your heart rate zones with this form.</p>
      {% if form.errors %}
    <p style="color: red;">
      Please correct the error{{ form.errors|pluralize }} below.
    </p>
    {% endif %}
    
    <form enctype="multipart/form-data" action="" method="post">
      <table>
        {{ form.as_table }}
      </table>
      {% csrf_token %}
      <div class="grid_2 prefix_2 suffix_2">
        <input class="button green" type="submit" value="Save">
    </form>
    </p>
    </div>
  </div>
  <div class="grid_6 omega">
    <p>
      <h2>Power Zones</h2>
    <p>The power zones are defined relative to power as measured by the
      indoor rower.</p>
      <form enctype="multipart/form-data" action="" method="post">
        {% if powerzonesform.errors %}
        <p style="color: red;">
          Please correct the error{{ powerzonesform.errors|pluralize }} below.
          {{ powerzonesform.non_field_errors }}
        
        </p>
        {% endif %}
        <table>
          <thead>
            <tr>
              <th>ID</th><th>Zone Name</th><th>Lower Boundary (Watt)</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>1</td><td>{{ powerzonesform.ut3name }}</td>
              <td></td>
            </tr>
            <tr>
              <td>2</td><td>{{ powerzonesform.ut2name }}</td>
              <td>{{ powerzonesform.pw_ut2 }}</td>
            </tr>
            <tr>
              <td>3</td><td>{{ powerzonesform.ut1name }}</td>
              <td>{{ powerzonesform.pw_ut1 }}</td>
            </tr>
            <tr>
              <td>4</td><td>{{ powerzonesform.atname }}</td>
              <td>{{ powerzonesform.pw_at }}</td>
            </tr>
            <tr>
              <td>5</td><td>{{ powerzonesform.trname }}</td>
              <td>{{ powerzonesform.pw_tr }}</td>
            </tr>
            <tr>
              <td>6</td><td>{{ powerzonesform.anname }}</td>
              <td>{{ powerzonesform.pw_an }}</td>
            </tr>
          </tbody>
        </table>
        {% csrf_token %}
        <div class="grid_2 prefix_2 suffix_2">
          <input class="button green" type="submit" value="Save">
        </div>
      </form>
    </p>
  </div>
</div>
<div class="grid_12 alpha">
  <div class="grid_6 alpha">
    <p>
      <h2>Account Information</h2>
      <div class="grid_6 alpha">
        <div class="grid_2 suffix_4 alpha">
          <p>
            {% if rower.user == user %}
            <a class="button gray small" href="/password_change/">Password Change</a>
            {% else %}
            &nbsp;
            {% endif %}
            </p>
        </div>
      </div>
    </p>
      {% if userform.errors %}
    <p style="color: red;">
      Please correct the error{{ form.errors|pluralize }} below.
    </p>
    {% endif %}
    {% if accountform.errors %}
    <p style="color: red;">
      
    </p>
    {% endif %}
    <form enctype="multipart/form-data" action="" method="post">
      <table>
        {{ userform.as_table }}
        {{ accountform.as_table }}
        <tr>
          <th>Plan</th><td>{{ rower.rowerplan }}</td>
        </tr>
        <tr>
          <th>Plan Expiry</th><td>{{ rower.planexpires }}</td>
        </tr>
      </table>
      {% csrf_token %}
      <div class="grid_2 alpha">
        {% if rower.rowerplan == 'basic' and rower.user == user %}
        <a class="button blue" href="/rowers/promembership">Upgrade</a>
        {% else %}
        &nbsp;
        {% endif %}
      </div>
      <div class="grid_2 suffix_2 omega">
        <input class="button green" type="submit" value="Save">
    </form>
    </div>
    

    </p>
  </div>
  <div class="grid_6 omega">
    <p>
      <h2>Functional Threshold Power and OTW Slack</h2>
    <p>Use this form to quickly change your zones based on the power of a
      recent
      full out 60 minutes effort on the ergometer.
      It will update all zones defined above.</p>
    <p>The OTW Power Slack is the percentage drop of your On-the-water
      rowing power
      vs the erg power. Typical values are around 15%. This will lower
      the power zones for your OTW workouts.</p> 
    <form enctype="multipart/form-data" action="" method="post">
      <table>
	{{ powerform.as_table }}
      </table>
      {% csrf_token %}
      <div class="grid_2 prefix_2 suffix_2">
        <input class="button green" type="submit" value="Save">
    </form>
    </div>
  </div>
</div>
{% if rower.user == user %}
<div class="grid_12 alpha">
  <div class="grid_6 alpha">
    <p>
      <h2>Teams</h2>
      <div class="grid_2 suffix_4 alpha">
        <a class="button gray small" href="/rowers/me/teams">Manage Teams</a>
      </div>
    </p>
  </div>

  <div class="grid_6 omega">
    <p>
      <h2>Favorite Charts</h2>
      <div class="grid_2 suffix_4 alpha">
        <a class="button gray small" href="/rowers/me/favoritecharts">Manage Favorite Charts</a>
      </div>
    </p>
  </div>
</div>
<div class="grid_12 alpha">
  <div class="grid_6 alpha">
    <p>
      <h2>Export Settings</h2>
      <div class="grid_2 suffix_4 alpha">
        <a class="button gray small" href="/rowers/me/exportsettings">Manage Export Settings</a>
      </div>
    </p>
  </div>
  <div class="grid_6 omega">
    <p>
      <h2>Configure Workflow Layout</h2>
      <div class="grid_2 suffix_4 alpha">
        <a class="button gray small" href="/rowers/me/workflowconfig2">Manage Workflow Layout</a>
      </div>
    </p>
  </div>
  

</div>

<div class="grid_12 alpha">
  <div class="grid_6 alpha">
    <p>
      <h2>GDPR - Data Protection</h2>
      <div class="grid_2 suffix_4 alpha">
        <p>
          <a class="button gray small" href="/rowers/exportallworkouts">Download your data</a>
          </p>
        </div>
      <div class="grid_2 suffix_4 alpha">
        <p>
          <a class="button gray small" href="/rowers/me/deactivate">Deactivate Account</a>
        </p>
        </div>
      <div class="grid_2 suffix_4 alpha">
        <p>
          <a class="button red small" href="/rowers/me/delete">Delete Account</a>
        </p>
        </div>
    </p>
  </div>
  <div class="grid_6 omega">
    {% if grants %}
    <p>
      <h2>Applications</h2>
      <table width="100%">
        <thead>
          <tr>
            <th>Application</th>
            <th>Scope</th>
            <th>Revoke</th>
          </tr>
        </thead>
        <tbody>
          {% for grant in grants %}
          <tr>
            <td>{{ grant.application }}</td>
            <td>{{ grant.scope }}</td>
            <td>
              <a class="button red small" href="/rowers/me/revokeapp/{{ grant.application.id }}">Revoke</a>
          </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </p>
    {% else %}
    <p>&nbsp;</p>
    {% endif %}
  </div>
</div>
{% endif %}



{% endblock %}
