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

correction BUG formation-agenda

parent fc915818
......@@ -25,7 +25,7 @@ return [
'dev_mode' => true,
'connection_options' => [
'driver' => 'pdo_pgsql',
'host' => 'cencosdev.oamp.lan', // cencosdev.oamp.lan
'host' => 'cesamdb.oamp.lan', // cencosdev.oamp.lan
'user' => 'jdev',
'password' => 'jdev2017',
'dbname' => 'jdev2017'
......
......@@ -57,11 +57,12 @@ final class DashboardAdminAgendaFormAction
$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'];
$id_salle = $agenda->getSalle()->getId();
if ($agenda){ $id_salle = $agenda->getSalle()->getId();}
else {$id_salle =0;}
$salle = $this->getSalleById($id_salle);
$salles = array_merge(array($salle), $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;
return $response;
}
else {
$this->view->render($response, 'dashboard_admin_agenda_form.twig', $a);
......
......@@ -47,9 +47,10 @@
</div>
<div class="form-group">
<label for="ordre">Ordre d'affichage dans l'agenda</label>
<!--
<input style="width: 100%" type="text" class="form-control" name="ordre" id="ordre" value="{% if agenda %}{{ agenda.getDisplay() }}{% endif %}" >
-->
<!--
<select name="ordre" id="ordre" class="form-control">
<option value="10" {% if agenda.getDisplay() == '' %}selected{% endif %}></option>
<option value="10" {% if agenda.getDisplay() == 10 %}selected{% endif %}>10 (Plénière)</option>
......@@ -58,6 +59,7 @@
<option value="20" {% if agenda.getDisplay() == 40 %}selected{% endif %}>40 (Groupe de travail - première session)</option>
<option value="20" {% if agenda.getDisplay() == 50 %}selected{% endif %}>50 (Groupe de travail - seconde session)</option>
</select>
-->
</div>
<div class="form-group">
<label for="jour">Selection de la Date</label> <span style="color: red;">*</span>
......@@ -75,9 +77,16 @@
<div class="form-group">
<label for="salle">Salle(s) disponible(s)</label> <span style="color: red;">*</span>
<select name="salle" id="salle" class="form-control" required disabled>
{% for salle in salles %}
<option value="{{ salle.id }}" {% if agenda.getSalle().getId() == salle.id %}selected{% endif %}>{{ salle.nom }}</option>
{% endfor %}
</select>
<!--
<select name="salle" id="salle" class="form-control" required disabled>
<option value="{{ agenda.getSalle().getId() }}">{{ agenda.getSalle().getNom() }}</option>
</select>
-->
</div>
<center>
......
......@@ -185,17 +185,20 @@
<td class="text-center" id="action_{{ id_agenda }}">
{% if agenda.check == 0 %}
{% if nb_inscriptions > 1 %}
<input type="hidden" id="vinscrit" name="vinscrit" value="21">
{% elseif inscription and inscription.getAgenda().getFormation().getType() != 'Groupe de Travail' %}
<input type="hidden" id="vinscrit" name="vinscrit" value="22">
{% elseif inscription
and (agenda['agenda'].getFormation().getType() != 'Groupe de Travail'
or (agenda['agenda'].getDateDebut() == inscription.getAgenda().getDateDebut() and agenda['agenda'].getDateFin() == inscription.getAgenda().getDateFin()))
%}
<input type="hidden" id="vinscrit" name="vinscrit" value="23">
{% else %}
<input type="hidden" id="vinscrit" name="vinscrit" value="2">
<a href="dashboard-participant-parcours-formation?token={{token}}&agenda={{id_agenda}}&valid=true&jour={{jour}}&debut={{debut}}&fin={{fin}}"
class="btn btn-success btn-inscription-formation"
data-toggle="tooltip" title="S'inscrire à cette formation">S'inscrire
</a>
<input type="hidden" id="vinscrit" name="vinscrit" value="24">
<a href="dashboard-participant-parcours-formation?token={{token}}&agenda={{id_agenda}}&valid=true&jour={{jour}}&debut={{debut}}&fin={{fin}}"
class="btn btn-success btn-inscription-formation"
data-toggle="tooltip" title="S'inscrire à cette formation">S'inscrire
</a>
{% endif %}
{% else %}
Inscrit &nbsp;
......
......@@ -835,11 +835,13 @@ $(document).ready(function() {
{
e.preventDefault();
var agenda_id = $('#agenda_id').val();
var vtype = 'POST';
if (agenda_id > 0) {
var vtype = 'PUT';
} else {
var vtype = 'POST';
vtype = 'PUT';
}
//else {
// var vtype = 'POST';
//}
var form = $(this);
$.ajax({
url: form.attr('action'),
......@@ -849,7 +851,12 @@ $(document).ready(function() {
document.location.href = $('#btn-back-agendas').attr('href');
},
error: function() {
if (vtype == 'POST'){
alert('L\'agenda n\'a pas pu être ajouté');
}
else{
alert('L\'agenda n\'a pas pu être modifié');
}
form.trigger('reset');
}
});
......@@ -1023,7 +1030,7 @@ $(document).ready(function() {
var tab_admin_agendas = $('#tab_admin_agenda');
if (tab_admin_agendas) {
intervalAllPointer = setInterval(refreshAllSessions, 5000);
intervalAllPointer = setInterval(refreshAllSessions, 3000);
}
});
......
......@@ -100,7 +100,7 @@ $(document).ready(function(){
var tab_agendas = $('#tab_agenda');
if (tab_agendas) {
intervalPointer = setInterval(refreshSessions, 5000);
intervalPointer = setInterval(refreshSessions, 3000);
}
$('.btn-inscription-formation').on('click', function(e) {
......@@ -206,7 +206,10 @@ var refreshSessions = function(token, jour, debut, fin) {
type: 'GET',
success: function(data) {
data.agendas.forEach(function(agenda) {
// gestion du Nb inscrits / quota
$('#nb_inscrits_' + agenda.id).text(agenda.nb_inscrits);
// gestion du Badge
var prct = Math.round(((agenda.nb_inscrits / agenda.quota) * 100));
var badge = '';
if (prct <= 50) {
......@@ -217,8 +220,14 @@ var refreshSessions = function(token, jour, debut, fin) {
badge = 'rouge';
}
$('#nb_inscrits_prct_' + agenda.id).html('<span class="badge badge-' + badge + '">' + prct + '%</span>');
// gestion du bouton Inscription/Desinscription
console.log('val='+ $('#vinscrit').val());
if (agenda.nb_inscrits >= agenda.quota){
if ( $('#vinscrit').val() != 1) { $('#action_' + agenda.id).hide();}
var contenu=$('#action_' + agenda.id).html();
console.log(contenu);
if ( $('#vinscrit').val() == 1) { $('#action_' + agenda.id).show();}
else { $('#action_' + agenda.id).hide();}
}
else {
$('#action_' + agenda.id).show();
......
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