{% 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-envelope-check"></i> Convocations
<span class="float-end badge bg-{{ formationEtat.colors }}">{{ formationEtat.intitule }}</span>
</h5>
<div class="card-body">
<p class="card-text">
<div class="mb-3" style="margin-top:-15px">
{% if convocations is empty %}
<div class="alert alert-secondary">Aucun stagiaire convoqué</div>
{% else %}
<div class="row">
<div class="col-6 fst-italic">
Convoqué(s) : <!--<span class="badge bg-secondary">{# convocations|length #}</span> / --> <span class="badge bg-primary">{{ formation.convocations|length }}
</div>
<div class="col-6">
{% if app.user.roles[0] != 'ROLE_CD' or app.user.roles[0] == 'ROLE_CFC' %}
{% if formation.etat == 1 and formation.formationInsciptions is not empty %}
<div class="text-end">
<a href="{{ path('convocations_generate', {'idFormation':formation.id}) }}" class="btn btn-primary btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="Seuls les stagiaires inscrits à cette formation pourront être convoqués">Convoquer</a>
</div>
{% endif %}
{% endif %}
</div>
</div>
{% for convocation in convocations %}
<div class="mt-2 row">
<div class="col-5">
{% if app.user.roles[0] != 'ROLE_CD' or app.user.roles[0] == 'ROLE_CFC' %}
<a href="{{ path('convocations_show', {'idConvocation':convocation.id}) }}" class="btn btn-primary btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="Visualiser les détails de cette convocation"><i class="bi bi-search"></i></a>
{% endif %}
<span class="fw-bold ms-2 me-3">{{ convocation.stagiaire.nom }} {{ convocation.stagiaire.prenom }}</span>
{% if stagiairesReportsTab[convocation.stagiaire.id][0] == true %}
<span class="badge bg-secondary">
{{ stagiairesReportsTab[convocation.stagiaire.id][0] }}x REPORT(S)
</span>
{% endif %}
{% if stagairesAbsencesTab[convocation.stagiaire.id][0] == true %}
<span class="badge bg-info">
{{ stagairesAbsencesTab[convocation.stagiaire.id][0] }}x ABSENCES(S)
</span>
{% endif %}
{% if convocation.stagiaire.dispenseDomaine1 == 1 or convocation.stagiaire.dispenseDomaine2 == 1 or convocation.stagiaire.dispenseDomaine3 == 1 %}
<span class="badge bg-warning text-black">
Dispensé(e) domaine(s) :
{% set temp = 0 %}
{% if convocation.stagiaire.dispenseDomaine1 %}
1
{% set temp = 1 %}
{% endif %}
{% if convocation.stagiaire.dispenseDomaine2 %}
{% if temp == 1 %} | {% endif %}
2
{% set temp = 1 %}
{% endif %}
{% if convocation.stagiaire.dispenseDomaine3 %}
{% if temp == 1 %} | {% endif %}
3
{% endif %}
</span>
{% endif %}
</div>
<div class="col-7">
<!-- <span class="badge bg-primary">{{ convocation.stagiaire.id }}</span> -->
{% if formation.etat == 1 %}
<a href="{{ path('convocations_generate_pdf', {'idConvocation':convocation.id}) }}" target="_blank" class="badge bg-primary text-white text-decoration-none"><i class="bi bi-file-earmark-pdf"></i> Convocation (PDF) G</a>
<a href="{{ path('convocations_mail',{'idConvocation':convocation.id}) }}" target="_blank" class="badge bg-secondary text-white text-decoration-none"><i class="bi bi-envelope-plus"></i> Envoyer convocation par mail</a>
{% else %}
<a href="{{ path('convocations_PDF_show', {'idConvocation':convocation.id}) }}" target="_blank" class="badge bg-primary text-white text-decoration-none"><i class="bi bi-file-earmark-pdf"></i> Convocation (PDF) S</a>
{% endif %}
{% if formation.etat == 1 %}
<a
href=""
class="buttonReponseConvocation"
data-bs-toggle="modal"
data-bs-target="#modalTraiterReponseConvocation"
data-idConvocation="{{ convocation.id }}"
data-nomPrenom="{{ convocation.stagiaire.nom }} {{ convocation.stagiaire.prenom }}"
data-action=""
>
{% endif %}
{% if convocation.reponse == null %}
<span id="badgeResponse-{{ convocation.id }}" class="badge bg-secondary">Convocation non traitée</span>{% if convocation.etat == 1 %}</a>{% endif %}
{% else %}
<span id="badgeResponse-{{ convocation.id }}" class="badge bg-{{ convocation.reponse.colors }}">{{ convocation.reponse.intitule }}</span>{% if formation.etat == 1 %}</a>{% endif %}
{% endif %}
{% if convocation.etat == 1 %}
{% set ico = 'bi-unlock' %}
{% else %}
{% set ico = 'bi-lock-fill' %}
{% endif %}
<!-- BOUTON DE CLOTURE DE LA CONVOCATION -->
{% if formation.etat == 1 %}
<a
href=""
class="buttonCloturerConvocation"
data-bs-toggle="modal"
data-bs-target="#modalCloturerConvocation"
data-idConvocation="{{ convocation.id }}"
data-nomPrenom="{{ convocation.stagiaire.nom }} {{ convocation.stagiaire.prenom }}"
data-action="{{ convocation.etat }}"
>
{% endif %}
<span id="badgeId-{{ convocation.id }}">
<span class="badge bg-{{ convocationEtat[convocation.etat-1].colors }}"><i class="bi {{ ico }}"></i> {{ convocationEtat[convocation.etat-1].intitule }}</span>
</span>
{% if formation.etat == 1 %}
</a>
{% endif %}
</div>
</div>
{% endfor %}
{% endif %}
</div>
{% if app.user.roles[0] != 'ROLE_CD' or app.user.roles[0] == 'ROLE_CFC' %}
{% if formation.etat == 1 and formation.formationInsciptions is not empty %}
<div class="text-end">
<a href="{{ path('convocations_generate', {'idFormation':formation.id}) }}" class="btn btn-primary btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="Seuls les stagiaires inscrits à cette formation pourront être convoqués">Convoquer</a>
</div>
{% endif %}
{% endif %}
{% if app.user.roles[0] != 'ROLE_CD' or app.user.roles[0] == 'ROLE_CFC' %}
<div id="zoneConvocationsTraitementsOk">
{% if traitementConvocProgress == true and convocations is not empty and ConvocAllClosed == false %}
<div class="alert alert-secondary mt-5 text-center" role="alert">
<h5><i class="bi bi-flag-fill"></i><br>Vous y êtes presque...</h5>
<div class="mt-3"><a href="{{ path('convocations_close_all', {'idFormation':formation.id})}}" class="btn btn-primary btn-xl" data-bs-toggle="tooltip" data-bs-placement="top" title="NB : il sera possible de rouvrir les convocations.">Clôturer toutes les convocations <i class="bi bi-play-circle-fill"></i></a></div>
</div>
{% endif %}
{% if ConvocAllClosed == true and formation.etat == 1 and convocations is not empty %}
<div class="alert alert-secondary mt-5 text-center" role="alert">
<h5><i class="bi bi-trophy fs-2"></i><br>Félicitations !<br>Toutes les convocations ont été traitées et clôturées.</h5>
<div class="mt-3"><a href="{{ path('formations_plages_construct', {'idFormation':formation.id})}}" class="btn btn-success btn-xl" data-bs-toggle="tooltip" data-bs-placement="top" title="Avertissement : il sera impossible de retourner dans l'état antérieur. Ne cliquez pas sur ce bouton si vous n'avez pas encore terminé de construire cette formation.">Démarrer la formation <i class="bi bi-play-circle-fill"></i></a></div>
</div>
{% endif %}
</div>
<div id="zoneConvocationsTraitementsRefresh" class="mt-3">
<div class="alert alert-secondary text-center">
<i class="bi bi-exclamation-triangle-fill fs-1 mb-3"></i>
<br>
<h5>Des modifications ont été effectuées sur les convocations. Veuillez recharger la page pour clôturer toutes les convocations ou démarrer la formation.</h5>
<br>
<a href="{{ path('formations_show_convocations', {'idFormation':formation.id}) }}" class="btn btn-primary"><i class="bi bi-arrow-clockwise"></i> Recharger</a>
</div>
</div>
{% endif %}
</p>
</div>
</div>
</div>
</div>
<div class="mb-5"></div>
<!-- MODALE POUR TRAITEMENT RAPIDE DES RÉPONSES AUX CONVOCATIONS -->
<div class="modal fade" id="modalTraiterReponseConvocation" tabindex="-1" aria-labelledby="modalTraiterReponseConvocation" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Traiter la réponse</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div id="modalZoneAttenteAjax">
<div class="spinner-border" role="status">
<span class="visually-hidden">Veuillez patienter...</span>
</div>
</div>
<div id="modalZoneFormulaire">
<div id="modalReponseConvocation_zoneHtml">
</div>
<form>
<select name="reponseId" id="reponseId" class="form-select mt-3">
{% for reponse in convocationsResponsesListe %}
<option value="{{ reponse.id }}">{{ reponse.intitule }}</option>
{% endfor %}
</select>
<textarea name="reponseObservations" id="reponseObservations" cols="30" rows="10" class="form-control mt-3" placeholder="Observations"></textarea>
</div>
<div id="reponseAlert" class="mt-3 alert alert-danger">Veuillez rouvrir la convocation afin de permettre la modification de la réponse !</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annuler</button>
<button id="modalTraiterReponseConvocation_BoutonConfirmer" type="button" class="btn btn-primary" data-idConvocation="">Enregistrer</button>
</div>
</div>
</div>
</div>
<!-- MODALE POUR TRAITEMENT RAPIDE DES CLÔTURES ET RÉOUVERTURES DES CONVOCATIONS -->
<div class="modal fade" id="modalCloturerConvocation" tabindex="-1" aria-labelledby="modalCloturerConvocation" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Clôturer la convocation</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="modalCloturerConvocation_zoneHtml">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annuler</button>
<button type="button" class="btn btn-primary" id="modalCloturerConvocation_BoutonConfirmer" data-idConvocation="">Confimer</button>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('#modalZoneAttenteAjax').hide();
$('#reponseAlert').hide();
$('#zoneConvocationsTraitementsRefresh').hide();
});
// TRAITEMENT RAPIDE DES REPONSES AUX COVOCATIONS
$('.buttonReponseConvocation').click(function() {
$('#modalZoneFormulaire').hide();
$('#modalZoneAttenteAjax').show();
var idConvocation = $(this).attr('data-idConvocation');
var valeurIdConvocation = $(this).attr('data-idConvocation');
var stagiaireNomPrenom = $(this).attr('data-NomPrenom');
var action = $(this).attr('data-action');
$('#modalTraiterReponseConvocation_BoutonConfirmer').attr('data-idConvocation', idConvocation);
var message = '<strong>'+stagiaireNomPrenom+'</strong> ('+idConvocation+')';
$.ajax({
method: "POST",
url: "{{ path('convocations_ajax_stagiaireReponseData') }}",
data: { idConvocation: valeurIdConvocation }
})
.done(function( msg ) {
if(msg != 'vide') {
msg = JSON.parse(msg);
var id = msg['id'];
var observations = msg['observations'];
$('#reponseId option[value="'+id+'"').prop('selected', true);
$('#reponseObservations').val(observations);
if(msg['etat'] !=1 ) {
$('#reponseId').attr('disabled', true);
$('#reponseObservations').attr('disabled', true);
$('#modalTraiterReponseConvocation_BoutonConfirmer').attr('disabled', true);
$('#reponseAlert').show();
}
else {
$('#reponseId').attr('disabled', false);
$('#reponseObservations').attr('disabled', false);
$('#modalTraiterReponseConvocation_BoutonConfirmer').attr('disabled', false);
$('#reponseAlert').hide();
}
}
$('#modalZoneAttenteAjax').hide();
$('#modalZoneFormulaire').show()
});
$('#modalReponseConvocation_zoneHtml').html(message);
});
$('#modalTraiterReponseConvocation_BoutonConfirmer').click(function() {
$('#modalZoneFormulaire').hide();
$('#modalZoneAttenteAjax').show();
var valeurReponseId = $('#reponseId').val();
var valeurReponseObservations = $('#reponseObservations').val();
valeurIdConvocation = $('#modalTraiterReponseConvocation_BoutonConfirmer').attr('data-idConvocation');
$.ajax({
method: "POST",
url: "{{ path('convocations_ajax_stagiaireReponse_enregistrer') }}",
data: { 'idConvocation': valeurIdConvocation, 'reponseId': valeurReponseId, 'reponseObservations': valeurReponseObservations }
})
.done(function( msg ) {
msg = JSON.parse(msg);
badgeColor = msg['color'];
badgeIntitule = msg['intitule'];
$('#badgeResponse-'+valeurIdConvocation).attr('class', 'badge bg-'+badgeColor);
$('#badgeResponse-'+valeurIdConvocation).html(badgeIntitule);
$('#modalTraiterReponseConvocation').modal('hide');
});
});
// TRAITEMENT RAPIDE DES CLÔTURES ET RÉOUVERTURE DES CONVOCATIONS AVEC MODALE
$('.buttonCloturerConvocation').click(function() {
var idConvocation = $(this).attr('data-idConvocation');
var stagiaireNomPrenom = $(this).attr('data-NomPrenom');
var action = $(this).attr('data-action');
$('#modalCloturerConvocation_BoutonConfirmer').attr('data-idConvocation', idConvocation);
// $('this').attr('data-badge', 1);
if(action == 1) {
var message = 'Vous êtes sur le point de clôturer la convocation de :<br><br><strong>'+stagiaireNomPrenom+'</strong> ('+idConvocation+')';
}
else {
var message = 'Vous êtes sur le point de rouvrir la convocation de :<br><br><strong>'+stagiaireNomPrenom+'</strong> ('+idConvocation+')';
}
$('#modalCloturerConvocation_zoneHtml').html(message);
});
$('#modalCloturerConvocation_BoutonConfirmer').click(function(){
var valeurIdConvocation = $(this).attr('data-idConvocation');
$.ajax({
method: "POST",
url: "{{ path('convocations_ajax_enclose') }}",
data: { idConvocation: valeurIdConvocation }
})
.done(function( msg ) {
msg = JSON.parse(msg);
badgeColor = msg['color'];
badgeIntitule = msg['intitule'];
$('#badgeId-'+valeurIdConvocation).attr('class', 'badge bg-'+badgeColor);
$('#badgeId-'+valeurIdConvocation).html(badgeIntitule);
$('#modalCloturerConvocation').modal('hide');
$('#zoneConvocationsTraitementsRefresh').show();
$('#zoneConvocationsTraitementsOk').hide();
});
});
</script>
{% endblock %}