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

{% block title %}{% trans %}title_group_view{% endtrans %}{% endblock %}

{% block body %}
{% set groupLogo = 'img/nologo.png' %}                
{% if group.imageSize != 0 %}
  {% set groupLogo = 'uploads/groups/' ~ group.imageName %}
{% endif %}
    <div class="row">
      <div class="col-md-8">
        <h2>{% trans %}title_group_ranks{% endtrans %} <a href="{{ path('admin_group_rank_add',  {id: group.id}) }}"><span class="badge rounded-pill bg-success"><i class="fa fa-plus"></i> {% trans %}button_create{% endtrans %}</span></a></h2>
        <hr>
        <table class="table table-dark table-striped">
          <thead>
              <tr>
                  <th scope="col">#</th>
                  <th scope="col">{% trans %}title_name{% endtrans %}</th>
                  <th scope="col">{% trans %}title_shortname{% endtrans %}</th>
                  <th scope="col">{% trans %}title_power{% endtrans %}</th>
                  <th scope="col">{% trans %}title_created_at{% endtrans %}</th>
                  <th scope="col">{% trans %}title_actions{% endtrans %}</th>
              </tr>
          </thead>
          <tbody>
              {% for i in group.ranks %}
                  <tr>
                      <th scope="row">{{i.id}}</th>                      
                      <td>{{ i.name }}</td>
                      <td>{{ i.shortname }}</td>
                      <td>{{ i.power }}</td>
                      <td>{{i.createdAt |date('_datetime.format'|trans)}}</td>
                      <td>
                      {% include '_cells/adminRankActions.html.twig' with {'rank': i} %}
                      </td>
                  </tr>
              {% endfor %}
          </tbody>
      </table>
      <h2>{% trans %}title_group_subgroups{% endtrans %} <a href="{{ path('admin_group_subgroup_add',  {id: group.id}) }}"><span class="badge rounded-pill bg-success"><i class="fa fa-plus"></i> {% trans %}button_create{% endtrans %}</span></a></h2>
        <hr>
        <table class="table table-dark table-striped">
          <thead>
              <tr>
                  <th scope="col">#</th>
                  <th scope="col">{% trans %}title_name{% endtrans %}</th>
                  <th scope="col">{% trans %}title_shortname{% endtrans %}</th>
                  <th scope="col">{% trans %}title_created_at{% endtrans %}</th>
                  <th scope="col">{% trans %}title_actions{% endtrans %}</th>
              </tr>
          </thead>
          <tbody>
              {% for i in group.subGroups %}
                  <tr>
                      <th scope="row">{{i.id}}</th>                      
                      <td>{{ i.name }}</td>
                      <td>{{ i.shortname }}</td>
                      <td>{{i.createdAt |date('_datetime.format'|trans)}}</td>
                      <td>
                      {% include '_cells/adminSubGroupActions.html.twig' with {'subgroup': i} %}
                      </td>
                  </tr>
              {% endfor %}
          </tbody>
      </table>
        <h2>{% trans %}title_members{% endtrans %}</h2>
        <hr>
        {% include '_cells/adminUserTable.html.twig' with {'users': group.users} %}
        <h2>{% trans %}title_documents{% endtrans %}</h2>
        <hr>
        <a href="{{ path('admin_group_documents', {id: group.id}) }}" class="btn btn-primary">{{ 'button_group_view_documents'|trans }}</a>
      </div>
      <div class="col-md-4">
        <h2>{% trans %}title_informations{% endtrans %}</h2>
        
        <div class="row">
          <div class="col-md-12 my-5">            
            <div class="text-center">     
              <img src="{{ asset(groupLogo) }}" alt="{{group.shortname}}" class="img-fluid">
            </div>
            <h3>{{group.name}}</h3>
            <h4>{% trans %}title_shortname{% endtrans %}: <small>{{group.shortname}}</small><span class="float-end">{% include '_cells/adminGroupActions.html.twig' with {'group': group} %}</span></h4>
            
          </div>
          <div class="col-md-12">
            <h6>{% trans %}title_motd{% endtrans %}</h6>
            <hr>
            <div class="border-start p-3">
                <div class="card">                
                  <div class="card-body">{{ group.motd | raw }}</div>
                  <div class="card-footer">{% trans %}title_last_update{% endtrans %} : {{ group.motdUpdatedAt | date('_datetime.format'|trans) }}</div>
                </div>
            </div>
          </div>
        </div>
        
        
      </div>
    </div>

{% endblock %}
