<?php

	$sPage  = "places_ind";
	require("admin/§lib_inc.php");
	require("admin/§lib_inc2.php");

	$nb_msg_par_page = @$_GET['nb_msg_par_page'];
	$FAMILY=isset($_REQUEST["FAMILY"])?$_REQUEST["FAMILY"] : -1; 
	$type=isset($_REQUEST["type"])?$_REQUEST["type"] : "place"; 
	$limite=isset($_REQUEST["limite"])?$_REQUEST["limite"] : 0; 

	$sTitle = decode_lng_text("FLASH_TITLE");
	require("§menu.php");
	require("§progress_bar.php");

	if($FAMILY!=-1)
	{
		$sReqFam=" and id_family=$FAMILY ";
	}
	else
	{
		$sReqFam="";
	}
	
// on determine le nombre de resultats vus par page
if (empty($nb_res_par_page))
	$nb_res_par_page = '100';
$limite_param=$limite;
$limite=intval($limite*$nb_res_par_page);

// on definit le nobmre de page avant les fleches << 1 2 3 >>
// mettre un chiffre pair
$nb_aff_page=9;

	//set_time_limit(0);
	
	flush();


	echo "<div id=panel><center><table>";
	echo "<TD>".decode_lng_text('FLASH_ORDER')." :</TD>";

	if ($type=="") {$type="place";}

	if ($type=="place")
	{
		echo "<TD><B>".decode_lng_text('FLASH_PLACE')."</B></TD>";
		$sortby = "pays, ville, name";
		$table = "<TD><B>".decode_lng_text('GEDTAG_CTRY')."</B></TD>";
		$table.= "<TD><B>".decode_lng_text('GEDTAG_CITY')."</B></TD>";
		$table.= "<TD><B>".decode_lng_text('GEDTAG_NAME')."</B></TD>";
	}
	else
	{
		echo "<TD><A HREF='§flashlist.php?FAMILY=$FAMILY&type=place'>".decode_lng_text('FLASH_PLACE')."</A></TD>";
	}

	if ($type=="name")
	{
		echo "<TD><B>".decode_lng_text('FLASH_NAME')."</B></TD>";
		$sortby = "name, pays, ville";
		$table = "<TD><B>".decode_lng_text('GEDTAG_NAME')."</B></TD>";
		$table.= "<TD><B>".decode_lng_text('GEDTAG_CTRY')."</B></TD>";
		$table.= "<TD><B>".decode_lng_text('GEDTAG_CITY')."</B></TD>";
	}
	else
	{
		echo "<TD><A HREF='§flashlist.php?FAMILY=$FAMILY&type=name'>".decode_lng_text('FLASH_NAME')."</A></TD>";
	}
		$table.= "<TD><B><center>".decode_lng_text('GEDTAG_BIRT')."</center></B></TD>";
		$table.= "<TD><B><center>".decode_lng_text('GEDTAG_MARR')."</center></B></TD>";
		$table.= "<TD><B><center>".decode_lng_text('GEDTAG_DEAT')."</center></B></TD>";
		$table.= "<TD><B><center>".decode_lng_text('PATRO_OTHER')."</center></B></TD>";
		$table.= "<TD><B>Min</B></TD>";
		$table.= "<TD><B>Max</B></TD><TR>";
	echo "</table>";
	echo "</div>";
	echo "<BR>";

	// on recupere la page + les parametres
	$lien = $_SERVER['REQUEST_URI'];
	// on retire le parametre limit
	$pos = strpos($lien,'&limite=');
	if ($pos > 0)
	{
		$lien = substr($lien,0,$pos);
	}
		
	$req_select = "select * from oxg_flashlist where 1=1 $sReqFam order by $sortby";
	$result2 = mysql_query($req_select);
	$nb_res_max = mysql_num_rows($result2);
	// on test si on affiche la limite de resulats
	if ($limite_param!=-1) { $req_select = $req_select." LIMIT $limite, $nb_res_par_page"; }
	
	//affichage du tableau final selon choix
	echo "<center><table border=1>";
	echo $table;
	//requete avec tri selon choix lieux ou nom
	$result = mysql_query($req_select);
	$nb_res = mysql_num_rows($result);
	if ($nb_res>0)
		{
		$limiteplus = intval($limite+$nb_res_par_page);
		if ($limiteplus>$nb_res_max)
			$limiteplus=$nb_res_max;
		$limitemoins = $limite+1;
		//echo "<hr>\n<b> $nb_res_max ";
		//display_lng_text("SEARCH_FOUND_RESULTS");
		//echo "  !</b> \n";
		if (($limite_param!=-1) && ($nb_res_max>$nb_res_par_page))
		{
			// lien pour ne pas mettre de limites de résultats
			echo "<a href=\"$lien&limite=-1\">";
			display_lng_text("SEARCH_NO_LIMITS");
			echo "</a><br>";
			
			//display_lng_text("SEARCH_RESULTS_NUMBERS");
			//echo " $limitemoins => $limiteplus<br>\n";
			display_lng_text("SEARCH_PAGE_NEXT");
			aff_numeros_pages($nb_res_par_page,$nb_aff_page,$nb_res_max,$lien,$limite_param);
			echo "<br>\n";
		}
	
	}
	else	
		{
		echo "<br>\n";
		display_lng_text("SEARCH_NO_RESULTS");
		echo "<br>\n";
	}	
	$cpt=1;	
	
	while ($row = mysql_fetch_array($result))
	{
	$country = $row['country'];
	$zone = $row['zone'];
	$city = $row['city'];
	$ville = $row['ville'];
	$link_city = "<a href='§detail_ind_zone.php?FAMILY=$FAMILY&COUNTRY=$country&ZONE=$zone&CITY=$city'>".$ville."</a>";
	if ($row['birth'] <> "") {$birth = $row['birth'];} else {$birth = 0;}
	if ($row['wedding'] <> "") {$wedding = $row['wedding'];} else {$wedding = 0;}
	if ($row['death'] <> "") {$death = $row['death'];} else {$death = 0;}
	if ($row['other'] <> "") {$other = $row['other'];} else {$other = 0;}
	if ($row['date_min'] <> "") {$date_min = substr($row['date_min'],0,4);} else {$date_min = "?";}
	if ($row['date_max'] <> "") {$date_max = substr($row['date_max'],0,4);} else {$date_max = "?";}
	if ($type=="place") { echo "<TD>".$row['pays']."</TD><TD>".$link_city."</TD><TD>".$row['name']."</TD>";}
	if ($type=="name") { echo "<TD>".$row['name']."</TD><TD>".$row['pays']."</TD><TD>".$link_city."</TD>";}
	echo "<TD><center>".$birth."</center></TD>";
	echo "<TD><center>".$wedding."</center></TD>";
	echo "<TD><center>".$death."</center></TD>";
	echo "<TD><center>".$other."</center></TD>";
	echo "<TD><center>".$date_min."</center></TD>";
	echo "<TD><center>".$date_max."</center></TD><TR>";
	}
	echo "</table>";

	affiche_pied_page(true);

?>

<html>
<script type="text/javascript">
document.getElementById('progress_bar').style.display="none"
</script>
</html>
