{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %}
    {% extends 'themes/' + theme() + '/base.html' %}
{% else %}
    {% extends "base.html" %}
{% endif %} %}
{% from 'bootstrap/form.html' import render_form %}
{% set active_child = 'admin_reports' %}

{% block app_content %}
<div class="row">
    <div class="col">
        <h1>{{ _('Reports') }}</h1>
        <form method="get">
            <input type="search" name="search" value="{{ search }}">
            <input type="radio" name="local_remote" value="local" id="local_remote_local" {{ 'checked' if local_remote == 'local' }}><label for="local_remote_local"> Local</label>
            <input type="radio" name="local_remote" value="remote" id="local_remote_remote" {{ 'checked' if local_remote == 'remote' }}><label for="local_remote_remote"> Remote</label>
            <input type="submit" name="submit" value="Search" class="btn btn-primary">
        </form>
        <table class="table table-striped">
            <tr>
               <th>Local/Remote</th>
               <th>Reasons</th>
               <th>Description</th>
               <th>Type</th>
               <th>Created</th>
               <th>Actions</th>
            </tr>
            {% for report in reports.items %}
                <tr>
                    <td>{{ 'Local' if report.is_local() else 'Remote' }}</td>
                    <td>{{ report.reasons }}</td>
                    <td>{{ report.description }}</td>
                    <td>{{ report.type_text() }}</td>
                    <td>{{ moment(report.created_at).fromNow() }}</td>
                    <td>
                        {% if report.suspect_conversation_id %}
                            <a href="/chat/{{ report.suspect_conversation_id }}#message">View</a>
                        {% elif report.suspect_post_reply_id %}
                            <a href="/post/{{ report.suspect_post_id }}#comment_{{ report.suspect_post_reply_id }}">View</a>
                        {% elif report.suspect_post_id %}
                            <a href="/post/{{ report.suspect_post_id }}">View</a>
                        {% elif report.suspect_user_id %}
                            <a href="/user/{{ report.suspect_user_id }}">View</a>
                        {% elif report.suspect_community_id %}
                            <a href="/user/{{ report.suspect_community_id }}">View</a>
                        {% endif %}
                    </td>
                </tr>
            {% endfor %}
        </table>
        <nav aria-label="Pagination" class="mt-4" role="navigation">
                {% if prev_url %}
                    <a href="{{ prev_url }}" class="btn btn-primary">
                        <span aria-hidden="true">&larr;</span> {{ _('Previous page') }}
                    </a>
                {% endif %}
                {% if next_url %}
                    <a href="{{ next_url }}" class="btn btn-primary">
                        {{ _('Next page') }} <span aria-hidden="true">&rarr;</span>
                    </a>
                {% endif %}
        </nav>
    </div>
</div>
<hr />
<div class="row">
    <div class="col">
        {% include 'admin/_nav.html' %}
    </div>
</div>
<hr />
{% endblock %}