<?
	require 'include/configurations.php'; // ITECHBIDS Configuration File
	$type=$_GET['type'];
	$level_query="select * from ref_levels";
	$level_result=mysql_query($level_query);
?>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
<?
	if($type=='edit' || $type=='new') {
		$id=$_GET['id'];
		$canChange=$_POST['canChange'];
		if($canChange==1) {
			$levelname=$_POST['txtLevelname'];
			$regbid=$_POST['txtregbid'];
			if($type=="edit")
			$sql="update ref_levels set reg_bid='$regbid' where level_id=$id";
			else
			$sql="insert into ref_levels(level_name,ref_levels,reg_bid) values('$levelname','$commission','$regbid')";
			$result=mysql_query($sql);
			echo '<meta http-equiv="refresh" content="0;url=settings.php?page=level">';
			exit();
		}
			if($type=="edit") {
				$sql="select * from ref_levels where level_id=$id";
				$result=mysql_query($sql);
				$row=mysql_fetch_array($result);
			}
?>
<table border="0" align="center" width="80%" cellpadding="5" cellspacing="2" class="ft">
<form name="frmLevel" action="<? $_SERVER['PHP_SELF']?>" method="post" onSubmit="this.canChange.value=1;">
<tr class="ct" height="25"><td colspan="2"><? if($type=="edit") echo 'Edit';else echo 'Add New';?>Referral Level Manager</td></tr>
<tr ><td>Bids on Registration</td><td><input type="text" class="bluetext"name="txtregbid" value="<?=$row['reg_bid']?>"></td></tr>
<tr><td colspan="2" align="center">
<input type="hidden" name="canChange" value="0"><input type="submit" class="button"   name="btn_Change" value="Change" >
</td></tr>
</form>
</table>
<?		
	}
	else {
?>
<table border="0" align="center" width="80%" cellpadding="5" cellspacing="2" class="ft">
<tr class="ct" height="25"><td colspan="4">Referral Level Manager</td></tr>
<tr>
  <td colspan="4">
  Here you can Set your Referral Level Details.
  </td>
</tr>
<tr class="ct" height="25"><td align="center"><b>Level</b></td>
<td align="center"><b>Bid on Registration</b></td>
<td align="center"><b>Action</b></td>
</tr>
<?
	while($level_row=mysql_fetch_array($level_result)) {
?>
<tr ><td align="center"><?=$level_row['levels']?></td><td align="center"><?=$level_row['reg_bid']?></td><td align="center"><a href="settings.php?page=level&type=edit&id=<?=$level_row['level_id']?>" id="link2">Edit</a></td></tr>
<?
	}
?>
</table>
<?
	}
?>
