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

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

{% block title %}
    {% trans "Product alerts" %} | {{ block.super }}
{% endblock %}

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

{% block headertext %}
    {% trans "Product alerts" %}
{% endblock %}

{% block dashboard_content %}
    <div class="table-header">
        <h3><i class="icon-search icon-large"></i> {% trans "Search product alerts" %}</h3>
    </div>
    <div class="well">
        <form action="." method="get" class="form-inline">
            {% include "partials/form_fields_inline.html" with form=form %}
            <button type="submit" class="btn btn-primary">{% trans "Search" %}</button>
            {% trans "or" %}
            <a href="{% url 'dashboard:user-alert-list' %}" class="btn">{% trans "reset" %}</a>
        </form>
    </div>

    <div class="table-header">
        <h2><i class="icon-group icon-large"></i>{{ queryset_description }}</h2>
    </div>

    {% if alerts %}
        <table class="table table-striped table-bordered table-hover">
            <tr>
                <th>{% trans "Product" %}</th>
                <th>{% trans "User" %}</th>
                <th>{% trans "Status" %}</th>
                <th>{% trans "Date created" %}</th>
                <th>{% trans "Date alert sent" %}</th>
                <th></th>
            </tr>
            {% for alert in alerts %}
                <tr>
                    <td>
                        <a href="{{ alert.product.get_absolute_url }}">{{ alert.product }}</a>
                    </td>
                    <td>
                        {% if alert.user %}
                            <a href="{% url 'dashboard:user-detail' pk=alert.user.id %}">{{ alert.user.email }}</a>
                        {% else %}
                            {{ alert.email }} {% trans "(Anonymous)" %}
                        {% endif %}
                    </td>
                    <td>
                        {{ alert.status }}
                    </td>
                    <td>{{ alert.date_created }}</td>
                    <td>{{ alert.date_closed|default:"-" }}</td>
                    <td>
                        <div class="btn-toolbar">
                            <div class="btn-group">
                                <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                                    {% trans "Actions" %}
                                    <span class="caret"></span>
                                </a>
                                <ul class="dropdown-menu pull-right">
                                    <li><a href="{% url 'dashboard:user-alert-update' pk=alert.id %}">{% trans "Edit" %}</a></li>
                                    <li><a href="{% url 'dashboard:user-alert-delete' pk=alert.id %}">{% trans "Delete" %}</a></li>
                                </ul>
                            </div>
                        </div>


                    </td>
                </tr>
            {% endfor %}
        </table>

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

    {% else %}
        <table class="table table-striped table-bordered table-hover">
            <tr><td>{% trans "No alerts found." %}</td></tr>
        </table>
    {% endif %}

{% endblock dashboard_content %}
