Commit 140ebfe5 authored by Chrystel Moreau's avatar Chrystel Moreau
Browse files

Merge branch 'master' of gitlab.lam.fr:cesamSI/jdev-boarding

Conflicts:
	app/templates/base_backoffice.twig
parents fc373e34 b251d842
......@@ -90,6 +90,10 @@ $container[App\Action\DashboardAdminFormationAction::class] = function ($c) {
return new App\Action\DashboardAdminFormationAction($c->get('view'), $c->get('logger'), $c->get('em'));
};
$container[App\Action\DashboardAdminFormationFormAction::class] = function ($c) {
return new App\Action\DashboardAdminFormationFormAction($c->get('view'), $c->get('logger'), $c->get('em'));
};
$container[App\Action\DashboardAdminOrganismeAction::class] = function ($c) {
return new App\Action\DashboardAdminOrganismeAction($c->get('view'), $c->get('logger'), $c->get('em'));
};
......
......@@ -73,6 +73,10 @@ $app->get('/dashboard-admin-formation', App\Action\DashboardAdminFormationAction
->add(App\Middleware\TokenMiddleware::class)
->setName('dashboard_admin_formation');
$app->map(['GET', 'POST', 'PUT', 'DELETE'], '/dashboard-admin-formation-form', App\Action\DashboardAdminFormationFormAction::class)
->add(App\Middleware\TokenMiddleware::class)
->setName('dashboard_admin_formation_form');
$app->get('/dashboard-admin-organisme', App\Action\DashboardAdminOrganismeAction::class)
->add(App\Middleware\TokenMiddleware::class)
->setName('dashboard_admin_organisme');
......
......@@ -80,7 +80,7 @@ final class AdminValidPaiementAction
private function sendEmail($participant)
{
$body = 'Bonjour ' . $participant->getPrenom() . ' ' . $participant->getNom() . PHP_EOL;
$body = 'Bonjour ' . $participant->getPrenom() . ' ' . $participant->getNom() . ',' . PHP_EOL;
$body .= PHP_EOL;
$body .= 'Votre prise en charge vient d\'être invalidée par votre organisme.' . PHP_EOL;
$body .= PHP_EOL;
......@@ -88,7 +88,7 @@ final class AdminValidPaiementAction
$body .= 'les frais d\'inscription sur la plate-forme Azur-Colloque: https://www.azur-colloque.fr/DR12/ .' . PHP_EOL;
$body .= PHP_EOL;
$body .= 'Bien cordialement' . PHP_EOL;
$body .= 'Le comité d\'ogranisation des JDEV2017';
$body .= 'Le comité d\'organisation des JDEV2017';
$message = \Swift_Message::newInstance('Validation inscription JDEV2017')
->setFrom(['noreply@jdev2017.fr' => 'jdev2017-inscription@services.cnrs.fr'])
......
......@@ -9,34 +9,43 @@ use Psr\Http\Message\ResponseInterface as Response;
final class DashboardAdminFormationAction
{
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)
private $view;
private $logger;
private $em;
public function __construct(Twig $view, LoggerInterface $logger, EntityManagerInterface $em)
{
$this->logger->info("dashboard admin formation page action dispatched");
$params = $request->getQueryParams();
$token = $params['token'];
$roleSI = $request->getAttribute('roleSI');
if ($roleSI != 'admin') {
return $response->withStatus(401);
}
$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);
}
$formations = $this->getFormations();
$this->view->render($response, 'dashboard_admin_formation.twig', [
'page' => 'dashboard-admin-formation',
'token' => $token
'token' => $token,
'formations' => $formations
]);
return $response;
}
public function getFormations() {
$dql = "SELECT a FROM App\Entity\Atelier a ORDER BY a.nom DESC";
$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 DashboardAdminFormationFormAction
{
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()) {
$thematiques = $this->getThematiques();
$salles = $this->getSalles();
$a = [
'page' => 'dashboard',
'token' => $token,
'thematiques' => $thematiques,
'salles' => $salles
];
if (array_key_exists('formation_id', $params)) {
$formation = $this->em->find('App\Entity\Atelier', $params['formation_id']);
$a['formation'] = $formation;
};
$this->view->render($response, 'dashboard_admin_formation_form.twig', $a);
}
if($request->isPost()) {
$parsedBody = $request->getParsedBody();
$thematique = $this->em->find('App\Entity\Thematique', $parsedBody['thematique']);
$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']);
$formation = new \App\Entity\Atelier();
$formation->setNom($parsedBody['nom']);
$formation->setThematique($thematique);
$formation->setSalle($salle);
$formation->setDateDebut($debut);
$formation->setDateFin($fin);
$this->em->persist($formation);
$this->em->flush();
$response = $response->write('Nouvelle formation enregistrée')->withStatus(201);
}
if($request->isPut()) {
$parsedBody = $request->getParsedBody();
$thematique = $this->em->find('App\Entity\Thematique', $parsedBody['thematique']);
$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']);
$formation = $this->em->find('App\Entity\Atelier', $parsedBody['formation_id']);
$formation->setNom($parsedBody['nom']);
$formation->setThematique($thematique);
$formation->setSalle($salle);
$formation->setDateDebut($debut);
$formation->setDateFin($fin);
$this->em->flush();
$response = $response->write('Formation n°' . $formation->getId() . ' modifiée')->withStatus(201);
}
if ($request->isDelete()) {
$formation = $this->em->find('App\Entity\Atelier', $params['formation_id']);
$this->em->remove($formation);
$this->em->flush();
$response = $response->write('Formation id: ' . $params['formation_id'] . ' supprimée')->withStatus(200);
}
return $response;
}
private function getThematiques()
{
$dql = "SELECT t FROM App\Entity\Thematique t ORDER BY t.nom ASC";
$query = $this->em->createQuery($dql);
return $query->getResult();
}
private function getSalles()
{
$dql = "SELECT s FROM App\Entity\Salle s ORDER BY s.nom ASC";
$query = $this->em->createQuery($dql);
return $query->getResult();
}
}
......@@ -9,9 +9,10 @@
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.2.4/css/buttons.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/select/1.2.1/css/select.dataTables.min.css">
<link rel="stylesheet" href="bower_components/datatables.net-buttons-bs/css/buttons.bootstrap.min.css">
<link rel="stylesheet" href="bower_components/datatables.net-select-bs/css/select.bootstrap.min.css">
<link rel="stylesheet" href="bower_components/jquery-ui/themes/base/jquery-ui.min.css">
<link rel="stylesheet" href="bower_components/jt.timepicker/jquery.timepicker.css">
<link rel="stylesheet" href="styles/style.css">
</head>
<body>
......@@ -70,18 +71,21 @@
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/bootstrap-validator/dist/validator.min.js"></script>
<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.4/js/dataTables.buttons.min.js"></script>
<script src="http://cdn.datatables.net/buttons/1.2.4/js/buttons.html5.min.js"></script>
<script src="http:////cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<!--<script src="js/inscription.js"></script>-->
<script src="js/connexion.js"></script>
<script src="js/new_passwd.min.js"></script>
<script src="bower_components/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
<script src="bower_components/datatables.net-buttons/js/buttons.html5.min.js"></script>
<script src="bower_components/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
<script src="bower_components/jszip/dist/jszip.min.js"></script>
<script src="bower_components/datatables.net-select/js/dataTables.select.min.js"></script>
<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_formation.js"></script>
<script src="js/admin.js"></script>
<script src="js/clo_admin.js"></script>
<script src="js/clo_admin.js"></script>
<!--
<script src="js/Chart.js"></script>
<script src="js/participant.js"></script>
-->
</body>
</html>
......@@ -7,16 +7,51 @@
<div class="title-main-content">Dashboard Admin Formation</div>
</div>
<div>
<div>
<a href="/dashboard-admin-formation-form?token={{ token }}" class="btn btn-treehouse pull-right">Ajouter une formation</a>
<h4><i class="fa fa-check-square-o"></i> Gestion des Sessions de formations</h4>
<ul>
<li>Affichage</li>
<li>Ajout</li>
<li>Fusion</li>
<li>Duplication</li>
<li>Edition</li>
<li>Suppression</li>
</ul>
<br>
{% if formations %}
<div class="table-responsive">
<table id="gformations" class="table table-striped table-bordered">
<thead>
<tr>
<th width="10%">Nom</th>
<th width="30%">Thématique</th>
<th width="10%">Salle</th>
<th width="5%">Date</th>
<th width="5%">Début</th>
<th width="5%">Fin</th>
<th width="10%" colspan="3" class="text-center">Actions</th>
</tr>
</thead>
<tbody>
{% for formation in formations %}
<tr>
<td>{{ formation.nom }}</td>
<td>{{ formation.thematique.nom }}</td>
<td>{{ formation.salle.nom }}</td>
<td>{{ formation.dateDebut|date("d/m") }}</td>
<td>{{ formation.dateDebut|date("H:i") }}</td>
<td>{{ formation.dateFin|date("H:i") }}</td>
<td class="text-center">
<a href="dashboard-admin-formation-form?token={{ token }}&formation_id={{ formation.id }}" class="btn btn-default fa fa-pencil-square-o"></a>
</td>
<td class="text-center">
<a href="#" class="btn btn-default fa fa-files-o"></a>
</td>
<td class="text-center">
<a href="dashboard-admin-formation-form?token={{ token }}&formation_id={{ formation.id }}" class="btn btn-default fa fa-trash-o btn-delete-formation"></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p>Pas encore de formations</p>
{% endif %}
</div>
</div>
{% endblock %}
{% extends "base_dashboard_admin.twig" %}
{% block title %}Admin{% endblock %}
{% block content_dashboard_admin %}
<div class="content-dashboard-admin">
<div class="title-main">
<div class="title-main-content">
{% if formation %}
Éditer une formation
{% else %}
Ajouter une formation
{% endif %}
</div>
</div>
<div class="row">
<div class="col-md-8">
<form id="form_formation" action="dashboard-admin-formation-form?token={{ token }}" role="form" data-toggle="validator">
{% if formation %}
<input type="hidden" id="formation_id" name="formation_id" value="{{ formation.getId() }}">
{% else %}
<input type="hidden" id="formation_id" name="formation_id" value="0">
{% endif %}
<div class="form-group">
<label for="nom">Nom</label> <span style="color: red;">*</span>
<input type="text" class="form-control" name="nom" id="nom" placeholder="Nom" {% if formation %}value="{{ formation.getNom() }}"{% endif %} required>
</div>
<div class="form-group">
<label for="thematique">Thématique</label> <span style="color: red;">*</span>
<select name="thematique" id="thematique" class="form-control" required>
{% for thematique in thematiques %}
<option value="{{ thematique.id }}" {% if formation.getThematique().getId() == thematique.id %}selected{% endif %}>{{ thematique.nom }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="jour">Date</label> <span style="color: red;">*</span>
<input type="text" class="form-control" name="jour" id="datepicker" placeholder="Date" {% if formation %}value="{{ formation.getDateDebut()|date("d/m/Y") }}"{% endif %} required>
</div>
<div class="form-group">
<label for="debut">Heure début</label> <span style="color: red;">*</span>
<input type="text" class="form-control" name="debut" id="debut-timepicker" placeholder="Début" {% if formation %}value="{{ formation.getDateDebut()|date("H:i") }}"{% endif %} required>
</div>
<div class="form-group">
<label for="fin">Heure fin</label> <span style="color: red;">*</span>
<input type="text" class="form-control" name="fin" id="fin-timepicker" placeholder="Fin" {% if formation %}value="{{ formation.getDateFin()|date("H:i") }}"{% endif %} required disabled>
</div>
<div class="form-group">
<label for="salle">Salle</label> <span style="color: red;">*</span>
<select name="salle" id="salle" class="form-control" required>
{% for salle in salles %}
<option value="{{ salle.id }}" {% if formation.getSalle().getId() == salle.id %}selected{% endif %}>{{ salle.nom }}</option>
{% endfor %}
{#<p class="text-center">#}
{#<i class="fa fa-spinner fa-pulse fa-2x" aria-hidden="true"></i>#}
{#</p>#}
</select>
</div>
<a href="/dashboard-admin-formation?token={{ token }}" id="btn-back-formations" class="btn btn-danger">Retour liste des formations</a>
<button type="submit" id="btn-inscription-submit" class="btn btn-primary" value="Envoyer">Soumettre</button>
</form>
</div>
</div>
</div>
{% endblock %}
......@@ -22,6 +22,13 @@
"font-awesome": "fontawesome#^4.7.0",
"bootstrap-validator": "^0.11.9",
"datatables.net": "^2.1.1",
"datatables.net-bs": "^2.1.1"
"datatables.net-bs": "^2.1.1",
"jquery-ui": "^1.12.1",
"jt.timepicker": "jquery-timepicker-jt#^1.11.10",
"datatables.net-buttons": "^1.2.4",
"datatables.net-buttons-bs": "^1.2.4",
"datatables.net-select": "^1.2.1",
"datatables.net-select-bs": "^1.2.1",
"jszip": "Stuk/jszip#^3.1.3"
}
}
$(document).ready(function() {
var changeTimepickerFin = function () {
if ($('#debut-timepicker').val() != '')
{
$('#fin-timepicker').attr('disabled', false);
$('#fin-timepicker').timepicker('option', 'minTime', $('#debut-timepicker').val());
}
else
{
$('#fin-timepicker').attr('disabled', true);
}
}
$('#form_formation').validator().on('submit', function(e) {
if (e.isDefaultPrevented())
{
alert('Veuillez remplir tous les champs obligatoires');
}
else
{
e.preventDefault();
var formation_id = $('#formation_id').val();
if (formation_id > 0) {
var vtype = 'PUT';
} else {
var vtype = 'POST';
}
var form = $(this);
$.ajax({
url: form.attr('action'),
type: vtype,
data: form.serialize(),
success: function(text) {
document.location.href = $('#btn-back-formations').attr('href');
},
error: function() {
alert('La formation n\'a pas pu être ajoutée');
form.trigger('reset');
}
});
}
});
$('.btn-delete-formation').on('click', function(e) {
e.preventDefault();
$.ajax({
url: $(this).attr('href'),
type: 'DELETE',
success: function(text) {
location.reload();
},
error: function() {
alert('La formation n\'a pas pu être supprimée');
}
});
});
$( "#datepicker" ).datepicker({
showAnim: "slideDown",
minDate: new Date("2017-07-04"),
maxDate: new Date("2017-07-07")
});
$('#debut-timepicker').timepicker({
'timeFormat': 'H:i',
'minTime': '8:00',
'maxTime': '17:00',
});
$('#fin-timepicker').timepicker({
'timeFormat': 'H:i',
'maxTime': '18:00'
});
changeTimepickerFin();
$('#debut-timepicker').on('change', function () {
$('#fin-timepicker').val('');
changeTimepickerFin();
})
});
\ No newline at end of file
Supports Markdown
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