{% extends "::base.html.twig" %}

{% block title %}Administration{% endblock %}

{% block navigation %}{% include 'SsoBackendBundle:Layout:navigation.html.twig' %}{% endblock %}

{% block body %}
    <div class="row">
        <div class="col-xs-12">
            <div class="tabs">
                <div class="tab-content">
                    <div id="activity" class="tab-pane active">
                        {% if app.debug %}
                            <a class="btn btn-xs btn-danger pull-right" href="{{ path('admin_activitylog_delete') }}"
                               onclick="return confirm('Delete activity log?');">Delete log</a>
                        {% endif %}
                        <h4 class="mb-xlg">Activity Log</h4>
                        <div class="timeline timeline-simple mt-xlg mb-md">
                            <div class="tm-body">
                                {% set currentMonth = '' %}
                                {% for action in activityLogs %}
                                    {% if currentMonth != action.createdAt|date('F Y') %}
                                        {% set currentMonth = action.createdAt|date('F Y') %}
                                        <div class="tm-title">
                                            <h3 class="h5 text-uppercase">{{ currentMonth }}</h3>
                                        </div>
                                    {% endif %}
                                    <ol class="tm-items">
                                        <li>
                                            <div class="tm-box">
                                                <p class="text-muted mb-none">{{ action.createdAt|date('Y-m-d H:i:s') }}</p>
                                                <p>
                                                    Username:
                                                    <span class="text-primary">{{ action.user.username }}</span><br/>
                                                    Name:
                                                    <span class="text-primary">{{ action.user.firstname }} {{ action.user.lastname }}</span><br/>
                                                    Email:
                                                    <span class="text-primary">{{ action.user.useremail }}</span><br/><br/>
                                                    Action Type:
                                                    <span class="text-primary">{{ action.type }}</span><br/>
                                                    Controller:
                                                    <span class="text-primary">{{ action.controller }}</span><br/>
                                                    Action:
                                                    <span class="text-primary">{{ action.action }}</span><br/>
                                                    {% if action.stats %}
                                                        Stats:
                                                        <br>
                                                        {% for name, value in action.stats %}
                                                            {% if value is not iterable %}
                                                                {{ name }}: {{ value }}<br />
                                                            {% endif %}
                                                        {% endfor %}
                                                        <br />
                                                    {% endif %}
                                                    {% if action.request %}
                                                        Request:
                                                        <span class="text-primary">{{ action.request|nl2br }}</span>
                                                        <br/>
                                                    {% endif %}
                                                    {% if action.response %}
                                                        Response:
                                                        <span class="text-primary">{{ action.response|nl2br }}</span>
                                                        <br/>
                                                    {% endif %}
                                                </p>
                                            </div>
                                        </li>
                                    </ol>
                                {% endfor %}
                            </div>
                        </div>
                        {{ knp_pagination_render(activityLogs) }}
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
