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

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

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

	if($FAMILY!=-1)
	{
		$sReqFam="and id_family=$FAMILY";
	}
	else
	{
		$sReqFam="";
	}

	$result_ind = mysql_query( "select * from oxg_individuals where id_individual='$INDIVIDU' $sReqFam");
	$row_ind = mysql_fetch_array($result_ind);

	$result_patro = mysql_query( "select * from oxg_patronyms where id_patronym='$row_ind[id_patronym]'");
	$row_patro = mysql_fetch_array($result_patro);

	$sTitle = $row_ind['first_name']." ".$row_patro['libelle'];

	require("§menu.php");
?>
<style type="text/css">
	table.t1	{border:0px;width=100%}
	td.c1	{border-top:2px;width=3%}
	td.c1	{border-right:0px;}
	td.c1	{border-left:0px;}
	td.c1	{border-bottom:0px;}
	
	td.c2	{border-top:0px;width=3%}
	td.c2	{border-right:2px groove black;}
	td.c2	{border-left:0px solid black;}
	td.c2	{border-bottom:2px groove black;}
	
	td.c3	{border-top:0px;width=3%}
	td.c3	{border-right:0px dasshed black;}
	td.c3	{border-left:2px groove black;}
	td.c3	{border-bottom:2px groove black;}
	
	td.c4	{border-top:0px;width=3%}
	td.c4	{border-right: 1px groove black;}
	td.c4	{border-left: 0px solid black;}
	td.c4	{border-bottom: 0px groove black;}
	
	td.c5	{border-top:0px;width=3%}
	td.c5	{border-right:0px dasshed black;}
	td.c5	{border-left:1px groove black;}
	td.c5	{border-bottom:0px groove black;}
	
	td.c6	{border-top:0px;width=3%}
	td.c6	{border-right:0px;}
	td.c6	{border-left:0px;}
	td.c6	{border-bottom:2px groove black;}
</style>
<?php
//	set_time_limit(0);
	
	flush();

	$result_ind = mysql_query( "select * from oxg_individuals where id_individual='$INDIVIDU' $sReqFam");
	$row_ind = mysql_fetch_array($result_ind);
	$id_father=$row_ind['id_father'];
	$id_mother=$row_ind['id_mother'];


//présence du père
	if($id_father!=-1)
	{
		$result_par = mysql_query( "select id_father, id_mother from oxg_individuals where id_individual='$id_father' $sReqCont $sReqFam");
		if($row_par = mysql_fetch_array($result_par))
		{
			$id_gfather1=$row_par['id_father'];
			$id_gmother1=$row_par['id_mother'];
		}
	}
	else
	{
		$id_gfather1=-1;
		$id_gmother1=-1;
	}


//présence de la mère
	if($id_mother!=-1)
	{
		$result_par = mysql_query( "select id_father, id_mother from oxg_individuals where id_individual='$id_mother' $sReqCont $sReqFam");
		if($row_par = mysql_fetch_array($result_par))
		{
			$id_gfather2=$row_par['id_father'];
			$id_gmother2=$row_par['id_mother'];
		}
	}
	else
	{
		$id_gfather2=-1;
		$id_gmother2=-1;
	}


//présence grand-parents paternels
	if($id_gfather1!=-1)
	{
		$result_par = mysql_query( "select id_father, id_mother from oxg_individuals where id_individual='$id_gfather1' $sReqCont $sReqFam");
		if($row_par = mysql_fetch_array($result_par))
		{
			$id_ggfather11=$row_par['id_father'];
			$id_ggmother11=$row_par['id_mother'];
		}
	}
	else
	{
		$id_ggfather11=-1;
		$id_ggmother11=-1;
	}
	if($id_gmother1!=-1)
	{
		$result_par = mysql_query( "select id_father, id_mother from oxg_individuals where id_individual='$id_gmother1' $sReqCont $sReqFam");
		if($row_par = mysql_fetch_array($result_par))
		{
			$id_ggfather12=$row_par['id_father'];
			$id_ggmother12=$row_par['id_mother'];
		}
	}
	else
	{
		$id_ggfather12=-1;
		$id_ggmother12=-1;
	}


//présence grand-parents maternels
	if($id_gfather2!=-1)
	{
		$result_par = mysql_query( "select id_father, id_mother from oxg_individuals where id_individual='$id_gfather2' $sReqCont $sReqFam");
		if($row_par = mysql_fetch_array($result_par))
		{
			$id_ggfather21=$row_par['id_father'];
			$id_ggmother21=$row_par['id_mother'];
		}
	}
	else
	{
		$id_ggfather21=-1;
		$id_ggmother21=-1;
	}
	if($id_gmother2!=-1)
	{
		$result_par = mysql_query( "select id_father, id_mother from oxg_individuals where id_individual='$id_gmother2' $sReqCont $sReqFam");
		if($row_par = mysql_fetch_array($result_par))
		{
			$id_ggfather22=$row_par['id_father'];
			$id_ggmother22=$row_par['id_mother'];
		}
	}
	else
	{
		$id_ggfather22=-1;
		$id_ggmother22=-1;
	}


