<?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'];
//var_dump($_SESSION['t_ligne_individus']);
	
	echo "<center><h1>".$_SESSION['s_Title']."</h1></center>";
	echo "<br>";	
	echo "<div id=panel>";
	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')."_1</OPTION><OPTION value='2'>".decode_lng_text('LIST_LIST')."_2</OPTION><OPTION value='3'>".decode_lng_text('LIST_CHAR')."</OPTION></select></td>";}
	if ($affichage==2) {echo "<select name=affichage><OPTION value='2'>".decode_lng_text('LIST_LIST')."_2</OPTION><OPTION value='1'>".decode_lng_text('LIST_LIST')."_1</OPTION><OPTION value='3'>".decode_lng_text('LIST_CHAR')."</OPTION></select></td>";}
	if ($affichage==3) {echo "<select name=affichage><OPTION value='3'>".decode_lng_text('LIST_CHAR')."</OPTION><OPTION value='1'>".decode_lng_text('LIST_LIST')."_1</OPTION><OPTION value='2'>".decode_lng_text('LIST_LIST')."_2</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_DESC_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 $this->Outils->affiche_lien_individu($INDIVIDU,true,true);
	}	
	if ($affichage==3) {
		echo "<br><b>".decode_lng_text('LIST_GEN')." 1</b><br>";
		echo "<table border=1>";
		echo "<tr><td><b></td><td align='center'><b>".decode_lng_text('GEDTAG_NAME')."</b></td><td align='center'><b>".decode_lng_text('LIST_BIRTH_DATE')."</b></td><td align='center'><b>".decode_lng_text('LIST_DEATH_DATE')."</b></td><td align='center'><b>".decode_lng_text('LIST_PARENT')."</b></td></tr>";
		echo "<td><b></td><td>".$this->Outils->affiche_ligne_individu($INDIVIDU)."</td></tr>";
	
	
		// echo "<br><b>".decode_lng_text('LIST_GEN')." 1</b><br>";
		// echo "<table border=1>";
		// echo "<tr><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 "".$this->Outils->affiche_ligne_individu($INDIVIDU)."</td></tr>";
	}

	$generation='';
	$parent='';
	$id_conjoint='';
	$old_conjoint='';

	
	foreach ($lignes_individus as $k=>$row) {

		if ($row['generation'] != $generation) {
			$generation=$row['generation'];
			$new_gen = 1;
		}
		if ($row['sex']==1) {
			$article=" ".decode_lng_text('LIST_DAU')." ";
			$flag=IMAGES."female.png";
		} 
		elseif ($row['sex']==0) {
			$article=" ".decode_lng_text('LIST_SON')." ";
			$flag=IMAGES."male.png";
		} 
		else {
			$article=" ".decode_lng_text('LIST_SON')." ";
			$flag="";
		}

		switch($affichage) {
			case 1:
				if ($new_gen==1) {echo "<BR><B>".decode_lng_text('LIST_GEN'). " ".$generation."</b><br>";$new_gen=0;}
				echo "<img src=".$flag.">".$row['nom_individu']."<i>".$article.$row['nom_pere']." ".decode_lng_text('GEDTAG_AND')." ".$row['nom_mere']."</i><br>";			
				break;
				
			case 2:
				if ($k==0) { echo "<i> ".decode_lng_text('DETAIL_IND_WITH')." ".$row['nom_mere']."</i><br>";}
				if ($row['nom_conjoint']!='') {
					echo indentation($row['generation']).$row['affiche']." --> <img src=".$flag."> ".$row['nom_individu']."<i> ".decode_lng_text("DETAIL_IND_WITH")." ".$row['nom_conjoint']."</i><br/>";
				}
				else {
					echo indentation($row['generation']).$row['affiche']." --> <img src=".$flag."> ".$row['nom_individu']." <br/>";
				}
			break;
			
			case 3:
			if ($new_gen==1) { 
				echo "</table> <br><b>".decode_lng_text('LIST_GEN')." ". $generation."</b><br>";
				echo "<table border=1><tr><td><b></td><td align='center'><b>".decode_lng_text('GEDTAG_NAME')."</b></td><td align='center'><b>".decode_lng_text('LIST_BIRTH_DATE')."</b></td align='center'><td align='center'><b>".decode_lng_text('LIST_DEATH_DATE')."</b></td><td align='center'><b>".decode_lng_text('LIST_PARENT')."</b></td></tr>";
				$new_gen=0;
			}

			echo "<tr><td align=right>".$row['affiche']."</td><td><img src=".$flag."> ".$row['nom_individu']."</td><td>".$article.$row['nom_pere']." ".decode_lng_text('GEDTAG_AND')." ".$row['nom_mere']."</td></tr>";
		

			break;
			
		}
		
	}
			



	if ($affichage==3) {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 />";


?>