{% extends "base.html" %}
{% load i18n %}

{% block reward__menu %}cur{% endblock %}
{% block content %}
<table class="g g_middle g_max g_padding-b_XL">
    <tr>
        <td class="c">
            <div class="title">
                <h2>{% trans "Награды" %}</h2>
            </div>
        </td>
        <td class="c c_right">
            <form method="GET" action="" class="form_reward">
                <span class="radiogroup form_reward_filter">
                    {% for code, status_description in form.status.field.choices %}
                    <button class="button button_size_M button_type_normal button_mode_radio {% if status == code %}button_state_check {% endif %}">
                        <span class="button__label">{{ status_description }}</span>
                        <input type="radio" name="status" value="{{ code }}" {% if status == code %}checked{% endif %}>
                    </button>
                    {% endfor %}
                </span>
            </form>
        </td>
    </tr>
</table>

<table class="b-t t-sort t-sort_awards">
    <thead>
        {% if messages %}
            <tr>
                {% for message in messages %}
                    <p class="{{ message.tags }}">{{ message }}</p>
                {% endfor %}
            </tr>
        {% endif %}
        <tr>
            <th><span class="sort">{% trans "ID награды" %}<i></i></span></th>
            <th><span class="sort">{% trans "Пользователь" %}<i></i></span></th>
            <th><span class="sort">{% trans "Тикет в Сансаре" %}<i></i></span></th>
            <th><span class="sort">{% trans "Тип" %}<i></i></span></th>
            <th><span class="sort">{% trans "Время создания награды" %}<i></i></span></th>
            <th><span class="sort">{% trans "Продукт" %}<i></i></span></th>
            <th class="b-t__right"><span class="sort">{% trans "Выплата" %}<i></i></span></th>
            <th class="b-t__right"><span class="sort">{% trans "Баллы" %}<i></i></span></th>
            <th><span class="sort">{% trans "Статус" %}<i></i></span></th>
            <th><span class="sort">{% trans "Выгрузка в YT" %}<i></i></span></th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        {% for reward, reporter_login in rewards %}
        <tr {% if reward.status == 2 %}class="b-t__gray"{% endif %}>
            <td class="b-t__mw250"><a href="{% url 'reward-edit' reward_id=reward.id %}" class="link">{{ reward.id }}</a></td>
            <td><span class="user-login">
                {% if reward.reporter %}<a href="{% url 'user_profile:edit_payment' pk=reward.reporter.id %}">{%endif%}
                    {{ reporter_login }}
                {% if reward.reporter %}</a>{% endif %}
            </span></td>
            <td class="b-t__mw250"><a href="{{ reward.startrek_ticket_url }}" class="link">{{ reward.get_full_ticket_info }}</a></td>
            <td>{{ reward.vulnerability_type.name }}</td>
            <td>{{ reward.payment_created|date:"Y-m-d H:i:s" }}</td>
            <td>{{ reward.product.title }}</td>
            <td class="b-t__right">{{ reward.humanized_payment }}</td>
            <td class="b-t__right">{{ reward.points }}</td>
            <td>{{ reward.get_status_display }}</td>
            <td>{{ reward.balance_contract_created|date:"Y-m-d" }}</td>
            <td class="b-t__ctrl">
                <a href="{% url 'reward-edit' reward_id=reward.id %}" class="button button_size_S button_type_clear button_icon-only_yes button_fontello button_hover">
                    <span class="icon-edit"></span>
                    <span class="button__label"></span>
                </a>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>

{% include "include/pagination.html" %}

<form method="get" action="{% url 'reward:add' %}">
    <button type="submit" class="button button_type_action button_size_L create_reward_button">
        <span class="button__ground"></span>
        <span class="button__ground"></span>
        <span class="button__label">
            {% trans "Create reward" %}
        </span>
    </button>
</form>

{% endblock %}