//affichage des arrières grand-parents paternels
	if($id_ggfather11!=-1)
	{
		$sGGFather11=affiche_lien_individu($FAMILY, $id_ggfather11);
		$sGGFather11.="<BR>";
		$sGGFather11.=affiche_lien_arbre($FAMILY, $id_ggfather11);
	}
	else
	{
		$sGGFather11="";
	}
	if($id_ggmother11!=-1)
	{
		$sGGMother11=affiche_lien_individu($FAMILY, $id_ggmother11);
		$sGGMother11.="<BR>";
		$sGGMother11.=affiche_lien_arbre($FAMILY, $id_ggmother11);
	}
	else
	{
		$sGGMother11="";
	}
	if($id_ggfather12!=-1)
	{
		$sGGFather12=affiche_lien_individu($FAMILY, $id_ggfather12);
		$sGGFather12.="<BR>";
		$sGGFather12.=affiche_lien_arbre($FAMILY, $id_ggfather12);
	}
	else
	{
		$sGGFather12="";
	}
	if($id_ggmother12!=-1)
	{
		$sGGMother12=affiche_lien_individu($FAMILY, $id_ggmother12);
		$sGGMother12.="<BR>";
		$sGGMother12.=affiche_lien_arbre($FAMILY, $id_ggmother12);
	}
	else
	{
		$sGGMother12="";
	}


//affichage des arrières grand-parents paternels
	if($id_ggfather21!=-1)
	{
		$sGGFather21=affiche_lien_individu($FAMILY, $id_ggfather21);
		$sGGFather21.="<BR>";
		$sGGFather21.=affiche_lien_arbre($FAMILY, $id_ggfather21);
	}
	else
	{
		$sGGFather21="";
	}
	if($id_ggmother21!=-1)
	{
		$sGGMother21=affiche_lien_individu($FAMILY, $id_ggmother21);
		$sGGMother21.="<BR>";
		$sGGMother21.=affiche_lien_arbre($FAMILY, $id_ggmother21);
	}
	else
	{
		$sGGMother21="";
	}
	if($id_ggfather22!=-1)
	{
		$sGGFather22=affiche_lien_individu($FAMILY, $id_ggfather22);
		$sGGFather22.="<BR>";
		$sGGFather22.=affiche_lien_arbre($FAMILY, $id_ggfather22);
	}
	else
	{
		$sGGFather22="";
	}
	if($id_ggmother22!=-1)
	{
		$sGGMother22=affiche_lien_individu($FAMILY, $id_ggmother22);
		$sGGMother22.="<BR>";
		$sGGMother22.=affiche_lien_arbre($FAMILY, $id_ggmother22);
	}
	else
	{
		$sGGMother22="";
	}


//affichage des grand-parents
	if($id_gfather1!=-1)
	{
		$sGFather1=affiche_lien_individu($FAMILY, $id_gfather1);
		$sGFather1.="<BR>";
		$sGFather1.=affiche_lien_arbre($FAMILY, $id_gfather1);
	}
	else
	{
		$sGFather1="";
	}
	if($id_gmother1!=-1)
	{
		$sGMother1=affiche_lien_individu($FAMILY, $id_gmother1);
		$sGMother1.="<BR>";
		$sGMother1.=affiche_lien_arbre($FAMILY, $id_gmother1);
	}
	else
	{
		$sGMother1="";
	}
	if($id_gfather2!=-1)
	{
		$sGFather2=affiche_lien_individu($FAMILY, $id_gfather2);
		$sGFather2.="<BR>";
		$sGFather2.=affiche_lien_arbre($FAMILY, $id_gfather2);
	}
	else
	{
		$sGFather2="";
	}
	if($id_gmother2!=-1)
	{
		$sGMother2=affiche_lien_individu($FAMILY, $id_gmother2);
		$sGMother2.="<BR>";
		$sGMother2.=affiche_lien_arbre($FAMILY, $id_gmother2);
	}
	else
	{
		$sGMother2="";
	}


