<?php

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

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

	$sTitle = decode_lng_text("DETAIL_PATRO_LIST");

	$result = mysql_query( "select * from oxg_patronyms where id_patronym='$PATRO'");
	$row = mysql_fetch_array($result);
	if($row['libelle']=='')
	{
		$sTitle .= " ?";
	}
	else
	{
		$sTitle .= " ";
		$sTitle .= $row['libelle'];
	}
	
	require("§menu.php");

	//set_time_limit(0);
	
	flush();

	if($bSessionOk==false)
	{
		$sReqCont="and contemporary=1";
	}
	else
	{
		$sReqCont="";
	}
	$sId_Event_Type_GIVN=get_id_event_type("GIVN");	// 99
	$sId_Event_Type_NICK=get_id_event_type("NICK");	// 123
	$sql_query="select id_family, id_individual, sex, event_nickname.libelle, first_name, date_naissance, date_deces, sosa ";
	$sql_query.="from oxg_individuals left join (select oxg_events_givn.id_individu, oxg_events_nick.libelle from oxg_events2 oxg_events_givn, oxg_events oxg_events_nick where oxg_events_givn.type=$sId_Event_Type_GIVN and oxg_events_nick.type_father=1 and oxg_events_nick.type=$sId_Event_Type_NICK and oxg_events_nick.id_father=oxg_events_givn.id_event ";
	if($FAMILY!=-1)
	{
		$sql_query .= " and oxg_events_givn.id_family=$FAMILY ";
		$sql_query .= " and oxg_events_nick.id_family=$FAMILY ";
	}
	$sql_query.=") event_nickname ";
	$sql_query.="on (oxg_individuals.id_individual=event_nickname.id_individu) ";
	$sql_query.="where id_patronym=$PATRO ";
	if($FAMILY!=-1)
	{
		$sql_query .= " and id_family=$FAMILY ";
	}
	$sql_query.=$sReqCont." order by first_name";
	$result=mysql_query($sql_query) or mysql_die();
	while($row = mysql_fetch_array($result))
	{
		if ($row['sex']==1) { $flag="female.png"; }
		if ($row['sex']==0) { $flag="male.png"; }
		echo "  <IMG SRC=$flag> ";
		echo "<A HREF='detail_individu.php?INDIVIDU=".$row['id_individual']."&FAMILY=".$row['id_family']."'>";
		if($row['first_name']=="")
		{
			echo "?";
		}
		else
		{
			echo $row['first_name'];
		}
		if($bSosa==true && $row['sosa']!='-1')
		{
			echo " <strong><font color=red>$row[sosa]</font></strong>";
		}
		if($row['libelle']!="")
		{
			if($row['sex']==1)	// Female
			{
				echo " dite ";
			}
			else
			{
				echo " dit ";
			}
			echo $row['libelle'];
		}
		echo "</A>";
		if($row['date_naissance']!="" || $row['date_deces']!="")
		{
			echo " (";
			if($row['date_naissance']!="")
			{
				echo decode_date_eng("$row[date_naissance]");
			}
			else
			{
				echo "?";
			}
			if($row['date_deces']!="")
			{
				echo " - ";
				echo decode_date_eng("$row[date_deces]");
			}
			echo ")";
		}
		echo "<BR>";
	}
	affiche_pied_page(true);
?>
