<?php

echo '<h2>'.CREN2.'</h2>';
echo '<p>'.FSTATS_INF3.'</p>';
include('freq_stats_form.php');
include('freq_stats_nivcolors.php');

$totalfreq = mysqli_query($bdd,"SELECT freq.freq_id FROM ".$prefix."_freq freq WHERE freq.date_freq >= '".$jourP1."' AND freq.date_freq <= '".$jourP2."' ".$filtre_activs."");
$totalfreq_nb = mysqli_num_rows($totalfreq);

if($grappes_check==1) {
	$elegrap_nb = mysqli_query($bdd,"SELECT nombre FROM ".$prefix."_freqgrappes WHERE date_freq >= '".$jourP1."' AND date_freq <= '".$jourP2."' AND passage = '0' ".$filtre_activs."");
	while($elegrap = mysqli_fetch_assoc($elegrap_nb)) {
		$totalfreq_nb += $elegrap['nombre'];
	}
}

echo '<ul class="menucren"><li class="itemcren"><a href="freq.php?page=stats&stat=creneaux&cren=all">Tous niveaux</a></li>';
if($nivs_info['valeur']=="PER") {
	$deb=0;
	foreach($noms as $checked_noms) {
		echo '<li class="itemcren"><a href="freq.php?page=stats&stat=creneaux&cren='.$tabDebniveau[$deb].'">';
		echo $checked_noms;
		echo '</a></li>';
		$deb++;
	}
}
else { 
	foreach($tabDebniveau as $divdeb) {
		echo '<li class="itemcren"><a href="freq.php?page=stats&stat=creneaux&cren='.$divdeb.'">';
		if($divdeb=='6'||$divdeb=='5'||$divdeb=='4'||$divdeb=='3') { 
			echo $divdeb.'ème'; }
		else if($divdeb=='2') { echo '2nde'; }
		else if($divdeb=='1') { echo '1re'; }
		else if($divdeb=='T') { echo 'Tale'; }
		else if($divdeb=='t') { echo 'Tale'; }
		else if($divdeb=='a') { echo 'Autre'; }
		echo '</a></li>';
	}
}	
echo '</ul>';

echo '<h2>Du '.$affpday1.' au '.$affpday2.'</h2>';

// S'il n'y a pas d'horaires configurés :
$hor_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_horaires"));
if($hor_nb==0) {
	echo '<p><a href="param.php?page=horaires">'.FREQ_HORNEED.'</a>.';
}
else if($totalfreq_nb==0) {
	echo FSTATS_INF1;
}
else {
	if(!isset($_GET['cren'])) { 			
		include('./db/proc/freq_stats_creneaux_all.php');
	}
	else {
		if($_GET['cren']=='all') { include('./db/proc/freq_stats_creneaux_all.php'); }
		else { include('./db/proc/freq_stats_creneaux_niv.php'); }
	}
} 
?>
