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

{% block title %}{% trans %}title_home{% endtrans %}{% endblock %}
{% block subtitle %}{% trans %}subtitle_home{% endtrans %}{% endblock %}

{% block body %}
        
<div class="row">
    <div class="col-xl-6 col-md-12">
        {% if wanted %}
        <div class="row">
            <div class="col">
                <h6>{% trans %}title_wanted_directory{% endtrans %}</h6>
                <hr>
                <div class="row">
                    {% for i in wanted %}
                    {% set path_directories_uploads  = 'uploads/directories' %}
                    {% if i.faceImageSize != 0 %}{% set faceImage = path_directories_uploads ~ '/' ~ i.faceImageName %}{% else %}{% set faceImage = 'img/nophoto.jpg' %}{% endif %}
                    
                    <div class="col-sm-6">
                        <div class="card prod-p-card background-pattern">                    
                            <div class="card-body">
                                <div class="row align-items-center m-b-0">
                                    <div class="col">
                                        <h6 class="m-b-5">{% trans %}title_wanted{% endtrans %}</h6>
                                        <h3 class="m-b-0"><a href="{{ path('directory_view', {id: i.id}) }}">{{ i.fullname}}</a></h3>
                                    </div>
                                    <div class="col-auto">
                                        <a data-toggle="lightbox" data-gallery="wanted" data-caption="{% trans %}title_wanted{% endtrans %}: {{ i.fullname }}" href="{{ asset(faceImage) }}"><img class="img-fluid" style="max-height: 100px;" src="{{ asset(faceImage) }}" alt="{{ i.fullname}}"></a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

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

        <div class="row">
            <h6>{% trans %}title_last_documents{% endtrans %}</h6>
            <hr>
            {% include '_cells/documentTable.html.twig' with {'documents': documents, 'noaction': true} %}
        </div>
    </div>
    <div class="col-xl-6 col-md-12">
        {% if app.user.mainGroup.motd %}
        <div class="row">
            <div class="col">
                <h6>{% trans %}title_motd{% endtrans %}</h6>
                <hr>
                <div class="card">                    
                    <div class="card-body">{{ app.user.mainGroup.motd | raw }}</div>
                    <div class="card-footer">{% trans %}title_last_update{% endtrans %} : {{ app.user.mainGroup.motdUpdatedAt | date('_datetime.format'|trans) }}</div>
                </div>
            </div>
        </div>
        {% endif %}
        
        <div class="row">
            <div class="col">
                <h6>{% trans %}title_announces{% endtrans %} <a href="{{ path('document_create', {type: 'announce'}) }}"><span class="badge rounded-pill bg-success"><i class="fa fa-plus"></i> {% trans %}button_create{% endtrans %}</span></a></h6>
                <hr>
                {% for a in announces %}
                    {% set groupLogo = 'img/nologo.png' %}
                    {% if a.mainGroup %}
                        {% if a.mainGroup.imageSize != 0 %}
                            {% set groupLogo = 'uploads/groups/' ~ a.mainGroup.imageName %}
                        {% endif %}
                    {% endif %}

                    <div class="card">
                        <div class="card-header">
                            <div class="row align-items-center">
                                <div class="col-2 col-md-1"><img src="{{ asset(groupLogo) }}" alt="{{  a.mainGroup.name }} " class="img-icon"></div>
                                <div class="col fw-bold">{{ a.title }}</div>
                            </div>
                        </div>
                        <div class="card-body">{{ a.content | raw }}</div>
                        <div class="card-footer">{{ a.creator.fullname }} {% trans %}for{% endtrans %} {{  a.mainGroup.name }} , {% trans %}title_created_at{% endtrans %} {{ a.createdAt|date('_datetime.format'|trans) }} | {% include '_cells/documentActions.html.twig' with {'document': a} %}</div>
                    </div>
                {% endfor %}
                <p class="text-center"><a href="{{ path('document_list', {type: 'announce'}) }}" class="btn btn-primary text-dark  btn-bloc">{% trans %}link_more_announces{% endtrans %}</a></p>
            </div>
        </div>

    </div>
</div>
{% endblock %}
