{% extends "mahjong_ranking/page.html" %}
{% load i18n comments%}


{% block teaser %}
<h1>Mahjong Ladder - {{ season }}</h1>
<div id="teaser_text">
<ul class="info">    
<li><span class="fa fa-calendar-o"></span> {% trans 'Start' %}: {{ season_start|date:'SHORT_DATE_FORMAT' }}</li>
<li><span class="fa fa-calendar-o"></span> {% trans 'End' %}: {{ season_end|date:'SHORT_DATE_FORMAT' }}</li>
<li><span class="fa fa-users"></span> {% trans 'Participants' %}: {{ seasonranking_list.count }}</li>
</ul>
</div>
{% endblock %}

{% block content %}
    <table>
        <thead>
        <tr>
            <th rowspan="2">{% trans "Rank" %}</th>
            <th rowspan="2">{% trans "Avatar" %}</th>
            <th rowspan="2">{% trans "Nickname" %}</th>
            <th rowspan="2">{% trans "Name" %}</th>
            <th colspan="2">{% trans 'Average' %}</th>
            <th colspan="3">Hanchans</th>
        </tr>
        <tr>
            <th>{% trans 'Placement' %}</th>
            <th>{% trans "Score" %}</th>
            <th>{% trans "count" %}</th>
            <th>{% trans "good" %}</th>
            <th>{% trans "won" %}</th>
        </tr>
        </thead>
        {% for player in seasonranking_list %}
        <tr>
            <td class="center">{{player.placement}}.</td>
            <td><a href="{{ player.get_absolute_url }}?season={{season}}"><img src="{% if player.user.avatar %}{{player.user.thumbnail.url}}{% else %}{{STATIC_URL}}img/unknown_thumbnail.png{% endif %}" class="avatar" alt=""/></a></td>
            <td><a href="{{ player.get_absolute_url }}?season={{season}}">{{player.user}}</a></td>
            <td>{% if user.is_authenticated %}{{player.user.last_name}} {{player.user.first_name}}{% else %}---{% endif %}</td>
            <td class="center">{{player.avg_placement|floatformat:2 }}</td>
            <td class="right">{{player.avg_score|floatformat:0 }}</td>
            <td class="right">{{player.hanchan_count}}</td>
            <td class="right">{{player.good_hanchans}}</td>
            <td class="right">{{player.won_hanchans}}</td>
        </tr>
        {% empty %}
        <tr>
            <td colspan="9">Leider hat es noch niemand in das Ranking geschafft.
                Ein Spieler wird erst ins Ranking genommen wenn er 5 Hanchans absolviert hat.
            </td>
        </tr>
        {% endfor %}
    </table>
{% endblock %}

{% block redbox %}
<h2>{% trans 'Latest Hanchans' %}</h2>
<ul class="fa-ul">
    {% for hanchan in latest_hanchan_list %}
    <li><span class="fa-li fa fa-table"></span> <a href="{% url 'event-hanchan-list' hanchan.event.pk %}">{{hanchan.event.name}}</a>
        {{hanchan.start|time:'H:i'}}:
        <small>{{hanchan.player_names}}</small>
    </li>
    {% endfor %}
</ul>
<h3>{% trans 'Latest Events' %}</h3>
<ul class="fa-ul">
    {% for event in latest_event_list %}
    <li><span class="fa-li fa fa-calendar-o"></span> <a href="{% url 'event-hanchan-list' event.pk %}">{{event.name}}</a></li>
    {% endfor %}
</ul>
<h3>{% trans 'Ladder Archive' %}</h3>
<form name="season_select">
    <label for="season">{% trans 'Season' %}</label>
        <select id="season" name="season" size="1" onChange="window.location.href = document.season_select.season.options[document.season_select.season.selectedIndex].value;">
        {% for season_link in season_list%}
        <option value="{% url 'mahjong-ladder' season_link %}" {% ifequal season season_link %}selected="selected"{% endifequal %}>{{ season_link }}</option>
        {% endfor %}
        </select>
</form>
{% endblock %}
