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

$user=$_SESSION['agent'];
//echo "admin success!!!";

$id = $_POST['id'];
$cName = $_POST['cName'];
$address = $_POST['address'];
$cNo = $_POST['cNo'];
$email = $_POST['email'];
$person = $_POST['person'];
$class = $_POST['class'];
$post = $_POST['post'];
$country = $_POST['country'];
$code = $_POST['codeCountry'];

$query=mysql_query("select * from price order by id desc");
$display=mysql_fetch_array($query);
$rate=$display['price'];

				
?>
<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>
</head>
<body>
<div id="content2">
<!-----------------Outer table--------------->
<table width=1000 border=0 cellspacing=10 cellpadding=3>
<tr>
	<td colspan=2>
	<?php include("head.php");?>
	</td>
	</tr>
<tr>
	<td colspan=2>
			<div class=main>&nbsp;&nbsp;>>
			<a href="<?php echo"agent.php";?>">&nbsp;Home&nbsp;</a>>>
			<a href="<?php echo"register.php";?>">&nbsp;New SignUp&nbsp;</a>>>
			&nbsp;Review New SignUp&nbsp;
			</div></td>
	</tr>
<tr>
	<td valign=top>
	<!--------------------Inner table 2----------------------->
	<table class=corners cellspacing=1 cellpadding=10 width=98% align=right>
	<tr>
		<td>
			<form action="<?php echo "registering.php";?>" method="POST" onSubmit="return finalCheck();">
	<fieldset>
		<legend>Review</legend>
		<table align=center width=600 cellpadding=5 cellspacing=3 border=0 style = 'border-color:white'>
		<tr>
			<td class="tdA">Company ID :</td>
			<td width=340 class="tdA"><input type="hidden" name="id" value="<?php echo $id; ?>" /><b><?php echo $id;?></b></td>
			</tr>
		<tr>
			<td class="tdA"><b>Class :</b></td>
			<td class="tdA"><input type="hidden" name="class" value="<?php echo $class;?>" /><?php echo $class;?></td>
			</tr>
		<tr>
			<td class="tdA">Company Name :</td>
			<td class="tdA"><input type="hidden" name="cName" value="<?php echo $cName;?>"/><?php echo $cName;?>
				</td>
			</tr>
		<tr>
			<td valign=top class="tdA">Company Address :</td>
			<td class="tdA"><input type="hidden" name="address" value="<?php echo $address;?>"><?php echo $address;?>
				</td>
			</tr>
		<tr>
			<td class="tdA">POST CODE :</td>
			<td class="tdA"><input type="hidden" name="post" size=15 value="<?php echo $post;?>"/><?php echo $post;?>
				</td>
			</tr>
		<tr>
			<td class="tdA">Country :</td>
			<td class="tdA">
			<input type="hidden" name="country" value="<?php echo $country;?>"/><?php echo $country;?>
			</td>
			</tr>
		<tr>
			<td class="tdA">Contact No :</td>
			<td class="tdA">
			<input type="hidden" name="code" id="codes"  value="<?php echo $code;?>"/>
			<input type="hidden" name="cNo" id="contact" value="<?php echo $cNo;?>" />
			<?php echo "($code) $cNo";?>
				</td>
			</tr>
		<tr>
			<td class="tdA">Email :</td>
			<td class="tdA"><input type="hidden" name="email" id="email" value="<?php echo $email;?>" />
			<?php echo $email;?></td>
			</tr>
		<tr>
			<td class="tdA">In Charge Person :</td>
			<td class="tdA"><input type="hidden" name="person" id="person" value="<?php echo $person;?>"/>
			<?php echo $person;?></td>
			</tr>
		<tr class="menu2">
			<td>Year License :</td>
			<td><input type="hidden" name="rate" value="<?php echo $rate;?>"/>
				<select name="year" onchange="checkPay(this.value,rate.value)">
				<option value="a">Select year:</option>
				<option value="1">1</option>
				<option value="2">2</option>
				<option value="3">3</option>
				</select>
				<div id="valiYear"></div>
			</td>
			</tr>
		<tr class=menu2>
			<td>Total Payment :</td>
			<td><div id="ttpay"></div></td>
			</tr>
		<tr class="menu2">
			<td>Pay By :</td>
			<td>
			<select name="paidBy" onchange="paidFun(this.value)">
			<option value="a">Select Pay By:</option>
			<option value="cheque">Cheque</option>
			<option value="cash">Cash</option>
			</select>
			<div id="valiPay"></div>
			</td>
			</tr>
		<tr class=menu2>
			<td><div id="extra"></div></td>
			<td><div id="extra2"></div><div id="checkE"></div></td>
			</tr>
		<tr class="menu">	
			<td colspan=2 align=center >
				<input type="submit" value="Submit" />
				</td>
			</tr>
		</table>
	</fieldset>
	</form>
		
		</td>
		</tr>
	</table>
	<!----------------------End inner table 2-------------------->
	
	</td>
	</tr>
</table>
</div>
<!-----------------------End outer table-------------------------->
<script type="text/javascript">
function paidFun(check){
	if(check=="a"){
		document.getElementById("valiPay").innerHTML = "";
	}
	
	if(check=="cheque"){
		document.getElementById("extra").innerHTML = "<td>Cheque ID :</td>"
		document.getElementById("extra2").innerHTML = "<td><input type=text name=chequeID onchange=chequeFun(this.value)/></td>"
	}else if(check=="cash"){
		document.getElementById("extra").innerHTML = "";
		document.getElementById("extra2").innerHTML = "";
		document.getElementById("valiPay").innerHTML = "OK";
		myObj=document.getElementById("valiPay");
		myObj.style.color = "green";
	}
}

function checkPay(year,rate){
if(year=="a"){
	document.getElementById("valiYear").innerHTML = "";
}else{
var total = parseInt(year) * parseInt(rate);
document.getElementById("ttpay").innerHTML = "RM "+total;
document.getElementById("valiYear").innerHTML = "OK";
myObj=document.getElementById("valiYear");
		myObj.style.color = "green";
}

}
function chequeFun(number){
	if(number.length==0){
		document.getElementById("checkE").innerHTML=""
	}else{
		document.getElementById("checkE").innerHTML="OK"
		myObj=document.getElementById("checkE");
		myObj.style.color = "green";
	}
	
}
function finalCheck(){
var data1 = document.getElementById("valiYear");
var data2 = document.getElementById("valiPay");

if(data1.innerHTML!="OK"){
	alert("Please select the license year")
	return false
}else if(data2.innerHTML!="OK"){
	alert("Please select the payment type")
	return false
}
return true
}
</script>


</body>
</html>