{% extends 'EvpTicketAdminBundle::base.html.twig' %}

{% block body %}
    {% javascripts
        '@EvpReportingBundle/Resources/public/js/bootstrap-datepicker.js'
        '@EvpReportingBundle/Resources/public/js/genericReport.js'
    %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}

    {% stylesheets '@EvpReportingBundle/Resources/public/css/datepicker.css' filter='cssrewrite' %}
        <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}

    <div class="panel panel-default">
        <div class="panel-heading">{{ 'report.form_heading'|trans }}</div>
        <br>
        {{ form_start(form, { 'attr' : { 'class' : 'form-horizontal', 'role' : 'form', 'novalidate' : 'novalidate' } }) }}
        {% for row in form %}
            {% if row.vars.block_prefixes.1 != 'hidden' %}
                {% if
                    row.vars.block_prefixes.1 == 'choice'
                    and row.vars.expanded == true
                    and row.vars.multiple == true
                %}
                    <div class="form-group">
                        {{ form_label(row, row.vars.label, {'label_attr' : { 'class' : 'control-label col-xs-2' }}) }}
                        <div class="col-sm-offset-2 col-xs-9">
                            <div class="checkbox">
                                {{ form_widget(row) }}
                            </div>
                        </div>
                    </div>
                {% elseif row.vars.block_prefixes.1 == 'submit' %}
                    <div class="form-group">
                        {{ form_label(row, row.vars.label, {'label_attr' : { 'class' : 'control-label col-xs-2' }}) }}
                        <div class="col-sm-offset-2 col-xs-9">
                            {{ form_widget(row, {'attr' : { 'class' : 'form-control' }}) }}
                        </div>
                    </div>
                {% else %}
                    <div class="form-group {{ row.vars.attr['class'] is defined ? row.vars.attr['class'] : '' }}">
                        {{ form_label(row, row.vars.label, {'label_attr' : { 'class' : 'control-label col-xs-2' }}) }}
                        <div class="col-xs-9">
                            {{ form_widget(row, {'attr' : { 'class' : 'form-control' }}) }}
                        </div>
                    </div>
                {% endif %}
            {% endif %}
        {% endfor %}
        {{ form_end(form) }}
    </div>

    {% if report is not empty %}
        <ul class="nav nav-tabs">
            {% if report.totals is not empty %} <li class="active"><a href="#totals" data-toggle="tab">{{ 'report.totals'|trans }}</a></li> {% endif %}
            {% if report.data is not empty %} <li {{ report.totals is not empty ? '' : 'class="active"' }}><a href="#details" data-toggle="tab">{{ 'report.details'|trans }}</a></li> {% endif %}
        </ul>
        <div class="tab-content">
            {% if report.totals is not empty %}
                <div class="tab-pane fade in active" id="totals">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            {% for col in report.cols %}
                                <th>{{ col.name|trans }}</th>
                            {% endfor %}
                        </tr>
                        </thead>
                        <tbody>
                        {% for row in report.totalsRows %}
                            <tr>
                                <td>{{ row|trans }}</td>
                                {% for data in report.totals %}
                                    <td>{{ data[row] }}</td>
                                {% endfor %}
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                </div>
            {% endif %}
            {% if report.data is not empty %}
                <div class="tab-pane fade {{ report.totals is not empty ? '' : ' in active' }}" id="details">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                {% for col in report.cols %}
                                    <th>{{ col.name|trans }}</th>
                                {% endfor %}
                            </tr>
                        </thead>
                        <tbody>
                            {% for row in report.rows %}
                                <tr>
                                    <td>{{ row|trans }}</td>
                                    {% for data in report.data %}
                                        <td>{{ data[row] }}</td>
                                    {% endfor %}
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            {% endif %}
        </div>
    {% endif %}
{% endblock %}
