{% extends 'dashboard/layout.html' %}
{% load compress %}
{% load static %}
{% load currency_filters %}
{% load sorting_tags %}
{% load i18n %}

{% block body_class %}{{ block.super }} refunds{% endblock %}

{% block title %}
  {% trans "Refunds" %} | {{ block.super }}
{% endblock title %}

{% block extrascripts %}
    {{ block.super }}

    {# Translation support for JavaScript strings. #}
    <script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>

    {% compress js %}
    <script src="{% static 'bower_components/js-cookie/src/js.cookie.js' %}" type="text/javascript"></script>
    <script src="{% static 'vendor-extensions/oscar/js/add_message.js' %}" type="text/javascript"></script>
    <script src="{% static 'vendor-extensions/oscar/js/refund_list.js' %}" type="text/javascript"></script>
    {% endcompress %}
{% endblock extrascripts %}

{% block breadcrumbs %}
<ul class="breadcrumb">
    <li>
        <a href="{% url 'dashboard:index' %}">{% trans "Dashboard" %}</a>
    </li>
    <li class="active">{% trans "Refunds" %}</li>
</ul>
{% endblock breadcrumbs %}

{% block header %}
<div class="page-header">
    <h1>{% trans "Refunds" %}</h1>
</div>
{% endblock header %}

{% block dashboard_content %}
  {% include "dashboard/partials/search_form.html" %}

{% if refunds %}
    {% include "dashboard/partials/refund_action_modal.html" %}
    {% block refund_list %}
        <table class="table table-striped table-bordered table-hover">
            <caption>
                <h3 class="pull-left"><i class="icon-repeat icon-large icon-flip-horizontal"></i></h3>
            </caption>

            <thead>
                <tr>
                    <th>{% anchor 'id' _("Refund ID") %}</th>
                    <th>{% trans "Total Credit" %}</th>
                    <th>{% trans "Number of Items" %}</th>
                    <th>{% trans "Status" %}</th>
                    <th>{% trans "Username" %}</th>
                    <th>{% trans "Email" %}</th>
                    <th>{% anchor 'created' _("Created") %}</th>
                    <th>{% trans "Actions" %}</th>
                </tr>
            </thead>
            <tbody>
            {% for refund in refunds %}
                <tr data-refund-id="{{ refund.id }}">
                    <td>
                        <a href="{% url 'dashboard:refunds:detail' pk=refund.id %}">{{ refund.id }}</a>
                    </td>
                    <td>{{ refund.total_credit_excl_tax|currency:refund.currency }}</td>
                    <td>{{ refund.num_items }}</td>
                    <td class="refund-status">{{ refund.status }}</td>
                    <td>
                        {% if refund.user %}
                            <a href="{% url 'dashboard:user-detail' pk=refund.user.id %}">{{ refund.user.username }}</a>
                        {% else %}
                            &lt;{% trans "Deleted" %}&gt;
                        {% endif %}
                    </td>
                    <td>
                      {% if refund.user %}
                        <a href="{% url 'dashboard:user-detail' pk=refund.user.id %}">{{ refund.user.email }}</a>
                      {% else %}
                        &lt;{% trans "Deleted" %}&gt;
                      {% endif %}
                    </td>
                    <td>{{ refund.created }}</td>
                    <td>
                        <a class="btn btn-info" href="{% url 'dashboard:refunds:detail' pk=refund.id %}">{% trans "View" %}</a>
                        {% include "dashboard/partials/refund_buttons.html" %}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    {% endblock refund_list %}

    {% include "partials/pagination.html" %}
{% else %}
    <table class="table table-striped table-bordered">
        <caption><i class="icon-repeat icon-large icon-flip-horizontal"></i>{{ queryset_description }}</caption>
        <tr>
            <td>{% trans "No refunds found." %}</td>
        </tr>
    </table>
{% endif %}
{% endblock dashboard_content %}
