Commit 8fefd210 authored by Chrystel Moreau's avatar Chrystel Moreau
Browse files

gestion Agenda (suppression etat formation) => done

parent 8abc5c27
......@@ -60,12 +60,12 @@ $container[App\Action\DashboardAction::class] = function ($c) {
return new App\Action\DashboardAction($c->get('view'), $c->get('logger'), $c->get('em'));
};
$container[App\Action\DashboardInscriptionAction::class] = function ($c) {
return new App\Action\DashboardInscriptionAction($c->get('view'), $c->get('logger'), $c->get('em'));
$container[App\Action\DashboardPreInscriptionAction::class] = function ($c) {
return new App\Action\DashboardPreInscriptionAction($c->get('view'), $c->get('logger'), $c->get('em'));
};
$container[App\Action\ParticipantInscriptionFormationAction::class] = function ($c) {
return new App\Action\ParticipantInscriptionFormationAction($c->get('view'), $c->get('logger'), $c->get('em'));
$container[App\Action\ParticipantPreInscriptionFormationAction::class] = function ($c) {
return new App\Action\ParticipantPreInscriptionFormationAction($c->get('view'), $c->get('logger'), $c->get('em'));
};
$container[App\Action\DashboardParcoursAction::class] = function ($c) {
......
......@@ -43,13 +43,13 @@ $app->get('/dashboard-home', App\Action\DashboardAction::class)
->add(App\Middleware\TokenMiddleware::class)
->setName('dashboard_home');
$app->get('/dashboard-inscription', App\Action\DashboardInscriptionAction::class)
$app->get('/dashboard-preinscription', App\Action\DashboardPreInscriptionAction::class)
->add(App\Middleware\TokenMiddleware::class)
->setName('dashboard_inscription');
->setName('dashboard_preinscription');
$app->map(['GET', 'POST'],'/dashboard-inscription-formation', App\Action\ParticipantInscriptionFormationAction::class)
$app->map(['GET', 'POST'],'/dashboard-preinscription-formation', App\Action\ParticipantPreInscriptionFormationAction::class)
->add(App\Middleware\TokenMiddleware::class)
->setName('dashboard_inscription_formation');
->setName('dashboard_preinscription_formation');
$app->get('/dashboard-parcours', App\Action\DashboardParcoursAction::class)
->add(App\Middleware\TokenMiddleware::class)
......
......@@ -115,7 +115,8 @@ final class DashboardAdminAgendaFormAction
private function getFormations()
{
$dql = "SELECT f FROM App\Entity\Formation f LEFT JOIN f.agendas a where f.confirme='t' AND a.dateDebut IS NULL ORDER BY f.nom ASC";
//$dql = "SELECT f FROM App\Entity\Formation f LEFT JOIN f.agendas a where f.confirme='t' AND a.dateDebut IS NULL ORDER BY f.nom ASC";
$dql = "SELECT f FROM App\Entity\Formation f LEFT JOIN f.agendas a where a.dateDebut IS NULL ORDER BY f.nom ASC";
$query = $this->em->createQuery($dql);
return $query->getResult();
}
......@@ -137,7 +138,7 @@ final class DashboardAdminAgendaFormAction
// order by salle.quota_physique;
private function getSalles($debut,$fin,$quota)
{
$dql = "SELECT s FROM App\Entity\Salle s LEFT JOIN s.agendas a ";
$dql = "SELECT distinct s FROM App\Entity\Salle s LEFT JOIN s.agendas a ";
$dql .= "WHERE s.quotaPhysique >= $quota AND s.id NOT IN ";
$dql .= " ( select s1.id FROM App\Entity\Salle s1 LEFT JOIN s1.agendas a1 ";
$dql .= " where a1.dateDebut between '$debut' and '$fin' and a1.dateFin between '$debut' and '$fin' )";
......
<?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 DashboardAdminAgendaAction
{
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 formation page action dispatched");
$params = $request->getQueryParams();
$token = $params['token'];
$roleSI = $request->getAttribute('roleSI');
if ($roleSI != 'admin') {
return $response->withStatus(401);
}
$agendas = $this->getAgendas();
$this->view->render($response, 'dashboard_admin_agenda.twig', [
'page' => 'dashboard-admin-agenda',
'token' => $token,
'agendas' => $agendas
]);
return $response;
}
public function getAgendas() {
$dql = "SELECT a FROM App\Entity\Agenda a ORDER BY a.dateDebut ASC";
$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 DashboardAdminAgendaFormAction
{
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') {
return $response->withStatus(401);
}
if($request->isGet()) {
$formations = $this->getFormations();
$a = [
'page' => 'dashboard',
'token' => $token,
'formations' => $formations
];
if (array_key_exists('agenda_id', $params)) {
$agenda = $this->em->find('App\Entity\Agenda', $params['agenda_id']);
$formations = $this->getOneFormation($params['agenda_id']);
$a['agenda'] = $agenda;
}
if (array_key_exists('quota', $params)) {
$parsedBody = $request->getParsedBody();
$debut = date_create_from_format('d/m/Y H:i', $params['jour'] . ' ' . $params['debut']);
$fin = date_create_from_format('d/m/Y H:i', $params['jour'] . ' ' . $params['fin']);
$quota = $params['quota'];
$salles = $this->getSalles($debut->format('Y-m-d H:i:s'),$fin->format('Y-m-d H:i:s'),$quota);
$response = $response->write(json_encode($salles))->withHeader('Content-type', 'application/json');
return $response;
}
else {
$this->view->render($response, 'dashboard_admin_agenda_form.twig', $a);
}
}
if($request->isPost()) {
$parsedBody = $request->getParsedBody();
$formation = $this->em->find('App\Entity\Formation', $parsedBody['formation']);
$debut = date_create_from_format('d/m/Y H:i', $parsedBody['jour'] . ' ' . $parsedBody['debut']);
$fin = date_create_from_format('d/m/Y H:i', $parsedBody['jour'] . ' ' . $parsedBody['fin']);
$salle = $this->em->find('App\Entity\Salle', $parsedBody['salle']);
$agenda = new \App\Entity\Agenda();
$agenda->setFormation($formation);
$agenda->setSalle($salle);
$agenda->setDateDebut($debut);
$agenda->setDateFin($fin);
$this->em->persist($agenda);
$this->em->flush();
$response = $response->write('Nouvel agenda enregistré')->withStatus(201);
}
if($request->isPut()) {
$parsedBody = $request->getParsedBody();
$formation = $this->em->find('App\Entity\Formation', $parsedBody['formation']);
$salle = $this->em->find('App\Entity\Salle', $parsedBody['salle']);
$debut = date_create_from_format('d/m/Y H:i', $parsedBody['jour'] . ' ' . $parsedBody['debut']);
$fin = date_create_from_format('d/m/Y H:i', $parsedBody['jour'] . ' ' . $parsedBody['fin']);
$agenda = $this->em->find('App\Entity\Agenda', $parsedBody['agenda_id']);
$agenda->setFormation($formation);
$agenda->setSalle($salle);
$agenda->setDateDebut($debut);
$agenda->setDateFin($fin);
$this->em->flush();
$response = $response->write('Agenda n°' . $agenda->getId() . ' modifié')->withStatus(201);
}
if ($request->isDelete()) {
$agenda = $this->em->find('App\Entity\Agenda', $params['agenda_id']);
$this->em->remove($agenda);
$this->em->flush();
$response = $response->write('Agenda id: ' . $params['agenda_id'] . ' supprimé')->withStatus(200);
}
return $response;
}
private function getFormations()
{
$dql = "SELECT f FROM App\Entity\Formation f LEFT JOIN f.agendas a where f.confirme='t' AND a.dateDebut IS NULL ORDER BY f.nom ASC";
$query = $this->em->createQuery($dql);
return $query->getResult();
}
private function getOneFormation($id_formation)
{
$dql = "SELECT f FROM App\Entity\Formation f where f.id=$id_formation";
$query = $this->em->createQuery($dql);
return $query->getResult();
}
// select distinct salle.id,salle.nom,salle.quota_physique,agenda.date_debut,agenda.date_fin from salle
// left join agenda on salle.id=agenda.id_salle
// where salle.quota_physique >= 30 and
// salle.id not in
// (select salle.id from salle left join agenda on salle.id=agenda.id_salle
// where (agenda.date_debut,agenda.date_fin) overlaps ('2017-07-04 14:00:00','2017-07-04 17:00:00'))
// order by salle.quota_physique;
private function getSalles($debut,$fin,$quota)
{
$dql = "SELECT s FROM App\Entity\Salle s LEFT JOIN s.agendas a ";
$dql .= "WHERE s.quotaPhysique >= $quota AND s.id NOT IN ";
$dql .= " ( select s1.id FROM App\Entity\Salle s1 LEFT JOIN s1.agendas a1 ";
$dql .= " where a1.dateDebut between '$debut' and '$fin' and a1.dateFin between '$debut' and '$fin' )";
$dql .= " ORDER BY s.quotaPhysique";
$query = $this->em->createQuery($dql);
return $query->getArrayResult();
}
}
......@@ -7,7 +7,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
final class DashboardInscriptionAction
final class DashboardPreInscriptionAction
{
private $view;
private $logger;
......@@ -30,7 +30,7 @@ final class DashboardInscriptionAction
$participant = $this->getParticipant($email);
$a = [
'page' => 'dashboard-inscription',
'page' => 'dashboard-preinscription',
'token' => $token,
'participant' => $participant
];
......@@ -48,7 +48,7 @@ final class DashboardInscriptionAction
$a['inscription'] = $inscription;
}
$this->view->render($response, 'dashboard_inscription.twig', $a);
$this->view->render($response, 'dashboard_preinscription.twig', $a);
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 ParticipantInscriptionFormationAction
{
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_inscription.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();
}
}
......@@ -30,7 +30,7 @@
{% for formation in formations %}
<tr>
<td>{{ formation.getNom() }}</td>
<td>{{ formation.getThematique().getNom() }}</td>
<td>{{ formation.getThematique().getLabel() }}</td>
<td>{{ formation.getType() }}</td>
<td>{{ formation.getIntervenant() }}</td>
<td>{{ formation.getQuota() }}</td>
......
......@@ -42,7 +42,12 @@
</div>
<div class="form-group">
<label for="type">Type</label> <span style="color: red;">*</span>
<input type="text" class="form-control" name="type" id="type" placeholder="Type" {% if formation %}value="{{ formation.getType() }}"{% endif %} required>
<select name="type" id="type" class="form-control" required>
<option value="Atelier" {% if formation.getType() == 'Atelier' %}selected{% endif %}>Atelier</option>
<option value="Atelier Préparatoire" {% if formation.getType() == 'Atelier Préparatoire' %}selected{% endif %}>Atelier Préparatoire</option>
<option value="Plénière" {% if formation.getType() == 'Plénière' %}selected{% endif %}>Plénière</option>
<option value="Groupe de Travail" {% if formation.getType() == 'Groupe de Travail' %}selected{% endif %}>Groupe de Travail</option>
</select>
</div>
<div class="form-group">
<label for="intervenant">Intervenant</label>
......
$(document).ready(function() {
// ======================================================================
// Validation d'un participants Organisateur, Invité, Sponsor, Exposant
// ======================================================================
$('.admin-valid-btn').on('click', function(e) {
e.preventDefault();
if (confirm("Confirmez-vous la validation du particiant en tant que organisateur ?")) {
var href = $(this).attr('href');
$.ajax({
url: href,
type: 'POST',
success: function(text) {
location.reload();
},
error: function() {
alert('Problème serveur !');
}
});
}
});
// ======================================================================
// Gestion des participants
// ======================================================================
$('#gparticipants').DataTable( {
//dom: 'Bfrtilp',
//buttons: [
......@@ -18,24 +42,7 @@ $(document).ready(function() {
]
});
// Validation d'un participants Organisateur, Invité, Sponsor, Exposant
$('.admin-valid-btn').on('click', function(e) {
e.preventDefault();
if (confirm("Confirmez-vous la validation du particiant en tant que organisateur ?")) {
var href = $(this).attr('href');
$.ajax({
url: href,
type: 'POST',
success: function(text) {
location.reload();
},
error: function() {
alert('Problème serveur !');
}
});
}
});
// ======================================================================
// Formulaire de gestion d'une salle
......
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