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

{% if operations is defined and operations is iterable %}
    {% for o in operations %}
        <div class="card bg-concrete operation" data-did="{{ o.demandepee|first.id }}" data-oid="{{ o.id }}" data-dstate="{{ o.demandepee|first.state }}" data-ostate="{{ o.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 app.user.type == constUserTypeProf and o.state not in [constant('AppBundle\\Enum\\OperationPEEState::CANCELLED'), constant('AppBundle\\Enum\\OperationPEEState::CLOSED')] %}{{ o.demandepee|first.state|transconst('AppBundle\\Enum\\DemandePEEState') }}{% else %}{{ o.state|transconst('AppBundle\\Enum\\OperationPEEState') }}{% endif %})</h2>
                        <p>Visite de l'entreprise {{ o.company }} du site {{ o.site }} {{ o.city }}</p>
                        <p>Le <strong>{{ o.dateVisite|date("d/m/Y") }}</strong> de <strong>{{ o.startTime|date('H:i') }}</strong> à <strong>{{ o.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 o.state not in [constant('AppBundle\\Enum\\OperationPEEState::CANCELLED'), constant('AppBundle\\Enum\\OperationPEEState::CLOSED')] and app.user.type == constUserTypeProf and o.demandepee|first.state not in [constant('AppBundle\\Enum\\DemandePEEState::WITHDRAWAL')] %}
                            <a data-fancybox data-type="ajax" class="btn btn-sm btn-white" href="{{ path('modal_cancel_demande_pee', {'demande' : (o.demandepee|first.id) }) }}" rel="nofollow">
                                Annuler ma visite
                            </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 %}
