{% extends 'base.html.twig' %}

{% block localstyle %}
    #page-wrapper {
        padding: 0px;
        min-height:0px !important;
    }
{% endblock %}

{% block pagewrapper %}
    <div style='margin-auto; text-align:center'>
        {% if not app.user %}
            Vous n'êtes pas autorisé à visualiser les fiches utilisateurs
        {% else %}
            <br>
            
            {%if user.avatar and not fields["avatar"]["perm"]==0 %}<img id="user_avatar_img" src="{{ asset('uploads/avatar/' ~ user.avatar) }}" class="avatar big" ><br>{%endif%}
            {%if user.username and not fields["login"]["perm"]==0 %}<b><b>Login</b> = {{ user.username }}<br>{%endif%}
            {% if not user.visible %}
                <br>L'utilisateur souhaite masquer ses informations personnelles.
            {% else %}
                {%if user.lastname and not fields["lastname"]["perm"]==0 %}<b>Nom</b> = {{ user.lastname }}<br>{%endif%}
                {%if user.firstname and not fields["firstname"]["perm"]==0 %}<b>{{fields["firstname"]["label"]}}</b> = {{ user.firstname }} {{fields["firstname"]["perm"]}}<br>{%endif%}
                {%if user.email %}<b>Email</b> = <a href='mailto:{{ user.email }}'>{{ user.email }}</a><br>{%endif%}
                {%if user.telephonenumber and not fields["telephonenumber"]["perm"]==0 %}<b>{{fields["telephonenumber"]["label"]}}</b> = {{ user.telephonenumber }}<br>{%endif%}
                {%if user.niveau01 %}<b>{{ labelniveau01 }}</b> = {{ user.niveau01.label }}<br>{%endif%}
                {%if viewniveau02 and user.niveau02%}<b>{{ labelniveau02 }}</b> = {{ user.niveau02.label }}<br>{% endif %}
                {%if user.job and not fields["job"]["perm"]==0 %}<b>{{fields["job"]["label"]}}</b> = {{ user.job }}<br>{%endif%}
                {%if user.position and not fields["position"]["perm"]==0 %}<b>{{fields["position"]["label"]}}</b> = {{ user.position }}<br>{%endif%}
                {%if user.postaladress and not fields["postaladress"]["perm"]==0 %}<b>{{fields["postaladress"]["label"]}}</b> = {{ user.postaladress }}<br>{%endif%}

                {%if user.visitedate and (not fields["visitedate"]["perm"]==0 or (not is_granted('ROLE_USER') and not is_granted('ROLE_ANIM'))) %}<b>Date de dernière visite</b> = {{ user.visitedate|date('d/m/Y H:i') }}<br>{%endif%}
                {%if user.visitecpt and (not fields["visitedate"]["perm"]==0 or (not is_granted('ROLE_USER') and not is_granted('ROLE_ANIM'))) %}<b>Nombre de visites</b> = {{ user.visitecpt }}<br>{%endif%}
                
                {% if not fields["group"].perm==0 or not is_granted('ROLE_USER') %}
                    <br>
                    {% set fgtitle=false %}
                    {% for usergroup in user.groups %}
                        {% if usergroup.group.fgcanshare %}
                            {% if not fgtitle %}
                                <br><b>Groupes de Travail</b><br>
                                {% set fgtitle=true %}
                            {% endif %}
                            
                            {{ usergroup.group.label }}<br>
                        {% endif %}
                    {% endfor %}
                {% endif %}
            {% endif %}
        {% endif %}
    </div>
{% endblock %}

