<?php
echo '<meta charset="utf-8" />';
if(isset($_SESSION['user_droits'])) {
	$droits = substr($_SESSION['user_droits'],3,1);
	
	if ($droits!="2") {
		echo '<p class="noaccess">'.NOMODULE.'<br><a href="./index.php">'.ACCUEIL.'</a></p>';
	}
	else {
		?><style type="text/css">
		#mfr7 { background-color: #fff; }
		#mfr7 td { border: 3px #B90404 solid; }
		#mfr6 td { border:0; }
		</style><?php
		function rand_chars($length = 25) {
		    $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
		    $charactersLength = strlen($characters);
		    $randomString = '';
		    for ($i = 0; $i < $length; $i++) {
		        $randomString .= $characters[rand(0, $charactersLength - 1)];
		    }
		    return $randomString;
		}

		echo '<h1>'.FREQC_PARAM1.'</h1>';

		echo FREQC_PARAM2;
		//Vérification des suspensions
		include('db/proc/freq_finsuspension.php');

		//HORAIRES
		echo '<h2>'.PARANAV5.'</h2>';
		echo FREQC_PARAM3;

		echo '<hr class="param">';

		//AFFICHAGE DES INSCRITS
		echo '<h2>'.FREQC_PARAM4.'</h2>';
		$espopt = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'espaces_gestion'"));
		echo '<p>'.FREQC_PARAM5;
		if($espopt['valeur']==1) { echo FREQC_PARAM6; } else { echo FREQC_PARAM7; }
		echo FREQC_PARAM8.'</p>';
		$oaf = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_ordreaff'");
		$oaf_info = mysqli_fetch_assoc($oaf);
		echo '<input type="radio" name="ordreaf" id="ordreaffdiv" value="div" ';
		if($oaf_info['valeur']=="div") { echo 'checked'; }
		echo ' /><label for="ordreaffdiv">'.ORDER4.'</label>
		<br><input type="radio" id="ordreaffact" name="ordreaf" value="act" '; 
		if($oaf_info['valeur']=="act") { echo 'checked'; }
		echo ' /><label for="ordreaffact">'.ORDER5.'</label>
		<br><input type="radio" id="ordreaffnom" name="ordreaf" value="nom" '; 
		if($oaf_info['valeur']=="nom") { echo 'checked'; }
		echo ' /><label for="ordreaffnom">'.ORDER6.'</label>
		<br><input type="radio" id="ordreaffhor" name="ordreaf" value="hor" '; 
		if($oaf_info['valeur']=="hor") { echo 'checked'; }
		echo ' /><label for="ordreaffhor">'.ORDER10.'</label>';
		if($espopt['valeur']==1) { 
			echo '<br><input type="radio" id="ordreaffesp" name="ordreaf" value="esp" '; 
			if($oaf_info['valeur']=="esp") { echo 'checked'; }
			echo ' /><label for="ordreaffesp">'.ORDER8.' - '.ORDER11.'</label>';
		}
		echo '<br><p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="ordreaffs(this);colorval(\'ordreaff\');" id="ordreaff" value="'.VALID.'" name="ordreaff_valid" /></p>';
		?><script type="text/javascript">
			function ordreaffs(param) {
			var param = "ordreaff";
			var typ = document.getElementsByName("ordreaf");              
            for(i = 0; i < typ.length; i++) {
                if(typ[i].checked)
                var typc = typ[i].value;
            }
			$.ajax({
			    type: "POST",
			    data: { param: param, typc: typc },
			    url: "js/idl/freq_param_syn.php",
			   });
			}
		</script><?php
		
		echo '<hr class="param">';

		//ACTIVITES
		echo '<h2 id="activites">'.ACTIV2.'</h2>';		
		
		// Gestion de la suppression d'une activité
		if(isset($_POST['activ_suppr'])) {
			$code_suppr = mysqli_real_escape_string($bdd, $_POST['suppractiv']);
			mysqli_query($bdd,"DELETE FROM ".$prefix."_freqactiv WHERE code_activ = '".$code_suppr."'");
		}		
		// Gestion du choix d'activité par défaut
		if(isset($_POST['activ_default'])) {
			$code_activ = $_POST['defaultactiv'];
			mysqli_query($bdd,"UPDATE ".$prefix."_freqactiv SET default_activ = 0");
			if($code_activ!="") {
				mysqli_query($bdd,"UPDATE ".$prefix."_freqactiv SET activ_activ = 1, default_activ = 1 WHERE code_activ = '".$code_activ."'");								
			}
			if(isset($_POST['verractiv'])) { $verractiv = 1; } else { $verractiv = 0; }
			mysqli_query($bdd,"UPDATE ".$prefix."_parametres SET valeur = '".$verractiv."' WHERE param_nom = 'freq_verractiv'");
		}
		
		// Gestion de l'ajout d'une activité
		if(isset($_POST['newactiv_valid'])) {
			$nomnew = mysqli_real_escape_string($bdd,trim($_POST['activite']));
			$nom_verif = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_freqactiv WHERE nom_activ = '".$nomnew."'"));
			if($nom_verif==0) {

			}
			$nomnew = mysqli_real_escape_string($bdd,trim($_POST['activite']));
			$nom_verif = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_freqactiv WHERE nom_activ = '".$nomnew."'"));
			if($nom_verif==0) {
				$code_activ = rand_chars(4);
				while(mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_freqactiv WHERE code_activ = '".$code_activ."'"))>0) {
					$code_activ = rand_chars(4);
				}
				mysqli_query($bdd,"INSERT INTO ".$prefix."_freqactiv (activ_id, code_activ, nom_activ, activ_activ, default_activ, consult_activ) VALUES ('', '".$code_activ."', '".$nomnew."', 1, 0, 1)");
			}
			else {
				echo FREQC_PARAM9;
			}
		}	
		if (isset($_POST['activ_defaultcren'])) {
		    $valeurs = [];
		    if (isset($_POST['defaultactiv']) && is_array($_POST['defaultactiv'])) {
		        foreach ($_POST['defaultactiv'] as $moment => $idActiv) {
		            $moment = substr($moment, 0, 1);
		            if ($idActiv > 0) {
		                $valeurs[] = $moment . $idActiv;
		            }
		        }
		    }
		    $valeurFinale = (!empty($valeurs)) ? implode(';', $valeurs) : '0';
		    mysqli_query(
		        $bdd,
		        "UPDATE ".$prefix."_parametres 
		         SET valeur = '".mysqli_real_escape_string($bdd, $valeurFinale)."'
		         WHERE param_nom = 'freq_activitescreneaux'"
		    );
		    if(isset($_POST['verractiv2'])) { $verractiv = 1; } else { $verractiv = 0; }
			mysqli_query($bdd,"UPDATE ".$prefix."_parametres SET valeur = '".$verractiv."' WHERE param_nom = 'freq_verractiv'");
		}		
		
		// Activations
		echo FREQC_PARAM10;
		$activ = mysqli_query($bdd,"SELECT * FROM ".$prefix."_freqactiv WHERE code_activ <> 'ZERO' ORDER BY nom_activ ASC");
		$nb_activ = mysqli_num_rows($activ);
		if($nb_activ==0) {
			echo '<p>'.NOACTIV.'.</p>';
		}
		else {
			foreach($activ as $check_activ) {
				if($check_activ['activ_activ'] == "1") { $check = "checked"; } else { $check = "0"; }
				echo '<input type="checkbox" name="'.$check_activ['code_activ'].'" id="c'.$check_activ['code_activ'].'" '.$check.'/> <label for="c'.$check_activ['code_activ'].'">'.$check_activ['nom_activ'].'</label><br>';
			}
			echo '<p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="activactiv(this);colorval(\'activactiv\');" value="'.VALID.'" id="activactiv" name="activ_valid" /></p>';
		}
		echo '<script type="text/javascript">
			function activactiv(param) {
			var param = "activactiv";';
			foreach($activ as $check_code) {
				echo ' var c'.$check_code['code_activ'].' = document.getElementById("c'.$check_code['code_activ'].'").checked;
				if(c'.$check_code['code_activ'].'===false) {
					var t'.$check_code['code_activ'].' = 0;
				}
				else {
					var t'.$check_code['code_activ'].' = 1;
				}';
			}
			echo ' $.ajax({
			    type: "POST",
			    data: { param: param'; 
			    foreach($activ as $check_code) { echo ', t'.$check_code['code_activ'].':t'.$check_code['code_activ'].' '; } 
			    echo '},
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script>';
		// Suppression
		echo '<p><b>'.FREQC_PARAM11.'</b></p>';
		$activ = mysqli_query($bdd,"SELECT fa.code_activ, fa.nom_activ FROM ".$prefix."_freqactiv fa LEFT JOIN ".$prefix."_freq fr ON fr.code_activ = fa.code_activ WHERE fr.code_activ IS NULL AND fa.code_activ <> 'ZERO' ORDER BY fa.nom_activ ASC");
		$nb_activ = mysqli_num_rows($activ);
		if($nb_activ==0) {
			echo NOACTIV2;
		}
		else {
			echo'<form method="POST" name="suppractiv" action="freq.php?page=param#activites" class="padd3">'.FREQC_PARAM12.' <div class="box"><select name="suppractiv" value=""><option></option>';
			$liste_activ = mysqli_fetch_assoc($activ);
			while ($liste = mysqli_fetch_assoc($activ)) {
				echo '<option value="'.$liste['code_activ'].'">'.$liste['nom_activ'].'</option>';
			}
			echo '</select></div> <input class="bouton boutfreq" type="submit" value="'.SUPPR.'" name="activ_suppr" /></form>';
		}
		// Choix de l'activité par défaut
		echo '<p><b>'.FREQC_PARAM13.'</b></p>';
		$activ = mysqli_query($bdd,"SELECT * FROM ".$prefix."_freqactiv WHERE code_activ <> 'ZERO' ORDER BY nom_activ ASC");
		$nb_activ = mysqli_num_rows($activ);
		if($nb_activ==0) {
			echo '<p>'.NOACTIV.'</p>';
		}
		else {
			$activd = mysqli_query($bdd,"SELECT * FROM ".$prefix."_freqactiv WHERE default_activ = 1");
			$nom_activd = mysqli_fetch_assoc($activd);
			if(@$nom_activd['code_activ']=="ZERO"||mysqli_num_rows($activd)==0) {
				echo FREQC_PARAM14;
			}
			else {
				echo '<p>'.FREQC_PARAM15.' "<b>'.$nom_activd['nom_activ'].'</b>" '.FREQC_PARAM16.'</p>';
			}
			echo'<form method="POST" name="defaultactiv" action="freq.php?page=param#activites" class="padd3">'.FREQC_PARAM17.' <div class="box"><select name="defaultactiv" value=""><option></option>';
			$liste_activ = mysqli_query($bdd,"SELECT * FROM ".$prefix."_freqactiv WHERE code_activ <> 'ZERO' ORDER BY nom_activ ASC");
			foreach($liste_activ as $liste) {
				echo '<option value="'.$liste['code_activ'].'"';
				if(@$nom_activd['code_activ']==$liste['code_activ']) {
					echo ' selected ';
				}
				echo '>'.$liste['nom_activ'].'</option>';
			}
			echo '</select></div>
			<br><input type="checkbox" id="verractiv" name="verractiv"';
			$verrtest = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_verractiv'"));
			if($verrtest['valeur']==1) { echo 'checked'; }
			echo ' /><label for="verractiv">'.FREQC_PARAM18.'</label><p class="paddvalid1"><input class="bouton boutfreq" type="submit" value="'.VALID.'" name="activ_default" /></p></form>';
		}

		echo '<p><b>'.FREQC_PARAM13B.'</b></p>';
		$activ = mysqli_query($bdd,"SELECT * FROM ".$prefix."_freqactiv WHERE code_activ <> 'ZERO' ORDER BY nom_activ ASC");
		$nb_activ = mysqli_num_rows($activ);
		if($nb_activ==0) {
			echo '<p>'.NOACTIV.'</p>';
		}
		else {
			echo FREQC_PARAM14B;
			$activcren = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_activitescreneaux'"));
			if($activcren['valeur']!='0') {
				$actcren = explode(';',$activcren['valeur']);
				foreach ($actcren as $val) {
			        $moment = substr($val, 0, 1);   // M, A, P...
			        $idActiv = substr($val, 1);     // 8, 12, 6
			        $defaultActivites[$moment] = $idActiv;
			    }
			}
			echo'<form method="POST" name="activcreneaux" action="freq.php?page=param#activites" class="padd3">';
			$hor_temps = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'hor_temps'"));
			$crecode = explode(';',$hor_temps['valeur']);
			echo '<table>';
			for($nuchor=0;$nuchor<count($crecode);$nuchor++) {
				echo '<tr><td>'.MOMENT[$crecode[$nuchor]];
				echo ' : </td><td><div class="box"><select name="defaultactiv['.$crecode[$nuchor].']"><option></option>';
				$liste_activ = mysqli_query($bdd,"SELECT * FROM ".$prefix."_freqactiv WHERE code_activ <> 'ZERO' ORDER BY nom_activ ASC");
				foreach($liste_activ as $liste) {
					echo '<option value="'.$liste['code_activ'].'"';
					if (
				        isset($defaultActivites[$crecode[$nuchor]]) &&
				        $defaultActivites[$crecode[$nuchor]] == $liste['code_activ']
				    ) {
				        echo ' selected';
				    }
					echo '>'.$liste['nom_activ'].'</option>';
				}
				echo '</select></div></td></tr>';				
			}
			echo '</table>';			
			echo '<br><input type="checkbox" id="verractiv2" name="verractiv2"';
			$verrtest = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_verractiv'"));
			if($verrtest['valeur']==1) { echo 'checked'; }
			echo ' /><label for="verractiv2">'.FREQC_PARAM18.'</label><p class="paddvalid1"><input class="bouton boutfreq" type="submit" value="'.VALID.'" name="activ_defaultcren" /></p></form>';
		}
		
		// Ajout d'une activité
		echo '<p><b>'.FREQC_PARAM19.'</b></p>';
		echo '<form method="POST" name="newactiv" action="freq.php?page=param#activites" class="padd3">'.FREQC_PARAM20.' <input type="text" class="inptxt" name="activite" maxlength="100" /> <input class="bouton boutfreq" type="submit" value="'.VALID.'" name="newactiv_valid" /></form>';
		
		// Activités visibles en consultation (paramétrage si option)
		echo '<p><b>'.FREQC_PARAM21.'</b></p>';
		$activ = mysqli_query($bdd,"SELECT * FROM ".$prefix."_freqactiv WHERE code_activ <> 'ZERO' ORDER BY nom_activ ASC");
		$nb_activ = mysqli_num_rows($activ);
		if($nb_activ==0) {
			echo '<p>'.NOACTIV.'.</p>';
		}
		else {
			echo FREQC_PARAM22;
			foreach($activ as $check_activ) {
				if($check_activ['consult_activ'] == "1") { $check = "checked"; } else { $check = "0"; }
				echo '<input type="checkbox" name="'.$check_activ['code_activ'].'" id="cons'.$check_activ['code_activ'].'" '.$check.'/> <label for="cons'.$check_activ['code_activ'].'">'.$check_activ['nom_activ'].'</label><br>';
			}
			echo '<p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="consultactiv(this);colorval(\'consultactiv\');" value="'.VALID.'" id="consultactiv" name="consultactiv_valid" /></p>';
		}
		echo '<script type="text/javascript">
			function consultactiv(param) {
			var param = "consultactiv";';
			foreach($activ as $check_code) {
				echo ' var cons'.$check_code['code_activ'].' = document.getElementById("cons'.$check_code['code_activ'].'").checked;
				if(cons'.$check_code['code_activ'].'===false) {
					var tc'.$check_code['code_activ'].' = 0;
				}
				else {
					var tc'.$check_code['code_activ'].' = 1;
				}';
			}
			echo ' $.ajax({
			    type: "POST",
			    data: { param: param'; 
			    foreach($activ as $check_code) { echo ', tc'.$check_code['code_activ'].':tc'.$check_code['code_activ'].' '; } 
			    echo '},
			    url: "js/idl/freq_param_syn.php",
			   });
			}
		</script>';

		// Visibilité des activités en consultation (paramétrage si option)
		echo '<p><b>'.FREQC_PARAM23.'</b></p>';
		echo '<input type="checkbox" id="activ_obli" name="activ_obli" ';
		$check_activ_obli = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_activ_obli'"));
		if($check_activ_obli['valeur']==1) { echo 'checked'; }
		echo ' /><label for="activ_obli"> '.FREQC_PARAM24.'</label><br>';
		echo '<input type="checkbox" id="consultactiv_opt" name="consultactiv_opt" ';
		$check_consultactiv_opt = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_consultactiv'"));
		if($check_consultactiv_opt['valeur']==1) { echo 'checked'; }
		echo ' /><label for="consultactiv_opt"> '.FREQC_PARAM25.'</label><p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="visibleactiv(this);colorval(\'visibleactiv\');" id="visibleactiv" value="'.VALID.'" name="consultactiv_opt_valid" /></p>';
		?><script type="text/javascript">
			function visibleactiv(param) {
			var param = "visibleactiv";
			var checkedver = document.getElementById("consultactiv_opt").checked;
			if(checkedver===false) {
				var visible = "0";
			}
			else {
				var visible = "1";
			}
			var checkedved = document.getElementById("activ_obli").checked;
			if(checkedved===false) {
				var obliga = "0";
			}
			else {
				var obliga = "1";
			}
			$.ajax({
			    type: "POST",
			    data: { param: param, visible: visible, obliga: obliga },
			    url: "js/idl/freq_param_syn.php",
			   });
			}
		</script><?php

		//Récupération de l'option de gestion des différents espaces
		$espopt = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'espaces_gestion'"));
		
		echo '<hr class="param">';

		//PASSAGE CRENEAU SUIVANT
		echo '<h2>'.FREQC_PARAM26.'<i class="fa-solid fa-street-view"></i></a></h2>';
		echo FREQC_PARAM27;
		$nb_anticip = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_creneausuiv'"));
		echo FREQC_PARAM28.' <div class="box"><select value="" id="minutes" name="minutes">
			<option></option>';
		$optant = array('0','5','10','15');
		for($i=0;$i<count($optant);$i++) {
			echo '<option value="'.$optant[$i].'"';
			if($nb_anticip['valeur']==$optant[$i]) {
				echo ' selected ';
			}
			echo '>'.$optant[$i].' '.PARAC_USER29.'</option>';
		}
		echo '</select></div>
		<p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="anticipval(this);colorval(\'anticipval\');" id="anticipval" value="'.VALID.'" name="anticip_valid" /></p>';
		?><script type="text/javascript">
			function anticipval(param) {
			var param = "anticipe";
			var val = document.getElementById("minutes").value;          
            $.ajax({
			    type: "POST",
			    data: { param: param, val: val },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script><?php

		//INSCRIPTION SUR PLUSIEURS CRENEAUX
		echo '<h2>'.FREQC_PARAM29.'<i class="fa-solid fa-street-view"></i></a></h2>';
		echo FREQC_PARAM30;
		$nb_cren = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_multiinscrit'"));
		echo FREQC_PARAM31.' <input type="number" min="0" max="20" value="'.$nb_cren['valeur'].'" id="nbcren" name="nbcren"><p class="paddvalid1">
		<input class="bouton boutfreq" type="submit" value="'.VALID.'" onclick="multicrenval(this);colorval(\'multicrenval\');" id="multicrenval" name="multicren_valid" /></p>';
		?><script type="text/javascript">
			function multicrenval(param) {
			var param = "multicren";
			var val = document.getElementById("nbcren").value;          
            $.ajax({
			    type: "POST",
			    data: { param: param, val: val },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script><?php

		echo '<hr class="param">';

		//AFFICHAGE DES INSCRITS SUR CRENEAU PRECEDENT
		echo '<h2 id="crenprecdiv">'.FREQC_PARAM32.'<i class="fa-solid fa-street-view"></i></a></h2>';
		$crprechoix_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_crprechoix'"));
		echo '<input type="radio" name="crenprec" id="0h" value="0h" ';
		if(substr($crprechoix_info['valeur'],0,1)==0) { echo 'checked'; }
		echo ' /><label for="0h">'.FREQC_PARAM33.'</label>
		<br><input type="radio" name="crenprec" id="1h" value="1h" '; 
		if($crprechoix_info['valeur']=='1h') { echo 'checked'; }
		echo ' /><label for="1h">'.FREQC_PARAM34.'</label>
		<br><input type="radio" name="crenprec" id="1b" value="1b" '; 
		if($crprechoix_info['valeur']=='1b') { echo 'checked'; }
		echo ' /><label for="1b">'.FREQC_PARAM35.'</label>
		<br><input type="radio" name="crenprec" id="2h" value="2h" '; 
		if($crprechoix_info['valeur']=='2h') { echo 'checked'; }
		echo ' /><label for="2h">'.FREQC_PARAM36.'</label>
		<br><input type="radio" name="crenprec" id="2b" value="2b" '; 
		if($crprechoix_info['valeur']=='2b') { echo 'checked'; }
		echo ' /><label for="2b">'.FREQC_PARAM37.'</label>';

		echo '<br><p class="paddvalid1"><input class="bouton boutfreq" onclick="crenprecval(this);colorval(\'crenprecval\');" id="crenprecval" type="submit" value="'.VALID.'" name="crenprec_valid" /></p>';
		?><script type="text/javascript">
			function crenprecval(param) {
			var param = "crenprec";
			var typ = document.getElementsByName("crenprec");              
            for(i = 0; i < typ.length; i++) {
                if(typ[i].checked)
                var typc = typ[i].value;
            }
			$.ajax({
			    type: "POST",
			    data: { param: param, typc: typc },
			    url: "js/idl/freq_param_syn.php",
			   });
			}
		</script><?php

		echo '<hr class="param">';

		//GRAPPES ET PASSAGES
		echo '<h2>'.FREQC_PARAM38.'</h2>';
		echo '<input type="checkbox" name="appelgrappes" id="appelgrappes"';
		$appelchoix = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_grappes'");
		$appelchoix_info = mysqli_fetch_assoc($appelchoix);
		if ($appelchoix_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="appelgrappes"> '.FREQC_PARAM39.'</label><br>';
		echo '<input type="checkbox" name="appelpass" id="appelpass"';
		$appelchoix = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_passages'");
		$appelchoix_info = mysqli_fetch_assoc($appelchoix);
		if ($appelchoix_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="appelpass"> '.FREQC_PARAM40.'</label><br>';
		echo '<p class="paddvalid1"><input class="bouton boutfreq" onclick="passagesval(this);colorval(\'passagesval\');" id="passagesval" type="submit" value="'.VALID.'" name="grap_valid" /></p>';
		?><script type="text/javascript">
			function passagesval(param) {
			var param = "passages";
			var checkedensem = document.getElementById("appelgrappes").checked;
			var checkedpass = document.getElementById("appelpass").checked;
			if(checkedensem===false) {
				var ensemble = "0";
			}
			else {
				var ensemble = "1";
			}
			if(checkedpass===false) {
				var passages = "0";
			}
			else {
				var passages = "1";
			}
			$.ajax({
			    type: "POST",
			    data: { param: param, ensemble: ensemble, passages: passages},
			    url: "js/idl/freq_param_syn.php",
			   });
			}
		</script><?php
		
		echo '<hr class="param">';

		//MAX ELEVES ET REFUS
		echo '<h2>'.FREQC_PARAM41.'</h2>';
		echo FREQC_PARAM421.$_SESSION['lieu_genre2'].$_SESSION['lieu_nom'].FREQC_PARAM422;
		echo FREQC_PARAM43;
		// Inscriptions :
		echo '<b>'.FREQC_PARAM44.'</b>';
		$sin = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_seuilnbi'");
		$sin_info = mysqli_fetch_assoc($sin);
		$sir = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_seuilreaci'");
		$sir_info = mysqli_fetch_assoc($sir);
		echo '<p>'.FREQC_PARAM45.' <input type="number" class="number" id="seuilinb" name="seuilinb" value="'.$sin_info['valeur'].'" /><br>'.FREQC_PARAM46.' <input type="radio" name="seuilireac" id="alert" value="alert" ';
		if($sir_info['valeur']=="alert") { echo 'checked'; }
		echo ' /><label for="alert">'.PARAC_ETAB27.'</label> <input type="radio" name="seuilireac" id="stopp" value="stopp" '; 
		if($sir_info['valeur']=="stopp") { echo 'checked'; }
		echo ' /><label for="stopp">'.PARAC_ETAB28.'</label> &nbsp; <input class="bouton boutfreq" type="submit" value="'.VALID.'" onclick="seuili_val(this);colorval(\'seuili_val\');" id="seuili_val" name="seuili_valid" /></p>';
		?><script type="text/javascript">
			function seuili_val(param) {
			var param = "seuili";
			var typ = document.getElementsByName("seuilireac");    
			var val = document.getElementById("seuilinb").value;          
            for(i = 0; i < typ.length; i++) {
                if(typ[i].checked)
                var typd = typ[i].value;
            }
			$.ajax({
			    type: "POST",
			    data: { param: param, typd: typd, val: val },
			    url: "js/idl/freq_param_syn.php",
			   });
			}
		</script><?php

		if($espopt['valeur']==1) {
			echo '<b>'.FREQC_PARAM47.'</b>';
			$visesp = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_vision_espaces_ins'"));
			echo '<p><input type="checkbox" name="visibesp" id="visibesp" ';
			if($visesp['valeur']==1) { $check = 'checked'; } else { $check = 0; }
			echo $check.' /><label for="visibesp">'.FREQC_PARAM48.'</label> &nbsp;  <input class="bouton boutfreq" onclick="visibleseuil(this);colorval(\'visibleseuil\');" id="visibleseuil" type="submit" value="'.VALID.'" name="visibesp_valid" /></p>';
			?><script type="text/javascript">
				function visibleseuil(param) {
				var param = "visibleseuil";
				var checkedver = document.getElementById("visibesp").checked;
				if(checkedver===false) {
					var visible = "0";
				}
				else {
					var visible = "1";
				}
				$.ajax({
				    type: "POST",
				    data: { param: param, visible: visible },
				    url: "js/idl/freq_param_syn.php",
				   });
				}
			</script><?php
		}
		// Réservations :
		echo '<b>'.FREQC_PARAM49.'</b>';
		$srn = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_seuilnbr'");
		$srn_info = mysqli_fetch_assoc($srn);
		$srr = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_seuilreacr'");
		$srr_info = mysqli_fetch_assoc($srr);
		echo '<p>'.FREQC_PARAM45.' <input type="number" class="number" name="seuilrnb" id="seuilrnb" value="'.$srn_info['valeur'].'" /><br>'.FREQC_PARAM46.' <input type="radio" name="seuilrreac" id="ralert" value="alert" ';
		if($srr_info['valeur']=="alert") { echo 'checked'; }
		echo ' /><label for="ralert">'.PARAC_ETAB27.'</label> <input type="radio" name="seuilrreac" id="rstopp" value="stopp" '; 
		if($srr_info['valeur']=="stopp") { echo 'checked'; }
		echo ' /><label for="rstopp">'.PARAC_ETAB28.'</label> &nbsp;  <input class="bouton boutfreq" type="submit" value="'.VALID.'" onclick="seuilr_val(this);colorval(\'seuilr_val\');" id="seuilr_val" name="seuilr_valid" /></p>';
		?><script type="text/javascript">
			function seuilr_val(param) {
			var param = "seuilr";
			var typ = document.getElementsByName("seuilrreac");    
			var val = document.getElementById("seuilrnb").value;          
            for(i = 0; i < typ.length; i++) {
                if(typ[i].checked)
                var typd = typ[i].value;
            }
			$.ajax({
			    type: "POST",
			    data: { param: param, typd: typd, val: val },
			    url: "js/idl/freq_param_syn.php",
			   });
			}
		</script><?php

		echo '<b id="suspension">'.FREQC_PARAM50.DOTS.'</b>';
		include('db/proc/freqres_suspensions.php');	
		
		echo '<hr class="param">';
		
		//EXCLUSIONS
		echo '<h2 id="exclusions">'.FREQNAV4.'</h2>';

		if(isset($_POST['exclu_valid'])) {
			if(isset($_POST['excluopt'])) { $excluopt = 1; } else { $excluopt = 0; }
			mysqli_query($bdd,"UPDATE ".$prefix."_parametres SET valeur = '".$excluopt."' WHERE param_nom = 'freq_excluopt'");			
			?><script language="Javascript">
			<!--
			document.location.replace("freq.php?page=param");
			// -->
			</script><?php
		}

		echo '<form method="POST" name="exclusions" action="" class="padd3">';

		echo '<input type="checkbox" name="excluopt" id="excluopt"';
		$excluopt_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_excluopt'"));
		if ($excluopt_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="excluopt"> '.FREQC_PARAM53.'</label><p class="paddvalid1"><input class="bouton boutfreq" type="submit" value="'.VALID.'" name="exclu_valid" /></p></form>';

		echo '<hr class="param">';
	
		//CRENEAU PAR DEFAUT RESERVATION
		echo '<h2 id="resas">'.FREQC_PARAM54.'</h2>';
		echo FREQC_PARAM55;
		// formulaire :
		echo '<div class="box"><select name="crendef" id="crendef" value="">';
		$crd = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_crendef'");
		$crd_info = mysqli_fetch_assoc($crd);
		echo '<option value="suivant"';
		if($crd_info['valeur'] == "suivant") {
			echo ' selected ';
		}
		echo '>'.FREQC_PARAM56.'</option>';
		if($crd_info['valeur'] != "suivant") {
			$crd_select = "SELECT param.valeur, hor.hor_name, hor.debut, hor.fin, hor.hor_freq
			FROM ".$prefix."_parametres param
			INNER JOIN ".$prefix."_horaires hor
			ON param.valeur = hor.hor_name
			WHERE param.param_nom = 'freq_crendef'";
			$crd = mysqli_query($bdd,$crd_select);
			$crd_info = mysqli_fetch_assoc($crd);
			$cren_check = $crd_info['valeur'];
		}
		if($freq_gestion_jourscren['valeur']==0) {
			$hor = mysqli_query($bdd,"SELECT * FROM ".$prefix."_horaires WHERE hor_freq LIKE '001%' ORDER BY num_creneau ASC");
		}
		else {
			$hor = mysqli_query($bdd,"SELECT * FROM ".$prefix."_horaires WHERE hor_freq LIKE '%001%' ORDER BY num_creneau ASC");
		}

		foreach($hor as $liste) {
			$cren = $liste['hor_name'];
			$deb_cren = substr("$cren", 0, 1);
			echo '<option value="'.$liste['hor_name'].'"';
			if($crd_info['valeur'] != "suivant") {
				if($cren_check==$liste['hor_name']) { echo ' selected '; }
			}
			echo '>'.$liste['hor_name'].' - ';
			echo MOMENT[$deb_cren];
			$deb = $liste['debut'];
			$dh = substr("$deb", 0, 2);
			$dm = substr("$deb", 3, 2);
			echo ' '.FROM.' '.$dh.'h'.$dm.' '.TO.' ';
			$fin = $liste['fin'];
			$fh = substr("$fin", 0, 2);
			$fm = substr("$fin", 3, 2);
			echo ''.$fh.'h'.$fm.'';
			echo '</option>';
		}
		echo '</select></div>';
		// Autorisation de choix du créneau :
		echo '<p><b>'.FREQC_PARAM57.'</b></p>';
		$ccr = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_crenchoix'");
		$ccr_info = mysqli_fetch_assoc($ccr);
		echo '<input type="radio" name="crenchoix" id="crenchoix1" value="1" ';
		if($ccr_info['valeur']=="1") { echo 'checked'; }
		echo ' /><label for="crenchoix1">'.FREQC_PARAM58.'</label> <br><input type="radio" id="crenchoix0" name="crenchoix" value="0" '; 
		if($ccr_info['valeur']=="0") { echo 'checked'; }
		echo ' /><label for="crenchoix0">'.FREQC_PARAM59.'</label>';

		echo '<p><b>'.FREQC_PARAM60.'</b></p>';
		echo '<input type="checkbox" name="onlyresas" id="onlyresas"';
		$onlyresas_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_onlyresas'"));
		if ($onlyresas_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="onlyresas"> '.PARAC_USER48.'</label> <a href="param.php?page=users" title="'.FREQC_PARAM113.'"><i class="fa-solid fa-street-view"></i></a>
		<br><input type="checkbox" name="resavisu" id="resavisu"';
		$resavisu_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_resvisuedt'"));
		if ($resavisu_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="resavisu"> '.PARAC_USER49.'</label> 
		<br> <br>&bull; '.FREQC_PARAM61.'<br><input type="checkbox" name="eventblock" id="eventblock"';
		$crprechoix_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_resblockevent'"));
		if ($crprechoix_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="eventblock"> '.FREQC_PARAM62.'</label><br>
		<input type="checkbox" name="resactiv" id="resactiv"';
		$resactivchoix = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_resactiv'"));
		if ($resactivchoix['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="resactiv"> '.FREQC_PARAM63.'</label><br>';
		echo FREQC_PARAM64;
		echo '<p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="crenchoixval(this);colorval(\'crenchoixval\');" id="crenchoixval" value="'.VALID.'" name="resopts_valid" /></p>';
		?><script type="text/javascript">
			function crenchoixval(param) {
			var param = "crenchoix";
			var crendef = document.getElementById("crendef").value;            
            var typ = document.getElementsByName("crenchoix");    
			for(i = 0; i < typ.length; i++) {
                if(typ[i].checked)
                var crch = typ[i].value;
            }
            var checkvisu = document.getElementById("resavisu").checked;
			if(checkvisu===false) {
				var resavisu = "0";
			}
			else {
				var resavisu = "1";
			}
			var checkonly = document.getElementById("onlyresas").checked;
			if(checkonly===false) {
				var onlyresas = "0";
			}
			else {
				var onlyresas = "1";
			}
            var checkbloc = document.getElementById("eventblock").checked;
			if(checkbloc===false) {
				var blocage = "0";
			}
			else {
				var blocage = "1";
			}
			var checkprec = document.getElementById("resactiv").checked;
			if(checkprec===false) {
				var precision = "0";
			}
			else {
				var precision = "1";
			}
			$.ajax({
			    type: "POST",
			    data: { param: param, crendef: crendef, crch: crch, resavisu: resavisu, onlyresas: onlyresas, blocage: blocage, precision: precision },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script><?php
				
		//RESERVATION PAR LES ELEVES
		echo '<h2 id="resele">'.FREQC_PARAM65.'</h2>';
		echo FREQC_PARAM66;
		$reserv_could=mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_reseleve'"));
		$reserv_could_mdp=mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_reseleve_mdp'"));
		echo '<input type="radio" id="reserv_distopt0" name="reserv_distopt" value="0" ';
		if ($reserv_could['valeur']==0) { echo 'checked'; }
		echo ' /><label for="reserv_distopt0"> '.FREQC_PARAM67.'</label><br>
		<input style="margin-bottom:7px;" type="radio" id="reserv_distopt1" name="reserv_distopt" value="1" ';
		if ($reserv_could['valeur']==1) { echo 'checked'; }
		echo ' /><label for="reserv_distopt1"> '.FREQC_PARAM68.'</label>
		<br>&nbsp; &nbsp; &nbsp; &nbsp; '.IDENT3.' ';
		if(@$multi=="ON"&&@$multipref==1) {
			echo @$_COOKIE['LOGGED_ETAB'];
		}
		echo 'reserver 
		<br>&nbsp; &nbsp; &nbsp; &nbsp; '.PW4.' <input type="password" class="inptxt" name="reservmdp" id="reservmdp" maxlength="15" placeholder="'.PW.'" /><i class="fa-solid fa-eye" id="eye" onclick="showPass()" style="margin-left: -26px; cursor: pointer;"></i><br>
		<input type="radio" id="reserv_distopt2" name="reserv_distopt" value="2" ';
		if ($reserv_could['valeur']==2) { echo 'checked'; }
		echo ' /><label for="reserv_distopt2"> '.FREQC_PARAM69.'</label>
		<p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="reservsubval(this);colorval(\'reservsubval\');" id="reservsubval" name="reservsub" value="'.VALID.'" /></p>';
		?><script language="Javascript">
			function showPass() {
			  var x = document.getElementById("reservmdp");
			  var y = document.getElementById("eye");
			  if (x.type === "password") {
			    x.type = "text";
			    y.className = "fa-solid fa-eye-slash";
			  } else {
			    x.type = "password";
			    y.className = "fa-solid fa-eye";
			  }
			}
		</script>
		<script type="text/javascript">
			function reservsubval(param) {
			var param = "reservsub";
			var mdp = document.getElementById("reservmdp").value;            
            var typ = document.getElementsByName("reserv_distopt");    
			for(i = 0; i < typ.length; i++) {
                if(typ[i].checked)
                var resopt = typ[i].value;
            }
            if(resopt=="0") {
            	document.getElementById("resele_opts").style.display = "none";
            }
            if(resopt=="1") {
            	document.getElementById("resele_opts").style.display = "block";
            }
            if(resopt=="2") {
            	document.getElementById("resele_opts").style.display = "block";
            }
            $.ajax({
			    type: "POST",
			    data: { param: param, resopt: resopt, mdp: mdp },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script><?php

		// Précision de l'activité dans la réservation à distance // Et EDT // Et Espaces
		$freq_reseleve_creneau = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_reseleve_creneau'"));
		$freq_reseleve_activ = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_reseleve_activ'"));
		echo '<div id="resele_opts" name="resele_opts"';
		if($reserv_could['valeur']>0) { echo ' style="display:block;" '; }
		else { echo ' style="display:none;" '; }
		echo '>';
		$check_perso = mysqli_query($bdd,"SELECT id_perso FROM ".$prefix."_eleves WHERE id_perso <> ''");
		$auth_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_resmodauth'"));
		echo '<b>'.FREQC_PARAM70.'</b><br>
		<input type="radio" name="resauth" id="resauth0" value="code" ';
		if($auth_info['valeur']=="code") { echo 'checked'; } echo ' /><label for="resauth0"> '.CODE3.'</label><br>
		<input type="radio" name="resauth" id="resauth1" value="prenomnom" ';
		if($auth_info['valeur']=="prenomnom") { echo 'checked'; } echo ' /><label for="resauth1"> '.NAMECH3.'</label><br>
		<input type="radio" name="resauth" id="resauth2" value="pnom" ';
		if($auth_info['valeur']=="pnom") { echo 'checked'; } echo ' /><label for="resauth2"> '.NAMECH4.'</label><br>';
		echo '<input type="radio" name="resauth" id="resauth3" value="perso" ';
		if($auth_info['valeur']=="perso") { echo 'checked'; } 
		if(mysqli_num_rows($check_perso)==0) { echo ' disabled="disabled" '; }
		echo ' /><label for="resauth3"> '.IDENT6;
		if(mysqli_num_rows($check_perso)==0) { echo FREQC_PARAM71; }
		else { echo FREQC_PARAM72; }
		echo '</label><br>';
		echo '<b>'.FREQC_PARAM79.'</b><br>';
		$crprpchoix_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_resprintedt'"));
		echo '<input type="radio" name="printedt" id="printedt0" value="0" ';
		if($crprpchoix_info['valeur']=="0") { echo 'checked'; } echo ' /><label for="printedt0"> '.FREQC_PARAM80.'</label><br>
		<input type="radio" name="printedt" id="printedt1" value="1" ';
		if($crprpchoix_info['valeur']=="1") { echo 'checked'; } echo ' /><label for="printedt1"> '.FREQC_PARAM81.'</label><br>
		<input type="radio" name="printedt" id="printedt2" value="2" ';
		if($crprpchoix_info['valeur']=="2") { echo 'checked'; } echo ' /><label for="printedt2"> '.FREQC_PARAM82.'</label><br>';

		echo '<b>'.FREQC_PARAM112.DOTS.'</b><br>
		<input type="checkbox" id="resele_creneau_check" name="resele_creneau_check"';
		if($freq_reseleve_creneau['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.' /><label for="resele_creneau_check"> '.FREQC_PARAM74.'</label><br>
		<i>'.FREQC_PARAM75.'</i><br>
		<input type="checkbox" id="resele_activ_check" name="resele_activ_check"';
		if($freq_reseleve_activ['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.' /><label for="resele_activ_check"> '.FREQC_PARAM76.'</label><br>';

		$freq_reseleve_nodiv = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_reseleve_nodiv'"));
		echo '<input type="checkbox" id="resele_nodiv_check" name="resele_nodiv_check"';
		if($freq_reseleve_nodiv['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.' /><label for="resele_nodiv_check"> '.FREQC_PARAM132.'</label><br>';

		$freq_reseleve_esp = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_reseleve_esp'"));
		if($espopt['valeur']==1) {
			echo '<input type="checkbox" id="resele_esp_check" name="resele_esp_check"';
			if($freq_reseleve_esp['valeur']==1) { $check = 'checked'; } else { $check = 0; }
			echo ' '.$check.' /><label for="resele_esp_check"> '.FREQC_PARAM77.'</label><br>';
		}
		$freq_reseleve_cgtmdp = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_reseleve_cgtmdp'"));
		echo '<input type="checkbox" id="resele_cgtmdp_check" name="resele_cgtmdp_check"';
		if($freq_reseleve_cgtmdp['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.' /><label for="resele_cgtmdp_check"> '.FREQC_PARAM78.'</label><br>';
		$freqres_raison_opt = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freqres_raison_opt'"));
		echo '<input type="checkbox" id="freqres_raison_opt" name="freqres_raison_opt"';
		if($freqres_raison_opt['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.' /><label for="freqres_raison_opt"> '.FREQC_PARAM125.'</label><br>';
		
		$freq_res_archives = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_res_archives'"));
		echo '<input type="checkbox" id="res_archives_check" name="res_archives_check"';
		if($freq_res_archives['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.' /><label for="res_archives_check"> '.FREQC_PARAM135.'</label><br>';

		$freq_reseleve_seqsvisu = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_res_seqsvisu'"));
		echo '<input type="checkbox" id="resele_seqsvisu_check" name="resele_seqsvisu_check"';
		if($freq_reseleve_seqsvisu['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.' /><label for="resele_seqsvisu_check"> '.FREQC_PARAM131.'</label><br>';

		$freq_res_visusigb = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_res_visusigb'"));
		echo '<input type="checkbox" id="res_visusigb_check" name="res_visusigb_check"';
		if($freq_res_visusigb['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.' /><label for="res_visusigb_check"> '.FREQC_PARAM136.'</label><br>';

		$freqres_inscriptallday = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freqres_inscriptallday'"));
		echo '<input type="checkbox" id="freqres_inscriptallday" name="freqres_inscriptallday"';
		if($freqres_inscriptallday['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.' /><label for="freqres_inscriptallday"> '.FREQC_PARAM127.'</label> <a href="param.php?page=users" title="'.FREQC_PARAM113.'"><i class="fa-solid fa-street-view"></i></a>';

		echo '<br><b>'.LIMITS.DOTS.'</b>';

		$freq_res_minutesmax = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_res_minutesmax'"));
		echo '<br>'.FREQC_PARAM133.' <input type="number" class="number" id="resminutesmax" name="resminutesmax" value="'.$freq_res_minutesmax['valeur'].'" />';

		$freqres_max = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freqres_max'"));
		echo '<br>'.FREQC_PARAM124.' <input type="number" class="number" id="resmaxo" name="resmax" value="'.$freqres_max['valeur'].'" />';

		$freq_res_nbmaxday = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_res_nbmaxday'"));
		echo '<br>'.FREQC_PARAM134.' <input type="number" class="number" id="nbmaxday" name="nbmaxday" value="'.$freq_res_nbmaxday['valeur'].'" />';

		$freqres_max_origin = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freqres_max_origin'"));
		echo '<br><input type="checkbox" id="freqres_max_origin" name="freqres_max_origin"';
		if($freqres_max_origin['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.' /><label for="freqres_max_origin"> '.FREQC_PARAM126.'</label>';

		$freq_reseleve_dureemax = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_reseleve_dureemax'"));
		echo '<br><b>'.FREQC_PARAM83.'</b><br><i> '.FREQC_PARAM84.'</i><br><input type="number" class="number" id="daymaxo" name="daymax" value="'.$freq_reseleve_dureemax['valeur'].'" /> '.PARAC_USER24.' <div class="box"><select name="dayone" id="dayone" value=""><option></option>';
		foreach (JOUR as $stkey => $stvalue){ 
			echo '<option value="'. $stkey .'"';
			if(substr($freq_reseleve_dureemax['valeur'],0,3)==$stkey) {
				echo ' selected';
			}
			echo '>'. $stvalue.'</option>'; 
		}
		echo '</select></div> &nbsp; &nbsp; '.TO2.' <div class="box"><select name="daytwo" id="daytwo" value=""><option></option>';
		foreach (JOUR as $stkey => $stvalue){ 
			echo '<option value="'. $stkey .'"';
			if(substr($freq_reseleve_dureemax['valeur'],3,3)==$stkey) {
				echo ' selected';
			}
			echo '>'. $stvalue.'</option>'; 
		}
		echo '</select></div>';
		echo '<p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="reservoptval(this);colorval(\'reservoptval\');" id="reservoptval" name="valid_reseleve_opts" value="'.VALID.'" /></p></div>';
		?><script type="text/javascript">
			function reservoptval(param) {
			var param = "reservopt";
			var val = document.getElementById("daymaxo").value; 
			var maxmins = document.getElementById("resminutesmax").value; 
			var max = document.getElementById("resmaxo").value; 
			var maxday = document.getElementById("nbmaxday").value; 			
			var mod = document.getElementsByName("resauth");  
			var done = document.getElementById("dayone").value;
			var dtwo = document.getElementById("daytwo").value;
			for(i = 0; i < mod.length; i++) {
                if(mod[i].checked)
                var resmod = mod[i].value;
            }         
            var typ = document.getElementsByName("printedt");    
			for(i = 0; i < typ.length; i++) {
                if(typ[i].checked)
                var resopt = typ[i].value;
            }
            var resele_creneau = document.getElementById("resele_creneau_check").checked;
            if(resele_creneau===false) {
				var reselec = "0";
			}
			else {
				var reselec = "1";
			}
			var resele_cgtmdp = document.getElementById("resele_cgtmdp_check").checked;
            if(resele_cgtmdp===false) {
				var resmdp = "0";
			}
			else {
				var resmdp = "1";
			}
			var resele_archives = document.getElementById("res_archives_check").checked;
            if(resele_archives===false) {
				var archives = "0";
			}
			else {
				var archives = "1";
			}
			var resele_seqsvisu = document.getElementById("resele_seqsvisu_check").checked;
            if(resele_seqsvisu===false) {
				var seqsvisu = "0";
			}
			else {
				var seqsvisu = "1";
			}
			var resele_visusigb = document.getElementById("res_visusigb_check").checked;
            if(resele_visusigb===false) {
				var visusigb = "0";
			}
			else {
				var visusigb = "1";
			}
			var resele_raison = document.getElementById("freqres_raison_opt").checked;
            if(resele_raison===false) {
				var raison = "0";
			}
			else {
				var raison = "1";
			}
			var resele_nodiv = document.getElementById("resele_nodiv_check").checked;
            if(resele_nodiv===false) {
				var nodiv = "0";
			}
			else {
				var nodiv = "1";
			}
			var res_allday = document.getElementById("freqres_inscriptallday").checked;
            if(res_allday===false) {
				var allday = "0";
			}
			else {
				var allday = "1";
			}
			var max_origin = document.getElementById("freqres_max_origin").checked;
            if(max_origin===false) {
				var maxo = "0";
			}
			else {
				var maxo = "1";
			}
            var resele_activ = document.getElementById("resele_activ_check").checked;
            if(resele_activ===false) {
				var reselea = "0";
			}
			else {
				var reselea = "1";
			}<?php
			if($espopt['valeur']==1) {
				echo 'var resele_esp = document.getElementById("resele_esp_check").checked;
				if(resele_esp===false) {
					var reselee = "0";
				}
				else {
					var reselee = "1";
				}';
			}
            echo '$.ajax({
			    type: "POST",
			    data: { param: param, val: val, maxmins: maxmins, max: max, maxday: maxday, done: done, dtwo: dtwo, resmod: resmod, resopt: resopt, resmdp: resmdp, archives: archives, seqsvisu: seqsvisu, visusigb: visusigb, raison: raison, nodiv: nodiv, allday: allday, maxo: maxo, reselea: reselea, reselec: reselec';
			    if($espopt['valeur']==1) {
			    	echo ', reselee: reselee';
			    }
			    echo ' },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}';?>
		</script>
		<?php
		echo '<hr class="param">';

		echo '<h2 id="resele">'.FREQC_PARAM85.'</h2>';
		echo FREQC_PARAM86;
		$ibulle_could=mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_connexion_infobulle'"));
		$ibulle_params = explode(";", $ibulle_could['valeur']);
		echo '<input type="radio" id="ibulle_distopt0" name="ibulle_distopt" value="0" ';
		if ($ibulle_params[0]=='0') { echo 'checked'; }
		echo ' /><label for="ibulle_distopt0"> '.FREQC_PARAM87.'</label><br>
		<input style="margin-bottom:7px;" type="radio" id="ibulle_distopt1" name="ibulle_distopt" value="1" ';
		if ($ibulle_params[0]=='1') { echo 'checked'; }
		echo ' /><label for="ibulle_distopt1"> '.FREQC_PARAM88.'</label>
		<br>&nbsp; &nbsp; &nbsp; &nbsp; '.FREQC_PARAM89.' <input type="text" class="inptxt" name="ibulleident" id="ibulleident" size="30" value="'.@$ibulle_params[1].'" placeholder="'.FREQC_PARAM90.'" onkeypress="return checkInput(event)" />
		<br>&nbsp; &nbsp; &nbsp; &nbsp; '.FREQC_PARAM91.' <input type="text" class="inptxt" name="ibullemdp" id="ibullemdp" size="28" value="'.@$ibulle_params[2].'" placeholder="'.FREQC_PARAM92.'" onkeypress="return checkInput(event)" /><br>
		<p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="ibullesubval(this);colorval(\'ibullesubval\');" id="ibullesubval" name="ibullesub" value="'.VALID.'" /></p>';
		?><script language="Javascript">
		  function checkInput(event) {
		    var charCode = event.which || event.keyCode;
		    if (charCode === 59) { // 59 est le code ASCII pour le point-virgule (;)
		      return false; // Empêche la saisie du point-virgule
		    }
		    return true; // Autorise la saisie de tous les autres caractères
		  }
		</script>
		<script type="text/javascript">
			function ibullesubval(param) {
			var param = "ibullesub";
			var cide = document.getElementById("ibulleident").value;  
			var cmdp = document.getElementById("ibullemdp").value;          
		    var typ = document.getElementsByName("ibulle_distopt");    
			for(i = 0; i < typ.length; i++) {
		        if(typ[i].checked)
		        var ibopt = typ[i].value;
		    }
		    $.ajax({
			    type: "POST",
			    data: { param: param, ibopt: ibopt, cide: cide, cmdp: cmdp },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script><?php

		echo '<hr class="param">';

		// Gestion des retards depuis PMB ou BCDI
		echo '<h2 id="sigb">'.FREQC_PARAM93.'</h2>';
		$verif_nivs_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_sigb'"));
		echo '<p><b>'.FREQC_PARAM94.'</b></p>
		<input type="radio" id="sigb_choix0" name="sigb_choix" value="non" ';
		if($verif_nivs_info['valeur']=="non") { echo 'checked'; }
		echo ' /><label for="sigb_choix0">'.FREQC_PARAM95.'</label>
		<br><input type="radio" id="sigb_choix1" name="sigb_choix" value="pmb" '; 
		if($verif_nivs_info['valeur']=="pmb") { echo 'checked'; }
		echo ' /><label for="sigb_choix1">'.FREQC_PARAM96.'</label>
		<br><input type="radio" id="sigb_choix2" name="sigb_choix" value="bcdi" '; 
		if($verif_nivs_info['valeur']=="bcdi") { echo 'checked'; }
		echo ' /><label for="sigb_choix2">'.FREQC_PARAM97.'</label>
		<br><p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="sigbval(this);colorval(\'sigbval\');" id="sigbval" value="'.VALID.'" name="sigb_valid" /></p>';
		?><script type="text/javascript">
			function sigbval(param) {
			var param = "sigb";
			var typ = document.getElementsByName("sigb_choix");    
			for(i = 0; i < typ.length; i++) {
                if(typ[i].checked)
                var type = typ[i].value;
            }
            $.ajax({
			    type: "POST",
			    data: { param: param, type: type },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script><?php

		echo '<p><b>'.FREQC_PARAM98.'</b></p>';
		// Gestion pour les inscriptions :
		echo FREQC_PARAM99;
		$oaf_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_retards_ordre'"));
		echo '<input type="radio" id="ordreretdiv" name="ordreret" value="div" ';
		if($oaf_info['valeur']=="div") { echo 'checked'; }
		echo ' /><label for="ordreretdiv">'.ORDER4.'</label>
		<br><input type="radio" id="ordreretnom" name="ordreret" value="nom" '; 
		if($oaf_info['valeur']=="nom") { echo 'checked'; }
		echo ' /><label for="ordreretnom">'.ORDER2.'</label>
		<br><input type="radio" id="ordrerettit" name="ordreret" value="tit" '; 
		if($oaf_info['valeur']=="tit") { echo 'checked'; }
		echo ' /><label for="ordrerettit">'.ORDER12.'</label>
		<br><input type="radio" id="ordreretdat" name="ordreret" value="dat" '; 
		if($oaf_info['valeur']=="dat") { echo 'checked'; }
		echo ' /><label for="ordreretdat">'.ORDER13.'</label>
		<br><input type="radio" id="ordreretale" name="ordreret" value="ale" '; 
		if($oaf_info['valeur']=="ale") { echo 'checked'; }
		echo ' /><label for="ordreretale">'.ORDER14.'</label>
		<br><p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="ordrretval(this);colorval(\'ordrretval\');" id="ordrretval" value="'.VALID.'" name="ordreret_valid" /></p>';
		?><script type="text/javascript">
			function ordrretval(param) {
			var param = "ordrreta";
			var typ = document.getElementsByName("ordreret");    
			for(i = 0; i < typ.length; i++) {
                if(typ[i].checked)
                var type = typ[i].value;
            }
            $.ajax({
			    type: "POST",
			    data: { param: param, type: type },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script><?php

		echo '<p id="idsonret"><b>'.FREQC_PARAM100.'</b></p>';

		if(isset($_POST['ajoutson_valid'])) {
			$mimes = array('audio/mpeg',
			'audio/ogg',
			'audio/vnd.wav',
			'audio/x-wav');	
			$file=$_FILES['fileson'];
			//$fichier=$_FILES['fichier'.$k.'']['name'];
			$actualSize = $file['size'];
			// Taille du fichier doit être sous 1,5 mo : 1500000
			$legalSize = "1500000";		
			$Rep = './img/wav/'.$prefix.'/';
			$Racine=opendir($Rep);
	        $Taille=0;
	        while($Dossier = readdir($Racine))
	        {
	          if ( $Dossier != '..' And $Dossier !='.' )
	          {
	            //Ajoute la taille du sous dossier
	            if(is_dir($Rep.'/'.$Dossier)) $Taille += TailleDossier($Rep.'/'.$Dossier);
	            //Ajoute la taille du fichier
	            else $Taille += filesize($Rep.'/'.$Dossier);

	          }
	        }
	        closedir($Racine);
	       	// Taille du dossier doit être sous 20 mo : 20000000
	        if(@in_array($file['type'],$mimes)&&$Taille<20000000&&$actualSize<$legalSize) {
	        	
	        	if (file_exists($Rep.'/'.preg_replace('/[^a-zA-Z0-9_-]/s','',pathinfo($file['name'], PATHINFO_FILENAME)).'.'.pathinfo($file['name'], PATHINFO_EXTENSION))) {
				    echo FREQC_PARAM101;
				}
				else {
					move_uploaded_file($file['tmp_name'], $Rep.'/'.preg_replace('/[^a-zA-Z0-9_-]/s','',pathinfo($file['name'], PATHINFO_FILENAME)).'.'.pathinfo($file['name'], PATHINFO_EXTENSION));
				}
			}
			else if($Taille>=20000000) {
				echo FREQC_PARAM102;
			}
			else if($actualSize>=$legalSize) {
				echo FREQC_PARAM103;
			}
		}      
    
    	$sontype="sonret";
    	$verif_bip_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_retards_bip'"));
		include('db/proc/sons_gestion.php');
		
		echo '<hr class="param">';

		// Gestion des réservations de docs depuis PMB ou BCDI
		echo '<h2 id="sigb">'.FREQC_PARAM104.'</h2>';
		$verif_nivs_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_sigb_resa'"));
		echo '<p><b>'.FREQC_PARAM94.'</b></p>
		<input type="radio" id="sigbr_choix0" name="sigbr_choix" value="non" ';
		if($verif_nivs_info['valeur']=="non") { echo 'checked'; }
		echo ' /><label for="sigbr_choix0">'.FREQC_PARAM95.'</label>
		<br><input type="radio" id="sigbr_choix1" name="sigbr_choix" value="pmb" '; 
		if($verif_nivs_info['valeur']=="pmb") { echo 'checked'; }
		echo ' /><label for="sigbr_choix1">'.FREQC_PARAM96.'</label>
		<br><input type="radio" id="sigbr_choix2" name="sigbr_choix" value="bcdi" '; 
		if($verif_nivs_info['valeur']=="bcdi") { echo 'checked'; }
		echo ' /><label for="sigbr_choix2">'.FREQC_PARAM97.'</label>
		<br><p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="sigbresaval(this);colorval(\'sigbresaval\');" id="sigbresaval" value="'.VALID.'" name="sigbresa_valid" /></p>';
		?><script type="text/javascript">
			function sigbresaval(param) {
			var param = "sigbresa";
			var typ = document.getElementsByName("sigbr_choix");    
			for(i = 0; i < typ.length; i++) {
                if(typ[i].checked)
                var type = typ[i].value;
            }
            $.ajax({
			    type: "POST",
			    data: { param: param, type: type },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script><?php

		echo '<p><b>'.FREQC_PARAM105.'</b></p>';
		// Gestion pour les inscriptions :
		echo FREQC_PARAM106;
		$oaf_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_sigb_resaord'"));
		echo '<input type="radio" id="ordreresdiv" name="ordreres" value="div" ';
		if($oaf_info['valeur']=="div") { echo 'checked'; }
		echo ' /><label for="ordreresdiv">'.ORDER4.'</label>
		<br><input type="radio" id="ordreresnom" name="ordreres" value="nom" '; 
		if($oaf_info['valeur']=="nom") { echo 'checked'; }
		echo ' /><label for="ordreresnom">'.ORDER2.'</label>
		<br><input type="radio" id="ordrerestit" name="ordreres" value="tit" '; 
		if($oaf_info['valeur']=="tit") { echo 'checked'; }
		echo ' /><label for="ordrerestit">'.ORDER12.'</label>
		<br><input type="radio" id="ordreresdat" name="ordreres" value="dat" '; 
		if($oaf_info['valeur']=="dat") { echo 'checked'; }
		echo ' /><label for="ordreresdat">'.ORDER15.'</label>
		<br><p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="ordrresval(this);colorval(\'ordrresval\');" id="ordrresval" value="'.VALID.'" name="ordreres_valid" /></p>';
		?><script type="text/javascript">
			function ordrresval(param) {
			var param = "ordrresa";
			var typ = document.getElementsByName("ordreres");    
			for(i = 0; i < typ.length; i++) {
                if(typ[i].checked)
                var type = typ[i].value;
            }
            $.ajax({
			    type: "POST",
			    data: { param: param, type: type },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script><?php

		echo '<p id="idsonret"><b>'.FREQC_PARAM100.'</b></p>';
    
    	$sontype="sonres";
    	$verif_bip_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_sigb_resabip'"));
		include('db/proc/sons_gestion.php');
		
		echo '<hr class="param">';

		//STATS NOTIF + SEUIL CRENEAUX
		echo '<h2 id="idsonvisits">'.FREQC_PARAM107.'</h2>';
		$nopt = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_notif_opt'"));
		$nnb = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_notif_nb'"));
		echo '<input type="checkbox" id="notifopt" name="notifopt"';
		if($nopt['valeur']==1) { echo ' checked'; }
		echo ' /><label for="notifopt">'.FREQC_PARAM108.'</label>'.FREQC_PARAM109.'<input type="number" id="notifnb" name="notifnb" class="number" value="'.$nnb['valeur'].'" /> '.FREQC_PARAM110.' <input class="bouton boutfreq" type="submit" value="'.VALID.'" onclick="statsopvalv(this);colorval(\'statsopvalv\');" id="statsopvalv" name="seuilcren_valid" /></p>';
		$sontype="sonvisits";
		$verif_bip_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_nbvisites_bip'"));
		echo '<div id="sonvisits" style="display:';
		if($nopt['valeur']==1) { echo 'block'; } else { echo 'none'; }
		echo ';" >';
		include('db/proc/sons_gestion.php');
		echo '</div>';

		$bopt = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_birthday_img'"));
		echo '<br><div id="idsonnniv"></div><input type="checkbox" id="notifbirth" name="notifbirth"';
		if($bopt['valeur']==1) { echo ' checked'; }
		echo ' /><label for="notifbirth">'.FREQC_PARAM111.' <input class="bouton boutfreq" type="submit" value="'.VALID.'" onclick="statsopvala(this);colorval(\'statsopvala\');" id="statsopvala" name="seuilcren_valid" /></p>';
		$sontype="sonanniv";
		$verif_bip_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_birthday_bip'"));
		echo '<div id="sonanniv" style="display:';
		if($bopt['valeur']==1) { echo 'block'; } else { echo 'none'; }
		echo ';" >';
		include('db/proc/sons_gestion.php');
		echo '</div>';
		
		?><script type="text/javascript">
			function statsopvalv(param) {
			var param = "notifsv";
			var valn = document.getElementById("notifnb").value;
			var checkeda = document.getElementById("notifopt").checked;
			if(checkeda===false) {
				var notifopt = "0";
				document.getElementById("sonvisits").style.display = "none";   
			}
			else {
				var notifopt = "1";
				document.getElementById("sonvisits").style.display = "block";   
			}
            $.ajax({
			    type: "POST",
			    data: { param: param, notifopt: notifopt, valn: valn },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script>
		<script type="text/javascript">
			function statsopvala(param) {
			var param = "notifsa";
			var checkedb = document.getElementById("notifbirth").checked;
			if(checkedb===false) {
				var notifbirth = "0";
				document.getElementById("sonanniv").style.display = "none";   
			}
			else {
				var notifbirth = "1";
				document.getElementById("sonanniv").style.display = "block";   
			}
            $.ajax({
			    type: "POST",
			    data: { param: param, notifbirth: notifbirth },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script><?php

		echo '<hr class="param">';

		//OPTIONS DIVERSES
		echo '<h2 id="alii">'.FREQC_PARAM112.'</h2>';
		echo '<input type="checkbox" name="cienchoix" id="cienchoix"';
		$cienchoix_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_cienchoix'"));
		if ($cienchoix_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="cienchoix"> '.FREQC_PARAM114.'</label> <a href="param.php?page=users" title="'.FREQC_PARAM113.'"><i class="fa-solid fa-street-view"></i></a><br>';

		echo '<input type="checkbox" name="validmes" id="validmes"';
		$validmes_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_validmes'"));
		if ($validmes_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="validmes"> '.FREQC_PARAM129.'</label> <a href="param.php?page=users" title="'.FREQC_PARAM113.'"><i class="fa-solid fa-street-view"></i></a><br>';

		echo '<input type="checkbox" name="codeonly" id="codeonly"';
		$codeonly_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_codeonly'"));
		if ($codeonly_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="codeonly"> '.FREQC_PARAM130.'</label> <a href="param.php?page=users" title="'.FREQC_PARAM113.'"><i class="fa-solid fa-street-view"></i></a><br>';

		echo '<input type="checkbox" name="classe" id="classe"';
		$classe_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_classe'"));
		if (substr($classe_info['valeur'],0,1)=='1') { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="classe"> '.PARAC_USER34.'</label> - <input type="radio" name="ordgroup" id="ordrgroup1" value="-perdiv"';
		if (substr($classe_info['valeur'],1)=='-perdiv'||substr($classe_info['valeur'],1,1)=='') { echo ' checked '; }
		echo ' /> <label for="ordrgroup1">'.PARAC_USER51.'</label><input type="radio" name="ordgroup" id="ordrgroup2" value="-pernom"';
		if (substr($classe_info['valeur'],1)=='-pernom') { echo ' checked '; }
		echo ' /> <label for="ordrgroup2">'.PARAC_USER52.'</label><a href="param.php?page=users" title="'.FREQC_PARAM113.'"> <i class="fa-solid fa-street-view"></i></a><br>';		
		echo '<input type="checkbox" name="seance_appel" id="seance_appel"';
		$appel_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_seance_appel'"));
		if ($appel_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="seance_appel"> '.FREQC_PARAM116.'</label> <a href="param.php?page=users" title="'.FREQC_PARAM113.'"><i class="fa-solid fa-street-view"></i></a><br>';		
		echo '<input type="checkbox" name="chgtactiv" id="chgtactiv"';
		$chgtactiv_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_chgtactiv'"));
		if ($chgtactiv_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="chgtactiv"> '.FREQC_PARAM117.'</label> <a href="param.php?page=users" title="'.FREQC_PARAM113.'"><i class="fa-solid fa-street-view"></i></a><br>';
		echo '<input type="checkbox" name="jouhor" id="jouhor"';
		$jhors_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_jhors'"));
		if ($jhors_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="jouhor"> '.FREQC_PARAM118.'</label><br>';
		echo '<input type="checkbox" name="appelchoix" id="appelchoix"';
		$appelchoix_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_appel'"));
		if (substr($appelchoix_info['valeur'],0,1)==2) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="appelchoix"> '.FREQC_PARAM119.'</label><br>';
		echo '<input type="checkbox" name="buttonchoix" id="buttonchoix"';
		$buttonchoix_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_inscritbutton'"));
		if ($buttonchoix_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="buttonchoix"> '.FREQC_PARAM120.'</label> <a href="param.php?page=users" title="'.FREQC_PARAM113.'"><i class="fa-solid fa-street-view"></i></a><br>';
		echo '<input type="checkbox" name="pronote" id="pronote"';
		$pronote_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_inscritpronote'"));
		if ($pronote_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="pronote"> '.FREQC_PARAM121.'</label><br>';
		echo '<input type="checkbox" name="actespauto" id="actespauto"';
		$actesp_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_res_actesp_autochange'"));
		if ($actesp_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="actespauto"> '.FREQC_PARAM137.'</label><br>';
		echo '<input type="checkbox" name="apinbins" id="apinbins"';
		$api_info = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'freq_api_nb'"));
		if ($api_info['valeur']==1) { $check = 'checked'; } else { $check = 0; }
		echo ' '.$check.'/><label for="apinbins"> '.FREQC_PARAM122.'</label><br>';
		if ($api_info['valeur']==1) { 
			echo '<span id="addrapi">&nbsp; &nbsp; &nbsp; <i>'.FREQC_PARAM123.' <a href="./img/edt/'.$prefix.'/nbinscrits.txt">/img/edt/'.$prefix.'/nbinscrits.txt</a></i></span>';
		}
		else {
			echo '<span id="addrapi"></span>';
		}
		echo '<p class="paddvalid1"><input class="bouton boutfreq" type="submit" onclick="aliival(this);colorval(\'aliival\');" id="aliival" value="'.VALID.'" name="alii_valid" /></p>';
		?><script type="text/javascript">
			function aliival(param) {
			var param = "alii";
			var checka = document.getElementById("cienchoix").checked;
			if(checka===false) { var cienchoix = "0"; }
			else { var cienchoix = "1"; }
			var checki = document.getElementById("validmes").checked;
			if(checki===false) { var validmes = "0"; }
			else { var validmes = "1"; }
			var checkj = document.getElementById("codeonly").checked;
			if(checkj===false) { var codeonly = "0"; }
			else { var codeonly = "1"; }
			var checkb = document.getElementById("classe").checked;
			if(checkb===false) { var classe = "0"; }
			else { var classe = "1"; }
			var checkh = document.getElementById("seance_appel").checked;
			if(checkh===false) { var seance_appel = "0"; }
			else { var seance_appel = "1"; }
			var checkc = document.getElementById("chgtactiv").checked;
			if(checkc===false) { var chgtactiv = "0"; }
			else { var chgtactiv = "1"; }
			var checkd = document.getElementById("jouhor").checked;
			if(checkd===false) { var jouhor = "0"; }
			else { var jouhor = "1"; }
			var checke = document.getElementById("appelchoix").checked;
			if(checke===false) { var appelchoix = "0"; }
			else { var appelchoix = "1"; }
			var checkf = document.getElementById("buttonchoix").checked;
			if(checkf===false) { var buttonchoix = "0"; }
			else { var buttonchoix = "1"; }
			var checkg = document.getElementById("pronote").checked;
			if(checkg===false) { var pronote = "0"; }
			else { var pronote = "1"; }
			var ordg = document.getElementsByName("ordgroup");              
            for(i = 0; i < ordg.length; i++) {
                if(ordg[i].checked)
                var ordgc = ordg[i].value;
            }
            var checki = document.getElementById("actespauto").checked;
			if(checki===false) { var actespauto = "0"; }
			else { var actespauto = "1"; }            
			var checkh = document.getElementById("apinbins").checked;
			if(checkh===false) { 
				var apinbins = "0"; 
				document.getElementById("addrapi").innerHTML = "";
			}
			else { 
				var apinbins = "1"; 
				document.getElementById("addrapi").innerHTML = "&nbsp; &nbsp; &nbsp; <i><?php echo FREQC_PARAM123; ?> <a href=\'img/edt/<?php echo $prefix; ?>/nbinscrits.txt\'>/img/edt/<?php echo $prefix; ?>/nbinscrits.txt</a></i>";
			}
			$.ajax({
			    type: "POST",
			    data: { param: param, cienchoix: cienchoix, validmes: validmes, codeonly: codeonly, classe: classe, seance_appel: seance_appel, chgtactiv: chgtactiv, jouhor: jouhor, appelchoix: appelchoix, buttonchoix: buttonchoix, pronote: pronote, ordgc: ordgc, actespauto: actespauto, apinbins: apinbins },
			    url: "js/idl/freq_param_syn.php",
			   });			
			}
		</script>
		<script type="text/javascript">
		function colorval(divs) {
			var couleur = "black 2px solid";
			var couleurw = "white 2px solid";
			var color = "black";
			var colorw = "white";			    
            document.getElementById(divs).style.border = couleur;
			document.getElementById(divs).style.color = color;
			setTimeout(() => {  
				document.getElementById(divs).style.color = colorw; 
				document.getElementById(divs).style.border = couleurw;
				}, 2000);
			}
		</script><?php
	}
}
else {
	include('include/noaccess.php');
	echo '<br><a href="./index.php">'.ACCUEIL.'</a></p>';
}
?>
