<?php

	$sPage  = "patro2";
	require("admin/§lib_inc.php");
	require("§lib_patro.php");

	$FAMILY=isset($_REQUEST["FAMILY"])?$_REQUEST["FAMILY"] : -1; 

	$sTitle = decode_lng_text("PATRO_TITLE");
	require("§menu.php");
	require("§progress_bar.php");

	if($bSessionOk==false)
	{
		$sReqCont="and contemporary=1";
	}
	else
	{
		$sReqCont="";
	}

//	set_time_limit(0);
	
	flush();


	if($FAMILY==-1)
	{
		$query = "select COUNT(*) as SOMME from oxg_patronyms, oxg_individuals where oxg_patronyms.id_patronym=oxg_individuals.id_patronym $sReqCont and (upper(left(oxg_patronyms.libelle_ord,1))<'A' or upper(left(oxg_patronyms.libelle_ord,1))>'Z' or oxg_patronyms.libelle_ord='')";
	}
	else
	{
		$query = "select COUNT(*) as SOMME from oxg_patronyms, oxg_individuals where oxg_patronyms.id_patronym=oxg_individuals.id_patronym $sReqCont and (upper(left(oxg_patronyms.libelle_ord,1))<'A' or upper(left(oxg_patronyms.libelle_ord,1))>'Z' or oxg_patronyms.libelle_ord='') and id_family=$FAMILY";
	}
	$result = mysql_query($query);
	if($row = mysql_fetch_array($result))
	{
		$rest = $row['SOMME'];
	}

	if($rest!=0)
	{
		affiche_liste_patro("AUTRES", $FAMILY, $rest);
	}
	
	if($FAMILY==-1)
	{
		$query = "SELECT upper(left(oxg_patronyms.libelle_ord,1)) as INITIALE, COUNT(*) as SOMME from oxg_patronyms, oxg_individuals where oxg_patronyms.id_patronym=oxg_individuals.id_patronym $sReqCont and upper(left(oxg_patronyms.libelle_ord,1))>='A' and upper(left(oxg_patronyms.libelle_ord,1))<='Z' GROUP BY INITIALE";
	}
	else
	{
		$query = "SELECT upper(left(oxg_patronyms.libelle_ord,1)) as INITIALE, COUNT(*) as SOMME from oxg_patronyms, oxg_individuals where oxg_patronyms.id_patronym=oxg_individuals.id_patronym $sReqCont and upper(left(oxg_patronyms.libelle_ord,1))>='A' and upper(left(oxg_patronyms.libelle_ord,1))<='Z' and id_family=$FAMILY GROUP BY INITIALE";
	}
	$result = mysql_query($query);
	while($row = mysql_fetch_array($result))
	{
		affiche_liste_patro($row['INITIALE'], $FAMILY, $row['SOMME']);
	}
	affiche_pied_page(true);
?>

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