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

{% if step < 4 %}
{% form_theme form with ['Front/Form/fields.html.twig'] %}
{% endif %}
{% block init_javascripts %}
    <!-- Google Maps JavaScript API v3 key -->
    <script src="https://maps.googleapis.com/maps/api/js?key={{ google_maps_id }}"></script>
    <script>
        var geocoder = new google.maps.Geocoder();
        {% if constant('AppBundle\\Enum\\UserType::TEACHER') == app.user.type %}
        var fieldPrefix = '#prof_demande_itdlc_step{{ step }}_';
        {% else %}
        var fieldPrefix = '#inge_demande_itdlc_step{{ step }}_';
        {% endif %}
    </script>
{% endblock %}

{% block body %}
    <div>
        <nav class="nav nav-pills nav-justified nav-counter no-margin-bottom">
            {% if constant('AppBundle\\Enum\\UserType::TEACHER') == app.user.type %}
                <span class="nav-item nav-link {% if step == 1 %}active{% endif %}">{{ 'form.front.itdlc.fieldset.teacher.personalinfos.legend'|trans({}, 'form') }}</span>
                <span class="nav-item nav-link {% if step == 2 %}active{% endif %}">{{ 'form.front.itdlc.fieldset.teacher.establishment.legend'|trans({}, 'form') }}</span>
                <span class="nav-item nav-link {% if step == 3 %}active{% endif %}">{{ 'form.front.itdlc.fieldset.teacher.operation.legend'|trans({}, 'form') }}</span>
                <span class="nav-item nav-link {% if step == 4 %}active{% endif %}">{{ 'form.front.itdlc.fieldset.teacher.intervenant.legend'|trans({}, 'form') }}</span>
            {% else %}
                <span class="nav-item nav-link {% if step == 1 %}active{% endif %}">{{ 'form.front.itdlc.fieldset.engineer.company.legend'|trans({}, 'form') }}</span>
                <span class="nav-item nav-link {% if step == 2 %}active{% endif %}">{{ 'form.front.itdlc.fieldset.engineer.personalinfos.legend'|trans({}, 'form') }}</span>
                <span class="nav-item nav-link {% if step == 3 %}active{% endif %}">{{ 'form.front.itdlc.fieldset.engineer.operation.legend'|trans({}, 'form') }}</span>
            {% endif %}
        </nav>

        <div class="module module-inview-demande-itdlc-form bg-alabaster pa">
            {% if (constant('AppBundle\\Enum\\UserType::TEACHER') == app.user.type and step < 4) or constant('AppBundle\\Enum\\UserType::TEACHER') != app.user.type %}
                {{ form_start(form, {attr: {class: 'form-demande-itdlc'}}) }}
                {{ form_rest(form) }}
            {% endif %}

            {% if constant('AppBundle\\Enum\\UserType::TEACHER') == app.user.type and step < 4 %}
                {% if constant('AppBundle\\Enum\\UserType::TEACHER') == app.user.type and step == 3 %}
                    {% if mode != 'edit' %}
                        <div class="form-group">
                            <label for="prof_demande_itdlc_step3_availabilities">Intervenant :</label>

                            <p>{{ 'sentence.itdlc.form.intervenants_select'|trans({}, 'sentence') }}</p>
                        </div>
                    {% else %}

                    {% endif %}
                {% endif %}

            {% elseif constant('AppBundle\\Enum\\UserType::TEACHER') == app.user.type and step == 4 %}
                {{ include('Front/User/_component/listeIngenieursProches.html.twig', { 'othersUsers' : othersUsers, 'form' : form }) }}
            {% endif %}

            <div class="form-group clearfix">
                {% if step > 1 %}
                    {% set backStep = step - 1 %}

                    {% set attr = {} %}
                    {% if backStep > 1 %}
                        {% set attr = attr|merge({'step':backStep}) %}
                    {% endif %}
                    {% if mode == 'edit' %}
                        {% set attr = attr|merge({'ope':ope.id}) %}
                    {% endif %}

                    {% if constant('AppBundle\\Enum\\UserType::TEACHER') == app.user.type %}
                        {#<a href="{{ path('espace_perso_prof_itdlc_' ~ mode, attr) }}" class="btn btn-theme float-left">#}
                        <a href="{{ path('espace_perso') }}" class="btn btn-theme float-left">
                    {% else %}
                        <a href="{{ path('espace_perso_inge_itdlc', attr) }}" class="btn btn-theme float-left">
                    {% endif %}
                        {{ 'word.backPerso'|trans({}, 'word') }}
                    </a>
                {% endif %}

                {% if step < 3 %}
                    <button type="submit" class="btn btn-theme float-right">
                        {{ 'form.itdlc.next'|trans({}, 'form') }}
                    </button>
                {% endif %}
                {% if step == 3 %}
                    <button type="submit" class="btn btn-theme float-right">
                        {{ 'form.itdlc.save'|trans({}, 'form') }}
                    </button>
                {% endif %}
            </div>

        </div>

        {% if (constant('AppBundle\\Enum\\UserType::TEACHER') == app.user.type and step < 4) or constant('AppBundle\\Enum\\UserType::TEACHER') != app.user.type %}
            {{ form_end(form) }}
        {% endif %}
    </div>


{% endblock %}

{% block before_body %}
    <header class="page-header bg-tundora">
        <div class="container">
            <div class="item-content">
                <h1 class="color-theme">{{ ('sentence.itdlc.' ~ app.user.type ~ '.header.' ~ mode ~ '.title')|trans({}, 'sentence') }}</h1>

                <p>{{ ('sentence.itdlc.' ~ app.user.type ~ '.header.' ~ mode ~ '.introduction')|trans({}, 'sentence') }}</p>
            </div>
        </div>
    </header>
    {{ render(controller('AppBundle:Render:module', { position:'before_body' })) }}
{% endblock %}

{% block after_body %}

{% endblock %}
