{% extends 'base.html.twig' %}
{% block content %}
<h5 class="text-uppercase fw-bold">
<a href="{{ path('formations') }}"><button type="button" class="btn btn-secondary text-uppercase" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Retour"><i class="bi bi-arrow-bar-left"></i> Liste Formations</button></a>
<i class="bi bi-caret-right"></i> Fiche formation
<i class="bi bi-caret-right"></i> <span class="text-decoration-underline">{{ formation.intitule }}</span>
</h5>
{% block navFormation %}
{# MENU DE NAVIGATION ONGLETS #}
{% include "navigation_onglets_formations.twig" %}
{% endblock %}
<div class="row">
<div class="col-12 mt-3">
<div class="card m-auto" style="width: 100%">
<h5 class="p-3 text-uppercase fw-bold bg-dark text-white">
<i class="bi bi-calendar-week"></i> Présences
<span class="float-end badge bg-{{ formationEtat.colors }}">{{ formationEtat.intitule }}</span>
</h5>
<div class="card-body">
<p class="card-text">
{% if formation.etat >= 2 %}
<div class="row text-start">
<div class="col-4">
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-filetype-pdf"></i> Feuilles de présences signées
</button>
<ul class="dropdown-menu">
<li><a href="{{ path('presences_download', {'idFormation': formation.id, 'message': 0 }) }}" class="dropdown-item"><i class="bi bi-download"></i> Télécharger le fichier</a></li>
<li><a href="{{ path('presences_upload', {'idFormation': formation.id, 'message': 0}) }}" class="dropdown-item"><i class="bi bi-upload"></i> Uploader le fichier</a></li>
</ul>
</div>
</div>
<div class="col-4 text-center">
<a href="{{ path('formations_presences_plages_stagiaires', {'idFormation':formation.id}) }}" class="btn btn-secondary"><i class="bi bi-person-workspace"></i> Afficher l'état des présences d'un stagiaire</a>
</div>
<div class="col-4 text-end">
<a href="{{ path('presences_generate_all_pdf', {'idFormation':formation.id}) }}" class="btn btn-primary" target="_blank"><i class="bi bi-file-earmark-pdf"></i> Générer toutes les feuilles de présences</a>
</div>
</div>
<div class="mt-3">
{% if plannings %}
<table class="table table-hover table-striped">
<thead>
<th></th>
<th></th>
<th>Absences</th>
<th>Date</th>
<th>Matin</th>
<th>Après-midi</th>
<th>Domaine</th>
<th>Intitulé</th>
<th>Formateur(trice)</th>
<th></th>
</thead>
<tbody>
{% for planning in plannings %}
{% if planning.etat == 2 %}
{% set textBarre = 'text-decoration:line-through;' %}
{% else %}
{% set textBarre = '' %}
{% endif %}
<tr style="{{ textBarre }}">
<td style="white-space: nowrap">
{% if app.user.roles[0] != 'ROLE_CD' or app.user.roles[0] == 'ROLE_CFC' %}
{% if formation.etat == 2 and planning.etat == 1 %}
<a href="{{path('formations_presences_plages', {'idPlanning':planning.id})}}" class="btn btn-success btn-sm">Saisir présences</a>
{% endif %}
{% endif %}
</td>
<td>
{% if planning.validationPresences == true %}
<span class="fw-bold fs-5" data-bs-toggle="tooltip" data-bs-placement="bottom" title="La saisie des presences est validée"><i class="bi bi-check2-circle"></i></span>
{% endif %}
</td>
<td style="white-space: nowrap">
<span data-bs-toggle="tooltip" data-bs-placement="bottom" title="Absences / Nbre total de plages">{{ tabAbsences[planning.id][0]}} / {{ tabAbsences[planning.id][1]}}</span>
</td>
<td style="white-space: nowrap">{{ planning.dateDebut|date('d/m/Y') }}</td>
<td style="white-space: nowrap">{{ planning.matinHoraireDebut|date('H:i') }} - {{ planning.matinHoraireFin|date('H:i') }}</td>
<td style="white-space: nowrap">{{ planning.apresMidiHoraireDebut|date('H:i') }} - {{ planning.apresMidiHoraireFin|date('H:i') }}</td>
<td><span class="badge {{ domainesColors[planning.domaine] }}">{{ planning.domaine }}</span></td>
<td>{{ planning.intitule }}</td>
<td style="white-space: nowrap">{{ planning.formateur.nom }} {{ planning.formateur.prenom }}</td>
<td>
{% if planning.etat == 1 %}
<a href="{{ path('presences_generate_one_pdf', {'idPlanning':planning.id}) }}" class="btn btn-primary btn-sm" target="_blank"><i class="bi bi-file-earmark-pdf"></i> Générer feuille présences</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
{% else %}
<div class="alert alert-secondary">Le traitement des présences pourront être effectué uniquement lorsque la formation sera dans l'état "FORMATION EN COURS"</div>
{% endif %}
</p>
</div>
</div>
</div>
</div>
{# <div id="resultats" class="mt-5">
toto
</div> #}
<div class="mb-5"></div>
<script>
$(document).ready(function(){
$('.presence').click(function(){
var idPlage = $(this).attr('idPlage');
var presence = $(this).prop('checked');
// alert(idPlage+' | '+presence);
$.ajax({
method: "POST",
url: "{{ path('formations_presences_ajax') }}",
data: {
idPlage: idPlage,
presence: presence
}
})
.done(function( msg ) {
// $('#resultats').html(msg);
});
});
});
</script>
{% endblock %}