{% extends 'webapp/base.html' %}
{% load i18n %}
{% load static %}
{% load bootstrap_pagination %}
{% block style_block %}
    <link rel="stylesheet" href="{% static "select2/select2.css" %}">
    <link rel="stylesheet" href="{% static "select2-bootstrap-css/select2-bootstrap.css" %}">
{% endblock %}
{% block page_content %}
    <div class="row">
        <div class="col-md-12">
            <h3><i class="icon-warning-sign"></i> {{ page_title }}</h3>

            <div class="well well-sm">
                <form action="" method="POST">
                    <fieldset>
                        <legend>{% trans "Filters" %}</legend>
                        {% csrf_token %}
                        <div class="form-group">
                            <div class="row">
                                {{ filter_form.site }}
                                {{ filter_form.timestamp }}
                                <button class="btn btn-warning"><i
                                        class="icon-search"></i> {% trans "Filter" %}
                                </button>
                                <a class="btn btn-default form-reset">{% trans "Reset" %}</a>
                            </div>
                        </div>
                    </fieldset>
                </form>
            </div>
            {% if object_list %}
                <table class="table table-striped table-bordered" width="100%">
                    <thead>
                    <tr>
                        <th>{% trans "Site" %}</th>
                        <th>{% trans "Exhausted items" %}</th>
                        <th>{% trans "Reported at" %}</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for report in object_list %}
                        <tr>
                            <td>{{ report.site.name }}</td>
                            <td>{{ report.summary }}</td>
                            <td>{{ report.created|date:"H:i:s d/m/Y" }}</td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            {% else %}
                <p>{% trans "No alerts" %}</p>
            {% endif %}
        </div>
    </div>
    {% if is_paginated %}
        <div class="row">
            <div class="col-md-12">
                {% bootstrap_paginate page_obj range=10 %}
            </div>
        </div>
    {% endif %}
{% endblock %}
{% block tail_script %}
    <script src="{% static "stringjs/lib/string.js" %}"></script>
    <script src="{% static "select2/select2.js" %}"></script>
    <script src="{% static "js/filters.js" %}"></script>
{% endblock %}
