<?php
session_start();
require 'include/header.php';
?>
<style type="text/css">
<!--
.style1 {
	color: #666666;
	font-weight: bold;
}
.style3 {color: #666666; font-size: 11px; font-family:Arial, Helvetica, sans-serif}
-->
</style><?php
require 'include/configurations.php'; // ITECHBIDS Configuration File
	$type=$_GET['type'];
	$level_query="select * from bidback_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'];
			$commission=$_POST['txtLevelcommission'];
			if($type=="edit")
			$sql="update bidback_levels set bidback_levels='$commission' where level_id=$id";
			else
			$sql="insert into bidback_levels(level_name,bidback_levels) values('$levelname','$commission')";
			$result=mysql_query($sql);
			echo '<meta http-equiv="refresh" content="0;url=bidback.php?page=level">';
			exit();
		}
			if($type=="edit") {
				$sql="select * from bidback_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';?> Bidback Manager</td></tr>
<tr ><td>Bidback Number</td><td><input type="text" class="bluetext"name="txtLevelcommission" value="<?=$row['bidback_levels']?>"></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="3"> Bidback Manager</td></tr>
<tr>
  <td colspan="3">
  Here you can Set your Bidback Details.
  </td>
</tr>
<tr class="ct" height="25"><td align="center"><b>Level</b></td>
<td align="center" colspan="2"><b>Bidback</b></td>
</tr>
<?
	while($level_row=mysql_fetch_array($level_result)) {
?>
<tr ><td align="center"><?=$level_row['levels']?></td><td align="center"><?=$level_row['bidback_levels']?>%</td><td align="center"><a href="bidback.php?page=level&type=edit&id=<?=$level_row['level_id']?>" id="link2">Edit</a></td></tr>
<?
	}
?>
</table>
<?
	}
?>
