<?php

echo '<h2>'.EDT_STATS4.' ('.$_SESSION['lieu_nom'].')</h2>';
if ($nb_espedt>0) {
	echo '<p class="signal">'.EDT_STATS2.'</p> ';
}
$_SESSION['bctabs']='';
// récupération des divisions et groupes
$div = mysqli_query($bdd,"SELECT division FROM ".$prefix."_eleves GROUP BY division ORDER BY division ASC");
$groupes = mysqli_query($bdd,"SELECT groupe_nom FROM ".$prefix."_groupes");

include('./db/proc/edt_stats_form.php');

// Stats
if(isset($anneesco)) {
	echo '<h2>'.YEAR.' '.$anneesco.' '.$info_comp.'</h2>';
	if($acadexist=="fnc") { $w1 = '07'; } 
	else if($acadexist=="civ") { $w1 = '01'; } 
	else { $w1 = '33'; }
	if($_SESSION['frag']=="actday") { $w2 = $_SESSION['w2']; }
	else if($_SESSION['frag']=="allyea") { 
		if($acadexist=="fnc") {
			$w2 = $anneesco."50"; 
		}
		else if($acadexist=="civ") {
			$w2 = $anneesco."52"; 
		}
		else {
			$w2 = substr($anneesco,5,4)."27"; 
		}
	}
	$eventdivs = mysqli_query($bdd,"SELECT * FROM ".$prefix."_edtevent event INNER JOIN ".$prefix."_userevent uevent ON event.uid = uevent.uid INNER JOIN ".$prefix."_espaces_event espevent ON event.uid = espevent.uid INNER JOIN ".$prefix."_edtbrik brik ON event.brik_id = brik.brik_id WHERE (brik.close = 1 OR brik.seance = 1) AND event.week >= '".substr($anneesco,0,4).$w1."' AND event.week <= '".$w2."' AND uevent.user_id=0 AND espevent.espace_id ='0'");
}
else if(isset($_SESSION['week1'])) {
	echo '<h2>'.WEEKS.' '.substr($_SESSION['week1'],0,4).'-'.substr($_SESSION['week1'],4,2).' '.TO.' '.substr($_SESSION['week2'],0,4).'-'.substr($_SESSION['week2'],4,2).'</h2><p>'.WEEKFROM.' '.date("d/m/Y",strtotime($day1)).' '.WEEKTO.' '.date("d/m/Y",strtotime($day2)).'.</p>';
	$eventdivs = mysqli_query($bdd,"SELECT * FROM ".$prefix."_edtevent event INNER JOIN ".$prefix."_userevent uevent ON event.uid = uevent.uid INNER JOIN ".$prefix."_espaces_event espevent ON event.uid = espevent.uid INNER JOIN ".$prefix."_edtbrik brik ON event.brik_id = brik.brik_id WHERE (brik.close = 1 OR brik.seance = 1) AND event.week >= '".$_SESSION['week1']."' AND event.week <= '".$_SESSION['week2']."' AND uevent.user_id=0 AND espevent.espace_id ='0'");	
}
$eventdiv_nb = 0;
foreach ($eventdivs as $eventdiv) {
	if($eventdiv['duration']==5) { $duree = 0.5; }
	else { $duree = substr($eventdiv['duration'],0,1).'.'.substr($eventdiv['duration'],1,1); }
	$eventdiv_nb += $duree;
}
if($eventdiv_nb==0) {
	echo '<p>'.NOSTATS2.'</p>';
}
else {

	//récupération des niveaux et couleurs par niveau
	include('freq_stats_nivcolors.php'); 
	include('edt_stats_arrays.php');
	require_once('./include/basiccolors.php');
	
	$dayhour = 1; // pour activer le comptage dans calweeknb
	include('calweeknb.php');
	// préparation des arrays
	$tabHeuresTotal1 = array(); //total
	$tabHeuresTotal2 = array(); // étude/séances
	$tabHeuresTotal3 = array(); // séquences ou pas
	$tabHeuresWeek1 = array();
	$tabHeuresWeek2 = array();
	$tabHeuresWeek3 = array();
	$tabHeuresTxt1 = array();
	$tabHeuresTxt2 = array();
	$tabHeuresTxt3 = array();
	// comptage et affichage récapitulatif
	$demijours_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_hordemis WHERE statut = 1"));
	$djours_nb = ($demijours_nb * $nb_week)-($nb_jclose*2);
	$jours_nb = (($demijours_nb * $nb_week)/2)-$nb_jclose;
	if($nb_week==0) {
		echo '<h3>'.NOSTATS3.'</h3>';
	}
	else {
		echo '<h3>'.STATS_RECAP1.'</h3>';
		echo $djours_nb.STATS_RECAP2.$jours_nb.STATS_RECAP3;
		echo '<br> <br>';

		echo $nb_fullhour.STATS_RECAP4.round(($nb_fullhour/$nb_week),1).STATS_RECAP5.'<br>';
		echo $nb_briks_close.' heures fermées ('.round(($nb_briks_close/$nb_week),1).STATS_RECAP5.'<br>';
		echo ($nb_fullhour-$nb_briks_close).' heures d\'ouverture globale ('.round((($nb_fullhour-$nb_briks_close)/$nb_week),1).STATS_RECAP5.'<br> <br>';
		array_push($tabHeuresTotal1,($nb_fullhour-$nb_briks_close));
		array_push($tabHeuresWeek1,round((($nb_fullhour-$nb_briks_close)/$nb_week),1));
		array_push($tabHeuresTxt1,STATS_RECAP6);
		array_push($tabHeuresTotal1,$nb_briks_close);
		array_push($tabHeuresWeek1,round(($nb_briks_close/$nb_week),1));
		array_push($tabHeuresTxt1,STATS_RECAP7);
			
		echo ($nb_fullhour-$eventdiv_nb).STATS_RECAP8.round((($nb_fullhour-$eventdiv_nb)/$nb_week),1).STATS_RECAP5.'<br>';
		array_push($tabHeuresTotal2,($nb_fullhour-$eventdiv_nb));
		array_push($tabHeuresWeek2,round((($nb_fullhour-$eventdiv_nb)/$nb_week),1));
		array_push($tabHeuresTxt2,STATS_RECAP9);
		echo $nb_briks_open_seance.STATS_RECAP10.round(($nb_briks_open_seance/$nb_week),1).STATS_RECAP5.'<br>';
		array_push($tabHeuresTotal2,$nb_briks_open_seance);
		array_push($tabHeuresWeek2,round(($nb_briks_open_seance/$nb_week),1));
		array_push($tabHeuresTxt2,STATS_RECAP11);
		echo DONT.'<br>';
		echo ($nb_briks_open_seance-$nb_briks_open_noseq).' '.HOURS.' '.STATS_RECAP12.' ('.round((($nb_briks_open_seance-$nb_briks_open_noseq)/$nb_week),1).STATS_RECAP5.'<br>';
		array_push($tabHeuresTotal3,($nb_briks_open_seance-$nb_briks_open_noseq));
		array_push($tabHeuresWeek3,round((($nb_briks_open_seance-$nb_briks_open_noseq)/$nb_week),1));
		array_push($tabHeuresTxt3,STATS_RECAP12);
		echo $nb_briks_open_noseq.' '.HOURS.' '.STATS_RECAP13.' ('.round(($nb_briks_open_noseq/$nb_week),1).STATS_RECAP5.'<br>';
		array_push($tabHeuresTotal3,$nb_briks_open_noseq);
		array_push($tabHeuresWeek3,round(($nb_briks_open_noseq/$nb_week),1));
		array_push($tabHeuresTxt3,STATS_RECAP13);
		echo '</p>';
		?>
	</article><article id="artleft" class="edtsep">
		<div id="wrapper" class="statcadre">
		<canvas id="chart_nbheurestotal" class="charts" width="400" height="400"></canvas>
		</div>
		<script type="text/javascript">
		(async function() {
		    
		    Chart.register(ChartDataLabels);
		    const labels = <?php echo json_encode($tabHeuresTxt1); ?>;
		    const data = {
		      labels: labels,
		      datasets: [{
					data: <?php echo json_encode($tabHeuresTotal1); ?>,
					backgroundColor: <?php echo json_encode($basicColors); ?>,
					borderColor: <?php echo json_encode($basicColors); ?>,
				}]
		    };
		new Chart(
		    document.getElementById('chart_nbheurestotal'),
		    {
		    type: 'pie',
		    data : data,
		    options: {
		        plugins: {
		            title: {
		                display: true,
		                text: "<?php echo STATS_TIT8; ?> (<?php echo $nb_fullhour; ?>)"
		            },
		            legend: {
		                display:true
		            },
		            tooltip : {
		                mode: 'point',
		                intersect: false,
		              }  ,    
		            datalabels: {
		              display: true, // Affiche les étiquettes de données
		              color: '#878787', // Couleur du texte
		              align: 'center', // Alignement horizontal
		              anchor: 'center', // Alignement vertical
		              font: {
		                weight: 'bold', // Style de police
		              },
		              display: function(context) {
		                  return context.dataset.data[context.dataIndex] !== 0; // N'affiche pas si la valeur est égale à 0
		                },
		            },
		        },
		        responsive: true,
		      }
		    }
		);
		})();
		</script>

		<div id="wrapper" class="statcadre">
		<canvas id="chart_nbheureshebdo" class="charts" width="400" height="400"></canvas>
		</div>
		<script type="text/javascript">
		(async function() {
		    
		    Chart.register(ChartDataLabels);
		    const labels = <?php echo json_encode($tabHeuresTxt1); ?>;
		    const data = {
		      labels: labels,
		      datasets: [{
					data: <?php echo json_encode($tabHeuresWeek1); ?>,
					backgroundColor: <?php echo json_encode($basicColors); ?>,
					borderColor: <?php echo json_encode($basicColors); ?>,
				}]
		    };
		new Chart(
		    document.getElementById('chart_nbheureshebdo'),
		    {
		    type: 'pie',
		    data : data,
		    options: {
		        plugins: {
		            title: {
		                display: true,
		                text: "<?php echo STATS_TIT9; ?> (<?php echo round(($nb_fullhour/$nb_week),1); ?>)"
		            },
		            legend: {
		                display:true
		            },
		            tooltip : {
		                mode: 'point',
		                intersect: false,
		              }  ,    
		            datalabels: {
		              display: true, // Affiche les étiquettes de données
		              color: '#878787', // Couleur du texte
		              align: 'center', // Alignement horizontal
		              anchor: 'center', // Alignement vertical
		              font: {
		                weight: 'bold', // Style de police
		              },
		              display: function(context) {
		                  return context.dataset.data[context.dataIndex] !== 0; // N'affiche pas si la valeur est égale à 0
		                },
		            },
		        },
		        responsive: true,
		      }
		    }
		);
		})();
		</script>

		<div id="wrapper" class="statcadre">
		<canvas id="chart_nbouverttotal" class="charts" width="400" height="400"></canvas>
		</div>
		<script type="text/javascript">
		(async function() {
		    
		    Chart.register(ChartDataLabels);
		    const labels = <?php echo json_encode($tabHeuresTxt2); ?>;
		    const data = {
		      labels: labels,
		      datasets: [{
					data: <?php echo json_encode($tabHeuresTotal2); ?>,
					backgroundColor: <?php echo json_encode($basicColors); ?>,
					borderColor: <?php echo json_encode($basicColors); ?>,
				}]
		    };
		new Chart(
		    document.getElementById('chart_nbouverttotal'),
		    {
		    type: 'pie',
		    data : data,
		    options: {
		        plugins: {
		            title: {
		                display: true,
		                text: "<?php echo STATS_TIT10; ?> (<?php echo ($nb_fullhour-$nb_briks_close); ?>)"
		            },
		            legend: {
		                display:true
		            },
		            tooltip : {
		                mode: 'point',
		                intersect: false,
		              }  ,    
		            datalabels: {
		              display: true, // Affiche les étiquettes de données
		              color: '#878787', // Couleur du texte
		              align: 'center', // Alignement horizontal
		              anchor: 'center', // Alignement vertical
		              font: {
		                weight: 'bold', // Style de police
		              },
		              display: function(context) {
		                  return context.dataset.data[context.dataIndex] !== 0; // N'affiche pas si la valeur est égale à 0
		                },
		            },
		        },
		        responsive: true,
		      }
		    }
		);
		})();
		</script>

		<div id="wrapper" class="statcadre">
		<canvas id="chart_nbouverthebdo" class="charts" width="400" height="400"></canvas>
		</div>
		<script type="text/javascript">
		(async function() {
		    
		    Chart.register(ChartDataLabels);
		    const labels = <?php echo json_encode($tabHeuresTxt2); ?>;
		    const data = {
		      labels: labels,
		      datasets: [{
					data: <?php echo json_encode($tabHeuresWeek2); ?>,
					backgroundColor: <?php echo json_encode($basicColors); ?>,
					borderColor: <?php echo json_encode($basicColors); ?>,
				}]
		    };
		new Chart(
		    document.getElementById('chart_nbouverthebdo'),
		    {
		    type: 'pie',
		    data : data,
		    options: {
		        plugins: {
		            title: {
		                display: true,
		                text: "<?php echo STATS_TIT11; ?> (<?php echo round((($nb_fullhour-$nb_briks_close)/$nb_week),1); ?>)"
		            },
		            legend: {
		                display:true
		            },
		            tooltip : {
		                mode: 'point',
		                intersect: false,
		              }  ,    
		            datalabels: {
		              display: true, // Affiche les étiquettes de données
		              color: '#878787', // Couleur du texte
		              align: 'center', // Alignement horizontal
		              anchor: 'center', // Alignement vertical
		              font: {
		                weight: 'bold', // Style de police
		              },
		              display: function(context) {
		                  return context.dataset.data[context.dataIndex] !== 0; // N'affiche pas si la valeur est égale à 0
		                },
		            },
		        },
		        responsive: true,
		      }
		    }
		);
		})();
		</script>
		
		<div id="wrapper" class="statcadre">
		<canvas id="chart_nbclassetotal" class="charts" width="400" height="400"></canvas>
		</div>
		<script type="text/javascript">
		(async function() {
		    
		    Chart.register(ChartDataLabels);
		    const labels = <?php echo json_encode($tabHeuresTxt3); ?>;
		    const data = {
		      labels: labels,
		      datasets: [{
					data: <?php echo json_encode($tabHeuresTotal3); ?>,
					backgroundColor: <?php echo json_encode($basicColors); ?>,
					borderColor: <?php echo json_encode($basicColors); ?>,
				}]
		    };
		new Chart(
		    document.getElementById('chart_nbclassetotal'),
		    {
		    type: 'pie',
		    data : data,
		    options: {
		        plugins: {
		            title: {
		                display: true,
		                text: "<?php echo STATS_TIT12; ?> (<?php echo $nb_briks_open_seance; ?>)"
		            },
		            legend: {
		                display:true
		            },
		            tooltip : {
		                mode: 'point',
		                intersect: false,
		              }  ,    
		            datalabels: {
		              display: true, // Affiche les étiquettes de données
		              color: '#878787', // Couleur du texte
		              align: 'center', // Alignement horizontal
		              anchor: 'center', // Alignement vertical
		              font: {
		                weight: 'bold', // Style de police
		              },
		              display: function(context) {
		                  return context.dataset.data[context.dataIndex] !== 0; // N'affiche pas si la valeur est égale à 0
		                },
		            },
		        },
		        responsive: true,
		      }
		    }
		);
		})();
		</script>
		
		<div id="wrapper" class="statcadre">
		<canvas id="chart_nbclassehebdo" class="charts" width="400" height="400"></canvas>
		</div>
		<script type="text/javascript">
		(async function() {
		    
		    Chart.register(ChartDataLabels);
		    const labels = <?php echo json_encode($tabHeuresTxt3); ?>;
		    const data = {
		      labels: labels,
		      datasets: [{
					data: <?php echo json_encode($tabHeuresWeek3); ?>,
					backgroundColor: <?php echo json_encode($basicColors); ?>,
					borderColor: <?php echo json_encode($basicColors); ?>,
				}]
		    };
		new Chart(
		    document.getElementById('chart_nbclassehebdo'),
		    {
		    type: 'pie',
		    data : data,
		    options: {
		        plugins: {
		            title: {
		                display: true,
		                text: '<?php echo STATS_TIT13; ?> (<?php echo round(($nb_briks_open_seance/$nb_week),1); ?>)'
		            },
		            legend: {
		                display:true
		            },
		            tooltip : {
		                mode: 'point',
		                intersect: false,
		              }  ,    
		            datalabels: {
		              display: true, // Affiche les étiquettes de données
		              color: '#878787', // Couleur du texte
		              align: 'center', // Alignement horizontal
		              anchor: 'center', // Alignement vertical
		              font: {
		                weight: 'bold', // Style de police
		              },
		              display: function(context) {
		                  return context.dataset.data[context.dataIndex] !== 0; // N'affiche pas si la valeur est égale à 0
		                },
		            },
		        },
		        responsive: true,
		      }
		    }
		);
		})();
		</script>
		
		<?php
		//texte libre par type :
		$tabNbPerCode = array();
		$tabPercentPerCode = array();
		$tabNbPerCodeODS = array();
		$tabPercentPerCodeODS = array();
		$tabTxtLibre = array();
		$tabTxtLibreColors = array();
		$txtlibres = mysqli_query($bdd,"SELECT textelibre FROM ".$prefix."_edtbrik WHERE textelibre != '' GROUP BY textelibre ORDER BY textelibre ASC");
		$ic=0;
		foreach($txtlibres as $txt) {
			$bctab1 = '<table style="text-align:right;">
			<thead><tr><td colspan="3" style="text-align:center;">'.STATS_TIT14.'<br>'.FROM2.' '.$affday1.' '.TO2.' '.$affday2.'</td></tr><tr><th>'.INTIT.'</th><th>'.NUMBER.'</th><th>%</th></tr></thead><tbody>';
			if(isset($anneesco)) {
				$nbseances_niv = mysqli_query($bdd,"SELECT event.uid, event.duration FROM ".$prefix."_edtevent event INNER JOIN ".$prefix."_userevent uevent ON event.uid = uevent.uid INNER JOIN ".$prefix."_espaces_event espevent ON event.uid = espevent.uid INNER JOIN ".$prefix."_edtbrik brik ON event.brik_id = brik.brik_id WHERE event.week >= '".substr($anneesco,0,4).$w1."' AND event.week <= '".$w2."' AND brik.textelibre = '".mysqli_real_escape_string($bdd,$txt['textelibre'])."' AND uevent.user_id=0 AND espevent.espace_id =0");
			}
			else {
				$nbseances_niv = mysqli_query($bdd,"SELECT event.uid, event.duration FROM ".$prefix."_edtevent event INNER JOIN ".$prefix."_userevent uevent ON event.uid = uevent.uid INNER JOIN ".$prefix."_espaces_event espevent ON event.uid = espevent.uid INNER JOIN ".$prefix."_edtbrik brik ON event.brik_id = brik.brik_id WHERE event.week >= '".$_SESSION['week1']."' AND event.week <= '".$_SESSION['week2']."' AND brik.textelibre = '".mysqli_real_escape_string($bdd,$txt['textelibre'])."' AND uevent.user_id=0 AND espevent.espace_id =0");
			}
			$nbseances = 0;
			foreach ($nbseances_niv as $eventdiv) {
				if($eventdiv['duration']==5) { $duree = 0.5; }
				else { $duree = substr($eventdiv['duration'],0,1).'.'.substr($eventdiv['duration'],1,1); }
				$nbseances += $duree;
			}
			if($nbseances>0) {
				$tabTxtLibre[]=$txt['textelibre'];
				$tabTxtLibreColors[]=$basicColors[$ic];
				array_push($tabNbPerCode, $nbseances);
				$percent = round(($nbseances * 100 / $eventdiv_nb),2);
				array_push($tabPercentPerCode, $percent);
				$ic++;
			}
			array_push($tabNbPerCodeODS, $nbseances);
			$percent = round(($nbseances * 100 / $eventdiv_nb),2);
			array_push($tabPercentPerCodeODS, $percent);
		}
		$t=0;$tot=0;
		foreach($txtlibres as $txt) {
			$bctab1 .= '<tr><td>'.$txt['textelibre'].'</td><td>'.$tabNbPerCodeODS[$t].'</td><td>'.number_format((float)$tabPercentPerCodeODS[$t],2,'.','').'</td></tr>';
			$t++;
			$tot+=$tabNbPerCodeODS[($t-1)];
		}
		$bctab1 .= '<tr><td>'.TOTAL.'</td><td>'.$tot.'</td><td>100.00</td></tr></tbody></table>';
		?>
		<div id="wrapper" class="statcadre">
		<canvas id="chart_nbtpercode" class="charts" width="600" height="300"></canvas>
		</div>
		<script type="text/javascript">
		(async function() {
		    
		    Chart.register(ChartDataLabels);
		    const labels = <?php echo json_encode($tabTxtLibre); ?>;
		    const data = {
		      labels: labels,
		      datasets: [{
		            label: '<?php echo HOURS;?> ',
		            data: <?php echo json_encode($tabNbPerCode); ?>,
		            backgroundColor: <?php echo json_encode($tabTxtLibreColors); ?>,
		            borderColor: <?php echo json_encode($tabTxtLibreColors); ?>,
		            borderWidth: 1
		        }]
		    };
		new Chart(
		    document.getElementById('chart_nbtpercode'),
		    {
		    type: 'bar',
		    data: data,
		    options: {
		        plugins: {
		            title: {
		                display: true,
		                text: '<?php echo STATS_TIT14;?>'
		            },
		            legend: {
		    			display:false
		    		},
		            tooltip : {
		                mode: 'point',
		                intersect: false,
		              }  ,    
		            datalabels: {
		              display: true, // Affiche les étiquettes de données
		              color: '#878787', // Couleur du texte
		              align: 'center', // Alignement horizontal
		              anchor: 'center', // Alignement vertical
		              font: {
		                weight: 'bold', // Style de police
		              },
		              display: function(context) {
		                  return context.dataset.data[context.dataIndex] !== 0; // N'affiche pas si la valeur est égale à 0
		                },
		            },
		        },
		        responsive: true,
		        scales: {
		            yAxes: [{
		                ticks: {
		                    beginAtZero:true
		                }
		            }]
		        },
		      }
		    }
		);
		})();
		</script>
		<?php
		echo '<br> <br>'.$bctab1;
		$_SESSION['bctabs'] .= $bctab1;
		$bctab2 = '<table style="text-align:right;">
		<thead><tr><td colspan="'.($i+1).'" style="text-align:center;">'.STATS_TIT15.'<br>'.FROM2.' '.$affday1.' '.TO2.' '.$affday2.'</td></tr><tr><th></th>';
		$bctab2 .= '<th>'.PERM.'</th><th>'.SEAN.'</th>';
		$bctab2 .= '<th>'.TOTAL.'</th></tr></thead><tbody>';
		$w=0;
		foreach($tabWeeks as $weekname) {
			$bctab2 .= '<tr><td>'.$weekname.'</td>';
			$m=1;
			$bctab2 .= '<td>'.$nb_week_etude[$w].'</td><td>'.$nb_week_classe[$w].'</td><td>'.($nb_week_etude[$w]+$nb_week_classe[$w]).'</td></tr>';
			$w++;
		}	
		$bctab2 .= '</tbody></table>';
		?>
		
		<div id="wrapper" class="statcadre">
		<canvas id="chart_nbperweekperetcl" class="charts" width="600" height="300"></canvas>
		</div>
		<script type="text/javascript">
		(async function() {
		    
		    Chart.register(ChartDataLabels);
		    const labels = <?php echo json_encode($tabWeeks); ?>;
		    const data = {
		      labels: labels,
		      datasets: [ 
		        {
		            label: '<?php echo PERM;?>',
		            data: <?php echo json_encode($nb_week_etude); ?>,
		            backgroundColor: '<?php echo $basicColors[0]; ?>',
		            borderColor: '<?php echo $basicColors[0]; ?>',
		            borderWidth: 1
		        },
		        {
		            label: '<?php echo SEAN;?>',
		            data: <?php echo json_encode($nb_week_classe); ?>,
		            backgroundColor: '<?php echo $basicColors[1]; ?>',
		            borderColor: '<?php echo $basicColors[1]; ?>',
		            borderWidth: 1
		        } ]
		    };
		new Chart(
		    document.getElementById('chart_nbperweekperetcl'),
		    {
		    type: 'bar',
		    data: data,
		    options: {
		        plugins: {
		            title: {
		                display: true,
		                text: '<?php echo STATS_TIT15;?>'
		            },
		            legend: {
		    			display:false
		    		},
		            tooltip : {
		                mode: 'point',
		                intersect: false,
		              }  ,    
		            datalabels: {
		              display: true, // Affiche les étiquettes de données
		              color: '#878787', // Couleur du texte
		              align: 'center', // Alignement horizontal
		              anchor: 'center', // Alignement vertical
		              font: {
		                weight: 'bold', // Style de police
		              },
		              display: function(context) {
		                  return context.dataset.data[context.dataIndex] !== 0; // N'affiche pas si la valeur est égale à 0
		                },
		            },
		        },
		        responsive: true,
		        scales: {
		            yAxes: [{
		                ticks: {
		                    beginAtZero:true
		                }
		            }]
		        },
		      }
		    }
		);
		})();
		</script>
		
<?php 
echo '<br> <br>'.$bctab2;
$_SESSION['bctabs'] .= '<table></table>'.$bctab2;
} 
}
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>';
?>