File "template_courte.php"
Full Path: /home/analogde/www/MassageProd/template_courte.php
File size: 23.28 KB
MIME-type: text/x-php
Charset: utf-8
<?php
session_start ();
if (!isset($_SESSION['nom']) && !isset($_SESSION['password']))
{
header("Location: login.php");
}
header( 'content-type: text/html; charset=utf-8' );
include('database.php');
include('fonctions.php');
include('generation_timing.php');
DB_connexion();
$mois = $_GET['mois'];
$annee = date('Y');
$annee = $_SESSION['year'];
?>
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="dialog-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script>
$(function() {
$( "#j_dialog" ).dialog({
autoOpen: true,
modal: true,
width: 350,
height: 300,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
},
show: {
effect: "bounce",
duration: 1500
},
hide: {
effect: "fade",
duration: 1000
}
});
});
$( ".selector" ).dialog({
closeOnEscape: false
});
</script>
</head>
<body>
<!--
<div id="j_dialog" title="Error">
<p>Impossible de refermer le créneau car il a été réservé !</p>
</div>
-->
<!--
<div>Some text! Some text!Some text!Some text!Some text!Some text!</div>
-->
</body>
</html>
<?php
$array_horaire_court = generation_timing($_SESSION['debut_horaire_courte'], $_SESSION['temps_sceance_courte'], $_SESSION['temps_sanitaire']);
$array_horaire_long = generation_timing($_SESSION['debut_horaire_longue'], $_SESSION['temps_sceance_longue'], $_SESSION['temps_sanitaire']);
//$_SESSION['table_gestion'] = "gestion_v3_test";
//$_SESSION['table_reservation']= "reservation2023_v3_test";
$table = $_SESSION['table_reservation'];
if( $_SESSION['mode_debug'] == "yes" )
{
$debug = true;
echo " ----> : Mode debug" ."<br>";
echo "<br>";
echo "<br>";
}
else
{
$debug = false;
}
if(isset($_GET['submit']))
{
if(isset($_GET['verrou']) && $_GET['verrou'] == "ok")
{
$nb_semaine = $_GET['nb_semaine'];
if( $debug == true )
{
echo " Nombre de semaines :" .$nb_semaine;
echo "<br>";
echo "<br>";
}
$sql = "SELECT * FROM " .$table ." WHERE annee ='$annee' and formule = 'courte' and mois ='$mois' and mode = 'actif' ";
if( $debug == true )
{
//echo $sql;
//echo "<br>";
//echo "<br>";
}
mysqli_query($connexion, "SET NAMES 'utf8'");
$result = mysqli_query($connexion, $sql );
$tab_jour = array();
while ($data = mysqli_fetch_assoc ($result))
{
$tab_jour[] = $data['rendezvous'];
}
if( $debug == true )
{
echo " Date dans le mois :";
echo "<br>";
echo '<pre>';
print_r($tab_jour);
echo '</pre>';
}
$tab_store = array();
$tab_checkbox = array();
for( $i=0; $i < $nb_semaine ; $i++)
{
${'text'.$i} = "cached_check".$i;
$val = ${'text'.$i};
$val = $_GET[$val];
$tab_checkbox[] = $val;
}
if( $debug == true )
{
echo " Lignes en mode selection :";
echo "<br>";
echo '<pre>';
print_r($tab_checkbox);
echo '</pre>';
}
$coco = array();
for( $i=0; $i < $nb_semaine ; $i++)
{
//$tab_store = array();
if($tab_checkbox[$i] == "actif")
{
${'text'.$i} = "select_debut".$i;
$val1 = ${'text'.$i};
$val1 = "start".$_GET[$val1];
$tab_store[] = $val1;
${'text'.$i} = "select_fin".$i;
$val2 = ${'text'.$i};
$val2 = "stop".$_GET[$val2];
$tab_store[] = $val2;
${'text'.$i} = "input_avant".$i;
$val3 = ${'text'.$i};
$tab_store[] = $_GET[$val3];
${'text'.$i} = "input_apres".$i;
$val4 = ${'text'.$i};
$tab_store[] = $_GET[$val4];
$sql = "UPDATE " .$table ." SET horairedebut = '$val1' , horairefin = '$val2' WHERE rendezvous ='$tab_jour[$i]' ";
//$coco[] = $tab_store;
if( $debug == true)
{
//echo $sql;
//echo '<br>';
//echo '<br>';
echo '<pre>';
print_r($tab_store);
echo '</pre>';
}
mysqli_query($connexion, "SET NAMES 'utf8'");
// non actif - pas utile de redéfinir les heures de début et de fin
//$result = mysqli_query($connexion, $sql );
if(!$result)
{
die('Impossible d\'exécuter la requête :' . mysql_error());
}
}
}
/*echo '<pre>';
print_r($coco);
echo '</pre>';*/
$step = 0;
for( $i=0; $i < $nb_semaine ; $i++)
{
if($tab_checkbox[$i] == "actif")
{
echo " *******************************************************";
echo '<br>';
echo '<br>';
$sql = "SELECT * FROM " .$table ." WHERE annee ='$annee' and formule = 'courte' and mois ='$mois' and mode = 'actif' and rendezvous ='$tab_jour[$i]' ";
if( $debug == true)
{
echo $sql;
echo '<br>';
echo '<br>';
}
$result = mysqli_query($connexion, $sql );
if(!$result)
{
die('Impossible d\'exécuter la requête :' . mysql_error());
}
$tab_tmp = array();
$data = mysqli_fetch_assoc ($result);
$tab_tmp[1] = $data['seance1'];
$tab_tmp[2] = $data['seance2'];
$tab_tmp[3] = $data['seance3'];
$tab_tmp[4] = $data['seance4'];
$tab_tmp[5] = $data['seance5'];
$tab_tmp[6] = $data['seance6'];
$tab_tmp[7] = $data['seance7'];
$tab_tmp[8] = $data['seance8'];
if( $debug == true)
{
echo '<pre>';
print_r($tab_tmp);
echo '</pre>';
}
$val1 = $tab_store[$step];
$val2 = $tab_store[$step+1];
$val3 = $tab_store[$step+2];
$val4 = $tab_store[$step+3];
$step = $step + 4;
$indice_debut = substr($val1, 5);
$indice_fin = substr($val2, 4);
//echo $indice_debut ." - " .$indice_fin;
//echo '<br>';
$tab_seance = array();
$verrou = false;
$tab_seance[] = "decalage";
for( $k=1; $k <9 ; $k++)
{
$tab_seance[] = "unselect";
}
if( $debug == true)
{
echo "<pre>";
print_r($tab_seance);
echo "</pre>";
}
for( $l = $indice_debut; $l <= $indice_fin ; $l++)
{
$tab_seance[$l] = "";
}
$supplement_avant_debut = $indice_debut - $val3;
$supplement_avant_fin = $indice_debut - 1;
$supplement_apres_debut = $indice_fin + 1;
$supplement_apres_fin = $indice_fin + $val4;
// tracking bug 14/04/2015
// probléme d'effacement - état figé
// pas utilisé !!!
/*
for( $l=1; $l <9 ; $l++)
{
if( $l >= $supplement_apres_debut && $l <= $supplement_apres_fin)
{
$tab_seance[$l] = "creneau fermer";
}
if( $l >= $supplement_avant_debut && $l <= $supplement_avant_fin)
{
$tab_seance[$l] = "creneau fermer";
}
}*/
$text_horaire_debut = "select_debut".$i;
$text_horaire_fin = "select_fin".$i;
$val_horaire_debut = $_GET[$text_horaire_debut];
$val_horaire_fin = $_GET[$text_horaire_fin];
//if( strcmp($val_seance_avant, "0") == 0 )
if( $val3 == 0)
{
$text_horaire_debut = "start" .$val_horaire_debut;
}
//if( strcmp($val_seance_avant, "1") == 0 )
if( $val3 == 1)
{
$val_horaire_debut = $val_horaire_debut - 1;
$text_horaire_debut = "start" .$val_horaire_debut;
}
//if( strcmp($val_seance_apres, "0") == 0 )
if( $val4 == 0)
{
$text_horaire_fin = "stop" .$val_horaire_fin;
}
//if( strcmp($val_seance_apres, "1") == 0 )
if( $val4 == 1)
{
$val_horaire_fin = $val_horaire_fin + 1;
$text_horaire_fin = "stop" .$val_horaire_fin;
}
/*$sql = "UPDATE " .$table ." SET seance1 = '$tab_seance[1]' ,
seance6 = '$tab_seance[6]' ,
horairedebut = '$text_horaire_debut' ,
horairefin = '$text_horaire_fin' ,
avant = '$val3' ,
apres = '$val4'
WHERE rendezvous ='$tab_jour[$i]' "; */
$sql = "UPDATE " .$table ." SET seance1 = '$tab_seance[1]' ,
seance6 = '$tab_seance[6]' ,
avant = '$val3' ,
apres = '$val4'
WHERE rendezvous ='$tab_jour[$i]' ";
if( $debug == true )
{
echo $sql;
echo '<br>';
echo '<br>';
}
$check1 = false;
$check6 = false;
if( strcmp($tab_tmp[1], "") == 0 || strcmp($tab_tmp[1], "unselect") == 0 || strcmp($tab_tmp[1], "creneau ouvert") == 0 || strcmp($tab_tmp[1], "creneau fermer") == 0 )
{
echo " ------> " .$tab_seance[1] ."<br><br>";
/*echo ' <script type="text/javascript">
alert("TRACE");
</script>';*/
}
else
{
/*echo '
<div id="j_dialog" title="Error">
<p>Impossible de refermer le créneau car il a été réservé !</p>
</div>';*/
$check1 = true;
}
if( strcmp($tab_tmp[6], "") == 0 || strcmp($tab_tmp[6], "unselect") == 0 || strcmp($tab_tmp[6], "creneau ouvert") == 0 || strcmp($tab_tmp[6], "creneau fermer") == 0 )
{
echo " ------> " .$tab_seance[6] ."<br><br>";
/*echo ' <script type="text/javascript">
alert("TRACE");
</script>';*/
}
else
{
/*echo ' <script type="text/javascript">
alert(" Impossible de repasser en mode inactif car la séance a été réservée !!!!!.");
</script>';*/
/*echo '
<div id="j_dialog" title="Error">
<p>Impossible de refermer le créneau car il a été réservé !</p>
</div>';*/
$check6 = true;
}
if( $check1 == true || $check6 == true )
{
echo '<div id="j_dialog" title="Error"><p>Impossible de repasser en mode inactif car la séance a été réservée par : ' .$tab_tmp[1] .'!</p></div>';
}
//$result = mysqli_query($connexion, $sql );
if(!$result)
{
die('Impossible d\'exécuter la requête :' . mysql_error());
}
}
}
echo "Les paramétres ont été pris en compte.";
echo "<br><br>";
}
}
?>
<html>
<body>
<style>
table, th, td { padding: 10px; border: 1px ; align: center;}
</style>
<script>
function valide(valeur)
{
var verif = true;
var msg_erreur = new Array();
for (i = 0; i < valeur; i++)
{
var index_start = "id_start"+i;
var index_stop = "id_stop"+i;
var index_avant = "id_avant"+i;
var index_apres = "id_apres"+i;
var val1 = document.getElementById(index_start).selectedIndex;
var val2 = document.getElementById(index_stop).selectedIndex;
var val3 = document.getElementById(index_avant).value;
var val4 = document.getElementById(index_apres).value;
val1 = parseInt(val1);
val2 = parseInt(val2);
val3 = parseInt(val3);
val4 = parseInt(val4);
//var ligne = 0;
var ligne = i + 1;
if(val1 - val3 <= 0)
{
msg_erreur[i] = "Hors plage : ligne "+ligne;
verif = false;
}
if(val2 + val4 > 8)
{
msg_erreur[i] = "Hors plage : ligne "+ligne;
verif = false;
}
if(val1 == 0 && val2 == 0 )
{
//verif = false;
//alert("PB"+1);
msg_erreur[i] = "Heure de début et de fin non conforme : ligne "+ligne;
verif = false;
}
if(val1 == 0 && val2 != 0 )
{
//alert("Début non conforme "+i);
msg_erreur[i] = "Heure de début non conforme : ligne "+ligne;
verif = false;
}
if(val1 != 0 && val2 == 0 )
{
//alert("Fin non conforme "+i);
msg_erreur[i] = "Heure de fin non conforme : ligne "+ligne;
verif = false;
}
if(val1 != 0 && val2 != 0 )
{
//alert("Probléme d'horaire "+i);
if(val2 <= val1)
{ msg_erreur[i] = "Probléme d'horaire : ligne "+ligne;
verif = false;
}
}
if(isNaN(val3) == true )
{
msg_erreur[i] = "Ce n'est pas un chiffre ligne "+ligne;
verif = false;
}
/* else
{ if(val3 >= 3 )
{ msg_erreur[i] = "Valeur possible: 0, 1 ou 2 ligne "+i;
verif = false;
}
}*/
if(isNaN(val4) == true )
{
msg_erreur[i] = "Ce n'est pas un chiffre ligne "+ligne;
verif = false;
}
/*
else
{ if(val4 >= 3 )
{ msg_erreur[i] = "Valeur possible: 0, 1 ou 2 ligne "+i;
verif = false;
}
}*/
}
if(verif == true)
{
var nb_semaine = document.getElementById('nb_semaine').value
for (j = 0; j < nb_semaine; j++)
{
var index_start = "id_start"+j;
var index_stop = "id_stop"+j;
var index_avant = "id_avant"+j;
var index_apres = "id_apres"+j;
var index_checkbox = "ele"+j;
var val1 = document.getElementById(index_start).selectedIndex;
var val2 = document.getElementById(index_stop).selectedIndex;
var val3 = document.getElementById(index_avant).value;
var val4 = document.getElementById(index_apres).value;
var val5 = document.getElementById(index_checkbox).checked;
var element1 = "select_debut"+j;
document.getElementById(element1).value = val1;
var element2 = "select_fin"+j;
document.getElementById(element2).value = val2;
var element3 = "input_avant"+j;
document.getElementById(element3).value = val3;
var element4 = "input_apres"+j;
document.getElementById(element4).value = val4;
var element5 = "cached_check"+j;
if(val5 == true)
{ document.getElementById(element5).value = "actif";
}
else
{ document.getElementById(element5).value = "non_actif";
}
document.getElementById('verrou').value="ok";
}
}
if(verif == false)
{
var affiche = msg_erreur.join("\n"); // n <br>
alert(affiche);
document.getElementById('verrou').value="erreur";
// document.getElementById('message').innerHTML = affiche ;
//message.textContent = "my text";
// document.getElementById('message').innerHTML = "text1. \n text2.";
}
}
</script>
<link rel="stylesheet" href="menu_style.css" type="text/css">
<div id='cssmenu'>
<ul>
<li><a href='home.php'><span>Home</span></a></li>
<li><a href='selection_planning_mois.php'><span>Planning</span></a></li>
<li><a href='selection_gestion_mois.php'><span>Gestion</span></a></li>
<li><a href='selection_statistique_mois.php'><span>Statistiques</span></a></li>
<?php
if($_SESSION['nom'] == "admin")
{
echo '<li><a href="deplacer_un_rendezvous_admin.php"><span>Déplacer</span></a></li>';
echo '<li><a href="configuration.php"><span>Configuration</span></a></li>';
}
else
{
echo '<li><a href="deplacer_un_rendezvous_user.php"><span>Déplacer</span></a></li>';
}
?>
<li><a href='change_password.php'><span>Changer password</span></a></li>
<li><a href='logout.php'><span>Déconnexion</span></a></li>
<li><a href='#'><span><?php echo $_SESSION['nom'] .' ' .$_SESSION['prenom'] .' connecté' ?></span></a></li>
<li><a href='#'><span><?php echo $_SESSION['year']; ?></span></a></li>
</ul>
</div>
<br>
<br>
<?php
echo ucfirst($mois) ." " .$annee .": Scéance de 20min" ;
echo '<br><br>';
// verifier que parametre 1 et parametre2 ne sont pas vide sinon on signal que la config est incompléte !!!
$sql = "SELECT * FROM " .$table ." WHERE annee ='$annee' and formule = 'courte' and mois ='$mois' and mode = 'actif' ";
//echo $sql;
mysqli_query($connexion, "SET NAMES 'utf8'");
$result = mysqli_query($connexion, $sql );
if(!$result)
{
die('Impossible d\'exécuter la requête :' . mysql_error());
}
$n = mysqli_num_rows($result);
echo "Jours Ouverts: " .$n;
echo ' <form action="#" name ="form_horaire" method="get">
<input type="hidden" id="myInput" value="W3Schools">
<input type="hidden" name="verrou" id="verrou" value="">';
?>
<input type="hidden" name="mois" id="mois" value="<?php echo $mois; ?>">
<input type="hidden" name="nb_semaine" id="nb_semaine" value="<?php echo $n; ?>">
<?php
for( $i=0; $i < $n ; $i++)
{ $element = 'select_debut' .$i;
echo "<input type='hidden' name='$element' id='$element' value=''>";
$element = 'select_fin' .$i;
echo "<input type='hidden' name='$element' id='$element' value=''>";
$element = 'input_avant' .$i;
echo "<input type='hidden' name='$element' id='$element' value=''>";
$element = 'input_apres' .$i;
echo "<input type='hidden' name='$element' id='$element' value=''>";
$element = 'cached_check' .$i;
echo "<input type='hidden' name='$element' id='$element' value=''>";
}
echo ' <table cellpadding="10">
<tr>
<th>Sem</th>
<th>Date</th>
<th>Jour</th>
<th>Premier Crénau</th>
<th>Dernier Créneau</th>
<th>Avant</th>
<th>Aprés</th>
<th>Changer</th>
<th></th>
</tr>';
$ptr = 0;
if($n != 0)
{
while ($data = mysqli_fetch_assoc ($result))
{
$semaine = $data['semaine'];
$rendezvous = $data['rendezvous'];
$jour = $data['jour'];
$horairedebut = $data['horairedebut'];
$horairefin = $data['horairefin'];
$avant = $data['avant'];
$apres = $data['apres'];
//echo $horairedebut ." " .$horairefin;
$id_start = "id_start" .$ptr;
$id_stop = "id_stop" .$ptr;
$id_mess = "id_mess" .$ptr;
$id_avant = "id_avant" .$ptr;
$id_apres = "id_apres" .$ptr;
echo '
<tr>
<td>' .$semaine .'</td>
<td>' .$rendezvous .'</td>
<td>' .$jour .'</td>
<td>
<select id = ' .$id_start .' = name = ' .$id_start .' ;>';
echo ' <option value="">Selection:</option>';
if($horairedebut == "start1")
{
echo '<option value="start1" selected>' .$array_horaire_court[0] .'</option>';
}
else
{
echo '<option value="start1">' .$array_horaire_court[0] .'</option>';
}
if($horairedebut == "start2")
{
echo '<option value="start2" selected>' .$array_horaire_court[1] .'</option>';
}
else
{
echo '<option value="start2">' .$array_horaire_court[1] .'</option>';
}
if($horairedebut == "start3")
{
echo '<option value="start3" selected>' .$array_horaire_court[2] .'</option>';
}
else
{
echo '<option value="start3">' .$array_horaire_court[2] .'</option>';
}
if($horairedebut == "start4")
{
echo '<option value="start4" selected>' .$array_horaire_court[3] .'</option>';
}
else
{
echo '<option value="start4">' .$array_horaire_court[3] .'</option>';
}
if($horairedebut == "start5")
{
echo '<option value="start5" selected>' .$array_horaire_court[4] .'</option>';
}
else
{
echo '<option value="start5">' .$array_horaire_court[4] .'</option>';
}
if($horairedebut == "start6")
{
echo '<option value="start6" selected>' .$array_horaire_court[5] .'</option>';
}
else
{
echo '<option value="start6">' .$array_horaire_court[5] .'</option>';
}
if($horairedebut == "start7")
{
echo '<option value="start7" selected>' .$array_horaire_court[6] .'</option>';
}
else
{
echo '<option value="start7">' .$array_horaire_court[6] .'</option>';
}
if($horairedebut == "start8")
{
echo '<option value="start8" selected>' .$array_horaire_court[7] .'</option>';
}
else
{
echo '<option value="start8">' .$array_horaire_court[7] .'</option>';
}
echo '
</select>
</td>
<td>';
echo '<select id = ' .$id_stop .' = name = ' .$id_stop . '>';
echo ' <option value="">Selection:</option>';
if($horairefin == "stop1")
{
echo '<option value="stop1" selected>' .$array_horaire_court[0] .'</option>';
}
else
{
echo '<option value="stop1">' .$array_horaire_court[0] .'</option>';
}
if($horairefin == "stop2")
{
echo '<option value="stop2" selected>' .$array_horaire_court[1] .'</option>';
}
else
{
echo '<option value="stop2">' .$array_horaire_court[1] .'</option>';
}
if($horairefin == "stop3")
{
echo '<option value="stop3" selected>' .$array_horaire_court[2] .'</option>';
}
else
{
echo '<option value="stop3">' .$array_horaire_court[2] .'</option>';
}
if($horairefin == "stop4")
{
echo '<option value="stop4" selected>' .$array_horaire_court[3] .'</option>';
}
else
{
echo '<option value="stop4">' .$array_horaire_court[3] .'</option>';
}
if($horairefin == "stop5")
{
echo '<option value="stop5" selected>' .$array_horaire_court[4] .'</option>';
}
else
{
echo '<option value="stop5">' .$array_horaire_court[4] .'</option>';
}
if($horairefin == "stop6")
{
echo '<option value="stop6" selected>' .$array_horaire_court[5] .'</option>';
}
else
{
echo '<option value="stop6">' .$array_horaire_court[5] .'</option>';
}
if($horairefin == "stop7")
{
echo '<option value="stop7" selected>' .$array_horaire_court[6] .'</option>';
}
else
{
echo '<option value="stop7">' .$array_horaire_court[6] .'</option>';
}
if($horairefin == "stop8")
{
echo '<option value="stop8" selected>' .$array_horaire_court[7] .'</option>';
}
else
{
echo '<option value="stop8">' .$array_horaire_court[7] .'</option>';
}
echo ' </select>
</td>';
echo ' <td>
<input type ="text" size = "3" maxlength="1" id = ' .$id_avant .' = name = ' .$id_avant .' value = ' .$avant .'>
</td>';
echo ' <td>
<input type ="text" size = "3" maxlength="1" id = ' .$id_apres .' = name = ' .$id_apres .' value = ' .$apres .'>
</td>';
$id_checkbox = "ele".$ptr;
echo ' <td>
<input type="checkbox" id=' .$id_checkbox .' name=' .$id_checkbox .' value ="">
</td>';
echo ' <td><p id="' .$id_mess .'"></p></td>
</tr>';
$ptr = $ptr + 1;
}
?>
</table>
<?php
echo '<input type="submit" name="submit" value="Enregistrer" onclick="valide(' .$ptr .')" />';
echo '</form>';
}
?>
</body>
</html>