Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
MassageProd
:
template_courte02.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?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']; $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']; $_SESSION['mode_debug'] = "yes"; if( $_SESSION['mode_debug'] == "yes" ) { $debug = true; echo " ----> : Mode debug"; echo "<br>"; echo "<br>"; print_r($_SESSION); echo "<br>"; echo "<br>"; } else { $debug = false; } //print_r($array_horaire_court); if(isset($_GET['submit'])) { if(isset($_GET['verrou']) && $_GET['verrou'] == "ok") { echo "<pre>"; print_r($_GET); echo "</spre>"; echo "<br>"; echo "<br>"; $nb_semaine = $_GET['nb_semaine']; $sql = "SELECT * FROM " .$table ." WHERE annee ='$annee' and formule = 'courte' and mois ='$mois' and mode = 'actif' "; if( $debug == true ) { echo "-- Nb de date à traiter --"; echo "<br>"; echo $nb_semaine; echo "<br>"; echo "<br>"; echo "-- Lecture des infos dans la DB --"; echo "<br>"; echo $sql; echo "<br>"; } $date = array(); mysqli_query($connexion, "SET NAMES 'utf8'"); $result = mysqli_query($connexion, $sql ); $tab_jour = array(); while ($data = mysqli_fetch_assoc ($result)) { $tab_jour[] = $data['rendezvous']; $tmp = array(); $tmp[] = $data['horairedebut']; $tmp[] = $data['horairefin']; $tmp[] = $data['avant']; $tmp[] = $data['apres']; //echo "<pre>"; //print_r($tmp); //echo "</pre>"; //$tab_jour[] = $tmp; } if( $debug == true ) { echo '<pre>'; print_r($tab_jour); echo "</pre>"; echo "<br>"; } $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 "-- Tab checkbox --" ."<br>"; echo "<pre>"; print_r($tab_checkbox); echo "</pre>"; echo "<br>"; } for( $i=0; $i < $nb_semaine ; $i++) { if($tab_checkbox[$i] == "actif") { $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]; $text_avant = "input_avant".$i; $text_apres = "input_apres".$i; $val_seance_avant = $_GET[$text_avant]; $val_seance_apres = $_GET[$text_apres]; if( $debug == true ) { echo " ++++ > " .$text_horaire_debut ." " .$text_horaire_fin; echo "<br>"; echo " ---- > " .$val_horaire_debut ." " .$val_horaire_fin; echo "<br>"; echo " ++++ > " .$text_avant ." " .$text_apres; echo "<br>"; echo " ---- > " .$val_seance_avant ." " .$val_seance_apres; echo "<br>"; } if( strcmp($val_seance_avant, "0") == 0 ) { $seance1 = "unselect"; $text_new_start = "start" .$val_horaire_debut; } if( strcmp($val_seance_avant, "1") == 0 ) { $val_horaire_debut = $val_horaire_debut - 1; $text_new_start = "start" .$val_horaire_debut; $seance1 = "creneau fermer"; if( $debug == true ) { echo "Change debut " .$val_horaire_debut; echo "<br>"; echo "Change " .$text_new_start; echo "<br>"; } } if( strcmp($val_seance_apres, "0") == 0 ) { $seance6 = "unselect"; $text_new_stop = "stop" .$val_horaire_fin; } if( strcmp($val_seance_apres, "1") == 0 ) { $val_horaire_fin = $val_horaire_fin + 1; $text_new_stop = "stop" .$val_horaire_fin; $seance6 = "creneau fermer"; if( $debug == true ) { echo "Change fin " .$val_horaire_fin; echo "<br>"; echo "Change " .$text_new_stop; echo "<br>"; } } mysqli_query($connexion, "SET NAMES 'utf8'"); $sql = "UPDATE " .$table ." SET seance1 = '$seance1' , seance6 = '$seance6' , avant = '$text_new_start' , apres = '$text_new_stop' WHERE rendezvous ='$tab_jour[$i]' "; $result = mysqli_query($connexion, $sql ); if( $debug == true ) { echo $sql; echo '<br>'; echo '<br>'; } echo "---------------------------------"; echo "<br>"; } } /*for( $i=0; $i < $nb_semaine ; $i++) { 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]' "; //if( $debug == true ) //{ // echo $sql; // echo "<br>"; //} //mysqli_query($connexion, "SET NAMES 'utf8'"); //$result = mysqli_query($connexion, $sql ); //if(!$result) //{ // die('Impossible d\'exécuter la requête :' . mysql_error()); //} } } */ /* if( $debug == true ) { echo "-- Etat avant le changement --"; echo "<br>"; echo "<pre>"; print_r($tab_store); echo "</pre>"; echo "<br>"; echo "-- Changement implémenté --"; echo "<br>"; } echo "----------------------------------------------------"; echo "<br>"; echo "<br>"; */ // $step = 0; /* for( $i=0; $i < $nb_semaine ; $i++) { if($tab_checkbox[$i] == "actif") { if( $debug == true ) { $sql = "SELECT * FROM " .$table ." WHERE annee ='$annee' and formule = 'courte' and mois ='$mois' and mode = 'actif' and rendezvous ='$tab_jour[$i]' "; echo $sql; 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>"; echo "<br>"; } $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>"; echo "<br>"; } 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; 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"; } } if( $debug == true ) { echo "<pre>"; print_r($tab_seance); echo "</pre>"; echo "<br>"; } $sql = "UPDATE " .$table ." SET seance1 = '$tab_seance[1]' , seance2 = '$tab_seance[2]' , seance3 = '$tab_seance[3]' , seance4 = '$tab_seance[4]' , seance5 = '$tab_seance[5]' , seance6 = '$tab_seance[6]' , seance7 = '$tab_seance[7]' , seance8 = '$tab_seance[8]' , avant = '$val3' , apres = '$val4' WHERE 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()); } } } */ 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>