//affichage des parents
	if($id_father!=-1)
	{
		$sFather = affiche_lien_individu($FAMILY, $id_father);
		$sFather.= "<BR>";
		$sFather.= affiche_lien_arbre($FAMILY, $id_father);
	}
	else
	{
		$sFather="";
	}
	if($id_mother!=-1)
	{
		$sMother = affiche_lien_individu($FAMILY, $id_mother);
		$sMother.= "<BR>";
		$sMother.= affiche_lien_arbre($FAMILY, $id_mother);
	}
	else
	{
		$sMother="";
	}

	echo "<table border=1 cellspacing=0>";


	if($sGGFather11!="" || $sGGFather12!="" || $sGGMother11!="" || $sGGMother12!="" || $sGGFather21!="" || $sGGFather22!="" || $sGGMother21!="" || $sGGMother22!="")
	{
			echo "<tr><td width=12% class=c1 align=center colspan=2>$sGGFather11</td><td class=c1 width=12% colspan=2 align=center>$sGGMother11</td><td width=12% class=c1 align=center colspan=2>$sGGFather12</td><td class=c1 width=12% colspan=2 align=center>$sGGMother12</td>";
			echo "<td width=12% class=c1 align=center colspan=2>$sGGFather21</td><td class=c1 width=22% colspan=2 align=center>$sGGMother21</td><td width=12% class=c1 align=center colspan=2>$sGGFather22</td><td class=c1 width=12% colspan=2 align=center>$sGGMother22</td></tr>";
			echo "<tr><td width=12% class=c1></td><td width=12% class=c3>&nbsp;</td><td width=12% class=c2>&nbsp;</td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c3>&nbsp;</td><td width=12% class=c2>&nbsp;</td><td width=12% class=c1></td>";
			echo "<td width=12% class=c1></td><td width=12% class=c3>&nbsp;</td><td width=12% class=c2>&nbsp;</td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c3>&nbsp;</td><td width=12% class=c2>&nbsp;</td><td width=12% class=c1></td></tr>";
			echo "<tr><td width=12% class=c1></td><td class=c4 width=12%>&nbsp;</td><td class=c5 width=12%>&nbsp;</td><td width=12% class=c1></td><td width=12% class=c1></td><td class=c4 width=12%>&nbsp;</td><td class=c5 width=12%>&nbsp;</td><td width=12% class=c1></td>";
			echo "<td width=12% class=c1></td><td class=c4 width=12%>&nbsp;</td><td class=c5 width=12%>&nbsp;</td><td width=12% class=c1></td><td width=12% class=c1></td><td class=c4 width=12%>&nbsp;</td><td class=c5 width=12%>&nbsp;</td><td width=12% class=c1></td></tr>";
	}
		if($sGFather1!="" || $sGFather2!="" || $sGMother1!="" || $sGMother2!="")
		{
			echo "<tr><td width=12% class=c1 align=center colspan=4>$sGFather1</td><td class=c1 width=12% colspan=4 align=center>$sGMother1</td>";
			echo "<td width=12% class=c1 align=center colspan=4>$sGFather2</td><td class=c1 width=12% colspan=4 align=center>$sGMother2</td></tr>";
			echo "<tr><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c3>&nbsp;</td><td class=c6 width=12%>&nbsp;</td><td class=c6 width=12%>&nbsp;</td><td width=12% class=c2>&nbsp;</td>";
			echo "<td width=12% class=c1></td><td width=12% class=c1><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c3>&nbsp;</td><td class=c6 width=12%>&nbsp;</td><td class=c6 width=12%>&nbsp;</td><td width=12% class=c2>&nbsp;</td></tr>";
			echo "<tr><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td class=c4 width=12%>&nbsp;</td><td class=c5 width=12%>&nbsp;</td><td width=12% class=c1></td><td width=12% class=c1></td>";
			echo "<td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td class=c4 width=12%>&nbsp;</td><td class=c5 width=12%>&nbsp;</td><td width=12% class=c1></td></tr>";
		}
		echo "<tr><td width=12% class=c1></td><td width=12% class=c1 align=center colspan=6>$sFather</td><td width=12% class=c1></td>";
		echo "<td width=12% class=c1></td><td class=c1 width=12% colspan=6 align=center>$sMother</td><td width=12% class=c1></td></tr>";
	
		echo "<tr><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c3>&nbsp;</td><td class=c6 width=12%>&nbsp;</td><td class=c6 width=12%>&nbsp;</td><td class=c6 width=12%>&nbsp;</td>";
		echo "<td class=c6 width=12%>&nbsp;</td><td class=c6 width=12%>&nbsp;</td><td class=c6 width=12%>&nbsp;</td><td width=12% class=c2>&nbsp;</td><td width=12% class=c1></td><td width=12% class=c1></td></tr>";
		echo "<tr><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td class=c4 width=12%>&nbsp;</td><td class=c5 width=12%>&nbsp;</td>";
		echo "<td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td><td width=12% class=c1></td></tr>";
	
		echo "<tr><TD width='100%' align='center' colspan=16 class=c1>";
		echo affiche_lien_individu($FAMILY, $INDIVIDU);
		echo "</TD></tr></table>";



	affiche_pied_page(true);
?>