Commit 4f62c3a9 authored by Chrystel Moreau's avatar Chrystel Moreau
Browse files

gestion Parcours en mode Graphe => DONE

parent e2e81012
......@@ -46,9 +46,12 @@ final class DashboardParticipantParcoursAction
$inscription = $this->getInscriptionAgenda($params['jour'],$params['debut'],$params['fin'],$participant->getId());
$a['inscription'] = $inscription;
$response = $response->write(json_encode($agendas))->withHeader('Content-type', 'application/json');
}
$this->view->render($response, 'dashboard_participant_parcours.twig', $a);
else {
$this->view->render($response, 'dashboard_participant_parcours.twig', $a);
}
return $response;
}
......@@ -72,9 +75,10 @@ final class DashboardParticipantParcoursAction
$date_debut=$jour." ".$debut;
$date_fin=$jour." ".$fin;
$dql = "SELECT a,";
//$dql .= "(select count(pa) from App\Entity\ParticipantAgenda pa where pa.agenda=a.id) as nb_inscrits, ";
$dql .= "(select count(p2) from App\Entity\ParticipantAgenda p2 where p2.agenda=a.id and p2.participant=$id) as check ";
$dql = "SELECT a as agenda, ";
$dql .= "(select count(pa) from App\Entity\ParticipantAgenda pa where pa.agenda=a.id) as nb_inscrits, ";
$dql .= "(select count(p2) from App\Entity\ParticipantAgenda p2 where p2.agenda=a.id and p2.participant=$id) as check, ";
$dql .= "(select count(p3) from App\Entity\ParticipantAgenda p3 LEFT JOIN p3.agenda ag where p3.participant=$id and ag.dateDebut between '$date_debut' and '$date_fin' and ag.dateFin between '$date_debut' and '$date_fin' as inscrit ";
$dql .= "FROM App\Entity\Agenda a ";
$dql .= "WHERE a.dateDebut between '$date_debut' and '$date_fin' and a.dateFin between '$date_debut' and '$date_fin'";
$query = $this->em->createQuery($dql);
......
<?php
namespace App\Action;
use Slim\Views\Twig;
use Psr\Log\LoggerInterface;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
final class ParticipantSondageFormationAction
{
private $view;
private $logger;
private $em;
public function __construct(Twig $view, LoggerInterface $logger, EntityManagerInterface $em)
{
$this->view = $view;
$this->logger = $logger;
$this->em = $em;
}
public function __invoke(Request $request, Response $response, $args)
{
$this->logger->info("dashboard page action dispatched");
$params = $request->getQueryParams();
$token = $params['token'];
$id_agenda = (int) $params['agenda'];
$valid = $params['valid'];
$email = $request->getAttribute('email');
$participant = $this->getParticipant($email);
$id_participant=(int)$participant->getId();
// Suppression de l'inscription à la formation
if ($valid == 'false') {
$inscription = $this->getInscriptionAgenda($id_participant,$id_agenda);
$this->em->remove($inscription[0]);
$this->em->flush();
}
// Inscription à la formation
if ($valid == 'true') {
$agenda=$this->getAgenda($id_agenda);
$inscription = new \App\Entity\ParticipantAgenda();
$inscription->setParticipant($participant);
$inscription->setAgenda($agenda[0]);
$ladate=date_create_from_format('d/m/Y H:i', '04/07/17 14:00');
$inscription->setDateInscription($ladate);
$this->em->persist($inscription);
$this->em->flush();
}
$this->view->render($response, 'dashboard_sondage.twig', [
'page' => 'dashboard',
'token' => $token,
'participant' => $participant
]);
return $response;
}
private function getParticipant($email)
{
$participant = $this->em->getRepository('App\Entity\Participant')->findOneBy(array('email' => $email));
if(isset($participant)) {
return $participant;
} else {
return false;
}
}
public function getInscriptionAgenda($id_participant,$id_agenda) {
$dql = "SELECT pa FROM App\Entity\ParticipantAgenda pa WHERE pa.participant=$id_participant AND pa.agenda=$id_agenda";
$query = $this->em->createQuery($dql);
return $query->getResult();
}
private function getAgenda($id_agenda)
{
$dql = "SELECT a FROM App\Entity\Agenda a WHERE a.id=$id_agenda";
$query = $this->em->createQuery($dql);
return $query->getResult();
}
}
......@@ -5,7 +5,7 @@ namespace App\Entity;
* @Entity
* @Table(name="agenda")
*/
class Agenda
class Agenda implements \JsonSerializable
{
/**
* @Id
......@@ -94,4 +94,18 @@ class Agenda
{
return $this->participants;
}
public function jsonSerialize()
{
return array(
'id' => $this->id,
'date_formation' => $this->dateDebut->format('d M Y A'),
'debut_formation' => $this->dateDebut->format('H:i:s'),
'fin_formation' => $this->dateFin->format('H:i:s'),
'nom_formation' => $this->formation->getNom(),
'quota_formation' => $this->formation->getQuota(),
'salle' => $this->salle->getNom()
);
}
}
......@@ -82,10 +82,8 @@
<script src="js/admin.js"></script>
<script src="js/clo_admin.js"></script>
<!--
<script src="js/Chart.js"></script>
-->
<script src="js/participant.js"></script>
</body>
</html>
......@@ -3,19 +3,20 @@
{% block content_dashboard %}
<div class="content-dashboard">
<div class="title-main">
<div class="title-main-content">Création du parcours de formation</div>
<div class="title-main-content">Création de votre parcours de formation</div>
</div>
<div>
<div id="seances">
Vous devez selectionner une demi-journée.<p>
Vous devez selectionner une demi-journée pour visualier les sessions de formation.<p>
<form id="form_inscription">
<input type="hidden" id="token" name="token" value="{{ token }}">
<input type="hidden" id="token" name="token" value="{{ token }}">
<table width='100%'>
<tr>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-04&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour">04 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-04&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour" value="04 Juillet 2017 - Matin">04 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-05&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour">05 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-06&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour">06 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-07&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour">07 Juillet 2017 - Matin</a></td>
......@@ -27,74 +28,36 @@
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-07&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block btn-jour">07 Juillet 2017 - Après-Midi</a></td>
</tr>
</table>
</form>
</div>
<hr>
<div class="panel panel-default" id="inscription">
<div class="panel-heading" id="panel-inscription">Liste des Sessions proposées le {{ jour }}</div>
<div class="panel-body">
<div>
{% if agendas %}
<table id="tab_agenda" class="table table-striped table-bordered">
<thead>
<tr>
<th width="10%">Session</th>
<th width="10%">Intervenant</th>
<th width="10%">Salle</th>
<th width="5%">Début</th>
<th width="5%">Fin</th>
<th width="10%" class="text-center">Action</th>
</tr>
</thead>
<tbody>
{% set quota = 0 %}
{% set id_agenda = 0 %}
{% for agenda in agendas %}
<tr>
{% for a in agenda | slice (0,1)%}
{% set quota=a.getFormation().getQuota() %}
{% set id_agenda=a.getId() %}
<td>{{ a.getFormation().getNom() }}</td>
<td>{{ a.getFormation().getIntervenant() }}</td>
<td>{{ a.getSalle.getNom() }}</td>
<td>{{ a.getDateDebut() | date("H:i") }}</td>
<td>{{ a.getDateFin() | date("H:i") }}</td>
{% endfor %}
<td class="text-center">
{% if agenda.check == 0 %}
{% if inscription %}
{% else %}
<a href="dashboard-participant-parcours-formation?token={{token}}&agenda={{id_agenda}}&valid=true"
class="btn btn-success btn-inscription-formation"
data-toggle="tooltip" title="S'inscrire à cette formation">S'inscrire
</a>
{% endif %}
{% else %}
Inscrit &nbsp;
<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">
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
{% endif %}
</div>
<!--
<canvas id="plot" data-type="Line" width="500" height="350"></canvas>
-->
<div class="panel panel-default" id="inscription" style="display:none">
<div class="panel-heading" id="panel-inscription"></div>
<div class="panel-body">
<div id="chart-legend" class="chart-legend"></div>
<canvas id="plot" data-type="Line" width="500" height="350"></canvas>
</div>
</div>
<div class="modal fade" id="participant_inscription" role="dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="titre_modal"></h4>
</div>
<div class="modal-body" id="body_modal">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends "base_dashboard.twig" %}
{% block content_dashboard %}
<div class="content-dashboard">
<div class="title-main">
<div class="title-main-content">Création de votre parcours de formation</div>
</div>
<div>
<div id="seances">
Vous devez selectionner une demi-journée pour visualier les sessions de formation.<p>
<form id="form_inscription">
<input type="hidden" id="token" name="token" value="{{ token }}">
<table width='100%'>
<tr>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-04&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour" value="04 Juillet 2017 - Matin">04 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-05&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour">05 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-06&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour">06 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-07&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour">07 Juillet 2017 - Matin</a></td>
</tr>
<tr>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-04&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block btn-jour">04 Juillet 2017 - Après-Midi</a></td>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-05&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block btn-jour">05 Juillet 2017 - Après-Midi</a></td>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-06&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block btn-jour">06 Juillet 2017 - Après-Midi</a></td>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour=2017-07-07&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block btn-jour">07 Juillet 2017 - Après-Midi</a></td>
</tr>
</table>
</form>
</div>
<hr>
<div class="panel panel-default" id="inscription">
<div class="panel-heading" id="panel-inscription"></div>
<div class="panel-body">
<!-- Version table
<div>
{% if agendas %}
<table id="tab_agenda" class="table table-striped table-bordered">
<thead>
<tr>
<th width="10%">Session</th>
<th width="10%">Intervenant</th>
<th width="10%">Salle</th>
<th width="5%">Début</th>
<th width="5%">Fin</th>
<th width="5%">Nb Inscrits</th>
<th width="5%">Taux</th>
<th width="10%" class="text-center">Action</th>
</tr>
</thead>
<tbody>
{% for agenda in agendas %}
{% set quota = 0 %}
{% set id_agenda = 0 %}
{% set inscrits = 0 %}
<tr>
{% for a in agenda | slice (0,1)%}
{% set quota=a.getFormation().getQuota() %}
{% set id_agenda=a.getId() %}
<td>{{ a.getFormation().getNom() }}</td>
<td>{{ a.getFormation().getIntervenant() }}</td>
<td>{{ a.getSalle.getNom() }}</td>
<td>{{ a.getDateDebut() | date("H:i") }}</td>
<td>{{ a.getDateFin() | date("H:i") }}</td>
{% endfor %}
<td>{{ agenda.nb_inscrits }} / {{ quota }}</td>
<td>{{ ((agenda.nb_inscrits / quota) * 100) | round }}</td>
<td class="text-center">
{% if agenda.check == 0 %}
{% if inscription %}
{% else %}
<a href="dashboard-participant-parcours-formation?token={{token}}&agenda={{id_agenda}}&valid=true"
class="btn btn-success btn-inscription-formation"
data-toggle="tooltip" title="S'inscrire à cette formation">S'inscrire
</a>
{% endif %}
{% else %}
Inscrit &nbsp;
<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">
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
{% endif %}
</div>
-->
<!-- Version ChartJS -->
<div id="chart-legend" class="chart-legend"></div>
<canvas id="plot" data-type="Line" width="500" height="350"></canvas>
</div>
</div>
<div class="modal fade" id="participant_inscription" role="dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="titre_modal"></h4>
</div>
<div class="modal-body" id="body_modal">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
</div>
{% endblock %}
\ No newline at end of file
......@@ -15,16 +15,16 @@
<input type="hidden" id="token" name="token" value="{{ token }}">
<table width='100%'>
<tr>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-04&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour">04 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-05&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour">05 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-06&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour">06 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-07&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour">07 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-04&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block">04 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-05&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block">05 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-06&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block">06 Juillet 2017 - Matin</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-07&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block">07 Juillet 2017 - Matin</a></td>
</tr>
<tr>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-04&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block btn-jour">04 Juillet 2017 - Après-Midi</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-05&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block btn-jour">05 Juillet 2017 - Après-Midi</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-06&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block btn-jour">06 Juillet 2017 - Après-Midi</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-07&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block btn-jour">07 Juillet 2017 - Après-Midi</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-04&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block">04 Juillet 2017 - Après-Midi</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-05&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block">05 Juillet 2017 - Après-Midi</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-06&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block">06 Juillet 2017 - Après-Midi</a></td>
<td><a href="dashboard-participant-sondage?token={{ token }}&jour=2017-07-07&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block">07 Juillet 2017 - Après-Midi</a></td>
</tr>
</table>
</form>
......@@ -42,7 +42,6 @@
<tr>
<th width="10%">Session</th>
<th width="10%">Intervenant</th>
<th width="10%">Salle</th>
<th width="5%">Début</th>
<th width="5%">Fin</th>
<th width="10%" class="text-center">Action</th>
......@@ -58,7 +57,6 @@
{% set id_preagenda=a.getId() %}
<td>{{ a.getFormation().getNom() }}</td>
<td>{{ a.getFormation().getIntervenant() }}</td>
<td>{{ a.getSalle.getNom() }}</td>
<td>{{ a.getDateDebut() | date("H:i") }}</td>
<td>{{ a.getDateFin() | date("H:i") }}</td>
{% endfor %}
......
......@@ -44,22 +44,7 @@ $(document).ready(function(){
"render": function (data) {
return "<b><a href=\"http://devlog.cnrs.fr/jdev2017/" + data + "\" target=_blank><i class=\"fa fa-external-link\"></i> " + data.toUpperCase()+"</a></b>";
}
},
//{
// "targets" : 6,
// "render": function (data) {
// if (data < 50){
// return "<span class=\"label label-success\">" + data + "%</span>";
// }
// if ((data => 50) && (data < 75)){
// return "<span class=\"label label-warning\">" + data + "%</span>";
// }
// if (data => 75){
// return "<span class=\"label label-danger\">" + data + "%</span>";
// }
// }
//}
}
]
});
......@@ -100,31 +85,159 @@ $(document).ready(function(){
}
});
$('#tab_agenda').DataTable({
"columnDefs":[
{
"targets" : 0,
"render": function (data) {
return "<b><a href=\"http://devlog.cnrs.fr/jdev2017/" + data + "\" target=_blank><i class=\"fa fa-external-link\"></i> " + data.toUpperCase()+"</a></b>";
}
// Gestion via ChartJS
var ctx = document.getElementById("plot");
var myBarChart=null;
var dataChart=[];
var letoken=$("#token").val();
$('.btn-jour').on('click', function(e) {
e.preventDefault();
var T_inscrits =[];
var T_quota =[];
var T_backcolor=[];
var T_labels=[];
var valeur_test=0;
if(myBarChart!=null){
myBarChart.destroy();
}
$.ajax({
url: $(this).attr('href'),
type: 'GET',
dataType:'json',
success: function(data) {
dataChart=data;
//console.log(data);
if (data.length > 0){
$.each(data, function(ag, agendas){
valeur_test=(agendas.nb_inscrits/agendas.agenda.quota_formation)*100;
if (valeur_test>100) valeur_test=100;
T_inscrits.push(valeur_test);
T_quota.push(100-valeur_test);
if (valeur_test<25){ T_backcolor.push('rgba(78, 150, 15, 0.9)');}
else if(valeur_test<50){T_backcolor.push('rgba(251, 174, 20, 0.9)');}
else{ T_backcolor.push('rgba(251, 55, 20, 0.9)');};
//T_labels.push(agendas.agenda.nom_formation+' (inscrits='+agendas.nb_inscrits+'/quota='+agendas.agenda.quota_formation+')');
if (agendas.check){
T_labels.push('(inscrit) '+agendas.agenda.nom_formation);
}
else {
T_labels.push(agendas.agenda.nom_formation);
}
});
var barChartData = {
labels:T_labels,
datasets: [
{
label: 'Inscrits',
data: T_inscrits,
backgroundColor:T_backcolor,
borderColor:T_backcolor
},
{
label: 'Places libres',
//backgroundColor: "rgba(151,187,205,0.5)",
backgroundColor: "rgba(218,215,215,0.5)",
data: T_quota
}]
};
myBarChart= new Chart(ctx, {
type:'horizontalBar', // 'bar',
data: barChartData,
options: {
tooltips: {
mode: 'label',
callbacks: {
title: function(tooltipItems, data) {
return data.labels[tooltipItems[0].index];
},
label: function(tooltipItem, data) {
return data.datasets[tooltipItem.datasetIndex].label +' '+tooltipItem.xLabel+'%';
},
}
},
responsive: true,
scales: {
xAxes: [{
stacked: true,
ticks: {
callback: function(value) { return value+'%'; }
}
}],
yAxes: [{
stacked: true,
maxRotation: 60
}]
}
}
});
}
else {
console.log('pas de data');
}
},
error: function() {
alert('PB inscription');
}
});
//{