<?php



session_start();
include "../config.php";
include "../header.php";
include "../style.php";
if( isset($_SESSION["alogin"]) ) {

    	?><table>

      	<tr>

        <td width="15%" valign=top><br>

        <? include("adminnavigation.php"); ?>

        </td>

        <td valign="top" align="center"><br><br> 

<?
if ($action=="save") {

        
               
         $update=mysql_query("update settings set setting='$moneypoolp' where name='moneypool'");
         $update=mysql_query("update settings set setting='$pointspoolp' where name='pointspool'");
         $update=mysql_query("update settings set setting='$ppoolp' where name='ppool'");
         $update=mysql_query("update settings set setting='$mpoolp' where name='mpool'");
         $update=mysql_query("update settings set setting='$buypoolp' where name='buypool'");
         $update=mysql_query("update settings set setting='$poolentrypricep' where name='poolentryprice'");
         $update=mysql_query("update settings set setting='$proentryp' where name='proentry'");
         $update=mysql_query("update settings set setting='$jventryp' where name='jventry'");
         $update=mysql_query("update settings set setting='$superjventryp' where name='superjventry'");


                  echo "<p><b>Your settings have been saved.</b></p>";

    }

    else {

?>
 <H2>Site Pool Settings</H2>

<form method="POST" action="poolsettings.php">

       <input type="hidden" name="action" value="save">

  Money Pool On<br>
   <input type="radio" name="mpoolp" value="1"<? if($mpool) echo " CHECKED"; ?>> Yes <input type="radio" name="mpoolp" value="0"<? if(!$mpool) echo " CHECKED"; ?>> No <br><br>
       Points Pool On<br>
   <input type="radio" name="ppoolp" value="1"<? if($ppool) echo " CHECKED"; ?>> Yes <input type="radio" name="ppoolp" value="0"<? if(!$ppool) echo " CHECKED"; ?>> No <br><br>


(1 is one percent)&nbsp;<input type="text" name="pointspoolp" size ="5" value="<? echo $pointspool; ?>">&nbsp;percent of the points earned by ads clicked (all ads) will go into the points pool.<br><br>

 Every time a new member clicks on an ad this amount of money goes into the money pool.
       <input type="text" name="moneypoolp" value="<? echo $moneypool; ?>"><br>0.001 is 1/1000th of 1 dollar or a tenth of 1 cent.<br><br>
      
When a member purchases advertising how many percent is added to the money pool?<br>

       <input type="text" name="buypoolp" value="<? echo $buypool; ?>"> percent.&nbsp;(1 is one percent)<br><br>

How many points does each pool drawing ticket cost a member?<br>

       <input type="text" name="poolentrypricep" value="<? echo $poolentryprice; ?>"> points<br><br>

How many free entries should be given to Pro members weekly?<br>

       <input type="text" name="proentryp" value="<? echo $proentry; ?>"> tickets<br><br>

How many free entries should be given to JV Partner members weekly?<br>

       <input type="text" name="jventryp" value="<? echo $jventry; ?>"> tickets<br><br>

How many free entries should be given to Super JV Partner members weekly?<br>

       <input type="text" name="superjventryp" value="<? echo $superjventry; ?>"> tickets<br><br>

 <input type="submit" value=" Save ">

       </form></center>
<?
}
?>
       <hr>   


<H2>Select Pool Winners</H2>

<table><tr><td>
<?

if ($mpool=="1") {

 $query = "select * from pool where name='money'";
		$result = mysql_query ($query)
	     	or die ("Query failed");

 while ($line = mysql_fetch_array($result)) {
	            $amountm = round($line["amount"], 3);
?>
  <b>Money Pool Balance: <font color=BLUE>$<? echo $amountm; ?></font></b> 
<?	                  }

}
	        ?>
<br>
<?
if ($ppool=="1") {
 $query = "select * from pool where name='points'";
		$result = mysql_query ($query)
	     	or die ("Query failed");

 while ($line = mysql_fetch_array($result)) {
	            $amountp = round($line["amount"], 3);
?>
   <b>Points Pool Balance: <font color=BLUE><? echo $amountp; ?></font></b> 
<?	                  }
}
	        ?></p>
</td></tr></table>

<?
if ($mpool=="0" AND $ppool=="0") {


}


else {
?>

 <table align=center width=600><tr><td>
<p align=left><font color=RED><b>WARNING:</b></font> Do not click on the link below unless your sure you want to choose a random winner for the money pool and points pool. When you click on the link it is done automatically for you.</p>
<?
}

if ($ppool=="1") {
?>
<p align=left>
<b>Choose the points pool winner <a href="pickpointswinner.php">here</a>.</b><br><br>
<?
}

else {

echo"<p align=center><b>Points Pool Not Activated</b></p>";

}

if ($mpool=="1") {
?>
<b>Choose the money pool winner <a href="pickmoneywinner.php">here</a>.</b><br><br><br><br>
</p>
<?
}

else {

echo"<p align=center><b>Money Pool Not Activated</b></p>";

}

if ($mpool=="1" OR $ppool=="1") {
?>

After the winners have been chosen you must empty the drawing entries by <b><a href="resetpoolentries.php">clicking here</a>.</b><br><br>
After the winners have been chosen reset referral trans for new week by <b><a href="resetreftrans.php">clicking here</a>.</b><br><br>
After the winners have been chosen reset prize trans for new week by <b><a href="resetprizetrans.php">clicking here</a>.</b><br><br>
<?
}
?>
</td></tr></table>

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

    	
		
<?

    }

else

	echo "Unauthorised Access!";



include "../footer.php";



?>