<?php


	//$phase = isset($this->request->params[0]) ? 1 : 0;
	$page = isset($this->request->params[0])?$this->request->params[0] : 1; 
	if ($page== 'S') {$page=1;}

	echo "<center><h1>".decode_lng_text("BIRTHDAY_TITLE")."</h1></center></br>";


		$sexe = $this->request->data->sexe;
		$choice = $this->request->data->choice;
		if ($choice=="") {$choice="all";}
		$period = $this->request->data->period;
		if ($period=="") {$period="all";}
	

	echo "<form action=".Router::url('statistiques/birthday/S')." method='post'>";

	echo "<center>";
	echo "<table border=1 >";
	echo "</td></tr>";

	echo "<tr><td ><strong>".decode_lng_text("INDEX_EVENT")."</strong> &nbsp;&nbsp;";

	if ($choice=='birth') {$check='checked';} else {$check='';}
	echo "<input type='radio' name='choice' value='birth' ".$check.">&nbsp;".decode_lng_text("GEDTAG_BIRT")."&nbsp;&nbsp;&nbsp;";
	if ($choice=='wedding') {$check='checked';} else {$check='';}
	echo "<input type='radio' name='choice' value='wedding' ".$check.">&nbsp;".decode_lng_text("GEDTAG_MARR")."&nbsp;&nbsp;&nbsp;";
	if ($choice=='death') {$check='checked';} else {$check='';}
	echo "<input type='radio' name='choice' value='death' ".$check.">&nbsp;".decode_lng_text("GEDTAG_DEAT")."&nbsp;&nbsp;&nbsp;";
	if ($choice=='other') {$check='checked';} else {$check='';}
	echo "<input type='radio' name='choice' value='other' ".$check.">&nbsp;".decode_lng_text("PATRO_OTHER")."&nbsp;&nbsp;&nbsp;";
	if ($choice=='all') {$check='checked';} else {$check='';}
	echo "<input type='radio' name='choice' value='all' ".$check.">&nbsp;".decode_lng_text("IDX_LIEUX_ALL")."&nbsp;&nbsp;";
	echo "</td>";
	echo "<td><strong>".display_lng_text("SEARCH_SEXE")."</strong> &nbsp;";
	echo "<select name=sexe>";
	echo "<option value=>".display_lng_text("SEARCH_SEXE_NO");
	echo "</option>";
	echo "<option ";
	if ($sexe=="M") { echo "selected "; }
	echo "value='M'>".display_lng_text("SEARCH_SEXE_MALE");
	echo "</option>";
	echo "<option ";
	if ($sexe=="F") { echo "selected "; }
	echo "value='F'>".display_lng_text("SEARCH_SEXE_FEMALE");
	echo "</option>";
	echo "</select></td></tr>";
	
	echo "<tr><td ><center><strong>".decode_lng_text("BIRTHDAY_WHEN")."</strong> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

	if ($period=='today') {$check='checked';} else {$check='';}
	echo "<input type='radio' name='period' value='today' ".$check.">&nbsp;".decode_lng_text("BIRTHDAY_TODAY")."&nbsp;&nbsp;&nbsp;";
	if ($period=='tomorrow') {$check='checked';} else {$check='';}
	echo "<input type='radio' name='period' value='tomorrow' ".$check.">&nbsp;".decode_lng_text("BIRTHDAY_TOMOROW")."&nbsp;&nbsp;&nbsp;";
	if ($period=='week') {$check='checked';} else {$check='';}
	echo "<input type='radio' name='period' value='week' ".$check.">&nbsp;".decode_lng_text("BIRTHDAY_WEEK")."&nbsp;&nbsp;&nbsp;";
	if ($period=='month') {$check='checked';} else {$check='';}
	echo "<input type='radio' name='period' value='month' ".$check.">&nbsp;".decode_lng_text("BIRTHDAY_MONTH")."&nbsp;&nbsp;&nbsp;";

	echo "</center></td></tr></table></br>";
	
	echo "<center><input type=submit value=".decode_lng_text('PRIVATE_ENTER')." onClick='AttenteVisibility();'></center>";
	echo "</form></br>";
	
//var_dump($_SESSION['t_results_out']);
	
/*
*     Affichage du résultat
*/



	echo "<div> <img src='".IMAGES."ligne_orange.png' width=100% height='2px'></div>";
	echo "<div id='recherches_resultats' style='visibility:display'>";
	echo "<table>";
	$nb_res_max = count($_SESSION['t_results_out']);
	if ($nb_res_max==0) 	{
		echo decode_lng_text("BIRTHDAY_NONE");
	}
	else {
		
		echo "<p style='color:#cc0000'><b><i><color=red>". $nb_res_max.' '.display_lng_text("SEARCH_FOUND_RESULTS")."</i></b></p>";
		//on test le parametre de limite
		//if (empty($page)) { $page=0; }
		
		if (empty($nb_res_par_page)) { $nb_res_par_page = 30; }
		
		$total_pages = ceil($nb_res_max/$nb_res_par_page);
	// mise en place de la pagination
		if ($total_pages>1) {
			echo '<div class="pagination"><ul>';
			$reload = 'Statistiques/birthday/';
			
			$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;
			}
		
			echo Pagination($reload, $page, $total_pages);

			
			echo "</ul></div><br/>";
		} // fin du div de pagination
		
		echo "<table>";
		$j=1;
		$row_out=array();

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


			// Affichage de la personne

			echo "<tr><th align=right>".decode_date($row_out['date'])."</th>";
			echo "<td>".$row_out['acte']." </th>";
			echo $row_out['nom_indiv'];

			//affichage du conjoint
				if($row_out['nom_compagne'] != '') {
					echo " ".decode_lng_text("GEDTAG_AND")." ".$row_out['nom_compagne'];

				}
			}
		
	echo "</table>";
	
		echo "</br><div> <img src='".IMAGES."ligne_orange.png' width=100% height='2px'></div>";
		
	} // fin de l'affichage des résultats	
	
	echo "</div>";
