Commit 27ee9849 authored by Chrystel Moreau's avatar Chrystel Moreau
Browse files

BUG inscription ssi non depassement du quota => DONE

parent 0d4a45d8
......@@ -30,15 +30,11 @@ final class DashboardParticipantParcoursFormationAction
$valid = $params['valid'];
$roleSI = $request->getAttribute('roleSI');
//if ( ($roleSI == 'admin') || ($roleSI == 'clo_pgm') ){
// $id_participant = $params['id'];
// $participant = $this->em->find('App\Entity\Participant', $params['id']);
//}
//else {
$email = $request->getAttribute('email');
$participant = $this->getParticipant($email);
$id_participant=(int)$participant->getId();
//}
// Recuperation du participant
$email = $request->getAttribute('email');
$participant = $this->getParticipant($email);
$id_participant=(int)$participant->getId();
// Suppression de l'inscription à la formation
if ($valid == 'false') {
......@@ -47,20 +43,29 @@ final class DashboardParticipantParcoursFormationAction
$this->em->remove($inscription[0]);
$this->em->flush();
}
// Inscription à la formation
if ($valid == 'true') {
$allParticipantAgenda = $this->getParcours($params['jour'], $params['debut'], $params['fin'], $id_participant);
$agenda=$this->getAgenda($id_agenda);
if(count($allParticipantAgenda) < 1 || $agenda[0]->getFormation()->getType() == 'Groupe de Travail') {
$inscription = new \App\Entity\ParticipantAgenda();
$inscription->setParticipant($participant);
$inscription->setAgenda($agenda[0]);
date_default_timezone_set('UTC');
$ladate=date_create_from_format('Y-m-d H:i:s', date("Y-m-d H:i:s"));
$inscription->setDateInscription($ladate);
$quota=(int)$agenda[0]->getFormation()->getQuota();
$nb_inscrits=count($this->getInscritsAgenda($id_agenda));
// verification du nb inscrits par rapport au quota
if ($nb_inscrits != $quota) {
// verification du nb d'inscription par 1/2 journée
if(count($allParticipantAgenda) < 1 || $agenda[0]->getFormation()->getType() == 'Groupe de Travail') {
$inscription = new \App\Entity\ParticipantAgenda();
$inscription->setParticipant($participant);
$inscription->setAgenda($agenda[0]);
date_default_timezone_set('UTC');
$ladate=date_create_from_format('Y-m-d H:i:s', date("Y-m-d H:i:s"));
$inscription->setDateInscription($ladate);
$this->em->persist($inscription);
$this->em->flush();
$this->em->persist($inscription);
$this->em->flush();
}
}
}
......@@ -121,6 +126,10 @@ final class DashboardParticipantParcoursFormationAction
return $query->getResult();
}
public function getInscritsAgenda($id_agenda) {
$dql = "select pa from App\Entity\ParticipantAgenda pa where pa.agenda=$id_agenda";
$query = $this->em->createQuery($dql);
return $query->getResult();
}
}
......@@ -13,13 +13,13 @@
<div id="tabs_agenda" hidden>
<ul>
{% if role_si != 'clo'%}
{% if role_si == 'admin' %}
<li><a href="#tabs_agenda_gestion" active>Gestion de l'agenda</a></li>
{% endif %}
<li><a href="#tabs_agenda_visu">Visualisation complète de l'agenda</a></li>
</ul>
{% if role_si != 'clo'%}
{% if role_si == 'admin'%}
<div id="tabs_agenda_gestion">
<div class="row">
<a href="dashboard-admin-agenda-form?token={{ token }}" class="btn btn-treehouse pull-right">Ajouter une session dans l'Agenda</a>
......
......@@ -183,7 +183,7 @@
{% set prct = ((agenda.nb_inscrits / quota) * 100) | round %}
<span class="badge badge-{% if prct <= 50 %}vert{% elseif prct > 50 and prct <= 75 %}orange{% else %}rouge{% endif %}">{{ prct }}%</span>
</td>
<td class="text-center">
<td class="text-center" id="action_{{ id_agenda }}">
{% if agenda.check == 0 %}
{% if nb_inscriptions > 1 %}
{% elseif inscription and inscription.getAgenda().getFormation().getType() != 'Groupe de Travail' %}
......@@ -192,6 +192,7 @@
or (agenda['agenda'].getDateDebut() == inscription.getAgenda().getDateDebut() and agenda['agenda'].getDateFin() == inscription.getAgenda().getDateFin()))
%}
{% else %}
<input type="hidden" id="vinscrit" name="vinscrit" value="2">
<a href="dashboard-participant-parcours-formation?token={{token}}&agenda={{id_agenda}}&valid=true&jour={{jour}}&debut={{debut}}&fin={{fin}}"
class="btn btn-success btn-inscription-formation"
data-toggle="tooltip" title="S'inscrire à cette formation">S'inscrire
......@@ -199,6 +200,7 @@
{% endif %}
{% else %}
Inscrit &nbsp;
<input type="hidden" id="vinscrit" name="vinscrit" value="1">
<a href="dashboard-participant-parcours-formation?token={{token}}&agenda={{id_agenda}}&valid=false"
class="btn fa fa-times btn-danger btn-delete-inscription-formation"
data-toggle="tooltip" title="Se Désinscrire de cette formation">
......
......@@ -182,7 +182,7 @@
{% set prct = ((agenda.nb_inscrits / quota) * 100) | round %}
<span class="badge badge-{% if prct <= 50 %}vert{% elseif prct > 50 and prct <= 75 %}orange{% else %}rouge{% endif %}">{{ prct }}%</span>
</td>
<td class="text-center">
<td class="text-center" id="action_{{ id_agenda }}">
{% if agenda.check == 0 %}
{% if nb_inscriptions > 1 %}
{% elseif inscription and inscription.getAgenda().getFormation().getType() != 'Groupe de Travail' %}
......@@ -191,13 +191,15 @@
or (agenda['agenda'].getDateDebut() == inscription.getAgenda().getDateDebut() and agenda['agenda'].getDateFin() == inscription.getAgenda().getDateFin()))
%}
{% else %}
<input type="hidden" id="vinscrit" name="vinscrit" value="2">
<a href="dashboard-participant-parcours-formation?token={{token}}&agenda={{id_agenda}}&valid=true&jour={{jour}}&debut={{debut}}&fin={{fin}}"
class="btn btn-success btn-inscription-formation"
data-toggle="tooltip" title="S'inscrire à cette formation">S'inscrire
</a>
</a>
{% endif %}
{% else %}
Inscrit &nbsp;
<input type="hidden" id="vinscrit" name="vinscrit" value="1">
<a href="dashboard-participant-parcours-formation?token={{token}}&agenda={{id_agenda}}&valid=false"
class="btn fa fa-times btn-danger btn-delete-inscription-formation"
data-toggle="tooltip" title="Se Désinscrire de cette formation">
......
......@@ -1057,6 +1057,14 @@ var refreshAllSessions = function(token) {
$('#nb_inscrits_prct_' + agenda.id).attr('class', 'badge badge-' + badge);
$('#nb_inscrits_prct_' + agenda.id).text(prct + '%');
//$('#nb_inscrits_prct_' + agenda.id).html('<span class="badge badge-' + badge + '">' + prct + '%</span>');
if (agenda.nb_inscrits >= agenda.quota){
if ( $('#vinscrit').val() != 1) { $('#action_' + agenda.id).hide();}
}
else {
$('#action_' + agenda.id).show();
}
});
},
error: function() {
......
......@@ -217,6 +217,12 @@ var refreshSessions = function(token, jour, debut, fin) {
badge = 'rouge';
}
$('#nb_inscrits_prct_' + agenda.id).html('<span class="badge badge-' + badge + '">' + prct + '%</span>');
if (agenda.nb_inscrits >= agenda.quota){
if ( $('#vinscrit').val() != 1) { $('#action_' + agenda.id).hide();}
}
else {
$('#action_' + agenda.id).show();
}
});
},
error: function() {
......
......@@ -176,7 +176,7 @@
.btn-session {
margin-bottom: 5px;
width: 80%;
width: 70%;
}
.btn-pre-session {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment