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

{% block title %}Gestion pour {{ event.name }}{% endblock %}

{% block content %}

{{ component('Modal')}}


<div class="card" {{ stimulus_controller('dropdown')}} >
  <div class="card-footer">
    <div class="dropdown card-footer-item is-flex is-justify-content-space-between is-align-items-center" data-action="click->dropdown#toggle">
      <button>
        <span><strong>{{ event.name }} - du {{ event.startOn|date('d/m/y à H:i', app_timezone) }} au {{ event.endOn|date('d/m/y à H:i', app_timezone)}}</strong></span>        
      </button>
      {% if events|length > 1 %}
      <span class="icon is-small">
        <twig:ux:icon name="bi:chevron-down" />&nbsp;
      </span>
      <div data-dropdown-target="menu" class="dropdown-menu">
        <div class="dropdown-content">
          {% for evt in events %}
          {% if event.id != evt.id %}
          <a href="{{ path('app_manage_planning', {id: evt.id})}}" class="dropdown-item"><strong>{{ evt.name }}</strong><small> du {{ evt.startOn|date('d/m/y H:i', app_timezone) }} au {{ evt.endOn|date('d/m/y H:i', app_timezone)}}</small></a>
          {% endif %}
          {% endfor %}
        </div>
      </div>
      {% endif %}
    </div>
  </div>





</div>

<div class="box is-clearfix">
  <div class="columns">
    {% if not event.isHiddenPlanning %}
    <div class="column">
      <p>{{ event.getParties()|length }} parties proposées</p>
    </div>
    {% endif %}
    <div class="column">
      <p class="is-inline-block icon-text">{{ event.getGamemastersAssigned|length }} meneur(euse)s de jeu
        {% for gamemaster in event.getGamemastersAssigned %}
          <span class="icon">
              <a href="{{ path('app_gamemaster_public_profile', {id: gamemaster.id}) }}" class="open-modal" title="{{ gamemaster.preferedName }}"><figure class="image is-24x24 is-inline-block">
              {% if gamemaster.picture %}
              <img class="is-rounded" src="/images/gamemasters/{{ gamemaster.picture }}" alt="{{ gamemaster.preferedName }}"/>
              {% else %}
              <twig:ux:icon name="bi:person-fill"/>
              {% endif %}
              </figure></a>
          </span>   
        {% endfor %}
      </p>
    </div>
  </div>

</div>

    <div class="tabs is-boxed">
        <ul>
            <li><a href="{{ path('app_manage_planning', {id: event.id}) }}">Planning</a></li>
            <li class="is-active"><a>Liste des parties</a></li>
            <li><a href="{{ path('app_manage_booking', {id: event.id}) }}">Liste des participant(e)s</a></li>
            {% if event.isEveryoneCanAskForGame %}<li><a  href="{{ path('app_manage_request', {id: event.id}) }}">Liste des demandes</a></li>{% endif %}


        </ul>
    </div>


<section>
        <table id="datatable" {{ stimulus_controller('datatables') }} class="table is-striped is-hoverable is-fullwidth">
            <thead>
            <tr>
                <th  data-priority="1">Horaire</th>
                <th  data-priority="3">Espace</th>
                <th  data-priority="1">Jeu</th>
                <th  data-priority="2">Meneur(euse)</th>
                <th  data-priority="3">Participant(e)s</th>
                <th  data-priority="1">Action</th>
            </tr>
            </thead>
            <tbody>
            {% for party in event.getParties %}
                <tr>
                    <th>{{ party.startOn|date('d/m/y \\d\\e H:i', app_timezone) }} à {{ party.endOn|date('H:i', app_timezone) }}</th>
                    <td>{{ party.slots.first.space.name }}</td>
                    <td>{{ party.game.name }}</td>
                    <td>{{ party.gamemaster.preferedName }}</td>
                    <td>{{ party.getSeatsOccuped }} / {{ party.getMaxParticipants }}</td>
                    <td>
                    	<div class="buttons has-addons">
                      {% if party.getSeatsOccuped < party.getMaxParticipants %}
                        <a href="{{ path('app_participation', {id: party.slots.first.id}) }}" class="button is-primary open-modal" title="Inscrire"><span class="icon"><twig:ux:icon name="bi:person-fill-add"/></span></a>
                      {% else %}
                        <button class="button is-primary" disabled><span class="icon"><twig:ux:icon name="bi:person-fill-add"/></span></button>
                      {% endif %}
                      <a href="{{ path('app_party_modify', {id: party.slots.first.id}) }}" class="button is-primary open-modal" title="Éditer"><span class="icon"><twig:ux:icon name="bi:pencil-square"/></span></a>
                      {% if party.getSeatsOccuped > 0 %}
                        <span class="is-sr-only">{% if party.participations|filter(p => p.checkin is null)|length > 0 %}À faire{% else %}Fait{% endif %}</span><a href="{{ path('app_checkin_party', {id: party.id}) }}" class="button open-modal" title="Checkins"><span class="icon"><twig:ux:icon name="bi:person-fill-check"/></span></a> 
                      {% else %}
                        <span class="is-sr-only">Sans inscriptions</span><button class="button" disabled><span class="icon"><twig:ux:icon name="bi:person-fill-check"/></span></button>
                      {% endif %}
                      </div>
                    </td>
                </tr>
            {% endfor %}
            </tbody>

        </table>
</section>

{% endblock %}
