Commit 0de5aaf1 authored by Chrystel Moreau's avatar Chrystel Moreau
Browse files

gestion inscription (debut)

parent 6b975625
......@@ -64,6 +64,10 @@ $container[App\Action\DashboardInscriptionAction::class] = function ($c) {
return new App\Action\DashboardInscriptionAction($c->get('view'), $c->get('logger'), $c->get('em'));
};
$container[App\Action\DashboardInscriptionFormationAction::class] = function ($c) {
return new App\Action\DashboardInscriptionFormationAction($c->get('view'), $c->get('logger'), $c->get('em'));
};
$container[App\Action\DashboardParcoursAction::class] = function ($c) {
return new App\Action\DashboardParcoursAction($c->get('view'), $c->get('logger'), $c->get('em'));
};
......
......@@ -47,6 +47,10 @@ $app->get('/dashboard-inscription', App\Action\DashboardInscriptionAction::class
->add(App\Middleware\TokenMiddleware::class)
->setName('dashboard_inscription');
$app->post('/dashboard-inscription-formation', App\Action\DashboardInscriptionFormationAction::class)
->add(App\Middleware\TokenMiddleware::class)
->setName('dashboard_inscription_formation');
$app->get('/dashboard-parcours', App\Action\DashboardParcoursAction::class)
->add(App\Middleware\TokenMiddleware::class)
->setName('dashboard_parcours');
......
......@@ -24,16 +24,16 @@ final class DashboardAction
{
$this->logger->info("dashboard page action dispatched");
$params = $request->getQueryParams();
$token = $params['token'];
$email = $request->getAttribute('email');
$params = $request->getQueryParams();
$token = $params['token'];
$email = $request->getAttribute('email');
$participant = $this->getParticipant($email);
$participant = $this->getParticipant($email);
$this->view->render($response, 'dashboard_home.twig', [
'page' => 'dashboard',
'token' => $token,
'participant' => $participant
'token' => $token,
'participant' => $participant
]);
return $response;
......
......@@ -57,7 +57,7 @@ final class DashboardAdminAddEditSalleAction
$this->em->persist($salle);
$this->em->flush();
$response = $response->write('Nouvel salle enregistrée')->withStatus(201);
$response = $response->write('Nouvelle salle enregistrée')->withStatus(201);
}
if($request->isPut()) {
......
......@@ -9,37 +9,57 @@ use Psr\Http\Message\ResponseInterface as Response;
final class DashboardInscriptionAction
{
private $view;
private $logger;
private $em;
public function __construct(Twig $view, LoggerInterface $logger, EntityManagerInterface $em)
{
$this->view = $view;
$this->logger = $logger;
$this->em = $em;
}
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)
public function __invoke(Request $request, Response $response, $args)
{
$this->logger->info("dashboard-inscription page action dispatched");
$params = $request->getQueryParams();
$token = $params['token'];
$email = $request->getAttribute('email');
$params = $request->getQueryParams();
$token = $params['token'];
$email = $request->getAttribute('email');
$participant = $this->getParticipant($email);
$a = [
'page' => 'dashboard-inscription',
'token' => $token,
'participant' => $participant
];
$participant = $this->getParticipant($email);
if (array_key_exists('jour', $params)) {
$j=explode("-",$params['jour']);
if ($params['debut'] == '08:00:00'){ $a['jour'] = $j[2].' Juillet 2017 - Matin';}
if ($params['debut'] == '13:00:00'){ $a['jour'] = $j[2].' Juillet 2017 - Après-midi';}
$agendas = $this->getAgendas($params['jour'],$params['debut'],$params['fin']);
$a['agendas'] = $agendas;
//var_dump($agendas);
//exit();
//foreach ($agendas as $agenda){
// $inscriptions = $this->getInscriptionAgenda($agenda->getId());
//}
//$a['inscriptions'] = $inscriptions;
}
$this->view->render($response, 'dashboard_inscription.twig', [
'page' => 'dashboard-inscription',
'token' => $token,
'participant' => $participant
]);
$this->view->render($response, 'dashboard_inscription.twig', $a);
return $response;
}
private function getParticipant($email)
private function getParticipant($email)
{
$participant = $this->em->getRepository('App\Entity\Participant')->findOneBy(array('email' => $email));
if(isset($participant)) {
......@@ -48,4 +68,23 @@ final class DashboardInscriptionAction
return false;
}
}
public function getAgendas($jour,$debut,$fin) {
$date_debut=$jour." ".$debut;
$date_fin=$jour." ".$fin;
$dql = "SELECT a,(select count(pa) from App\Entity\ParticipantAgenda pa where pa.agenda=a.id) as nb_inscrits 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);
return $query->getResult();
}
public function getInscriptionAgenda($id_agenda) {
//$dql = "SELECT a FROM App\Entity\ParticipantAgenda a LEFT JOIN a.participants p WHERE a.agenda = $id_agenda";
$dql = "SELECT count(pa) FROM App\Entity\ParticipantAgenda pa WHERE pa.agenda = $id_agenda";
$query = $this->em->createQuery($dql);
return $query->getArrayResult();
}
}
<?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 ParticipantInscriptionFormationAction
{
private $view;
private $logger;
private $em;
private $mailer;
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("inscription formation page action dispatched");
$params = $request->getQueryParams();
$token = $params['token'];
$email = $request->getAttribute('email');
$participant = $this->getParticipant($email);
$a = [
'page' => 'dashboard-inscription-formation',
'token' => $token,
'participant' => $participant
];
$participant = $this->getParticipant($params['email']);
if (!$participant) {
return $response->withStatus(400);
}
$inscription = new \App\Entity\ParticipantAgenda();
$inscription->setParticipant($participant->getId());
$this->em->persist($inscription);
$this->em->flush();
$response = $response->write('Inscription éffectuée')->withStatus(201);
}
private function getParticipant($email)
{
$participant = $this->em->getRepository('App\Entity\Participant')->findOneBy(array('email' => $email));
if(isset($participant)) {
return $participant;
} else {
return false;
}
}
}
......@@ -84,7 +84,8 @@
<!--
<script src="js/Chart.js"></script>
<script src="js/participant.js"></script>
-->
<script src="js/participant.js"></script>
</body>
</html>
......@@ -3,7 +3,7 @@
{% block title %}Participant{% endblock %}
{% block content %}
<div class="container">
<!--
<nav class="hidden-xs hidden-sm navbar-dashboard">
<h3 class="navbar-dashboard-item-title">Dashboard Menu</h3>
<ul class="navbar-dashboard-item-list">
......@@ -18,7 +18,7 @@
</li>
</ul>
</nav>
-->
{% block content_dashboard %}{% endblock %}
......
......@@ -9,7 +9,7 @@
<div>
<a href="dashboard-admin-agenda-form?token={{ token }}" class="btn btn-treehouse pull-right">Ajouter une session dans l'Agenda</a>
<h4><i class="fa fa-list-alt"></i> Liste de l'Agenda des sessions de formation</h4>
<h4><i class="fa fa-list-alt"></i> Agenda des sessions de formation</h4>
<br>
{% if agendas %}
......@@ -17,7 +17,7 @@
<table id="gformations" class="table table-striped table-bordered">
<thead>
<tr>
<th width="10%">Formation</th>
<th width="10%">Session</th>
<th width="10%">Salle</th>
<th width="5%">Date</th>
<th width="5%">Début</th>
......@@ -30,7 +30,7 @@
<tr>
<td>{{ agenda.getFormation().getNom() }}</td>
<td>{{ agenda.getSalle.getNom() }}</td>
<td>{{ agenda.getDateDebut() | date("d/m") }}</td>
<td>{{ agenda.getDateDebut() | date("d/m/y") }}</td>
<td>{{ agenda.getDateDebut() | date("H:i") }}</td>
<td>{{ agenda.getDateFin() | date("H:i") }}</td>
<td class="text-center">
......@@ -51,7 +51,7 @@
</table>
</div>
{% else %}
<p>Pas encore de d'Agenda</p>
<p>Pas encore d'Agenda</p>
{% endif %}
</div>
</div>
......
......@@ -6,7 +6,7 @@
<div class="title-main-content">S'inscrire aux sessions de formation</div>
</div>
<div id="inscription">
<div>
<!--
<p style="text-align: center"><i class="fa fa-calendar"></i> <i>ouverture des inscriptions aux ateliers
à partir du 30 avril 2017</i>
......@@ -15,29 +15,71 @@
<div id="seances">
Pour vous inscrire, vous devez selectionner une demi-journée.<p>
<table width='100%'>
<tr>
<td><a id="seance04-am" href = "#" class="btn btn-info btn-sm btn-block" role ="button">04 Juillet 2017 - Matin</a></td>
<td><a id="seance05-am" href = "#" class="btn btn-info btn-sm btn-block" role ="button">05 Juillet 2017 - Matin</a></td>
<td><a id="seance06-am" href = "#" class="btn btn-info btn-sm btn-block" role ="button">07 Juillet 2017 - Matin</a></td>
<td><a id="seance07-am" href = "#" class="btn btn-info btn-sm btn-block" role ="button">08 Juillet 2017 - Matin</a></td>
</tr>
<tr>
<td><a id="seance04-pm" href = "#" class="btn btn-primary btn-sm btn-block" role ="button">04 Juillet 2017 - Matin</a></td>
<td><a id="seance05-pm" href = "#" class="btn btn-primary btn-sm btn-block" role ="button">05 Juillet 2017 - Matin</a></td>
<td><a id="seance06-pm" href = "#" class="btn btn-primary btn-sm btn-block" role ="button">06 Juillet 2017 - Matin</a></td>
<td><a id="seance07-pm" href = "#" class="btn btn-primary btn-sm btn-block" role ="button">07 Juillet 2017 - Matin</a></td>
</tr>
</table>
<form id="form_inscription">
<input type="hidden" id="token" name="token" value="{{ token }}">
<table width='100%'>
<tr>
<td><a href="dashboard-inscription?token={{ token }}&jour=2017-07-04&debut=08:00:00&fin=13:00:00" id="2017-07-04_am" class="btn btn-info btn-sm btn-block">04 Juillet 2017 - Matin</a></td>
<td><button id="2017-07-05_am" class="btn btn-info btn-sm btn-block">05 Juillet 2017 - Matin</button></td>
<td><button id="2017-07-06_am" class="btn btn-info btn-sm btn-block">07 Juillet 2017 - Matin</button></td>
<td><button id="2017-07-07_am" class="btn btn-info btn-sm btn-block">08 Juillet 2017 - Matin</button></td>
</tr>
<tr>
<td><button id="2017-07-04_pm" class="btn btn-primary btn-sm btn-block">04 Juillet 2017 - Après-midi</button></td>
<td><button id="2017-07-05_pm" class="btn btn-primary btn-sm btn-block">05 Juillet 2017 - Après-midi</button></td>
<td><button id="2017-07-06_pm" class="btn btn-primary btn-sm btn-block">06 Juillet 2017 - Après-midi</button></td>
<td><button id="2017-07-07_pm" class="btn btn-primary btn-sm btn-block">07 Juillet 2017 - Après-midi</button></td>
</tr>
</table>
</form>
</div>
<hr>
<div class="panel panel-default">
<div class="panel-heading">Inscription /Atelier</div>
<div class="panel-heading" id="panel-inscription">Inscription / Session : {{ jour }}</div>
<div class="panel-body">
<div id="inscription">
{% if agendas %}
<table id="tab_agenda" class="table table-striped table-bordered">
<thead>
<tr>
<th width="10%">Session</th>
<th width="10%">Salle</th>
<th width="5%">Début</th>
<th width="5%">Fin</th>
<th width="5%">Quota</th>
<th width="10%" colspan="3" class="text-center">Actions</th>
</tr>
</thead>
<tbody>
{% for agenda in agendas %}
<tr>
<td>{{ agenda.getFormation().getNom() }}</td>
<td>{{ agenda.getSalle.getNom() }}</td>
<td>{{ agenda.agenda.getDateDebut() | date("H:i") }}</td>
<td>{{ agenda.dateFin | date("H:i") }}</td>
<td>{{ dump(agenda) }}</td>
<td class="text-center">
<a href="dashboard-inscription-formation?token={{token}}&formation={{agenda.getFormation().getId()}}"
class="btn fa fa-check-square-o btn-success btn-inscription-formation"
data-toggle="tooltip" title="S'inscrire">
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
<!--
<canvas id="plot" data-type="Line" width="500" height="350"></canvas>
-->
</div>
</div>
......
......@@ -3,7 +3,7 @@
{% block content_dashboard %}
<div class="content-dashboard-admin">
<div class="title-main">
<div class="title-main-content">Votre parcours</div>
<div class="title-main-content">Votre parcours : {{ participant.getNom()}}</div>
</div>
<div id="inscription">
......
$(document).ready(function(){
var mydata_graph;
var myPieChart=null;
var ctx = document.getElementById("plot");
// Get Atelier
// SELECT distinct atelier.id AS atelier_id, atelier.nom AS atelier_nom,
// SUM( inscrire.id_participant ) AS inscrits,
// SUM( salle.quota_officiel ) AS quota,
// SUM( salle.quota_physique ) AS PC
// FROM inscrire, atelier, salle
// WHERE inscrire.id_atelier=atelier.id and salle.id = atelier.id_salle
var data=[1,'T1.a2',25,30,30];
$('.btn-inscription-formation').on('click', function(e) {
e.preventDefault();
if (confirm("Confirmez-vous l'inscription à cette formation ?")) {
$.ajax({
url: $(this).attr('href'),
type: 'POST',
success: function(text) {
location.reload();
},
error: function() {
alert('PB');
}
});
}
});
var T_inscrits =[];
var T_quota =[];
var T_backcolor=[];
var T_labels=[];
for(var i=0;i<data.length ;i++)
{
valeur_test=percent(output.data[i].inscrits,output.data[i].quota);
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(0, 255, 0, 0.9)');
}
else if(valeur_test<50)
{
T_backcolor.push('rgba(255, 153, 0, 0.9)');
}
else{
T_backcolor.push('rgba(255, 0, 0, 0.9)');
};
T_labels.push(output.data[i].atelier_nom+' ('+output.data[i].inscrits+'/'+output.data[i].quota+')');
}
var barChartData = {
labels:T_labels,
datasets: [{
label: 'Inscrits ',
// backgroundColor: "rgba(220,220,220,0.5)",
data: T_inscrits,
backgroundColor:T_backcolor,
borderColor:T_backcolor
}, {
label: 'Quota',
backgroundColor: "rgba(151,187,205,0.5)",
data: T_quota
}]
};
var myChart = new Chart(ctx, {
type: 'horizontalBar',
data: {
labels: ["T1-a2"],
datasets: [{
label: 'Inscrits',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
$('#2017-07-05_am').on('click', function(e) {
e.preventDefault();
var letoken=$("#token").val();
$.ajax({
url: 'dashboard-inscription?token='+letoken+'&jour=2017-07-04&debut=09&fin=14',
type: 'GET',
datatype : 'json',
success: function(agenda) {
$.each(agenda, function (key, val) {
value=val['id'];
$('#inscription').append(value+'<br>');
});
},
error: function() {
alert('PB recupérartion de l\'agenda');
}
}
});
});
});
});
$(document).ready(function(){
var mydata_graph;
var myPieChart=null;
var ctx = document.getElementById("plot");
// Get Atelier
// SELECT distinct atelier.id AS atelier_id, atelier.nom AS atelier_nom,
// SUM( inscrire.id_participant ) AS inscrits,
// SUM( salle.quota_officiel ) AS quota,
// SUM( salle.quota_physique ) AS PC
// FROM inscrire, atelier, salle
// WHERE inscrire.id_atelier=atelier.id and salle.id = atelier.id_salle
var data=[1,'T1.a2',25,30,30];
var T_inscrits =[];
var T_quota =[];
var T_backcolor=[];
var T_labels=[];
for(var i=0;i<data.length ;i++)
{
valeur_test=percent(output.data[i].inscrits,output.data[i].quota);
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(0, 255, 0, 0.9)');
}
else if(valeur_test<50)
{
T_backcolor.push('rgba(255, 153, 0, 0.9)');
}
else{
T_backcolor.push('rgba(255, 0, 0, 0.9)');
};
T_labels.push(output.data[i].atelier_nom+' ('+output.data[i].inscrits+'/'+output.data[i].quota+')');
}
var barChartData = {
labels:T_labels,
datasets: [{
label: 'Inscrits ',
// backgroundColor: "rgba(220,220,220,0.5)",
data: T_inscrits,
backgroundColor:T_backcolor,
borderColor:T_backcolor
}, {
label: 'Quota',
backgroundColor: "rgba(151,187,205,0.5)",
data: T_quota
}]
};
var myChart = new Chart(ctx, {
type: 'horizontalBar',
data: {
labels: ["T1-a2"],
datasets: [{
label: 'Inscrits',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});
});