<?php
	$sPage  = "dates";
	require("admin/§lib_inc.php");

	$FAMILY=isset($_REQUEST["FAMILY"])?$_REQUEST["FAMILY"] : -1; 
	$sTitle = decode_lng_text("IDX_DATES_TITLE");
	require("§menu.php");

	require("§progress_bar.php");

/*	if($bSessionOk==false)
	{
		$sReqCont="and contemporary=1";
	}
	else*/
	{
		$sReqCont="";
	}
	if($FAMILY!=-1)
	{
		$sReqFam="and id_family=$FAMILY";
	}
	else
	{
		$sReqFam="";
	}

//	set_time_limit(0);
	
	flush();
	

	$sReq="select min(left(devnt,4)) ANNEE from oxg_events2 where devnt<>'' $sReqFam";
	$result = mysql_query( $sReq );
	$row = mysql_fetch_array($result);
	$anneee_min=$row['ANNEE'];

	$sReq="select max(left(devnt,4)) ANNEE from oxg_events2 where devnt<>'' and left(devnt,4)<'9999' $sReqFam";
	$result = mysql_query( $sReq );
	$row = mysql_fetch_array($result);
	$anneee_max=$row['ANNEE'];
	$anneee_max+=1;

	$nb_dates=($anneee_max-$anneee_min)/(($anneee_max-$anneee_min)/10);

	echo "<table align=center cellspacing=0>";

	$tbAnneeCnt=array();
	$iMaxCnt=0;
	for($iAnnee=$anneee_min;$iAnnee<$anneee_max;$iAnnee+=$nb_dates)
	{
		$iAnneeFin=$iAnnee+$nb_dates;
		$sReq="select COUNT(*) as somme from oxg_events2 where devnt<>'' $sReqFam and left(devnt,4)>='$iAnnee' and left(devnt,4)<'$iAnneeFin'";
		$result = mysql_query( $sReq );
		$row = mysql_fetch_array($result);
		$tbAnneeCnt[]=$row['somme'];
		if($row['somme']>$iMaxCnt)
		{
			$iMaxCnt=$row['somme'];
		}
	}
	$iCptLig=0;
	for($iAnnee=$anneee_min;$iAnnee<$anneee_max;$iAnnee+=$nb_dates)
	{
		$iAnneeFin=$iAnnee+$nb_dates-1;
		$iSomme=$tbAnneeCnt[$iCptLig++];
		$iAnneeDep=ceil($iAnnee);
		$iAnneeFin=ceil($iAnneeFin);
		echo "<tr><td>";
		echo "<a href='§detail_date.php?FAMILY=$FAMILY&DATE_BEG=$iAnneeDep&DATE_END=$iAnneeFin'>$iAnneeDep</a>";
		echo "</td><td>";
		echo $iAnneeFin;
		echo "</td><td>";
		echo "$iSomme";
		echo "</td><td>";
		if($iSomme>0)
		{
			$iTaille=(($iSomme/$iMaxCnt)*1000);
			echo "<img src='blue.png' width=$iTaille height=10>";
		}
		echo "</td></tr>";
	}
	echo "</table>";
	affiche_pied_page(true);
?>

<html>
<script type="text/javascript">
document.getElementById('progress_bar').style.display="none"
</script>
</html>

