{% extends 'reporting/layout.html.twig' %}

{% block report_title %}{{ report_title|trans({}, 'reporting') }}{% endblock %}

{% block report %}

    {% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
        {% import "macros/widgets.html.twig" as widgets %}
        {% block box_before %}
            {{ form_start(form, {'attr': {'class': 'form-inline', 'id': 'user-filter-form'}}) }}
        {% endblock %}
        {% block box_after %}
            {{ form_end(form) }}
        {% endblock %}
        {% block box_title %}
            {% if form.user is defined %}
                {{ form_row(form.user, {'label': false}) }}
            {% else %}
                {{ widgets.username(user) }}
            {% endif %}
            {{ form_widget(form.date) }}
            <div class="btn-group"{% if form.sumType.vars.choices|length <= 1 %} style="display: none"{% endif %}>
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <i class="{{ 'display'|icon }}"></i> <span class="caret"></span>
                </button>
                <ul class="dropdown-menu checkbox-menu">
                    <li>
                        {{ form_widget(form.sumType) }}
                    </li>
                </ul>
            </div>
        {% endblock %}
        {% block box_body_class %}{{ box_id }} table-responsive no-padding{% endblock %}
        {% block box_body %}
            {% embed 'reporting/report_by_user_data.html.twig' %}
                {% block period_name %}
                    <th class="text-center text-nowrap">
                        <a href="{{ path('report_user_month', {'date': column|report_date, 'sumType': dataType, 'user': user.id}) }}">
                            {{ column|month_name }}<br>
                            {{ column|date_format('Y') }}
                        </a>
                    </th>
                {% endblock %}
                {% block column_classes_project %}{% endblock %}
                {% block column_classes_activity %}{% endblock %}
                {% block column_classes_total %}{% endblock %}
            {% endembed %}
        {% endblock %}
    {% endembed %}

{% endblock %}

{% block javascripts %}
    {{ parent() }}
    <script type="text/javascript">
        document.addEventListener('kimai.initialized', function() {
            jQuery('#user-filter-form').on('change', function(ev) {
                jQuery(this).submit();
            });
        });
    </script>
{% endblock %}
