<?php

if(isset($_GET["s"])){	
	$_SESSION['bctabs']='';
	if($_GET["s"]=="freqpereleve"||$_GET["s"]=="exclusor"||$_GET["s"]=="all") {
		//vérification de présence de stats non nominatives:
		$verif_nonnom = mysqli_query($bdd,"SELECT * FROM ".$prefix."_freq WHERE eleves_id=0 AND date_freq >= '".$day1."' AND date_freq <= '".$day2."' ".$filtre_activs."");
		$verif_nonnom_nb = mysqli_num_rows($verif_nonnom);
		$verif_elesup = mysqli_query($bdd,"SELECT freq.freq_id, eleves.eleves_id, eleves.division, eleves.nom, eleves.prenom FROM ".$prefix."_freq freq 
		INNER JOIN ".$prefix."_eleves eleves
		ON freq.eleves_id = eleves.eleves_id
		WHERE date_freq >= '".$day1."' AND date_freq <= '".$day2."' ".$filtre_activs."");
		$verif_elesup_nb = mysqli_num_rows($verif_elesup);
		//fréquentation par élève :
		$eleves_select = "SELECT freq.freq_id, COUNT(eleves.eleves_id), eleves.division, eleves.nom, eleves.prenom FROM ".$prefix."_freq freq 
		INNER JOIN ".$prefix."_eleves eleves
		ON freq.eleves_id = eleves.eleves_id
		WHERE date_freq >= '".$day1."' AND date_freq <= '".$day2."' ".$filtre_activs." GROUP BY eleves.eleves_id ORDER BY COUNT(eleves.eleves_id) DESC";
		$eleves = mysqli_query($bdd,$eleves_select);
		$eleves_nb = mysqli_num_rows($eleves);

		if($eleves_nb>0) {
			if($verif_nonnom_nb>0||($totalfreq_nb-$verif_elesup_nb)>0) {
				$nb_nonnom = ($verif_nonnom_nb+($totalfreq_nb-$verif_elesup_nb));
				echo '<p class="maxwidth">'.FDIR_S_ELEV1.' '.$nb_nonnom.' ';
				if($nb_nonnom==1) { echo FDIR_S_ELEV2; }
				else { echo FDIR_S_ELEV3; }
				echo FDIR_S_ELEV4;
				if($nb_nonnom==1) { echo FDIR_S_ELEV5; }
				else { echo FDIR_S_ELEV6; }
				echo FDIR_S_ELEV7.'</p>';
			}
		}
	}
	if($_GET["s"]=="freqpereleve"||$_GET["s"]=="all") {
		//fréquentation par élève :
		include('freq_stats_elechart_freqpereleve.php');
		$_SESSION['bctabs'].= $bctab1;
	}
	if($_GET["s"]=="exclusor"||$_GET["s"]=="all") {
		include('freq_stats_elechart_exclusor.php');		
	}
	if($_GET["s"]=="absfreq"||$_GET["s"]=="all") {
		include('freq_stats_elechart_absfreq.php');
	}
	echo '<br> <a onclick="submitods();" id="preview-ods"><i class="fa-solid fa-file-export" style="font-size:1.5em;"></i> '.STATS_DL1.'</a>';
	if(isset($_POST['haveods'])) {
		include('stats_ods_loader.php');
	}
    echo '<form id="loadods" action="db/proc/stats/stats_ods_loader.php" method="post"><input type="hidden" name="haveods" value="1" /></form>';

    echo '<script type="text/javascript">
	function submitods(){
		$("#loadods").submit()
	}
	</script>';
}
?>
