{# utilisé par : assistant_maternel/recherche_dispo_assmat.html.twig #}
{# Paramètres en entrée : form_dispo le formulaire qui contient le planning (la liste d'objets "PlanningDispo") #}
{# Prérequis : la liste des items de planning_dispo sont triés par id_periode, id_tranche_horaire, id_jour #}
{# Pré-requis 2 : les ids des tranches et jours commencent à 0 et se suivent #}
{# Paramètre : edition true/false #}
<div class="py-2">
<span class="fa-09x">Cliquer dans le calendrier pour indiquer les créneaux libres recherchés</span>
</div>
{% set crtIdPeriode = 0 %}
{% set crtIdTranche = 0 %}
{% set classes = ['accueil_vide', 'bg-dispo'] %}
{# En-tête jours #}
<table id="{{ (edition ? 'periode_1' : 'synthese_periode_1') }}" class="table table-bordered table_planning">
<thead class="thead-light">
<tr class="d-none d-sm-table-row">
<th class="d-none d-sm-table-cell"></th>
{% for jour in liste_jours %}
<th scope="col" class="d-none d-md-table-cell" >{{ jour.libelle }}</th>
{% endfor %}
{% for jour in liste_jours %}
<th scope="col" class="d-none d-sm-table-cell d-md-none" >{{ jour.libelle | slice(0, 3) }}</th>
{% endfor %}
</tr>
</thead>
<col span="1" class="wide d-none d-sm-table-column">
<tbody>
{# Itération sur les créneaux du planning #}
{% for planning in form_dispo.planning_dispo %}
{# Récupération des données à partir du formulaire #}
{% set entity = planning.vars.data %}{# get entity object #}
{# ? #}
{% set crtIdJour = entity.getJourSemaine.id %}
{# ? #}
{% if crtIdPeriode != entity.periode.id %}
{% set crtIdPeriode = entity.periode.id %}
{% set crtIdTranche = 0 %}
{% endif %}
{% if crtIdTranche != entity.getTrancheHoraire.id %}
{% set crtIdTranche = entity.getTrancheHoraire.id %}
{# changement de tranche : nouvelle ligne #}
{% set tranche = liste_tranches[crtIdTranche-1] %}
<tr class="d-table-row d-sm-none thead-light"><th colspan="{{ liste_jours | length }}" title="{{tranche.description}}">{{ tranche.libelle }}</th></tr>
<tr class="">
<th class="d-none d-sm-table-cell" title="{{tranche.description}}">{{ tranche.libelle }}</th>
{% endif %}
{% set jour = liste_jours[entity.getJourSemaine.id-1] %}
<td class="">
<div id="{{edition ? 'planning' : 'synthese_planning'}}_{{ crtIdPeriode }}_{{ crtIdTranche }}_{{ jour.id }}" class="toggle_accueil {{ classes[entity.getFrequenceDispo().id-1] }}" data-statut="0">
<span class="jour d-block d-sm-none">{{ jour.libelle | first | upper }}</span>
{% if edition %} {{ form_row(planning.id_frequence_dispo) }} {% endif %}
</div>
{% if edition %}
{{ form_row(planning.id_periode) }}
{{ form_row(planning.id_tranche_horaire) }}
{{ form_row(planning.id_jour_semaine) }}
{% endif %}
</td>
{% if crtIdJour == liste_jours|length %}
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>