<?php
session_start();
require 'include/configurations.php'; // ITECHBIDS Configuration File
require 'include/header.php';
$page_query="select * from genaralsettings where set_id=22";
$page_table=mysql_query($page_query);
if($page_row=mysql_fetch_array($page_table));
$page_length=$page_row['set_value'];
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="100%"><tr><td>
<br><br>
<?
if($_REQUEST['page']=="reven")
{
?>
<center><strong>Members Who have Paid the amount  comes under  Revenue List.</strong></center>
<br>
<?
 $query="select * from member_details a , admin_earnings b where a.user_id = b.user_id group by b.user_id";
$tab=mysql_query($query);
?>

<?
if(mysql_num_rows($tab)==0)
{
 echo "<table width=100% >";
 echo "<tr  height=30 ><td  align=center >";
 echo "<strong> No Rows Selected <strong>";
 echo "</td></tr>";
 echo "<tr><td colspan=7 >";
 require 'include/footer.php';
 echo "</td></tr>";
 echo "</table>";
 exit();
}
?>




<?

$total=mysql_num_rows($tab);
$totalx=($total/$page_length);

$reminder=($total%$page_length);
settype($totalx,'int');

if(($reminder==0)&&($total!=0))
$totalx=$totalx-1;

$set=$_REQUEST['set'];
if($set=="")$set=0;
$href ="report.php?";
$href .="&page=" .$_REQUEST['page'];

$href.="&set=";
?>
<table width="60%" align="center">
<tr><td colspan="8" align="center" >
<b>There are <?= $total; ?> Row Selected.</b>
</td>
<td>
<? if($set!=0){ ?>  <a href="<?=$href.($set-1) ?>  style="text-decoration:none"  id="link1"">  <? }?>    Prev <? if($set!=0) {?> </a>  <? }?>
</td><td>
<? if($set!=$totalx){ ?>  <a href="<?=$href.($set+1) ?>  style="text-decoration:none"  id="link1"">  <? }?>     Next  <? if($set!=$totalx) {?> </a> <? }?>
</td></tr>
</table>
<table align="center" width="90%" class="ft">
<tr class="ct" height="25">
<td align="center">Serial No</td>
<td align="center">User Name</td>
<td align="center">Email</td>
<td align="center">Membership Account</td>
<td align="center">Date of Join</td>
<td align="center">Payment Date</td>
<td align="center">Amount</td>
</tr>


<?
$start= $set*$page_length +1;
$end=$set*$page_length +$page_length;
$i=0;
while($row=mysql_fetch_array($tab))
{
$i++;
if(($i<$start)||($i>$end))
continue;
?>
<tr >
<td><?= $i; ?></td>

<? 
 $seller_query="select * from member_details where user_id ='$row[user_id]'";
 $seller_tab=mysql_query($seller_query);
 if($seller_row=mysql_fetch_array($seller_tab))
 $seller_name=$seller_row['user_name'];
 if($seller_row['member_account']==2)
 $account="Basic";
 else if($seller_row['member_account']==3)
 $account="Superior";
?>
<td><?= $seller_name; ?></td>
<td><?= $seller_row['email']; ?></td>
<td><?= $account; ?></td>

<td><?= $seller_row['date_of_registration']; ?></td>
<td><?= $row['payment_date']; ?></td>
<td><?= $row['amount']; ?></td>
</tr>
<?
}
?>
</table>
<?
}
if($_REQUEST['page']=="out")
{
?>
<center><strong>Members Who have not Paid the amount comes under  Outstanding Account.</strong></center>
<br>
<?
$query="select * from member_details a , admin_earnings b where a.user_id != b.user_id group by b.user_id";
$tab=mysql_query($query);
$tot_records=mysql_num_rows($tab);
?>
<?
if(mysql_num_rows($tab)==0)
{
 echo "<table width=100% >";
 echo "<tr  height=30 ><td  align=center >";
 echo "<strong> No Rows Selected <strong>";
 echo "</td></tr>";
 echo "<tr><td colspan=7 >";
 require 'include/footer.php';
 echo "</td></tr>";
 echo "</table>";
 exit();
}
?>
<?
$total=mysql_num_rows($tab);
$totalx=($total/$page_length);
$reminder=($total%$page_length);
settype($totalx,'int');
if(($reminder==0)&&($total!=0))
$totalx=$totalx-1;
$set=$_REQUEST['set'];
if($set=="")$set=0;
$href ="report.php?";
$href .="&page=" .$_REQUEST['page'];
$href.="&set=";
?>
<table width="60%" align="center">
<tr><td colspan="8" align="center" >
<b>There are <?= $total; ?>  Row Selected.</b>
</td>
<td>
<? if($set!=0){ ?>  <a href="<?=$href.($set-1) ?>  style="text-decoration:none"  id="link1"">  <? }?>    Prev <? if($set!=0) {?> </a>  <? }?>
</td><td>
<? if($set!=$totalx){ ?>  <a href="<?=$href.($set+1) ?>  style="text-decoration:none"  id="link1"">  <? }?>     Next  <? if($set!=$totalx) {?> </a> <? }?>

</td></tr>
</table>

<table align="center" width="90%" class="ft">
<tr class="ct" height="25">
<td align="center">Serial No</td>
<td align="center">User Name</td>
<td align="center">Email</td>
<td align="center">Membership Account</td>
<td align="center">Date of Join</td>
<td align="center">Payment Date</td>
<td align="center">Amount</td>
</tr>


<?
$start= $set*$page_length +1;
$end=$set*$page_length +$page_length;
$i=0;
while($row=mysql_fetch_array($tab))
{
$i++;
if(($i<$start)||($i>$end))
continue;
?>
<tr >
<td><?= $i; ?></td>
<? 
 /*$item_query="select * from auction_details where productid ='$row[productid]'";
 $item_tab=mysql_query($item_query); 
if($item_row=mysql_fetch_array($item_tab))
 $item_name=$item_row['producttitle']; */
?>

<? 
 $seller_query="select * from member_details where user_id ='$row[user_id]'";
 $seller_tab=mysql_query($seller_query);
 if($seller_row=mysql_fetch_array($seller_tab))
 $seller_name=$seller_row['user_name'];
 if($seller_row['member_account']==2)
 $account="Basic";
 else if($seller_row['member_account']==3)
 $account="Superior";
?>
<td><?= $seller_name; ?> </td>
<td><?= $seller_row['email']; ?> </td>
<td><?= $account; ?></td>

<td><?= $seller_row['date_of_registration']; ?> </td>
<td><?= $row['payment_date']; ?> </td>
<td><?= $row['amount']; ?> </td>
</tr>

<?
}
?>
<tr>
    <td colspan="8" >
      
    </td>
</tr>

</table>

<?
}
if($_REQUEST['page']=="top")
{
?>
<center><strong>Members Who have posted More Item come under Top Seller List</strong></center>
<br>

<?
//finding Number of top seller from admin settings
$myquery="select * from genaralsettings where set_id = 21";
$mytab=mysql_query($myquery);
if($row=mysql_fetch_array($mytab))
$range=$row['set_value'];

//
$query="SELECT user_id, count( user_id ) count_user FROM auction_details  GROUP BY user_id having count(user_id) >=$range ORDER BY count_user DESC";
$tab=mysql_query($query);
?>

<?
if(mysql_num_rows($tab)==0)
{
 echo "<table width=100% >";
 echo "<tr  height=30 ><td  align=center >";
 echo "<strong> No Rows Selected <strong>";
 echo "</td></tr>";
 echo "<tr><td colspan=7 >";
 require 'include/footer.php';
 echo "</td></tr>";
 echo "</table>";
 exit();
}
?>


<?

$total=mysql_num_rows($tab);
$totalx=($total/$page_length);

$reminder=($total%$page_length);
settype($totalx,'int');

if(($reminder==0)&&($total!=0))
$totalx=$totalx-1;

$set=$_REQUEST['set'];
if($set=="")$set=0;
$href ="report.php?";
$href .="&page=" .$_REQUEST['page'];

$href.="&set=";
?>
<table width="60%" align="center">
<tr><td colspan="8" align="center" >
<b>There are <?= $total; ?> Row Selected.</b>
</td>
<td>
<? if($set!=0){ ?>  <a href="<?=$href.($set-1) ?>  style="text-decoration:none"  id="link1"">  <? }?>    Prev <? if($set!=0) {?> </a>  <? }?>
</td><td>
<? if($set!=$totalx){ ?>  <a href="<?=$href.($set+1) ?>  style="text-decoration:none"  id="link1"">  <? }?>     Next  <? if($set!=$totalx) {?> </a> <? }?>

</td></tr>
</table>












<table align="center" width="80%" class="ft">
<tr class="ct" height="25">
<td align="center">Serial No</td>
<td align="center">User Id</td>
<td align="center">User Name</td>
<td align="center">Email Address </td>
<td align="center"> Country</td>
</tr>

<?
$count=mysql_num_rows($tab);
$i=1;

$start= $set*$page_length +1;
$end=$set*$page_length +$page_length;
$w=0;
while($row=mysql_fetch_array($tab))
{
$w++;
if(($w<$start)||($w>$end))
continue;

$user_query="select * from member_details where user_id = '$row[user_id]'";
$user_tab=mysql_query($user_query);
$user_row=mysql_fetch_array($user_tab);
?>
<tr >
<td><?= $i++; ?></td>
<td><?= $row['user_id']; ?></td>
<td><?= $user_row['user_name']; ?></td>
<td><?= $user_row['email']; ?></td>
<?
$country_query="select * from site_countries where country_id ='$user_row[country]'";
$country_tab=mysql_query($country_query);
$country_row=mysql_fetch_array($country_tab);
?>
<td> <?= $country_row['country'] ?></td>
</tr>
<?
}
?>
<tr>
    <td colspan="8" >
      
    </td>
</tr>

</table>

<?
}
if($_REQUEST['page']=="user")
{
?>


<center><strong>Members Who have Currently Login to our Site come under Users Online</strong></center>
<br>
<?
$query="SELECT * from member_details where onlinestatus='online'";
$tab=mysql_query($query);
?>
<?
if(mysql_num_rows($tab)==0)
{
 echo "<table width=100% >";
 echo "<tr  height=30 ><td  align=center >";
 echo "<strong> No Rows Selected <strong>";
 echo "</td></tr>";
 echo "<tr><td colspan=7 >";
 require 'include/footer.php';
 echo "</td></tr>";
 echo "</table>";
 exit();
}


$total=mysql_num_rows($tab);
$totalx=($total/$page_length);

$reminder=($total%$page_length);
settype($totalx,'int');

if(($reminder==0)&&($total!=0))
$totalx=$totalx-1;

$set=$_REQUEST['set'];
if($set=="")$set=0;
$href ="report.php?";
$href .="&page=" .$_REQUEST['page'];

$href.="&set=";
?>
<table width="60%" align="center">
<tr><td colspan="8" align="center" >
<b>There are <?= $total; ?> Row Selected.</b>
</td>
<td>
<? if($set!=0){ ?>  <a href="<?=$href.($set-1) ?>  style="text-decoration:none"  id="link1"">  <? }?>    Prev <? if($set!=0) {?> </a>  <? }?>
</td><td>
<? if($set!=$totalx){ ?>  <a href="<?=$href.($set+1) ?>  style="text-decoration:none"  id="link1"">  <? }?>     Next  <? if($set!=$totalx) {?> </a> <? }?>

</td></tr>
</table>






<table align="center" width="80%" class="ft">
<tr class="ct" height="25">
<td align="center">Serial No</td>
<td align="center">User Id</td>
<td align="center">User Name</td>
<td align="center">Email Address </td>
<td align="center"> Country</td>
</tr>
<?

$start= $set*$page_length +1;
$end=$set*$page_length +$page_length;
$i=0;
while($row=mysql_fetch_array($tab))
{
$i++;
if(($i<$start)||($i>$end))
continue;
?>
<tr >
<td><?= $i ?></td>
<td><?= $row['user_id']; ?></td>
<td><?= $row['user_name']; ?></td>
<td><?= $row['email']; ?></td>
<?
$country_query="select * from site_countries where country_id ='$row[country]'";
$country_tab=mysql_query($country_query);
$country_row=mysql_fetch_array($country_tab);
?>
<td> <?= $country_row['country'] ?></td>
</tr>
<?
}
?>
<tr>
    <td colspan="8" >
      
    </td>
</tr>

</table>












<?
}
?>


<br><br>
</td></tr>
<tr><td><? require 'include/footer.php'; ?></td></tr>
</table>

</body>
</html>
