<?php

echo '<h2>'.FSTATS_RESAS1.'</h2>';

include('freq_stats_form.php');

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

echo '<p>'.RESA6.DOTS.' ';

$totalfreq_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT freq.freqres_id FROM ".$prefix."_freqres freq WHERE freq.date_freqres >= '".$day1."' AND freq.date_freqres <= '".$day2."' ".$filtre_activs.""));

if($totalfreq_nb==0) {
	echo FSTATS_INF1;
}
else {
	echo $totalfreq_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="resas" />
	<div class="box"><select name="s" id="statschoix">';
		$stcode = array('zero','nbperniv','percentperniv','nbperdiv','percentperdiv','nbperweek','nbperweekperniv','nbperday','nbperdayperniv','all');
		$stname = $stname9;
		for($sno=0;$sno<count($stcode);$sno++) {
			if($stcode[$sno]=="nbperday"||$stcode[$sno]=='nbperdayperniv') {
				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></div> <input type="submit" class="bouton boutfreq" value="'.CHOOSE.'" />
	</form>';

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

	include('stats/freq_stats_resas_div.php');

} ?>