{% set theme = app.session.get('theme') %}
{% if theme is not empty %}
    {{ include('@Theme/'~theme~'/function.html.twig') }}
{% endif %}

{% import "Pagewidget/constants.twig" as constants %}

{% set stylewidget = constants.mystylewidget(entity) %}
{% set stylewidgetmenu = constants.mystylewidgetmenu(entity) %}
{% set stylewidgetheader = constants.mystylewidgetheader(entity) %}
{% set stylewidgetbody = constants.mystylewidgetbody(entity) %}
{% set stylewidgetbodyimage = constants.mystylewidgetbodyimage(entity) %}
{% set stylewidgetbodyreverse = constants.mystylewidgetbodyreverse(entity) %}

{% set color = app.session.get('color') %}

{% set stylelink = "color:#" ~ entity.colorheaderfont %}
{% if entity.colorheaderfont is null %}
    {% set stylelink = "color:#" ~ color['fontcolorhover'] %}
{% endif %}

{%if mini %}
    <div class="widget widget-mini widget-info" data-id="{{ entity.id }}" loc="{{ entity.loc }}">
        <div class="widgetheader">
            <a style="cursor:pointer" onClick="bigWidget({{entity.id}})">
            {% if icon %}
                {% if icon=="/uploads/avatar/noavatar.png" %}
                    <img src="{{ asset("uploads/icon/icon_profle.png") }}" class="logo" title="{{ title }}"/>
                {% else %}
                    <img src="{{ asset(icon) }}" class="logo" title="{{ title }}"/>
                {% endif %}
            {% else %}
                <img src="{{ asset("uploads/icon/icon_users.png") }}" class="logo" title="{{ title }}"/>
            {% endif %}
            </a>
        </div>
    </div>    
{% else %}
    <div class="widget {%if entity.border %} widget-bordered {%else%} widget-notbordered {%endif%} widget-info" data-id="{{ entity.id }}" loc="{{ entity.loc }}" style="{{ stylewidget }}" height="{{ entity.height }}px">
        <div class="widgetmenu">
            {% if canupdate  %}
            <i class="fa fa-trash fa-fw" title="Supprimer le Widget" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
            <i class="fa fa-file fa-fw" title="Modifier le Widget" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
            {% endif %}

            {% if look=="list" %}
            <i class="glyphicon glyphicon-resize-small" title="Réduire le Widget" onClick="smallWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
            {% else %}
            <i class="glyphicon glyphicon-resize-full" title="Agrandir le Widget" onClick="bigWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
            {% endif %}
        </div>
        

        <div class="widgetheader" style="{{ stylewidgetheader }}">
            {% if icon %}
                <img src="{{ asset(icon) }}" class="logo" style="border-radius:100%"/>
            {% else %}
                <img src="{{ asset("uploads/icon/icon_users.png") }}" class="logo"/>
            {% endif %}
            <span class="title">{{ title }}</span>
        </div>

        <div class="widgetbody" style="{{ stylewidgetbody }}">           
            <div style="text-align: center;">
                {{ description | raw }}
            
                {%if usage=="group" %}
                    <div class="grid clearfix">
                        <div class="grid-sizer  grid-verysmall"></div>
                        <div class="grid-gutter-sizer"></div>   

                        {% if canadd==true %}
                            <div class="grid-item grid-verysmall" style="{{ stylewidgetbodyreverse }};">
                                <div class="grid-item-content">      
                                    <a href="{{path('app_core_user_group_users',{'id':id,'idreturn':idpage})}}" target="_top" style="{{ stylewidgetbodyreverse }};">
                                        <div class="item-link clearfix">
                                            <div class="grid-item-logo">
                                                <img class="grid-item-img imageshadow" height="110" src="{{ asset("uploads/icon/icon_add.png") }}" />
                                            </div>                    
            
                                
                                            <div class="grid-item-title">
                                                <h2 style="{{ stylewidgetbodyreverse }};">Ajouter un membre</h2>
                                            </div>
                                        </div>
                                    </a>
                                </div>
                            </div>                    
                        {% endif %}

                        {% for member in members %}
                            <div class="grid-item grid-verysmall" style="{{ stylewidgetbodyreverse }};">
                                <div class="grid-item-content">    
                                    <div class="item-link clearfix">  
                                        <div class="grid-item-logo">
                                            <img onclick="seeUser({{member.user.id}})" src="{{ asset("uploads/avatar/"~member.user.avatar) }}" class="grid-item-img avatar" height="110" style="cursor:pointer;">   
                                        </div>
                                    
                                        <div class="grid-item-title">
                                            <h2 style="{{ stylewidgetbodyreverse }};">
                                            {{ member.user.lastname }} {{ member.user.firstname }}
                                            {% if member.rolegroup==100 %}
                                                <br><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i>
                                            {% elseif member.rolegroup==90 %}
                                                <br><i class="fa fa-star"></i><i class="fa fa-star"></i>
                                            {% elseif member.rolegroup==50 %}
                                                <br><i class="fa fa-star"></i>
                                            {% endif %}
                                            </h2>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        {% endfor %}


                    </div>
                {% endif %}
            </div>
        </div>
    </div>
{% endif %}



