<?php
include ('header.inc.php');
include ('classes/Ranking.php');

if(!isset($_GET['start_rank'])) $_GET['start_rank']=1;
if(!isset($_GET['number_rank'])) $_GET['number_rank']=40;

//Get ranking array
$o_mensual_rank = new Ranking();
$a_list_rank = $o_mensual_rank->GetRanking($_GET['start_rank'],$_GET['start_rank']+($_GET['number_rank']-1));

//calculate the number of elements to show 
$i_nomber_show = count($a_list_rank);
if($i_nomber_show%2!=0) $i_nomber_show++;

?>
<center><br>
<i class="accstyle"><b><img src="images/icons/li.png" alt="" />&nbsp;Classement Mensuel Actuel :</b></i><br><br>
<table border='0' width='400' cellpadding='0' cellspacing='0' class="ranking">
	<tr align='center'>
		<td width='50' style="text-align: left;" >N°</td>
		<td width='350' style="text-align: left;">Pseudo</td>
		<td width='50' style="text-align: left;">N°</td>
		<td width='350' style="text-align: left;">Pseudo</td>
	</tr>
	<?php
//loop for create the table
for($i=$_GET['start_rank'];$i<($_GET['start_rank']+($i_nomber_show/2));$i++)
{
	$o_temp_player = new PlayerAccount();
	$o_temp_player->SetPlayerID($a_list_rank[$i]);
	?>
	<tr>
		<td><?php echo $i;?></td>
		<td><a href='player-stats.php?pid=<?php echo $a_list_rank[$i];?>' class="accstyle" style="text-decoration: none;"><?php echo $o_temp_player->GetPlayerName();?></a></td>
	<?php
	if(isset($a_list_rank[($i+($i_nomber_show/2))]))
	{
		$o_temp_player->SetPlayerID($a_list_rank[($i+($i_nomber_show/2))]);
		?>
		<td><?php echo ($i+($i_nomber_show/2));?></td>
		<td><a href='player-stats.php?pid=<?php echo $a_list_rank[($i+($i_nomber_show/2))];?>' class="accstyle" style="text-decoration: none;"><?php echo $o_temp_player->GetPlayerName();?></a></td>
	</tr>
		<?php
	}
	else
	{
		?>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
		<?php
	}
}
?>
</table>
<br>
<?php
//Page system
if($_GET['start_rank']>$_GET['number_rank'])
{
	?>
	
	<a href='ranking.php?start_rank=<?php echo $_GET['start_rank']-$_GET['number_rank'];?>&number_rank=<?php echo $_GET['number_rank'];?>'class="accstyle">&lt;&lt;Précédent</a> - 
	<?php
}
?><i class="accstyle">Page <?php echo ((($_GET['start_rank']-1)/$_GET['number_rank'])+1);?></i>
<?php
if(($_GET['start_rank']-1+$i_nomber_show)%$_GET['number_rank']==0)
{
	?>
	 - <a href='ranking.php?start_rank=<?php echo $_GET['start_rank']+$_GET['number_rank'];?>&number_rank=<?php echo $_GET['number_rank'];?>' class="accstyle">Suivant&gt;&gt;</a></center><br>
	<?php
}
//Select the number of players showed
?>
</center>
<center>
<form action='' method='get' class="smofr">
<table><tr>
	<td><input type='hidden' name='start_rank' id='start_rank' value='<?php echo $_GET['start_rank'];?>'/><td></tr>
	<tr><td>Nombre de joueurs par page : </td><td><input type='text' size='3' maxlength='3' name='number_rank' id='number_rank' value='<?php echo $_GET['number_rank'];?>' class="smofr" style="width: 40px;"/></td><td><input type='submit' name='submit' id='submit' value='Ok' class="buttons"/></td></tr>
</table>
</form>
</center>
<?php
include ('footer.inc.php');
?>