<div class="s-bk-lf">
	<div class="acc-title">Results of Competitions</div>
</div>


<div class="silver-bk"><div class="clr"></div>	
<center><a href="/competition" class="stn">Current offers</a> || <a href="/competition/list" class="stn">Completed</a></center><BR />
<?PHP


if(isset($_GET["list"])){


	
	$db->Query("SELECT * FROM db_competition WHERE status > 0");
	if($db->NumRows() > 0){
	
	?>
	
	
	<?PHP
		while($data = $db->FetchArray()){
		
		?>
			<table width="99%" border="0" align="center">
			<tr bgcolor="#efefef">
				<td align="center" width="75" class="m-tb">ID</td>
				<td align="center" class="m-tb">Ongoing</td>
				<td align="center" class="m-tb">Completed</td>
				<td align="center" class="m-tb">Funds</td>
			</tr>
			<tr class="htt" >
				<td align="center"><?=$data["id"]; ?></td>
				<td align="center"><?=date("d.m.Y", $data["date_add"]); ?></td>
				<td align="center"><?=date("d.m.Y", $data["date_end"]); ?></td>
				<td align="center" color = "red"><?=$data["1m"]+$data["2m"]+$data["3m"]; ?>mBTC</td>
		 	</tr>
			<tr bgcolor="#efefef">
				<td align="center" width="75" class="m-tb">Status</td>
				<td align="center" class="m-tb">1 place / Price</td>
				<td align="center" class="m-tb">2 place / Price</td>
				<td align="center" class="m-tb">3 place / Price</td>
			</tr>
			<tr class="htt" >
				<td align="center"><?=($data["status"] > 1) ? "Cancel" : "Finish"; ?></td>
				<td align="center"><?=$data["user_1"]; ?> / <?=$data["1m"]; ?></td>
				<td align="center"><?=$data["user_2"]; ?> / <?=$data["2m"]; ?></td>
				<td align="center"><?=$data["user_3"]; ?> / <?=$data["3m"]; ?></td>
		 	</tr>
			</table>
		<BR /><BR />
		<?PHP
		}

	}else echo "<center><b><font color = 'red'>No supplemented offers</font></b></center><BR />";


?>
</div>
<div class="clr"></div>	
<?PHP

return;
}


$db->Query("SELECT * FROM db_competition WHERE status = 0 LIMIT 1");
if($db->NumRows() == 1){
$comp = $db->FetchArray();	
	?>
<b>Competition N° <?=$comp["id"]; ?> with a total winner : <?=$comp["1m"]+$comp["2m"]+$comp["3m"]; ?> <font color = 'red'>mBTC</font><BR /><BR />
Start Date: <?=date("d.m.Y & H:i:s", $comp["date_add"]); ?> <BR />End date: <?=date("d.m.Y & H:i:s", $comp["date_end"]); ?>
<BR /><BR />
<u>Winners gains :</u><BR /><BR />
1 - <?=$comp["1m"]; ?> mBTC <BR />
2 - <?=$comp["2m"]; ?> mBTC <BR />
3 - <?=$comp["3m"]; ?> mBTC <BR /><BR />

The competition takes into consideration only your referrals who register after the start of the competition. <BR />For each mBTC invested by your referral during this period (registered after the start of the competition) you will have 1 point,<BR /> 1 point = 1 mBTC.
<BR />Start distributing your referral links to increase your chance of winning. <BR /><BR />
</b>
	<?PHP
	
	
	$db->Query("DELETE FROM `db_competition_users` WHERE `user`='test'");
	$db->Query("SELECT * FROM db_competition_users ORDER BY points DESC LIMIT 100");
	if($db->NumRows() > 0){
	
	?>
	<center> <b> Ranking </b> </center>
<table width="99%" border="0" align="center">
  <tr bgcolor="#efefef">
    <td align="center" width="75" class="m-tb"> Position </td>
    <td align="center" class="m-tb">User</td>
    <td align="center" class="m-tb">Points</td>
<td align="center" class="m-tb">Price</td>
  </tr>
	<?PHP
		$position = 1;
		while($data = $db->FetchArray()){
		
		?>
			<tr class="htt" >
				<td align="center" width="75"><?=$position; ?></td>
				<td align="center"><?=$data["user"]; ?></td>
				<td align="center"><?=sprintf("%.0f",$data["points"]); ?></td>
				<td align="center"><?=(intval($comp["{$position}m"]) > 0) ? $comp["{$position}m"]." mBTC" : "-" ?></td>
		 	</tr>
		<?PHP
		$position++;
		}
	
	?>
</table>
<BR/>
	<?PHP
	
	}else echo " <center> <b> <font color = 'red'> No participant in the competition </font> </b> </center> <BR /> " ;

} else echo " <center> <b> <font color = 'red'> At the moment, there is no competition in progress </font> </b> </center> <BR/> " ;

?>
</div>
<div class="clr"></div>	