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

	$FAMILY=isset($_REQUEST["FAMILY"])?$_REQUEST["FAMILY"] : -1; 
	$event=isset($_REQUEST["event"])?$_REQUEST["event"] : "all"; 
	$sTitle = decode_lng_text("IDX_LIEUX_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();

	echo "<div id=panel><center><table>";
	echo "<TD>".decode_lng_text('STATS_TOP15_DATE_C')." :</TD>";
	if ($event=="")
	{
		$event="all";
	}

	if ($event=="birth")
	{
		echo "<TD><B>".decode_lng_text('GEDTAG_BIRT')."</B></TD>";
		//$ReqEvent=",oxg_individuals where oxg_countries.id_country=oxg_individuals.id_pays_naissance and id_country<>'999999' $sReqCont $sReqFam";
		$ReqEvent=",oxg_events2 where oxg_countries.id_country=oxg_events2.id_country and oxg_events2.id_country<>'' and oxg_events2.id_country<>'999999' and oxg_events2.type='51' $sReqFam";
	}
	else
	{
		echo "<TD><A HREF='§idx_lieux.php?FAMILY=$FAMILY&event=birth'>".decode_lng_text('GEDTAG_BIRT')."</A></TD>";
	}

	if ($event=="wedding")
	{
		echo "<TD><B>".decode_lng_text('GEDTAG_MARR')."</B></TD>";
		//$ReqEvent=",oxg_individuals where oxg_countries.id_country=oxg_individuals.id_pays_deces and id_country<>'999999' $sReqCont $sReqFam";
		$ReqEvent=",oxg_events2 where oxg_countries.id_country=oxg_events2.id_country and oxg_events2.id_country<>'' and oxg_events2.id_country<>'999999' and oxg_events2.type='115' $sReqFam";
	}
	else
	{
		echo "<TD><A HREF='§idx_lieux.php?FAMILY=$FAMILY&event=wedding'>".decode_lng_text('GEDTAG_MARR')."</A></TD>";
	}
	
	if ($event=="death")
	{
		echo "<TD><B>".decode_lng_text('GEDTAG_DEAT')."</B></TD>";
		//$ReqEvent=",oxg_individuals where oxg_countries.id_country=oxg_individuals.id_pays_deces and id_country<>'999999' $sReqCont $sReqFam";
		$ReqEvent=",oxg_events2 where oxg_countries.id_country=oxg_events2.id_country and oxg_events2.id_country<>'' and oxg_events2.id_country<>'999999' and oxg_events2.type='77' $sReqFam";
	}
	else
	{
		echo "<TD><A HREF='§idx_lieux.php?FAMILY=$FAMILY&event=death'>".decode_lng_text('GEDTAG_DEAT')."</A></TD>";
	}
	
	if ($event=="other")
	{
		echo "<TD><B>".decode_lng_text('PATRO_OTHER')."</B></TD>";
		//$ReqEvent=",oxg_individuals where oxg_countries.id_country=oxg_individuals.id_pays_deces and id_country<>'999999' $sReqCont $sReqFam";
		$sRexclusion = "and oxg_events2.type<>'45' and oxg_events2.type<>'99' and oxg_events2.type<>'125' and oxg_events2.type<>'129' and oxg_events2.type<>'148' and oxg_events2.type<>'156' and oxg_events2.type<>'163' and oxg_events2.type<>'167' and oxg_events2.type<>'179'";
		$sReqFiltre = " and oxg_events2.type<>'51' and oxg_events2.type<>'77' and oxg_events2.type<>'115' ".$sRexclusion;
		$ReqEvent=",oxg_events2 where oxg_countries.id_country=oxg_events2.id_country and oxg_events2.id_country<>'' and oxg_events2.id_country<>'999999' $sReqFiltre $sReqFam";
		
	}
	else
	{
		echo "<TD><A HREF='§idx_lieux.php?FAMILY=$FAMILY&event=other'>".decode_lng_text('PATRO_OTHER')."</A></TD>";
	}

	if ($event=="all")
	{
		echo "<TD><B>".decode_lng_text('IDX_LIEUX_ALL')."</B></TD>";
		$sRexclusion = "and oxg_events2.type<>'45' and oxg_events2.type<>'99' and oxg_events2.type<>'125' and oxg_events2.type<>'129' and oxg_events2.type<>'148' and oxg_events2.type<>'156' and oxg_events2.type<>'163' and oxg_events2.type<>'167' and oxg_events2.type<>'179'";
		$ReqEvent=",oxg_events2 where oxg_events2.id_country=oxg_countries.id_country $sRexclusion $sReqFam";
	}
	else
	{
		echo "<TD><A HREF='§idx_lieux.php?FAMILY=$FAMILY&event=all'>".decode_lng_text('IDX_LIEUX_ALL')."</A></TD>";
	}

	echo "</table></center></div><BR>";

	$sql_query="select oxg_countries.id_country, oxg_countries.libelle, COUNT(*) as somme from oxg_countries $ReqEvent group by oxg_countries.id_country order by oxg_countries.libelle";
	$result = mysql_query( $sql_query ) or mysql_die();
	while($row = mysql_fetch_array($result))
	{
		echo "<P><A HREF='§detail_zone.php?PAYS=$row[id_country]&FAMILY=$FAMILY&event=$event'>";
		echo "$row[libelle]</A> ($row[somme])";

		$result_carte = mysql_query( "select * from oxg_zones where oxg_zones.id_country='$row[id_country]' and oxg_zones.pos_remp_x<>''");
		if($row_carte = mysql_fetch_array($result_carte))
		{
			echo " <A HREF='§carte.php?PAYS=$row[id_country]&FAMILY=$FAMILY'>";
			display_lng_text("IDX_LIEUX_MAP");
			echo "</A>";
		}
		echo "<BR>";
	}
	affiche_pied_page(true);
?>

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