<?php
include("../../session.php");
include("../../connect.php");

$user=$_SESSION['admin'];

?>
<html>
<head>
<link href="../header.css" rel="stylesheet" type="text/css"/>
<link type="text/css" rel="stylesheet" href="overflow.css" />
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<div id="content2">
<!-----------------Outer table--------------->
<table width=1000 border=0 cellspacing=10 cellpadding=3 class=outer >
<tr>
	<td colspan=2>
	<?php include("../head.php");?>
	</td>
	</tr>
<tr>
	<td colspan=2>
			<div class=main>&nbsp;&nbsp;>>
			<a href="<?php echo"../admin.php";?>">&nbsp;Home&nbsp;</a>>>
			<a href="<?php echo"price.php";?>">&nbsp;Licensing Rate&nbsp;</a>>>
			&nbsp;New Rate&nbsp;
			</div></td>
	</tr>
<tr>
	<td width=200 valign=top >
	<table width=100% cellpadding=8 cellspacing=3 border=1>
	<tr>
		<td align=center><a href="<?php echo "price.php";?>">New Rate</a></td>
		</tr>
	<tr>
		<td align=center><a href="<?php echo "historyRate.php";?>">History Rate</a></td>
		</tr>
	</table>
	</td>
	<td valign=top>
	<!--------------------Inner table 2----------------------->
	<?php
		$query=mysql_query("select * from price order by id desc");
		$display=mysql_fetch_array($query);
		$price=$display['price'];
		$date=$display['date'];
		$time=$display['time'];
	
	?>
	<table class=corners cellspacing=1 cellpadding=10 width=98% align=center>
	<tr>
		<td>
		<!--------------------Inner table 2----------------------->
	<?php
		$query=mysql_query("select * from price order by id desc");
		$display=mysql_fetch_array($query);
		$price=$display['price'];
		$date=$display['date'];
		$time=$display['time'];
	
	?>
	<table class=corners cellspacing=1 cellpadding=10 width=98% align=center>
	<tr>
		<td>
			<form action="<?php echo "adjusting.php";?>" method="POST" onSubmit="return finalCheck();">
	<fieldset>
		<legend>Adjust License Rate</legend>
		<table align=center width=500 cellpadding=5 cellspacing=3 border=0>
		<tr>
			<td>Latest Rate :</td>
			<td><?php echo $price; ?></td>
			</tr>
		<tr>
			<td>Last adjust time :</td>
			<td><?php echo $date."&nbsp;&nbsp;&nbsp;".$time; ?></td>
			</tr>
		<tr>
			<td>New Rate :</td>
			<td><input type="text" name="newRate" value="" maxlength=10 onchange="isNumber(this.value);" />
				<div id="valiRate">*Please fill in</div></td>
			</tr>
		<tr>	
			<td colspan=2 align=center>
				<input type="submit" value="Submit" />
				<input type="reset" value="Reset" /></td>
			</tr>
		</table>
	</fieldset>
	</form>
		
		</td>
		</tr>
	</table>
		</td>
		</tr>
	</table>
	<!----------------------End inner table 2-------------------->
	
	</td>
	</tr>
</table>
</div>
<!-----------------------End outer table-------------------------->
<script type="text/javascript">
function isNumber (number)  {
	if(number.length==0){
		document.getElementById('valiRate').innerHTML = "*Please fill in";
		return;
	}

    if(isNaN(number)){
		document.getElementById('valiRate').innerHTML = "*Is not a number";
	}else{
		document.getElementById('valiRate').innerHTML = "OK";
	}
}

function finalCheck(){

var div = document.getElementById('valiRate');

if(div.innerHTML!="OK"){
	alert("Please make sure all fields are properly completed.");
	return false;
}

return true;
}


</script>

</body>
</html>