Commit fd2f34f8 authored by Chrystel Moreau's avatar Chrystel Moreau
Browse files

Dashboard Participant : nouveau Parcours (DataTable) => done

parent 5aaf5e52
......@@ -70,7 +70,7 @@ $container[App\Action\DashboardParticipantSondageFormationAction::class] = funct
$container[App\Action\DashboardParticipantParcoursAction::class] = function ($c) {
return new App\Action\DashboardParticipantParcoursAction($c->get('view'), $c->get('logger'), $c->get('em'));
return new App\Action\DashboardParticipantParcoursAction($c->get('view'), $c->get('logger'), $c->get('em'), $c->get('settings'));
};
$container[App\Action\DashboardParticipantParcoursFormationAction::class] = function ($c) {
......
<?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 DashboardCloAction
{
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 admin page action dispatched");
$params = $request->getQueryParams();
$token = $params['token'];
$roleSI = $request->getAttribute('roleSI');
if ($roleSI != 'clo') {
return $response->withStatus(401);
}
$participants = $this->getParticipants();
$this->view->render($response, 'dashboard_clo_home.twig', [
'page' => 'dashboard-clo',
'token' => $token,
'participants' => $participants
]);
return $response;
}
private function getParticipants()
{
$dql = "SELECT p FROM App\Entity\Participant p WHERE p.role = 'Participant' and p.emailValide='t' ORDER BY p.nom";
$query = $this->em->createQuery($dql);
return $query->getResult();
}
}
<?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 DashboardCloAdminAction
{
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 admin page action dispatched");
$params = $request->getQueryParams();
$token = $params['token'];
$roleSI = $request->getAttribute('roleSI');
if ( ($roleSI != 'clo_admin') && ($roleSI != 'admin') ){
return $response->withStatus(401);
}
$participants = $this->getParticipants();
if ($roleSI == 'clo_admin'){
$this->view->render($response, 'dashboard_cloadmin_home.twig', [
'page' => 'dashboard-clo-admin',
'token' => $token,
'participants' => $participants
]);
}
if ($roleSI == 'admin'){
$this->view->render($response, 'dashboard_admin_paiement.twig', [
'page' => 'dashboard-admin-participant',
'token' => $token,
'participants' => $participants
]);
}
return $response;
}
private function getParticipants()
{
$dql = "SELECT p FROM App\Entity\Participant p WHERE p.role = 'Participant' and p.emailValide='t' ORDER BY p.nom";
$query = $this->em->createQuery($dql);
return $query->getResult();
}
}
<?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 DashboardCloParticipantFormAction
{
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'];
$roleSI = $request->getAttribute('roleSI');
if ( ($roleSI != 'admin') && ($roleSI != 'clo') ) {
return $response->withStatus(401);
}
if($request->isGet()) {
$a = [
'token' => $token
];
if (array_key_exists('id', $params)) {
$participant = $this->em->find('App\Entity\Participant', $params['id']);
$a['participant'] = $participant;
}
else {
return $response->withStatus(400);
}
if (array_key_exists('present', $params)) {
$valid=$params['present'];
if ($valid == 'true') {
$participant->setPresent(true);
}
if ($valid == 'false') {
$participant->setPresent(false);
}
$this->em->flush();
$this->view->render($response, 'dashboard_clo_home.twig', $a);
}
else {
$this->view->render($response, 'dashboard_clo_participant_form.twig', $a);
}
}
if($request->isPut()) {
$parsedBody = $request->getParsedBody();
$participant = $this->em->find('App\Entity\Participant', $parsedBody['participant_id']);
$participant->setNom($parsedBody['nom']);
$participant->setPrenom($parsedBody['prenom']);
$participant->setStatut($parsedBody['statut']);
$participant->setEmploi($parsedBody['emploi']);
$organisme = $this->em->find('App\Entity\Organisme', $parsedBody['organisme']);
$participant->setOrganisme($organisme);
$participant->setUnite($parsedBody['unite']);
$participant->setRole($parsedBody['role']);
$participant->setRegion($parsedBody['region']);
if (isset($parsedBody['mailing_list']) && $parsedBody['mailing_list'] == 'on') {
$participant->setMailingList(true);
} else {
$participant->setMailingList(false);
}
if (isset($parsedBody['evenement_social']) && $parsedBody['evenement_social'] == 'on') {
$participant->setEvenementSocial(true);
} else {
$participant->setEvenementSocial(false);
}
$this->em->flush();
$response = $response->write('Participant id=' . $participant->getId() . ' modifié')->withStatus(201);
}
return $response;
}
}
<?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 DashboardCloParticipantParcoursAction
{
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'];
$roleSI = $request->getAttribute('roleSI');
if ( ($roleSI != 'admin') && ($roleSI != 'clo') ) {
return $response->withStatus(401);
}
$a = [
'token' => $token
];
if (array_key_exists('id', $params)) {
$participant = $this->em->find('App\Entity\Participant', $params['id']);
$a['participant'] = $participant;
}
else {
return $response->withStatus(400);
}
$a['pa_4_am'] = $this->getParcours('2017-07-04','08:00:00','13:00:00',$participant->getId());
$a['pa_4_pm'] = $this->getParcours('2017-07-04','12:00:00','19:00:00',$participant->getId());
$a['pa_5_am'] = $this->getParcours('2017-07-05','08:00:00','13:00:00',$participant->getId());
$a['pa_5_pm'] = $this->getParcours('2017-07-05','12:00:00','19:00:00',$participant->getId());
$a['pa_6_am'] = $this->getParcours('2017-07-06','08:00:00','13:00:00',$participant->getId());
$a['pa_6_pm'] = $this->getParcours('2017-07-06','12:00:00','19:00:00',$participant->getId());
$a['pa_7_am'] = $this->getParcours('2017-07-07','08:00:00','13:00:00',$participant->getId());
$a['pa_7_pm'] = $this->getParcours('2017-07-07','12:00:00','19:00:00',$participant->getId());
if (array_key_exists('jour', $params)) {
$agendas = $this->getAgendas($params['jour'],$params['debut'],$params['fin'],$participant->getId());
$a['agendas'] = $agendas;
$response = $response->write(json_encode($agendas))->withHeader('Content-type', 'application/json');
}
else {
$this->view->render($response, 'dashboard_clo_participant_parcours.twig', $a);
}
return $response;
}
//select *,
// (select count(*) from participant_x_agenda pa where pa.id_agenda=a.id) as nb_inscrits,
// (select count(*) from participant_x_agenda p2 where p2.id_agenda=a.id and p2.id_participant=100) as check from agenda a;
public function getAgendas($jour,$debut,$fin,$id) {
$date_debut=$jour." ".$debut;
$date_fin=$jour." ".$fin;
$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);
return $query->getResult();
}
public function getParcours($jour,$debut,$fin,$id) {
$date_debut=$jour." ".$debut;
$date_fin=$jour." ".$fin;
$dql = "SELECT pa FROM App\Entity\ParticipantAgenda pa LEFT JOIN pa.agenda a ";
$dql .= "WHERE pa.participant=$id ";
$dql .= "AND 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();
}
}
......@@ -12,12 +12,14 @@ final class DashboardParticipantParcoursAction
private $view;
private $logger;
private $em;
private $settings;
public function __construct(Twig $view, LoggerInterface $logger, EntityManagerInterface $em)
public function __construct(Twig $view, LoggerInterface $logger, EntityManagerInterface $em, $settings)
{
$this->view = $view;
$this->logger = $logger;
$this->em = $em;
$this->settings = $settings;
}
public function __invoke(Request $request, Response $response, $args)
......@@ -32,27 +34,35 @@ final class DashboardParticipantParcoursAction
$a = [
'page' => 'dashboard-participant-parcours',
'token' => $token,
'participant' => $participant
'participant' => $participant,
'jdev' => $this->settings['jdev']
];
$a['pa_4_am'] = $this->getParcours('2017-07-04','08:00:00','13:00:00',$participant->getId());
$a['pa_4_pm'] = $this->getParcours('2017-07-04','12:00:00','19:00:00',$participant->getId());
$a['pa_5_am'] = $this->getParcours('2017-07-05','08:00:00','13:00:00',$participant->getId());
$a['pa_5_pm'] = $this->getParcours('2017-07-05','12:00:00','19:00:00',$participant->getId());
$a['pa_6_am'] = $this->getParcours('2017-07-06','08:00:00','13:00:00',$participant->getId());
$a['pa_6_pm'] = $this->getParcours('2017-07-06','12:00:00','19:00:00',$participant->getId());
$a['pa_7_am'] = $this->getParcours('2017-07-07','08:00:00','13:00:00',$participant->getId());
$a['pa_7_pm'] = $this->getParcours('2017-07-07','12:00:00','19:00:00',$participant->getId());
$a['pa_4_am'] = $this->getParcours($this->settings['jdev']['j1'],'08:00:00','13:00:00',$participant->getId());
$a['pa_4_pm'] = $this->getParcours($this->settings['jdev']['j1'],'12:00:00','19:00:00',$participant->getId());
$a['pa_5_am'] = $this->getParcours($this->settings['jdev']['j2'],'08:00:00','13:00:00',$participant->getId());
$a['pa_5_pm'] = $this->getParcours($this->settings['jdev']['j2'],'12:00:00','19:00:00',$participant->getId());
$a['pa_6_am'] = $this->getParcours($this->settings['jdev']['j3'],'08:00:00','13:00:00',$participant->getId());
$a['pa_6_pm'] = $this->getParcours($this->settings['jdev']['j3'],'12:00:00','19:00:00',$participant->getId());
$a['pa_7_am'] = $this->getParcours($this->settings['jdev']['j4'],'08:00:00','13:00:00',$participant->getId());
$a['pa_7_pm'] = $this->getParcours($this->settings['jdev']['j4'],'12:00:00','19:00:00',$participant->getId());
if (array_key_exists('jour', $params)) {
$agendas = $this->getAgendas($params['jour'],$params['debut'],$params['fin'],$participant->getId());
$a['agendas'] = $agendas;
$response = $response->write(json_encode($agendas))->withHeader('Content-type', 'application/json');
$inscription = $this->getParcours($params['jour'],$params['debut'],$params['fin'],$participant->getId());
$a['inscription'] = $inscription;
$a['jour'] = $params['jour'];
$a['debut'] = $params['debut'];
$a['fin'] = $params['fin'];
if ($params['debut'] == '08:00:00'){ $a['journee'] = ' - Matin';}
if ($params['debut'] == '13:00:00'){ $a['journee'] = ' - Après-midi';}
//$response = $response->write(json_encode($agendas))->withHeader('Content-type', 'application/json');
}
else {
//else {
$this->view->render($response, 'dashboard_participant_parcours.twig', $a);
}
//}
return $response;
......
......@@ -40,7 +40,7 @@ final class DashboardParticipantSondageAction
if (array_key_exists('jour', $params)) {
$j=explode("/",$params['jour']);
//$j=explode("/",$params['jour']);
if ($params['debut'] == '08:00:00'){ $a['journee'] = ' - Matin';}
if ($params['debut'] == '13:00:00'){ $a['journee'] = ' - Après-midi';}
......
......@@ -80,11 +80,13 @@
<script src="bower_components/jquery-ui/jquery-ui.min.js"></script>
<script src="bower_components/jt.timepicker/jquery.timepicker.min.js"></script>
<script src="js/admin.js"></script>
<script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.24/build/pdfmake.min.js"></script>
<script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.24/build/vfs_fonts.js"></script>
<!--
<script src="js/clo_admin.js"></script>
<script src="js/clo.js"></script>
-->
<script src="js/Chart.js"></script>
-->
<script src="js/participant.js"></script>
</body>
......
......@@ -15,11 +15,11 @@
<li class="navbar-dashboard-item">
<a href="dashboard-participant-sondage?token={{ token }}"><i class="fa fa-address-card-o"></i> Sondage</a>
</li>
<!--
<li class="navbar-dashboard-item">
<a href="dashboard-participant-parcours?token={{ token }}"><i class="fa fa-cogs"></i> Parcours</a>
</li>
-->
</ul>
</nav>
......
......@@ -19,12 +19,12 @@
<table id="tab-admin-participants" class="table table-striped table-bordered">
<thead>
<tr>
<th>Présence</th>
<th>Participant</th>
<th>Email</th>
<th>Emploi</th>
<th>Statut</th>
<th>Edition</th>
<th>Présence</th>
<th>Parcours</th>
......@@ -33,21 +33,7 @@
<tbody>
{% for participant in participants %}
<tr>
<td class="text-center">
{% if participant.getPresent() == true %}
<i class="fa fa-check-circle-o"></i> &nbsp;
<a href="dashboard-admin-participant-form?token={{ token }}&id={{ participant.id }}&present=false"
class="btn btn-danger btn-admin-nopresent fa fa-check-square-o"
data-toggle="tooltip" title="Invalider la presence aux JDEV">
</a>
{% else %}
<a href="dashboard-admin-participant-form?token={{ token }}&id={{ participant.id }}&present=true"
class="btn btn-success btn-admin-present fa fa-check-square-o"
data-toggle="tooltip" title="Valider la presence aux JDEV">
</a>
{% endif %}
</td>
<td>{{ participant.getNom()|upper }} {{ participant.getPrenom() }}</td>
<td><a href="mailto:{{ participant.getEmail() }}"><i class="fa fa-envelope"></i></a></td>
<td>{{ participant.getEmploi() }}</td>
......@@ -67,6 +53,22 @@
</a>
</td>
<td class="text-center">
{% if participant.getPresent() == true %}
<i class="fa fa-check-circle-o"></i> &nbsp;
<a href="dashboard-admin-participant-form?token={{ token }}&id={{ participant.id }}&present=false"
class="btn btn-danger btn-admin-nopresent fa fa-check-square-o"
data-toggle="tooltip" title="Invalider la presence aux JDEV">
</a>
{% else %}
<a href="dashboard-admin-participant-form?token={{ token }}&id={{ participant.id }}&present=true"
class="btn btn-success btn-admin-present fa fa-check-square-o"
data-toggle="tooltip" title="Valider la presence aux JDEV">
</a>
{% endif %}
</td>
<td class="text-center">
<a href="dashboard-admin-participant-parcours?token={{ token }}&id={{ participant.id }}"
class="btn btn-warning fa fa-calendar btn-info"
......
......@@ -8,7 +8,6 @@
<div>
<div id="seances">
Vous devez selectionner une demi-journée pour visualier les sessions de formation.<p>
<form id="form_inscription">
......@@ -17,18 +16,20 @@
<table id="tab_mon_parcours" class="table table-bordered">
<thead>
<tr>
<th class="td-parcours">04 Juillet 2017</th>
<th class="td-parcours">05 Juillet 2017</th>
<th class="td-parcours">06 Juillet 2017</th>
<th class="td-parcours">07 Juillet 2017</th>
<th class="td-parcours">{{ jdev.j1 |date("d/m/Y")}}</th>
<th class="td-parcours">{{ jdev.j2 |date("d/m/Y")}}</th>
<th class="td-parcours">{{ jdev.j3 |date("d/m/Y")}}</th>
<th class="td-parcours">{{ jdev.j4 |date("d/m/Y")}}</th>
</tr>
</thead>
<tbody>
<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">Matin</a>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour={{ jdev.j1 }}&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour" value="04 Juillet 2017 - Matin">Matin</a><br>
{% if pa_4_am %}
{% for p in pa_4_am %}
<b>Formation</b> : {{ p.getAgenda().getFormation().getNom() }}<br>
<b>Intitulé</b> : {{ p.getAgenda().getFormation().getTitre() }}<br>
<b>Horaire</b> : {{ p.getAgenda().getDateDebut() | date("H:i") }} - {{ p.getAgenda().getDateFin() | date("H:i") }}<br>
<b>Salle</b> : {{ p.getAgenda().getSalle().getNom() }}<br>
{% endfor %}
......@@ -36,7 +37,7 @@
pas d'inscription
{% endif %}
</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" value="05 Juillet 2017 - Matin">Matin</a>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour={{ jdev.j2 }}&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour" value="05 Juillet 2017 - Matin">Matin</a> <br>
{% if pa_5_am %}
{% for p in pa_5_am %}
<b>Formation</b> : {{ p.getAgenda().getFormation().getNom() }}<br>
......@@ -47,7 +48,7 @@
pas d'inscription
{% endif %}
</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" value="06 Juillet 2017 - Matin">Matin</a>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour={{ jdev.j3 }}&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour" value="06 Juillet 2017 - Matin">Matin</a><br>
{% if pa_6_am %}
{% for p in pa_6_am %}
<b>Formation</b> : {{ p.getAgenda().getFormation().getNom() }}<br>
......@@ -58,7 +59,7 @@
pas d'inscription
{% endif %}
</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" value="07 Juillet 2017 - Matin">Matin</a>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour={{ jdev.j4 }}&debut=08:00:00&fin=13:00:00" class="btn btn-info btn-sm btn-block btn-jour" value="07 Juillet 2017 - Matin">Matin</a><br>
{% if pa_7_am %}
{% for p in pa_7_am %}
<b>Formation</b> : {{ p.getAgenda().getFormation().getNom() }}<br>
......@@ -72,7 +73,7 @@
</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" value="04 Juillet 2017 - Après-Midi">Après-Midi</a>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour={{ jdev.j1 }}&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block btn-jour" value="04 Juillet 2017 - Après-Midi">Après-Midi</a><br>
{% if pa_4_pm %}
{% for p in pa_4_pm %}
<b>Formation</b> : {{ p.getAgenda().getFormation().getNom() }}<br>
......@@ -83,7 +84,7 @@
pas d'inscription
{% endif %}
</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" value="05 Juillet 2017 - Après-Midi">Après-Midi</a>
<td><a href="dashboard-participant-parcours?token={{ token }}&jour={{ jdev.j2 }}&debut=13:00:00&fin=19:00:00" class="btn btn-primary btn-sm btn-block btn-jour" value="05 Juillet 2017 - Après-Midi">Après-Midi</a><br>
{% if pa_5_pm %}
{% for p in pa_4_pm %}
<b>Formation</b> : {{ p.getAgenda().getFormation().getNom() }}<br>
......@@ -94,7 +95,7 @@
pas d'inscription
{% endif %}