<?php
include("../config.php3");
include($BIB."bib_generic.php3");

?>
<html>
<head></head>
<link rel="stylesheet" href="admin.css">
<body rightmargin=0>
<div align=center class=trTitle>Les gagnants</div>
<br>
<?php
if ($month!="")
{
	$from="";
	$to="";
	$current_month = $month;
}
else
{
	$current_month = date("m", my_local_time());
}

if ($from=="" or $to=="")
{
	$current_year = date("Y", my_local_time());
	$from = $current_year."-".$current_month."-01 00:00:00";
	$to = $current_year."-".$current_month."-31 00:00:00";
}


$rows = main_db_query("SELECT *,Winners.Id AS WId,Winners.Score AS WScore FROM Winners ".
	" LEFT JOIN Players ON Winners.PlayerId=Players.Id ".
	" LEFT JOIN Members ON Members.Id=Players.MemberId".
	" WHERE Date>'".$from."' AND Date<'".$to."' ORDER BY Date DESC, Session ASC, Ordre ASC");
echo "<table border=1><tr class=trTitle><td>Id</td><td>Session</td><td>Ordre</td><td>Pseudo</td><td>Cadeau</td><td>Date</td><td>Score</td>";
echo "<td>Email</td><td>Prenom</td><td>Nom</td><td>Adresse</td><td>CP</td><td>Ville</td><td>Pays</td><td>Tel</td></tr>";
while($row = db_fetch_array($rows))
{
	echo "<tr>";
	echo "<td>".$row[WId]."</td>";
	echo "<td>".$row[Session]."</td>";
	echo "<td>".$row[Ordre]."</td>";
	echo "<td>".$row[NickName]."</td>";
	echo "<td>".$row[Gift]."</td>";
	echo "<td>".$row["Date"]."</td>";
	echo "<td>".$row[WScore]."</td>";
	
	echo "<td>".$row[Email]."</td>";
	echo "<td>".$row[FirstName]."</td>";
	echo "<td>".$row[Name]."</td>";
	echo "<td>".$row[Address]."</td>";
	echo "<td>".$row[Zip]."</td>";
	echo "<td>".$row[Town]."</td>";
	echo "<td>".$row[Country]."</td>";
	echo "<td>".$row[Phone]."</td>";
	echo "</tr>";
}
echo "</table>";

?>
<form>
Voir les gagnants
<br>
de <input type=text name=from value="<?php echo $from ?>"> à <input type=text name=to value="<?php echo $to ?>">
<br>ou pour le mois :
<input type=text name=month value="<?php echo $month ?>">
<br>
<input type=submit name=submit value="Rafraichir">
<br><br>
</form>
