{% extends "discounts/base.html" %}
{% load discount_tags %}
{% load tagging_tags %}
{% load category_tags %}
{% load base_tags %}
{% load base_filters %}
{% load i18n %}

{% block title %}{{ block.super }} {{ discount.discount_code }}{% endblock %}

{% block extra_head %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}css/discounts.css">
{% endblock %}

{% block body %}
{% tags_for_object discount as tags %}

<div class="t">
    {% discount_nav request.user discount %}
    
    <div class="discounts-wrap">
        <a href="{{ discount.get_absolute_url }}"><h1>{{ discount.discount_code }}</h1></a>
		<div class="content">
            <table>
                <tr>
                    <td class="label"><b>{% trans "Discount Code" %}:</b></td>
                    <td>{{ discount.discount_code }}</td>
                </tr>
                <tr>
                    <td class="label"><b>{% trans "Discount Value" %}:</b></td>
                    <td>{{ discount.value }}</td>
                </tr>
                <tr>
                    <td class="label"><b>{% trans "Number of uses" %}:</b></td>
                    <td> {{ discount.num_of_uses }} out of {{ discount.cap }} max</td>
                </tr>
                <tr>
                    <td class="label"><b>{% trans "Duration" %}:</b></td>
                    <td>{{ discount.start_dt }} to {{ discount.end_dt }}</td>
                </tr>
                <tr>
                    <td class="label"><b>{% trans "Still Available" %}:</b></td>
                    <td>{% if discount.available %}{% trans 'Yes' %}{% else %}{% trans 'No' %}{% endif %}</td>
                </tr>
            </table>
		</div>

        {% if discount.discountuse_set.count > 0 %}
        <div class="usage-report">
            <h3>{% trans "Discount Usage Report" %}</h3>
            <table>
                <tr>
                    <th>{% trans "Username" %}</th>
                    <th>{% trans "Url" %}</th>
                    <th>{% trans "Invoice Url" %}</th>
                </tr>
                {% for reg in registrant_list %}
                <tr>
                    <td>
                    {% if reg.user %}
                        <a href="{% url profile reg.user.username %}">{{ reg.user.username }}</a>
                    {% elif reg.get_name %}
                        {{ reg.get_name }}
                    {% else %}
                        {% trans "Guest" %}
                    {% endif %}
                    </td>
                    <td><a href="{{ reg.get_absolute_url }}">{% trans "Registration URL" %}</a></td>
                    <td><a href="{{ reg.registration.invoice.get_absolute_url }}">{% trans "Invoice URL" %}</a></td>
                </tr>
                {% endfor %}
                {% for mem in membership_list %}
                <tr>
                    <td><a href="{% url profile mem.user.username %}">{{ mem.user.username }}</a></td>
                    <td><a href="{{ mem.get_absolute_url }}">{% trans "Membership URL" %}</a></td>
                    <td><a href="{{ mem.get_invoice.get_absolute_url }}">{% trans "Invoice URL" %}</a></td>
                </tr>
                {% endfor %}
            </table>
        </div>
        {% endif %}

    </div>
</div>
{% endblock %}
