{% extends "membership/membership_detail.html" %}
{% load i18n %}

{% block title %} {% trans 'Ladder Score for' %} {{membership.username}} / {{ season }}{% endblock %}
{% block teaser %}<h1>{% trans 'Ladder Score for' %} {{membership.username}} / {{ season }}</h1>{% endblock %}

{% block score_list %}
<h2 class="grid_12">{% trans 'Hanchans that apply to the Ladder Score' %} - {{ season }}</h2>

 <table>
    <thead>
     <tr>
      <th rowspan="2">{% trans 'Date' %}</th>
      <th rowspan="2">{% trans 'Event' %}</th>
      <th rowspan="2">{% trans 'Start' %}</th>
      <th rowspan="2">{% trans 'Placement' %}</th>
      <th colspan="4">{% trans 'Players' %}</th>
      <th rowspan="2"></th>
     </tr>
     <tr>
      <th>1.</th>
      <th>2.</th>
      <th>3.</th>
      <th>4.</th>
     </tr>
     </thead>
    <tbody>
    {% for hanchan in hanchan_list %}
     <tr>
      <td>{{ hanchan.start|date:'SHORT_DATE_FORMAT' }}</td>
      <td><a href="{{ hanchan.get_absolute_url }}">{{ hanchan.event.name }}</a></td>
      <td>{{ hanchan.start|time:'TIME_FORMAT' }}</td>
      <td class="center">{{ hanchan.placement }}.</td>
      <td class="center">
        <a href="{% url 'player-ladder-score' hanchan.player1 %}?season={{season}}">{{hanchan.player1}}</a><br>
        {{hanchan.player1_game_score}}
      </td>
      <td class="center">
        <a href="{% url 'player-ladder-score' hanchan.player2 %}?season={{season}}">{{hanchan.player2}}</a><br>
        {{hanchan.player2_game_score}}
      </td>
      <td class="center">
        <a href="{% url 'player-ladder-score' hanchan.player3 %}?season={{season}}">{{hanchan.player3}}</a><br>
        {{hanchan.player3_game_score}}
      </td>
      <td class="center">
        <a href="{% url 'player-ladder-score' hanchan.player4 %}?season={{season}}">{{hanchan.player4}}</a><br>
        {{hanchan.player4_game_score}}
      </td>
      <td class="center">
      {% if perms.mahjong_ranking.delete_hanchan %}
       <a href="{% url 'delete-hanchan' hanchan.pk %}"><span class="fa fa-trash" title="{% trans 'Delete Hanchan' %}"></span></a>
      {% endif %}
      {% if perms.mahjong_ranking.change_hanchan %}
       <a href="{% url 'edit-hanchan' hanchan.pk %}"><span class="fa fa-pencil" title="{% trans 'Edit Hanchan' %}"></span></a>
      {% endif %}
      </td>
     </tr>
    {% endfor %}
    </tbody>
    <tfoot><tr><td colspan="9" class="right">
        <form action="{% url 'player-ladder-score' membership.username %}" method="get">
            <label for="season">{% trans 'Season' %}:</label>
            <select id="season" name="season" size="1">
            {% for season_link in season_list%}
                <option
                  {% ifequal season season_link %} selected="selected"{% endifequal %}
                  value="{{ season_link }}">{{ season_link }}</option>
            {% endfor %}
            </select>
            <button type="submit">{% trans 'Go' %}</button>
        </form>
    </td></tr></tfoot>
</table>
{% endblock %}

{% block buttonbar %}
<a href="?download=xlsx" class="button"><span class="fa fa-table"></span> Download</a>
{% endblock %}
