<?php
/*
* récupération des éléments à traiter
*/
	$INDIVIDU = $_SESSION['s_individu'];
	$affichage = $_SESSION['s_affichage'];
	$gen_limit = $_SESSION['s_gen_limit'];
	$lignes_individus=$_SESSION['t_ligne_individus'];
	
	
	echo "<center><h1>".$_SESSION['s_Title']."</h1></center>";
	echo "<br>";
	echo "<div id=panel><center>";
	echo "<form action=\"\" method=get>";
	echo "<input type=hidden name=INDIVIDU value=".$INDIVIDU.">";
	echo "<input type=hidden name=FAMILY value=".$_SESSION['FAMILY'].">";
	echo "<center>";
	echo "<table border=1><tr>";
	echo "<td>".decode_lng_text('TREE_NBGEN')." ";
	echo  "<input type=text name=gen_limit value=".$gen_limit." maxlength=2 size=2></td>";
	echo "<td>".decode_lng_text('LIST_SHOW')." ";
	if ($affichage==1) {echo "<select name=affichage><option value='1'>".decode_lng_text('LIST_LIST')."</option><option value='2'>".decode_lng_text('LIST_CHAR')."</option></select></td>";}
	if ($affichage==2) {echo "<select name=affichage><option value='2'>".decode_lng_text('LIST_CHAR')."</option><option value='1'>".decode_lng_text('LIST_LIST')."</option></select></td>";}
	echo "<td><input type=submit></td>";
	echo "</tr></table></form>";
	echo "</center>";
	echo "</div>";

		echo "<br>";
		echo "<H3>";
		echo decode_lng_text('LIST_ASC_TITLE');
		echo "</H3>";
		
	if ($affichage==1) {
		echo "<br><b>".decode_lng_text('LIST_GEN')." 1</b><br>";
		echo $this->Outils->affiche_lien_individu($INDIVIDU,true,true)."<br>";
	}
	if ($affichage==2) {
		echo "<br><b>".decode_lng_text('LIST_GEN')." 1</b><br>";
		echo "<table border=1>";
		echo "<td><b>".decode_lng_text('GEDTAG_NAME')."</b></td></td><td><b>".decode_lng_text('LIST_BIRTH_DATE')."</b></td><td><b>".decode_lng_text('LIST_DEATH_DATE')."</b></td><td><b>".decode_lng_text('LIST_PARENT')."</b></td></tr>";
		echo "<td>".$this->Outils->affiche_ligne_individu($INDIVIDU)."</td></tr>";
	}


	$all_count=1;
	$new_tab = Array();
	$new_tab[] = $INDIVIDU;
	$G=1;
	$generation='';

	foreach ($lignes_individus as $row) {
		//var_dump($row);
		//for ($L=2; $L<$gen_limit+1; $L++) {
		if ($row['generation'] != $generation) {
			$generation=$row['generation'];
			$new_gen = 0;
		}

		$father=$row['id_father'];
		$mother=$row['id_mother'];
		
		if ($affichage==1) {
			if($new_gen==0 and ($father!="-1" or $mother!="-1")) {echo "<br><b>".decode_lng_text('LIST_GEN')." ". $generation."</b><br>";$new_gen=1;$G++; }
					
			if($father!="-1" and $father!="")
				{
				echo $row['nom_pere']."<i> ".decode_lng_text('LIST_FATHER')." ".$row['relation_pere']."</i><br>";
				$all_count= $all_count +1;
				}
			if($mother!="-1" and $mother!="")
				{
				echo $row['nom_mere']."<I> ".decode_lng_text('LIST_MOTHER')." ".$row['relation_mere']."</i><br>";
				$all_count= $all_count +1;
				}
				
		}
		if ($affichage==2) {
			if($new_gen==0 and ($father!="-1" or $mother!="-1")) {
					echo "</table> <br><b>".decode_lng_text('LIST_GEN')." ". $generation."</b><br>";
					echo "<table border=1><tr><center><td><b>".decode_lng_text('GEDTAG_NAME')."</td><td><b>".decode_lng_text('LIST_BIRTH_DATE')."</b></td><td><b>".decode_lng_text('LIST_DEATH_DATE')."</b></td><td><b>".decode_lng_text('LIST_PARENT')."</b></center></td></tr>";
					$new_gen=1;$G++; 
				}
				
			if($father!="-1" and $father!="") {
				
				echo "<td>".$row['nom_pere']."<i><td> ".decode_lng_text('LIST_FATHER')." ".$row['relation_pere']."</i></td></tr>";
				$all_count= $all_count +1;
				}
			if($mother!="-1" and $mother!="") {
				echo "<td>".$row['nom_mere']."<i><td> ".decode_lng_text('LIST_MOTHER')." ".$row['relation_mere']."</i></td></tr>";
				$all_count= $all_count +1;
				}
		}
	}

	if ($affichage==2) {echo "</table>";}

	echo "<br>";
	echo "<br>";
	$max=1;
	for ($i=1; $i<=$G; $L++)
		{$max=$max*2;$i=$i+1;}
	$max=$max-1;
	echo decode_lng_text('LIST_TOTAL')." $all_count ".decode_lng_text('LIST_PEOPLE')." / $G ".decode_lng_text('LIST_GEN')." (max=$max)";
				
			
	echo "<br /> <br />";

	

?>