<?php
if($droits!=2&&$droits!=6&&$droits!=4) {
	// Gestion de l'absence de droits sur créneau et classe
	$_POST['datepick'] = "";
	$_POST['crenpicker'] = "";
	$_POST['classe'] = "";
}

$code_activ = @$_POST['selectactiv'];
$_SESSION['code_activ'] = $code_activ;
if($crenchoix_info['valeur']==1&&$_POST['datepick']!=""&&$_POST['crenpicker']!="") {
	$_SESSION['datepickchoix'] = $_POST['datepick'];
	$_SESSION['crenpickerchoix'] = $_POST['crenpicker'];
	$day = date('Y-m-d', strtotime(str_replace("/","-",$_POST['datepick'])));
	$jouraff = date('Ymd', strtotime(str_replace("/","-",$_POST['datepick'])));
	$creneau = $_POST['crenpicker'];
	if($espopt['valeur']==1) { 
		$espace_id = $_POST['selectespace']; $_SESSION['espace_id']=$espace_id; }
	if($_POST['seance']=="create"&&$_POST['sequence']=="") {
		echo FREQ_SEQU1;
	}
	else {
		if(($classe_info_valeur==1&&$_POST['classe']!="")||isset($_POST['proncheck'])) { // pour inscription de classe ou pronote
			$classe=1;
			$array = array_keys($_POST);
			unset($array[0]);
			unset($array['eleve']);
			foreach($array as $checked_id) {
				$eleve_id = $checked_id;
				if(is_int($eleve_id)) {
					// Récupération de la division :
					$diveleve = mysqli_query($bdd,"SELECT division, sexe, naissance FROM ".$prefix."_eleves WHERE eleves_id = '".$eleve_id."'");
					$diveleve_nb = mysqli_num_rows($diveleve);
					if($diveleve_nb!=0) {
						$diveleve_info = mysqli_fetch_assoc($diveleve);
					}
					$eleve_div = $diveleve_info['division'];
					$eleve_sex = $diveleve_info['sexe'];
					$eleve_naissance = $diveleve_info['naissance'];
					// Inscription :
					include('./db/proc/freq_inscription.php');
				}
			}
		}
		else if(isset($eleve_id)) { // sinon
			$classe=0;
			include('./db/proc/freq_inscription.php');
		}
	}
}
else {
	if(isset($_SESSION['datepickchoix'])) {
		unset($_SESSION['datepickchoix']);
	}
	if(isset($_SESSION['crenpickerchoix'])) {
		unset($_SESSION['crenpickerchoix']);
		$_POST['soluce']==1;
	}
	if(@$creneau_info['hor_freq']==0||@$_POST['soluce']==0) { 
		echo '<p><b>'.FREQ_NO1.'</b></p>';
	}
	else {
		if(isset($_SESSION['nextday'])) {
			$day = $_SESSION['nextday'];
		}
		else {
			$day = date("Y-m-d");
		}
		$creneau = @$_SESSION['ccren'];
		if($espopt['valeur']==1) { 
			$espace_id = $_POST['selectespace']; $_SESSION['espace_id']=$espace_id; }
		if(($classe_info_valeur==1&&@$_POST['classe']!="")||isset($_POST['proncheck'])) { // pour inscription de classe ou pronote
			$classe=1;
			$array = array_keys($_POST);
			foreach($array as $checked_id) {
				$eleve_id = $checked_id;
				if(is_int($eleve_id)) {
					// Récupération de la division :
					$diveleve = mysqli_query($bdd,"SELECT division, sexe, naissance FROM ".$prefix."_eleves WHERE eleves_id = '".$eleve_id."'");
					$diveleve_nb = mysqli_num_rows($diveleve);
					if($diveleve_nb!=0) {
						$diveleve_info = mysqli_fetch_assoc($diveleve);
					}
					$eleve_div = $diveleve_info['division'];
					$eleve_sex = $diveleve_info['sexe'];
					$eleve_naissance = $diveleve_info['naissance'];
					// Inscription :
					include('./db/proc/freq_inscription.php');
				}
			}
		}
		else if(isset($eleve_id)) { // sinon
			$classe=0;
			include('./db/proc/freq_inscription.php');
		}
	}
}
?>
