<?php
	
	echo "<center><h1>".decode_lng_text("SOSA_TITLE")."</h1></center>";
	echo "<br>".decode_lng_text('SOSA_MAIN')."<br>";

	$max=0;
	$OldGene=0;
	$generation=0;
	$nb_res_max = count($_SESSION['t_individus']);

//		echo "<p style='color:#cc0000'><b><i><color=red>". $nb_res_max.' '.display_lng_text("SEARCH_FOUND_RESULTS")."</i></b></p><br/>";
		//on teste le parametre de limite
		if (!isset($this->request->params[0]) ) { $page = 1; }
		else { $page= $this->request->params[0];}
		
		if (empty($nb_res_par_page)) { $nb_res_par_page = 35; }
		$reload = 'familles/liste_asc/';

		echo '<div class="pagination"><ul>';
		
// mise en place de la pagination		
		$total_pages = ceil($nb_res_max/$nb_res_par_page);
        $i_deb = ($page - 1) * $nb_res_par_page;
		$i_fin = $i_deb + $nb_res_par_page;
		if ($i_fin > $nb_res_max) {
			$i_fin = $nb_res_max;
		}
  
		
		if ($total_pages > 1) {
			echo Pagination($reload, $page, $total_pages);
		}
		
		echo "</ul></div><br/>";
		
//		list($i_deb, $i_fin) = Pagination($nb_res_par_page,$nb_aff_pag,$nb_res_max,$lien,$page)	;

	
		echo "<table>";
		$j=1;
		$row_out=array();
		
	//	var_dump($_SESSION['t_individus']);
// var_dump($this->request->params);
// echo 'deb '.$i_deb. ' fin '.$i_fin;

		for($i=$i_deb;$i<$i_fin;$i++) {
			$row_out=$_SESSION['t_individus'][$i];

	

		//foreach($_SESSION['t_individus'] as $k => $row) {
			$temp=$row_out['sosa'];
			if($max<=$temp) {
				$generation=1;
				while($temp>1) 	{
					$temp = $temp - ($temp%2);
					$generation++;
					$temp = $temp/2;
				}
				$max = pow(2,$generation);
				echo "<br>";
				echo "<b><i>";
				echo display_lng_text('SOSA_GENERATION');
				echo " ".$generation."</b></i> :<br>";
				echo "<b><i>________________</b></i><br>";
				echo "<br>";
			}
			// Build your formatted results here.

			if ($_SESSION['b_connecte']==false and $row_out['contemporary']==0)
				{
				echo $row_out['sosa'].'&nbsp;';
				echo decode_lng_text('PRIVATE_MSG');
				}
			else {
				echo "<a href=".Router::url('individus/detail_individu/'.$row_out['id_individual']).">".$row_out['sosa']."</a>&nbsp;";
				echo $row_out['first_name']."&nbsp;".$row_out['libelle'];
				if($row_out['date_naissance']<>"")
					{
					echo " ";
					if($row_out['sex']==1)
						{
						echo display_lng_text('SOSA_BIRTH_F');
						}
					else
						{
						echo display_lng_text('SOSA_BIRTH_M');
						}
					echo " <b>".$row_out['date_naissance']."</b>";
					}
				if($row_out['date_deces']<>"")
					{
					echo " ";
					if($row_out['sex']==1)
						{
						echo display_lng_text('SOSA_DEATH_F');
						}
					else {
						echo display_lng_text('SOSA_DEATH_M');
						}
					echo " <b>".$row_out['date_deces']."</b>";
					}
			}

			echo "<br>";
		}
		
		
	echo "</table>";

?>