<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Joueurs venant de la Gironde...</title>
</head>
<link rel="stylesheet" href="admin.css">
<body>
<div align=center class=trTitle>- Statistiques Joueurs venant du jeu Girondins Coach -</DIV>
<p>&nbsp;</p>
<form name=main action='fromgirondins.php3' method="post">
<table align=center border=0 cellpadding=2 cellspacing=5>
<tr>
	<td align=center colspan=2 class='trTitle'>
	les joueurs venant des Girondins
	</td>
</tr>
<tr>
	<td class='univers' align=center>
	Girondins inscrits à partir du... <INPUT name="DateMin" value="<?php echo $DateMin; ?>" size="21" class='univers'>
	jusqu'au... <INPUT name="DateMax" value="<?php echo $DateMax; ?>" size="21" class='univers'><br>(au format AAAA-MM-JJ HH:MM:SS)
	</td>
</tr>
<tr>
	<td align=center>
	<input type="submit" value="Dessiner" class='univers'>&nbsp;
	<INPUT type="reset" value="Annuler" class='univers'>
	</td>
</tr>
</table>
</FORM>

<?
if ($DateMax)
{
	include ("generic.inc");
	
	##############
	# CONSTANTES #
	##############
	
	# $DATABASE est la base du KestuFoot
/*
# local	
	# la seconde base (des Girondins)
	$BASEGIRONDINS = array(# Host for the database
			  "host" => "localhost",
			  # Login for the database connection
			  "login" => "dummy",
			  # Password for the database connection
			  "password" => "dummy",
			  # Name of the main database
			  "main_name" => "m6_girondins",
			  # Name of the session database
			  "session_name" => "m6_girondins");
*/
	# la seconde base (des Girondins)
	$BASEGIRONDINS = array(# Host for the database
			  "host" => "localhost",
			  # Login for the database connection
			  "login" => "m6_girondins",
			  # Password for the database connection
			  "password" => "watB1",
			  # Name of the main database
			  "main_name" => "m6_girondins",
			  # Name of the session database
			  "session_name" => "m6_girondins");
	
	##################
	# FIN CONSTANTES #
	##################
	
	
	
	# dans la base du Kestufoot,
	# on compte les joueurs inscrits au KtF après la $DateMax
	$row = main_db_query("SELECT Email FROM Members WHERE Time>='$DateMax' ORDER BY Email");
	$i=0;
	while ($result = db_fetch_array($row))
	{
		$emails_ktf[$i] = $result[Email];
		$i++;
	}
	
	# puis on compte les joueurs déjà inscrits au KtF au moment de la $DateMax
	$rowdeja = main_db_query("SELECT Email FROM Members WHERE Time<'$DateMax' ORDER BY Email");
	$i=0;
	while ($resultdeja = db_fetch_array($rowdeja))
	{
		$emailsdeja_ktf[$i] = $resultdeja[Email];
		$i++;
	}
	
	
	
	# dans la base des Girondins
	switchBase($BASEGIRONDINS);
	
	$row = mysql_query("SELECT Email FROM Members WHERE Time<='$DateMax' AND Time>='$DateMin'");
	while ($res = db_fetch_array($row))
	{
		$emails_gir[$res[Email]] = 1;
	}
	
	
	
	# intersection
	for ($i=0,$nb=0,$nbdeja=0 ; $i<count($emails_ktf) ; $i++)
	{
		if ($emails_gir[$emails_ktf[$i]]==1)
		{
			$nb += 1;
			#echo "nb".$nb."<br>";
		}
		elseif ($emails_gir[$emailsdeja_ktf[$i]]==1)
		{
			$nbdeja += 1;
			#echo "nbdeja".$nbdeja."<br>";
		}
	}
	
	$pc = (count($emails_gir)==0)?0:round(10000*$nb/count($emails_gir))/100;
	$pcdeja = (count($emails_gir)==0)?0:round(10000*$nbdeja/count($emails_gir))/100;
	
	echo "<p align=center>Sur ".count($emails_gir)." nouveaux girondins inscrits entre le $DateMin et le $DateMax,</p>
		<table align=center>
		<tr>
			<td> $nbdeja étaient déjà inscrits au KtF, soit $pcdeja %
			</td>
		</tr>
		<tr>
			<td> $nb se sont inscrits au KtF, soit $pc %
			</td>
		</tr>
		</table>";
}

?>

</body>
</html>
