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

{% trans_default_domain 'form' %}

{% block javascripts %}
    <script>
        $(function() {
            $('.fancybox').fancybox({
                autoSize: false,
                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-operationitdlc">{{ 'action.save'|trans({}, 'action') }}</button>
            </li>
        </ul>

        <h1>{% if ope.id is not null %}Modifier lʼ{% else %}Ajouter une {% endif %}opération ITDLC</h1>
    </header>
605
    {{ form_start(form, {'attr': {'id': 'form-operationitdlc'}}) }}
        {% if ope.id is not null %}
            <h3>État de la demande</h3>
            <h3>Informations demande</h3>
            <strong>Nom de l'établissement : </strong>{{ ope.prof.establishmentName }}<br/>
             {% if ope.inge.getEstablishment().getPartnerGroup() != '' %}
                <p><strong>Groupement: </strong>{{ ope.inge.getEstablishment().getPartnerGroup() }}</p>
            {% endif %}
            <strong>Adresse de l'établissement : </strong> {{ ope.prof.establishmentAddress }}<br/>
            <strong>Code postal de l'établissement : </strong> {{ ope.prof.establishmentZipcode }}<br/>
            <strong>Ville de l'établissement : </strong> {{ ope.prof.establishmentCity }}<br/>
            <strong>{{ 'form.academy.label'|trans }}&nbsp;: </strong> {{ ope.prof.academy }}<br/>

            <div class="borderBottom"></div>
        {% endif %}

        {{ form_widget(form) }}

        {% if ope.id is not null %}
            <div class="blockDispos">
                {% for availability in dates %}
                    <div class="container-item delete-element-container">
                        {% if availability.dayoftheweek is not null %}
                            <a
                                class="fancybox fancybox.iframe"
                                href="{{ path('admin_availability_edit', {
                                    'availability': availability.id,
                                    'typedispo': 'hebdo',
                                    'iframe':true }) }}"
                            ><b>Disponibilité {{ loop.index }}</b></a><br/>
                            {{ availability.dayoftheweek }}
                        {% else %}
                            <a
                                class="fancybox fancybox.iframe"
                                href="{{ path('admin_availability_edit', {
                                    'availability':availability.id,
                                    'typedispo': 'precis',
                                    'iframe':true }) }}"
                            ><b>Disponibilité {{ loop.index }}</b></a><br/>
                            {{ availability.dateVisite|date("d/m/Y") }}<br/>
                        {% endif %}
                        de {{ availability.startTime|date('H\\hi') }} à
                        {{ availability.endTime|date('H\\hi') }}
                        <a class="delete-element" href="{{ path('admin_availability_delete', {id: availability.id})}}" title="{{ 'action.delete.label'|trans({}, 'action') }}">
                            <span>{{ 'action.delete.label'|trans({}, 'action') }}</span>
                        </a>
                    </div>
                {% endfor %}

            <ul class="btns">
                <li>
                    <a
                        class="btn btn-add fancybox fancybox.iframe"
                        href="{{ path('admin_availability_add', {'ope':ope.id, 'typedispo':'precis', 'iframe':true }) }}"
                    >
                        {{ 'action.add.availability.precise'|trans({}, 'action') }}
                    </a>
                </li>
            </ul>
            </div>
        {% endif %}

        <ul class="btns">
            <li>
                <input class="btn btn-save" type="submit" value="{{ 'action.save'|trans({}, 'action') }}"/>
            </li>
        </ul>
    {{ form_end(form) }}
{% endblock %}
