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

{% trans_default_domain 'form' %}

{% block body %}
    {{ knp_menu_render('actions_stats_demandes_pee') }}

    <form action="{{ path('admin_statistics_pee_demande') }}" class="search-admin" method="get">
        <fieldset>
            <legend>{{ 'form.teacher.label'|transchoice(1) }}</legend>
            <div class="search-fields">
                <p>
                    <label for="user_name">Nom et prénom</label>
                    <input id="user_name" type="text" value="{{ user_name }}" name="user_name"/>
                </p>
                <p>
                    <label for="user_academy">{{ 'form.academy.label'|trans }}</label>
                    <select id="user_academy" name="user_academy">
                        <option value="">- Toutes -</option>
                        {% for academy in u_academies %}
                            <option value="{{ academy }}"{% if academy == u_academy %} selected="selected"{% endif %}>
                                {{ academy }}
                            </option>
                        {% endfor %}
                    </select>
                </p>
            </div>
        </fieldset>
        <fieldset>
            <legend>Demande PEE</legend>
            <div class="search-fields">
                <p>
                    <label for="demande_state">{{ 'form.state.label'|trans }}</label>
                    <select id="demande_state" name="demande_state">
                        <option value="">- Toutes -</option>
                        {% for key, label in d_states %}
                            <option value="{{ key }}"{% if key == d_state %} selected="selected"{% endif %}>
                                {{ label }}
                            </option>
                        {% endfor %}
                    </select>
                </p>
            </div>
        </fieldset>
        <fieldset>
            <legend>Opération PEE</legend>
            <div class="search-fields">
                <p>
                    <label for="ope_datemin">Date de début</label>
                    <input id="ope_datemin" type="text" value="{{ ope_datemin ? ope_datemin|date('d/m/Y') : '' }}" class="date" name="ope_datemin"/>
                </p>
                <p>
                    <label for="ope_datemax">Date de fin</label>
                    <input id="ope_datemax" type="text" value="{{ ope_datemax ? ope_datemax|date('d/m/Y') : '' }}" class="date" name="ope_datemax"/>
                </p>
                {#
                <p>
                    <label for="ope_company">Entreprise et site</label>
                    <input id="ope_company" type="text" value="{{ ope_company }}" name="ope_company" />
                </p>
                #}
                <p>
                    <label for="ope_state">{{ 'form.state.label'|trans }}</label>
                    <select id="ope_state" name="ope_state">
                        <option value="">- Tous -</option>
                        {% for key, label in o_states %}
                            <option value="{{ key }}"{% if key == o_state %} selected="selected"{% endif %}>
                                {{ label }}
                            </option>
                        {% endfor %}
                    </select>
                </p>
            </div>
        </fieldset>
        <p>
            <input class="btn" type="submit" value="{{ 'action.search'|trans({}, 'action') }}"/>
        </p>
    </form>
    
    {% set title_additional = "" %}
    {% if pagination|length > 1 %}
        {% set title_additional = " (pour les " ~ pagination|length ~ " pages de résultats)" %}
    {% endif %}
    <table class="tableBo">
        <thead>
        <tr>
            <td colspan="2">{{ 'form.teacher.label'|transchoice(1) }}</td>
            <td colspan="3">Demande PEE</td>
            <td colspan="4">Opération PEE</td>
        </tr>
        <tr>
            <td>Nom et prénom</td>
            <td>{{ 'form.academy.label'|trans }}</td>
            <td>{{ 'form.date.label'|trans }}</td>
            <td>{{ 'form.state.label'|trans }}</td>
            <td>{{ 'form.externalRegistration.label'|trans }}</td>
            <td>Entreprise et site</td>
            <td>{{ 'form.date.visit.label'|trans }}</td>
            <td>{{ 'form.state.label'|trans }}</td>
            <td>{{ 'form.city.label'|trans }}</td>
        </tr>
        </thead>
        <tbody>
            {% if demandes|length > 0 %}
                {% for demande in demandes %}
                    <tr>
                        <td>{{ demande.cuser.lastname ~ ' ' ~ demande.cuser.firstname }}</td>
                        <td>{{ demande.cuser.academy }}</td>
                        <td class="center">{{ demande.created|date('d/m/Y') }}</td>
                        <td>{{ demande.state|transconst('AppBundle\\Enum\\DemandePEEState') }}</td>
                        <td>{{ demande.type|transconst('AppBundle\\Enum\\DemandePEEType')|raw }}</td>
                        <td>{{ demande.operationpee.company ~ ' ' ~ demande.operationpee.site }}</td>
                        <td class="center">{{ demande.operationpee.dateVisite|date('d/m/Y') }}</td>
                        <td>{{ demande.operationpee.state|transconst('AppBundle\\Enum\\OperationPEEState') }}</td>
                        <td>{{ demande.operationpee.city }}</td>
                    </tr>
                {% endfor %}
            {% else %}
                <tr><td colspan="9">Aucune demande ne correspond à votre recherche.</td></tr>
            {% endif %}
        </tbody>
    </table>

    {{ include('Admin/Paginator/pagination.html.twig', {pages:pagination|length}) }}
{% endblock %}