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

{% set modalClass = 'itdlc demande' %}
{% set headerClass = 'bg-tangerine' %}
{% set bodyClass = '' %}
{% set footerClass = '' %}

{% set constUserTypeProf = constant('AppBundle\\Enum\\UserType::TEACHER') %}
{% set constUserTypeInge = constant('AppBundle\\Enum\\UserType::ENGINEER') %}

{% set interest_txt_unchecked = ('sentence.interest.select')|trans({}, 'sentence') %}
{% set interest_txt_checked = ('sentence.interest.selected')|trans({}, 'sentence') %}

{% block header %}
    <div class="container">
        <div class="row">
            <div class="col-md-4">
                <div class="block-donnees-photo photo-badge">
                    {% if demande.prof.photo %}
                        <img alt="Photo de profil" class="img-fluid" src="{{ demande.prof.getWebPhoto|imagine_filter('150Lx150H') }}">
                    {% else %}
                        {{ include('Front/_component/icon.html.twig', {id: 'user--user', class:'icon-profile-default'}) }}
                    {% endif %}
                </div>
            </div>
            <div class="col-md-8">
                <h3 class="item-title h6 text-no-transform">
                    {{ demande.prof.establishmentName ?? demande.prof.establishmentNameOther }}
                </h3>
                <p class="">
                    {{ demande.prof.establishmentAddress }}<br />
                    {{ demande.prof.establishmentZipcode }} {{ demande.prof.establishmentCity }}
                </p>
                <p class="text-small">
                    <strong>Intervention&nbsp;:</strong>
                    "{{ demande.goalCategory|transconst('\\AppBundle\\Enum\\ITDLCGoalCategory') }}"
                    {% if 1 == demande.availability|length -%}
                        {% set availability = demande.availability|first %}
                        
                        {% if availability.dayoftheweek is null %}
                            le <strong>{{ availability.dateVisite|date('d/m/Y') }}</strong>
                        {% else %}
                            tous les <strong>{{ availability.dayoftheweek|lower }}</strong>
                        {% endif %}
                        de <strong>{{ availability.startTime|date('H\\hi') }}</strong> à <strong>{{ availability.endTime|date('H\\hi') -}}</strong>
                    {% endif %}
                </p>
            </div>
        </div>
    </div>
{% endblock %}

{% block body %}
    <p>
        <strong>{{ 'word.teacher.label'|trans({}, 'word') }}&nbsp;:</strong>
        {{ demande.prof.firstname }} {{ demande.prof.lastname }}
    </p>
    <p>
        <strong>{{ 'form.profile.teacher.job.label'|trans({}, 'form') }}&nbsp;:</strong>
        {% if demande.prof.categoryJob is not empty %}{{ demande.prof.categoryJob|transconst('AppBundle\\Enum\\UserJobTeacherCategory') }} / {% endif %}{% if demande.prof.jobOther is not empty %}{{ demande.prof.jobOther }}{% else %}{{ demande.prof.job|transconst('AppBundle\\Enum\\UserJobTeacher') }}{% endif %}
    </p>
    <p>
        <strong>{{ 'form.itdlc.classLevel.label'|trans({}, 'form') }}&nbsp;:</strong>
        {{ demande.classLevel }} {% if demande.classOption %}({{ demande.classOption }}){% endif %}
    </p>
    <p>
        <strong>{{ 'form.itdlc.nbStudent.label'|trans({}, 'form') }}&nbsp;:</strong>
        {{ demande.nbStudent }}
    </p>
    <p>
        <strong>{{ 'form.profile.teacher.establishment.label'|trans({}, 'form') }}&nbsp;:</strong>
        {{ demande.prof.establishmentName ?? demande.prof.establishmentNameOther }}<br />
        {{ demande.prof.establishmentAddress }}<br />
        {{ demande.prof.establishmentZipcode }} {{ demande.prof.establishmentCity }}
    </p>
    {% if demande.availability|length > 1 %}
    <p>
        Différentes dates disponibles : <br />
        {% for availability in demande.availability %}
            {% if availability.dayoftheweek is null %}
                Le <strong>{{ availability.dateVisite|date('d/m/Y') }}</strong>
            {% else %}
                Tous les <strong>{{ availability.dayoftheweek|lower }}</strong> 
            {% endif %} 
            de <strong>{{ availability.startTime|date('H\\hi') }}</strong> à <strong>{{ availability.endTime|date('H\\hi') -}}</strong><br />
        {% endfor %}
    </p>
    {% endif %}
{% endblock %}

{% block footer %}
    {% if app.user.type == constUserTypeProf and app.user.id == demande.prof.id %}
        {% if demande.state not in [constant('AppBundle\\Enum\\OperationITDLCState::CANCELLED'), constant('AppBundle\\Enum\\OperationITDLCState::CLOSED')] %}
            <a class="btn btn-sm btn-white" href="{{ path('espace_perso_prof_itdlc_edit', {ope:d.id, step: 3}) }}">
                Modifier ma demande
            </a>
        {% endif %}   
    {% elseif app.user.type == constUserTypeInge %}
        <button id="modal_ditdlc_interest_{{ demande.id }}_select" type="button" class="btn btn-sm select-interest-itdlc{% if isInterested %} has-select-icon{% endif %}" data-demande="{{ demande.id }}">
            {% if isInterested %}  
                {{ interest_txt_checked|raw }}
            {% else %}
                {{ interest_txt_unchecked|raw }}
            {% endif %}
        </button>
    {% endif %}
{% endblock %}