{% extends 'Admin/layout.html.twig' %}
{%- import 'Admin/Form/macros.html.twig' as m -%}

{% trans_default_domain 'form' %}

{% block javascripts %}
    <script>
        //<![CDATA[
        $(function() {
            $('.fancybox').fancybox({
                'autoSize':true,
                'width': 900,
                'height': 500,
                'padding': 0,
                'afterClose' : function() {
                    window.location.reload();
                }
            });
        });
        //]]>
    </script>
{% endblock %}

{% block body %}
    <header>
        <ul class="btns">
            <li class="btns-back">
                {{ m.step_back() }}
            </li>
            <li>
                <button class="btn btn-save" form="form-demandeitdlcprof">
                    {{ 'action.save'|trans({}, 'action') }}
                </button>
            </li>
        </ul>

        <h1>Modifier la demande ITDLC</h1>
    </header>

    
    <h3>État de la demande</h3>

    <div class="blockTop">
        <h3>Informations demande</h3>
        <strong>Statut du demandeur&nbsp;:</strong> {{ ('word.type.user.' ~ ope.prof.type ~ '.label')|trans({}, 'word') }}<br/>
        <strong>Date du dépôt&nbsp;:</strong> {{ ope.created|date('d/m/Y') }}<br/>
        <strong>Demandeur&nbsp;:</strong> {{ ope.prof.lastname }}, {{ ope.prof.firstname }}<br/>
            {{ ope.prof.email }}<br/>
            {{ ope.prof.phone }}<br/>
    </div>

    <div class="blockTop">
        <h3>Détails de la demande</h3>
        <strong>Établissement&nbsp;:</strong> {{ ope.prof.establishmentName }}<br/>
        <strong>Adresse Établissement&nbsp;:</strong> {{ ope.prof.establishmentAddress }}<br/>
        <strong>CP Établissement&nbsp;:</strong> {{ ope.prof.establishmentZipcode }}<br/>
        <strong>Ville Établissement&nbsp;:</strong> {{ ope.prof.establishmentCity }}<br/>
        <strong>{{ 'form.academy.label'|trans }}&nbsp;:</strong> {{ ope.prof.academy }}<br/>
        <strong>Niveau classe&nbsp;:</strong> {{ ope.classLevel }}<br/>
        <strong>Matière classe&nbsp;:</strong> {{ ope.classOption }}<br/>
        <strong>{{ 'form.itdlc.goalCategory.label'|trans }}&nbsp;:</strong> {{ ope.goalCategory|transconst('AppBundle\\Enum\\ITDLCGoalCategory') }}<br/>
        <strong>{{ 'form.itdlc.goal.label'|trans }}&nbsp;:</strong> {{ ope.goal }}<br/>
    </div>


    <div class="blockTop">
    <div class="borderBottom"></div>
        <h3>Préférence pour :</h3>
        {% for p in preferences %}
            {% if loop.first %}
                <ul>
            {% endif %}

            <li>{{ p.selectedUser.fullName }}</li>

            {% if loop.last %}
                </ul>
            {% endif %}
        {% endfor %}

        <div class="borderBottom"></div>
        {{ form_start(form, {'attr': {'id':'form-demandeitdlcprof'}}) }}

        {{ form_widget(form) }}

        {{ form_end(form) }}
        
        <ul class="btns">
            <li class="text-center">
                <button class="btn btn-save" form="form-demandeitdlcprof">
                    {{ 'form.itdlc.saveDemande'|trans({}, 'form') }}
                </button>
            </li>
        </ul>
    </div>
    <div class="blockTop mb-5">
        <div class="borderBottom"></div>
        {% if ope.lastMerITDLC is not empty %}
        <h3>Date de l'intervention :</h3>
        <div class="borderBottom"></div>
        
            {% if ope.lastMerITDLC.answer is null or ope.lastMerITDLC.answer == "autre" %}
            <ul>
                {% for date in ope.lastMerITDLC.AllDates %}
                    {% if date.day is not null %}
                        <li class="mt-5"><a href="{{ path('admin_merITDLC_reponse', {mer: ope.lastMerITDLC.id, reponse: 'date'~loop.index}) }}"
                            class="btn btn-theme btn-sm" onclick="return confirm(txt_confirm)"
                            style="{% if loop.first %}margin-top: 15px;{% endif %}margin-right: 15px">
                            Valider le {{ date.day|date('d/m/Y') }}
                            de {{ date.hours.startTime|date('H\\hi') }}
                            à {{ date.hours.endTime|date('H\\hi') -}}</a></li>
                    {% endif %}
                {% endfor %}
                </ul>
            {% endif %}
        {% endif %}
    </div>

<script>
    var txt_confirm = "Merci de confirmer votre réponse;";
</script>
{% endblock %}
