<?php 
echo '<meta charset="utf-8" />';
if(isset($_SESSION['user_droits'])) {
	if($_SESSION['user_droits'][4]!="2")
	{
		echo '<p class="noaccess">'.NOMODULE.'<br><a href="./index.php">'.ACCUEIL.'</a></p>';
	}
	else {
		?><style type="text/css">
		#mpa6 { background-color: #fff; }
		#mpa6 td { border: 3px #7D7777 solid; }
		#mpa5 td { border: 0; }
		</style><?php	
		echo '<script language="javascript">
		function toggleDiv(divid){
			if(document.getElementById(divid).style.display == \'none\'){
				document.getElementById(divid).style.display = \'block\';
			}else{
				document.getElementById(divid).style.display = \'none\';
			}
		}
		</script>';
		
		$tabDebniveau = array('6', '5', '4', '3', '2', '1', 't');
		$tabNiveau = array('6ème', '5ème', '4ème', '3ème', '2nde', '1re', 'Tale');
	
		// Pour confirmer la suppression de la grille personnalisée
		if(isset($_POST['delper'])) {
			echo PARAC_SAVS1;
			echo '<form method="POST" action=""><input class="bouton boutparam" type="submit" name="delperconf" value="'.PARAC_SAVS2.'" /></form>';
		}
			
		// En cas de suppression confirmée de la grille personnalisée
		if(isset($_POST['delperconf'])) {
			//suppression des savoirs et liens
			foreach($tabDebniveau as $divdeb) {
				mysqli_query($bdd,"DELETE FROM ".$prefix."_savoirs".$divdeb." WHERE s".$divdeb."_id LIKE 'PER%'");
			}
			mysqli_query($bdd,"DELETE FROM ".$prefix."_savele WHERE s_id LIKE 'PER%'");
			mysqli_query($bdd,"DELETE FROM ".$prefix."_seqsav WHERE s_id LIKE 'PER%'");
			$verif_param_sav = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'savoirs'");
			$verif_param_sav_info = mysqli_fetch_array($verif_param_sav);
			if($verif_param_sav_info['valeur'] == "A0E0P1") {
				$param_sav = mysqli_query($bdd,"UPDATE ".$prefix."_parametres SET valeur='A1E0P0' WHERE param_nom='savoirs'");
			}
			//suppression des champs spécifiques
			mysqli_query($bdd,"DELETE FROM ".$prefix."_savchamps WHERE champs_id != 'CE01' AND champs_id != 'CP02' AND champs_id != 'CR03' AND champs_id != 'CT04' AND champs_id != 'AU01' AND champs_id != 'EX02' AND champs_id != 'ME03' AND champs_id != 'PR04'");
		}
		
		// Vérification de la présence de grilles : EMI et PERSO
		$nb_sav_emi = 0;
		foreach($tabDebniveau as $divdeb) {
			$verif_per = mysqli_query($bdd,"SELECT * FROM ".$prefix."_savoirs".$divdeb." WHERE s".$divdeb."_id LIKE 'EMI%'");
			$nb_sav = mysqli_num_rows($verif_per);
			$nb_sav_emi += $nb_sav;
		}
		$nb_sav_per = 0;
		foreach($tabDebniveau as $divdeb) {
			$verif_per = mysqli_query($bdd,"SELECT * FROM ".$prefix."_savoirs".$divdeb." WHERE s".$divdeb."_id LIKE 'PER%'");
			$nb_sav = mysqli_num_rows($verif_per);
			$nb_sav_per += $nb_sav;
		}
		
		// Gestion du nombre de degrés d'évaluation
		echo '<h1>'.PARAC_SAVS3.'</h1>
		<p class="maxwidth">'.PARAC_SAVS4.'</p>';
		$degres = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'eval_degres'");
		$degres_info = mysqli_fetch_assoc($degres);
		echo '<input type="radio" name="degres" id="degres3" value="3"'; if($degres_info['valeur']=="3") { echo 'checked'; } echo '/><label for="degres3">'.PARAC_SAVS5.'</label><br />
		<input type="radio" name="degres" id="degres4" value="4"'; if($degres_info['valeur']=="4") { echo 'checked'; } echo '/><label for="degres4">'.PARAC_SAVS6.'</label><br /><p class="paddvalid1"><input class="bouton boutparam" onclick="degres(this);colorval(\'degres_val\');" id="degres_val" type="submit" value="'.VALID.'" name="degreschoix" /></p>';
		echo '<script type="text/javascript">
			function degres(param) {
			var param = "degres";
			var typ = document.getElementsByName("degres");              
            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/param_syn.php",
			   });
			}
		</script>';
		
		// Gestion de l'activation des grilles si au moins deux grilles
		if($nb_sav_emi>0 || $nb_sav_per>0) {
			echo PARAC_SAVS7;
			$verif_param_sav = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'savoirs'");
			$verif_param_sav_info = mysqli_fetch_array($verif_param_sav);
			$valeur = $verif_param_sav_info['valeur'];
			$apd = substr($valeur, 1, 1);
			$emi = substr($valeur, 3, 1);
			$per = substr($valeur, 5, 1);
			if($apd == "1") { $apd_check = "checked"; } else { $apd_check = ""; }
			if($emi == "1") { $emi_check = "checked"; } else { $emi_check = ""; }
			if($per == "1") { $per_check = "checked"; } else { $per_check = ""; }
			echo '<input type="checkbox" name="apd" id="apd" '.$apd_check.'/> <label for="apd">'.PARAC_SAVS8.'</label><br />';
			if($nb_sav_emi>0) {
				echo '<input type="checkbox" name="emi" id="emi" '.$emi_check.' /> <label for="emi">'.PARAC_SAVS9.'</label><br />';
			}
			if($nb_sav_per>0) {
				echo '<input type="checkbox" name="per" id="per" '.$per_check.' /> <label for="per">'.PARAC_SAVS10.'</label><p />';
			}
			echo '<input class="bouton boutparam" type="submit" onclick="choixgrilles(this);colorval(\'choixgrilles_val\');" id="choixgrilles_val" value="'.VALID.'" name="choixsav" />';
			echo '<script type="text/javascript">
				function choixgrilles(param) {
				var param = "choixgrilles";
				var checkedapd = document.getElementById("apd").checked;
				if(checkedapd===false) {
					var apd = "0";
				}
				else {
					var apd = "1";
				}
				';
				if($nb_sav_emi>0) {
					echo 'var checkedemi = document.getElementById("emi").checked;
					if(checkedemi===false) {
						var emi = "0";
					}
					else {
						var emi = "1";
					}
					';
				}
				else {
					echo 'var emi = "0";
					';
				}
				if($nb_sav_per>0) {
					echo 'var checkedper = document.getElementById("per").checked;
					if(checkedper===false) {
						var per = "0";
					}
					else {
						var per = "1";
					}
					';
				}
				else {
					echo 'var per = "0"; 
					';
				}
				echo '$.ajax({
				    type: "POST",
				    data: { param: param, apd: apd, emi: emi, per: per },
				    url: "js/idl/param_syn.php",
				   });
				}
			</script>';
		}
		
		// Message sur les savoirs du curriculume APDEN
		echo PARAC_SAVS11.'<p><a onmousedown="toggleDiv(\'divapd\');">'.PARAC_SAVS12.'</a></p><div style="overflow: auto;  white-space: nowrap;">';
		$i=0;
		echo '<div id="divapd" style="display:none;">';
		foreach($tabDebniveau as $divdeb) {
			echo '<h2>'.$tabNiveau[$i].'</h2>';
			$tabsav_select = 
			"SELECT sav.nom_savoir nom_savoir, SUBSTR(sav.s".$divdeb."_id,7,3) sidsub, SUBSTR(sav.s".$divdeb."_id,1,3) cadre, sav.s".$divdeb."_id savdiv_id, sc.bgcolor bg
			FROM ".$prefix."_savoirs".$divdeb." sav
			INNER JOIN ".$prefix."_savchamps sc
			ON sav.champs_id = sc.champs_id
			WHERE sav.s".$divdeb."_id LIKE 'APD%'
			ORDER BY s".$divdeb."_id ASC";
			$tabsav = mysqli_query($bdd,$tabsav_select);
			echo '<table class="param_sav paramform">';
			foreach ($tabsav as $savoir)
			{
				echo '<tr>';
				echo '<td class="eval_sav" style="background-color:'.$savoir['bg'].';">
				<span title="'.$savoir['nom_savoir'].'">'.$savoir['cadre'].'-'.$savoir['sidsub'].'. ';
				echo mb_ereg_replace("[?]","",mb_convert_encoding($savoir['nom_savoir'],"utf-8"));
				echo '</td></tr>';
			}
			echo '</table>';
			$i++;
		}
		echo '</div></div>';
				
		// Installation ou message sur les compétences EMI
		if($nb_sav_emi>0) {
			echo PARAC_SAVS13.'<p><a onmousedown="toggleDiv(\'divemi\');">'.PARAC_SAVS14.'</a></p><div style="overflow: auto;  white-space: nowrap;">';
			$tabsav_select = 
			"SELECT sav.nom_savoir nom_savoir, SUBSTR(sav.s5_id,7,3) sidsub, SUBSTR(sav.s5_id,1,3) cadre, sav.s5_id savdiv_id, sc.bgcolor bg
			FROM ".$prefix."_savoirs5 sav
			INNER JOIN ".$prefix."_savchamps sc
			ON sav.champs_id = sc.champs_id
			WHERE sav.s5_id LIKE 'EMI%'
			ORDER BY s5_id ASC";
			$tabsav = mysqli_query($bdd,$tabsav_select);
			echo '<div id="divemi" style="display:none;"><table class="param_sav paramform">';
			foreach ($tabsav as $savoir)
			{
				echo '<tr>';
				echo '<td class="eval_sav" style="background-color:'.$savoir['bg'].';">
				<span title="'.$savoir['nom_savoir'].'">'.$savoir['cadre'].'-'.$savoir['sidsub'].'. ';
				echo mb_ereg_replace("[?]","",mb_convert_encoding($savoir['nom_savoir'],"utf-8"));
				echo '</td></tr>';
			}
			echo '</table></div></div>';
		}
		else {
			echo PARAC_SAVS15;
		}

		// Installation ou message sur une grille d'évaluation personnalisée
		if($nb_sav_per>0) {
			// Message
			echo PARAC_SAVS16;
			// Choix d'une évaluation par niveau ou globale :
			if(isset($_POST['evalperso_valid'])) {
				$choix = $_POST['evalperso'];
				mysqli_query($bdd,"UPDATE ".$prefix."_parametres SET valeur = '".$choix."' WHERE param_nom = 'eval_perso'");
			}
			echo PARAC_SAVS17;
			$ccr = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'eval_perso'");
			$ccr_info = mysqli_fetch_assoc($ccr);
			echo '<form method="POST" name="evalperso" action="" class="padd3"><input type="radio" name="evalperso" value="niveau" ';
			if($ccr_info['valeur']=="niveau") { echo 'checked'; }
			echo ' />'.PARAC_SAVS18.' <br /><input type="radio" name="evalperso" value="global" '; 
			if($ccr_info['valeur']=="global") { echo 'checked'; }
			echo ' />'.PARAC_SAVS19.' <p class="paddvalid1"><input class="bouton boutparam" type="submit" value="'.VALID.'" name="evalperso_valid" /></p></form>';
			// Liste des savoirs :
			echo '<h2>'.PARAC_SAVS20.'</h2>';
			$i=0;
			foreach($tabDebniveau as $divdeb) {
				$find_sav = mysqli_query($bdd,"SELECT * FROM ".$prefix."_savoirs".$divdeb." WHERE s".$divdeb."_id LIKE 'PER%'");
				$find_nb = mysqli_num_rows($find_sav);
				if($find_nb != 0) {
					echo '<p><b>'.$tabNiveau[$i].'</b></p><p>';
					while($find_sav_info = mysqli_fetch_assoc($find_sav)) {
						echo ''.$find_sav_info['s'.$divdeb.'_id'].'. '.$find_sav_info['nom_savoir'].'<br>';
					}
					echo '</p>';
					$check_champs = $divdeb; // pour la récupération des champs pour couleurs
				}
				$i++;
			}
			// Liste des champs :
			$tabDebniveau = array('6', '5', '4', '3', '2', '1', 't');
			$perchamps = array();
			foreach($tabDebniveau as $divdeb) {
				$testchs = mysqli_query($bdd,"SELECT champs_id FROM ".$prefix."_savoirs".$divdeb." WHERE s".$divdeb."_id LIKE 'PER%' GROUP BY champs_id");
				foreach($testchs as $testch) {
					if(!in_array($testch['champs_id'], $perchamps)) {
						array_push($perchamps, $testch['champs_id']);
					}
				}
			}
			echo '<h2>'.PARAC_SAVS21.'</h2>
			<table class="paramform">';
			foreach($perchamps as $perchamp) {
				$champsper = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_savchamps WHERE champs_id = '".$perchamp."'"));
				if($champsper['champs_id']!="CE01"&&$champsper['champs_id']!="CP02"&&$champsper['champs_id']!="CR03"&&$champsper['champs_id']!="CT04"&&$champsper['champs_id']!="AU01"&&$champsper['champs_id']!="EX02"&&$champsper['champs_id']!="ME03"&&$champsper['champs_id']!="PR04") {
					echo '<tr><td>'.$champsper['champs_id'].'</td><td><input type="text" class="inptxt" id="pername'.$champsper['champs_id'].'" name="pername'.$champsper['champs_id'].'" maxlength="50"  value="'.$champsper['champs_nom'].'" /></td> <td><input type="color" id="percouleur'.$champsper['champs_id'].'" name="couleur'.$champsper['champs_id'].'" maxlength="30" value="'.$champsper['bgcolor'].'" /></tr>';
				}
				else {
					echo '<tr><td>'.$champsper['champs_id'].'</td><td>'.$champsper['champs_nom'].'</td><td><input type="hidden" id="pername'.$champsper['champs_id'].'" name="pername'.$champsper['champs_id'].'" value="'.$champsper['champs_nom'].'" /><input type="color" id="percouleur'.$champsper['champs_id'].'" name="couleur'.$champsper['champs_id'].'" maxlength="30" value="'.$champsper['bgcolor'].'" /></tr>';
				}
			}
			echo '<tr><td colspan="3"><input class="bouton boutparam preins" onclick="colorperval(this);colorval(\'colorperval\');" id="colorperval" type="submit" value="'.VALID.'" name="axesper" /></td></tr>
			</table>';
			echo '<script type="text/javascript">
				function colorperval(param) {
				var param = "colorperval";';
				foreach($perchamps as $perchamp) {
					$champsper = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_savchamps WHERE champs_id = '".$perchamp."'"));
					echo ' var percouleur'.$champsper['champs_id'].' = document.getElementById("percouleur'.$champsper['champs_id'].'").value;
					var pername'.$champsper['champs_id'].' = document.getElementById("pername'.$champsper['champs_id'].'").value;';
					if($champsper['champs_id']=="CE01"||$champsper['champs_id']=="CP02"||$champsper['champs_id']=="CR03"||$champsper['champs_id']=="CT04"||$champsper['champs_id']=="AU01"||$champsper['champs_id']=="EX02"||$champsper['champs_id']=="ME03"||$champsper['champs_id']=="PR04") {
						echo ' document.getElementById("apdcouleur'.$champsper['champs_id'].'").value =  percouleur'.$champsper['champs_id'].'; ';
					}
				}							
				echo '$.ajax({
				    type: "POST",
				    data: { param: param';
				    foreach($perchamps as $perchamp) {
				    	$champsper = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_savchamps WHERE champs_id = '".$perchamp."'"));
				    	echo ', percouleur'.$champsper['champs_id'].': percouleur'.$champsper['champs_id'].' , pername'.$champsper['champs_id'].': pername'.$champsper['champs_id'];
				    }
				    echo ' },
				    url: "js/idl/param_syn.php",
				   });
				}
			</script>';
			// Proposition de mise à jour
			echo '<h2>'.PARAC_SAVS22.'</h2>';
			echo PARAC_SAVS23.PARAC_SAVS231;
			echo '<form enctype="multipart/form-data" action="db/install_savoirs_permaj.php" method="POST">
			<p><input class="boutontab" name="file" type="file" accept=".csv,.ods" /></p>
			<p><input class="bouton boutparam" type="submit" value="'.SENDFILE.'" /></p>
			</form>';
			// Proposition de suppression
			echo '<h2>'.PARAC_SAVS24.'</h2>';
			echo '<form method="POST" action=""><input class="bouton boutparam" type="submit" name="delper" value="'.PARAC_SAVS25.'" /></form>';
		}
		else {
			// Proposition d'intégration d'une grille personnalisée s'il n'y en a pas
			echo PARAC_SAVS232.PARAC_SAVS231.PARAC_SAVS233.'
			<form enctype="multipart/form-data" action="db/install_savoirs_per.php" method="POST">
			  <p>
				 <input class="boutontab" name="file" type="file" accept=".csv,.ods" />
			  </p>
			   <p><input class="bouton boutparam" type="submit" value="'.SENDFILE.'" /></p>
			</form>';
		}
		//Couleurs savoirs
		echo '<h1 id="colsav">'.PARAC_SAVS26.'</h1>';
		// APD
		$apd = mysqli_query($bdd,"SELECT * FROM ".$prefix."_savchamps WHERE champs_id = 'CE01' OR champs_id = 'CP02' OR champs_id = 'CR03' OR champs_id = 'CT04' ORDER BY champs_id");
		echo '<h2>'.PARAC_SAVS27.'</h2>
		<table class="paramform">';
		foreach($apd as $champsapd) {
			echo '<tr><td>'.$champsapd['champs_id'].'. '.$champsapd['champs_nom'].'</td>';
			echo '<td><input type="color" id="apdcouleur'.$champsapd['champs_id'].'" name="couleur'.$champsapd['champs_id'].'" maxlength="30" value="'.$champsapd['bgcolor'].'" />';
			echo '</td></tr>';	
		}
		echo '<tr><td colspan="2"><input class="bouton boutparam" onclick="colorapddef(this);colorval(\'colorapddef\');" id="colorapddef" type="submit" value="'.COLOR2.'" name="coldefapd" /> <input class="bouton boutparam preins" onclick="colorapdval(this);colorval(\'colorapdval\');" id="colorapdval" type="submit" value="'.VALID.'" name="colorapd" /></td></tr>
		</table>';
		echo '<script type="text/javascript">
			function colorapddef(param) {
			var param = "colorapddef";';
			foreach($apd as $champsapd) {
				if($champsapd['champs_id']=="CE01") { 
					echo 'document.getElementById("apdcouleur'.$champsapd['champs_id'].'").value = "#CEF6CE";
					document.getElementById("percouleur'.$champsapd['champs_id'].'").value =  "#CEF6CE";'; }
				else if($champsapd['champs_id']=="CP02") { 
					echo 'document.getElementById("apdcouleur'.$champsapd['champs_id'].'").value = "#F5F6CE";
					document.getElementById("percouleur'.$champsapd['champs_id'].'").value =  "#F5F6CE";'; }
				else if($champsapd['champs_id']=="CR03") { 
					echo 'document.getElementById("apdcouleur'.$champsapd['champs_id'].'").value = "#CECEF6";
					document.getElementById("percouleur'.$champsapd['champs_id'].'").value =  "#CECEF6";'; }
				else if($champsapd['champs_id']=="CT04") { 
					echo 'document.getElementById("apdcouleur'.$champsapd['champs_id'].'").value = "#F6CED8";
					document.getElementById("percouleur'.$champsapd['champs_id'].'").value =  "#F6CED8";'; }
			}			
			echo '$.ajax({
			    type: "POST",
			    data: { param: param },
			    url: "js/idl/param_syn.php",
			   });
			}
		</script>';
		echo '<script type="text/javascript">
			function colorapdval(param) {
			var param = "colorapdval";';
			foreach($apd as $champsapd) {
				echo ' var apdcouleur'.$champsapd['champs_id'].' = document.getElementById("apdcouleur'.$champsapd['champs_id'].'").value; '; 
				if($champsapd['champs_id']=="CE01"||$champsapd['champs_id']=="CP02"||$champsapd['champs_id']=="CR03"||$champsapd['champs_id']=="CT04"||$champsapd['champs_id']=="AU01"||$champsapd['champs_id']=="EX02"||$champsapd['champs_id']=="ME03"||$champsapd['champs_id']=="PR04") {
					echo ' document.getElementById("percouleur'.$champsapd['champs_id'].'").value =  apdcouleur'.$champsapd['champs_id'].'; ';
				}
			}							
			echo '$.ajax({
			    type: "POST",
			    data: { param: param';
			    foreach($apd as $champsapd) {
			    	echo ', apdcouleur'.$champsapd['champs_id'].': apdcouleur'.$champsapd['champs_id'];
			    }
			    echo ' },
			    url: "js/idl/param_syn.php",
			   });
			}
		</script>';
		// EMI
		if($nb_sav_emi>0) {
			$emi = mysqli_query($bdd,"SELECT champs_id, champs_nom, bgcolor FROM ".$prefix."_savchamps WHERE champs_id = 'AU01' OR champs_id = 'EX02' OR champs_id = 'ME03' OR champs_id = 'PR04' ORDER BY champs_id");
			echo '<h2>'.PARAC_SAVS28.'</h2>
			<table class="paramform">';			
				foreach($emi as $champsemi) {
					echo '<tr><td>'.$champsemi['champs_id'].'. '.$champsemi['champs_nom'].'</td>';
					echo '<td><input type="color" id="emicouleur'.$champsemi['champs_id'].'" name="couleur'.$i.'" maxlength="30" value="'.$champsemi['bgcolor'].'" />';
					echo '</td></tr>';					
				}
				echo '<tr><td colspan="2"><input class="bouton boutparam" onclick="coloremidef(this);colorval(\'coloremidef\');" id="coloremidef" type="submit" value="'.COLOR2.'" name="coldefemi" /> <input class="bouton boutparam preins" onclick="coloremival(this);colorval(\'coloremival\');" id="coloremival" type="submit" value="'.VALID.'" name="coloremi" /></td></tr>
			</table>';
			echo '<script type="text/javascript">
				function coloremidef(param) {
				var param = "coloremidef";';
				foreach($emi as $champsemi) {
					if($champsemi['champs_id']=="AU01") { 
						echo 'document.getElementById("emicouleur'.$champsemi['champs_id'].'").value = "#CEF6CE";
						document.getElementById("percouleur'.$champsemi['champs_id'].'").value =  "#CEF6CE";'; }
					else if($champsemi['champs_id']=="EX02") { 
						echo 'document.getElementById("emicouleur'.$champsemi['champs_id'].'").value = "#F5F6CE";
						document.getElementById("percouleur'.$champsemi['champs_id'].'").value =  "#F5F6CE";'; }
					else if($champsemi['champs_id']=="ME03") { 
						echo 'document.getElementById("emicouleur'.$champsemi['champs_id'].'").value = "#CECEF6";
						document.getElementById("percouleur'.$champsemi['champs_id'].'").value =  "#CECEF6";'; }
					else if($champsemi['champs_id']=="PR04") { 
						echo 'document.getElementById("emicouleur'.$champsemi['champs_id'].'").value = "#F6CED8";
						document.getElementById("percouleur'.$champsemi['champs_id'].'").value =  "#F6CED8";'; }			
				}
				echo '$.ajax({
				    type: "POST",
				    data: { param: param },
				    url: "js/idl/param_syn.php",
				   });
				}
			</script>';
			echo '<script type="text/javascript">
				function coloremival(param) {
				var param = "coloremival";';
				foreach($emi as $champsemi) {
					echo ' var emicouleur'.$champsemi['champs_id'].' = document.getElementById("emicouleur'.$champsemi['champs_id'].'").value;';
					if($champsemi['champs_id']=="CE01"||$champsemi['champs_id']=="CP02"||$champsemi['champs_id']=="CR03"||$champsemi['champs_id']=="CT04"||$champsemi['champs_id']=="AU01"||$champsemi['champs_id']=="EX02"||$champsemi['champs_id']=="ME03"||$champsemi['champs_id']=="PR04") {
						echo ' document.getElementById("percouleur'.$champsemi['champs_id'].'").value =  emicouleur'.$champsemi['champs_id'].'; ';
					} 
				}							
				echo '$.ajax({
				    type: "POST",
				    data: { param: param';
				    foreach($emi as $champsemi) {
				    	echo ', emicouleur'.$champsemi['champs_id'].': emicouleur'.$champsemi['champs_id'];
				    }
				    echo ' },
				    url: "js/idl/param_syn.php",
				   });
				}
			</script>';
		}		
		echo '<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>';
	}
}
else {
	include('include/noaccess.php');
	echo '<br><a href="./index.php">'.ACCUEIL.'</a></p>';
}
?>
