<?php session_start();  //Developed by ITechScripts
   require 'include/configurations.php'; // ITECHBIDS Configuration File
?> 
<?
function getReferral_details($userid,$level) 
	{
	    $select_referral_query="select * from member_details where intro_id=$userid";
		$select_referral_result=mysql_query($select_referral_query);
		/* $select_level_row=mysql_fetch_array($select_level_result);
		$level_limit=$select_level_row[0]; */
		if(mysql_num_rows($select_referral_result)>0)
	    {
		$level+=1;
		while($select_referral_row=mysql_fetch_array($select_referral_result)) 
		{
				echo "<tr><td>$level</td><td>".$select_referral_row['user_name']."</td><td>".$select_referral_row['date_of_registration']."</td></tr>";
						$intro_id=$select_referral_row['user_id'];
						getReferral_details($intro_id,$level);
		}
		}
		
		}		
?>
<html>
<head>
<title>Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>
<? 
 require 'include/header.php';
 $id=$_GET[id];
$query="select * from genaralsettings where set_id = 1";
$table=mysql_query($query);
if($row=mysql_fetch_array($table))
$yoursite = $row['set_value'];
$select_referral_query="select * from member_details  where intro_id=$id";
$select_referral_result=mysql_query($select_referral_query);
$total_referrals=mysql_num_rows($select_referral_result);
$ref_sql="select SUM(referral_commission) from referral_commission where intro_id=$id";
$ref_res=mysql_query($ref_sql);
$com_res=mysql_fetch_array($ref_res);
$total_commission=$com_res[0];
 $user="select * from member_details where user_id=$id";
  $user_res=mysql_query($user);
  $user_rec=mysql_fetch_array($user_res);
?>
<table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
<tr align="center">
<td align="center"><a href="useritechds.php?id=<?=$id?>&type=gen">General</a></td>
<td><a href="useritechds.php?id=<?=$id?>&type=per">Personal</a></td>
<td><a href="usertrans.php?id=<?=$id?>">Transaction Details</a></td> 
</tr><tr align="center">
<td><a href="userbid.php?id=<?=$id?>">Bid Details</a></td>
<td><a href="userref.php?id=<?=$id?>">Refferal Details</a></td>
<td><a href="addfunds.php?id=<?=$id?>">Add Bids</a></td>
</tr>
</table><BR><BR>
<table align="center" width="580" class="ft">
<tr>
<td  align="center" class="ct"><b>Referrals Details of <?= $user_rec[user_name]; ?></b></td>
</tr>
<tr>
<td ><b>Total Referrals</b> <?=$total_referrals?></td>
</tr>
 <tr>
<td ><b>Total Commission Earned</b> $ <?=$total_commission?></td>
</tr>  
<tr>
<td class="ct">
<div style="line-height:20px">
<?= $yoursite  ?>/?<?= $user_rec[user_name]; ?>
</div>
</td>
</tr>
</table><br>
<table border="0" align="center" cellpadding="0" cellspacing="0" width="580" class="ft">
<tr><td class="ct" colspan="3"><b>Details of your Downline</b></td></tr>
<tr class="ct">
<td><b>Level</b></td><td><b>Username</b></td><td>Join Date</td>
</tr>
<? getReferral_details($id,0) ?>
</table>
</td>
</tr>
</table>

<? require'include/footer.php'; ?>
  </body>
</html>
