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

{% if demandes is defined and demandes is iterable %}
    {% for d in demandes %}
    <div class="card bg-concrete demande" data-did="{{ d.id }}" data-oid="{{ d.operationpee.id }}" data-dstate="{{ d.state }}" data-ostate="{{ d.operationpee.state }}">
        <div class="item-content">
            <div class="row">
                <div class="col-md-8 col-lg-9 col-xl-10">
                    <h2 class="h3 text-no-transform text-normal color-theme">Demande de visite d'entreprise ({% if d.operationpee.state not in [constant('AppBundle\\Enum\\OperationPEEState::CANCELLED'), constant('AppBundle\\Enum\\OperationPEEState::CLOSED')] %}{{ d.state|transconst('AppBundle\\Enum\\DemandePEEState') }}{% else %}{{ d.operationpee.state|transconst('AppBundle\\Enum\\OperationPEEState') }}{% endif %})</h2>
                    <p>Visite de l'entreprise {{ d.operationpee.company }} du site {{ d.operationpee.site }} {{ d.operationpee.city }}</p>
                    <p>Le <strong>{{ d.operationpee.dateVisite|date("d/m/Y") }}</strong> de <strong>{{ d.operationpee.startTime|date('H:i') }}</strong> à <strong>{{ d.operationpee.endTime|date('H:i') }}</strong></p>
                </div>
                <div class="col-md-4 col-lg-3 col-xl-2 d-flex align-items-center">
                    <div class="w-100 text-center">
                    {% if d.state not in [constant('AppBundle\\Enum\\DemandePEEState::WITHDRAWAL')] and app.user.type == constUserTypeProf and d.operationpee.state not in [constant('AppBundle\\Enum\\OperationPEEState::CANCELLED'), constant('AppBundle\\Enum\\OperationPEEState::CLOSED')] %}
                        <a class="btn btn-sm btn-white" href="{{ path('espace_perso_pee_add', {step: 3, ope:d.operationpee.id}) }}" rel="nofollow">
                            Modifier ma demande
                        </a>
                        
                        <a data-fancybox data-type="ajax" class="btn btn-sm btn-white" href="{{ path('modal_cancel_demande_pee', {'demande' : d.id }) }}" rel="nofollow">
                            Annuler ma demande
                        </a>
                    {% endif %}
                    </div>
                </div>
            </div>
        </div>
    </div>
    {% endfor %}   
{#% else %}
    {% if dPeeWaitingValidation is defined and dPeeWaitingValidation > 0 %}
        <p>Vos demandes sont en cours de traitement et apparaîtront ici une fois traitées.</p>
    {% else %}
        <p>Aucune demande.</p>
    {% endif %#}
{% endif %} 

