<?php

echo FSTATS_TIT10;

echo FSTATS_AVERT2;

include('freq_stats_form.php');

echo '<h2>'.FROM21.' '.$affday1.' '.TO2.' '.$affday2.'</h2>';

echo '<p>'.FSTATS_TIT11.' ';

$totalpass_nb = 0;
$passages_nb = mysqli_query($bdd,"SELECT nombre FROM ".$prefix."_freqgrappes WHERE date_freq >= '".$day1."' AND date_freq <= '".$day2."' AND passage = '1' ".$filtre_activs."");
while($passages = mysqli_fetch_assoc($passages_nb)) {
	$totalpass_nb += $passages['nombre'];
}

if($totalpass_nb==0) {
	echo FSTATS_INF1;
}
else {
	echo $totalpass_nb;
	echo ' '.ELEVS1.'.</p>';

	//récupération des niveaux et couleurs par niveau
	include('freq_stats_nivcolors.php');

	$tabWeeks = array();
	foreach (new DatePeriod($jourP1date, new DateInterval('P7D') /* pas de sept jours */, $jourP2date) as $dt) {
		$week = $dt->format('oW');
		array_push($tabWeeks, $week);
	} 

	echo '<form name="statscform" method="GET" action="">
	<input type="hidden" name="page" value="stats" />
	<input type="hidden" name="stat" value="passages" />
	<select name="s" id="statschoix">';
		$stcode = array('zero','passperniv','pcpassperniv','passperdiv','pcpassperdiv','passperweek','passperweekperniv','passperday','passperdayperniv','all');
		$stname = $stname6;
		for($sno=0;$sno<count($stcode);$sno++) {
			if($stcode[$sno]=="passperday"||$stcode[$sno]=='passperdayperniv') {
				if(count($tabWeeks)<6) {
					echo '<option value="'.$stcode[$sno].'"';
					if(isset($_GET['s'])) {
						if($_GET['s']==$stcode[$sno]) {
							echo ' selected ';
						}
					}
					echo '>'.$stname[$sno].'</option>';
				}
			}
			else {
				echo '<option value="'.$stcode[$sno].'"';
				if(isset($_GET['s'])) {
					if($_GET['s']==$stcode[$sno]) {
						echo ' selected ';
					}
				}
				echo '>'.$stname[$sno].'</option>';
			}
		}
		echo '</select> <input type="submit" class="bouton boutfreq" value="'.CHOOSE.'" />
	</form>';

	echo '</article><article id="artleft" class="freqsep">';

	include('stats/freq_stats_pass_div.php');

} 
?>