<html>
<body style="background-color: #ffffff;background-image:url(rail.jpg);background-repeat: repeat-y">
<?php
include('link2.php');
?>
<center>
<h2>Book Room</h2>

</center>

<?php
$time_offset ="240"; 
$time_a = ($time_offset * 120);
$d = date('Y-m-d');
$t = date("H:i",time());
$login=mysql_connect('localhost', 'wauhaha_karaoke', 'cross123','wauhaha_karaoke');
	
	mysql_selectDB("wauhaha_karaoke",$login);
$RoomNo = $_GET['RoomNo'];
$BookID = $_GET['BookID'];
$result = mysql_query("select * from room where RoomNo='$RoomNo'");
$row=mysql_fetch_array($result);
$rt=$row['roomtype'];
$result2 = mysql_query("select * from roomtype where roomtype='$rt' ");
$row2=mysql_fetch_array($result2);
$result3 = mysql_query("select * from room where RoomNo='$RoomNo'");
$row3 = mysql_fetch_array($result3);
$a = $row3['status'];
$p1=$row2['price1'];
$p2=$row2['price2'];
$result4 = mysql_query("select * from roomtrans where BroomID='$BookID' ");
$row4=mysql_fetch_array($result4);
$bt = $row4['booktime'];
if($bt != ""){
$bt2 = $bt - $t;
}
if(($a == "Unavailable")||($a == "Maintenance")){

		echo "<script>alert('It is Unavailable')</script>";
		echo "<script language='javascript'>window.location='viewroom2.php?roomtype=$rt'</script>";die;
}
if($bt2 !=""){
	if ($bt2 < 4){
		echo "<script>alert('Reserved')</script>";
		echo "<script language='javascript'>window.location='viewroom2.php?roomtype=$rt'</script>";die;

}
}
if(($t>= 23)||($t <5)){
		echo "<script>alert('Closed')</script>";
		echo "<script language='javascript'>window.location='viewroom2.php?roomtype=$rt'</script>";die;
}
echo "
<center><h3><a href='http://www.wauhaha.com/karaoke/viewroom1.php?roomtype=$rt'>Back</a></h3></center>
<form method=post action=http://www.wauhaha.com/karaoke/bookroom2action.php?RoomNo=$RoomNo&BookID=$BookID >
<table align=center>
<tr>
	<td>Room No &nbsp;&nbsp;&nbsp;:</td>
	<td>$RoomNo </td>
</tr>
<tr>
	<td>Room Type :</td>
	<td>$rt <input type=hidden name=rt value=".$rt."></td>
</tr>
<tr>
	<td>IC Name:</td>
	<td><input type=text name=name></td>
</tr>
<tr>
	<td>IC No:</td>
	<td><input type=text name=ic></td>
</tr>
<tr>
	<td>Contact:</td>
	<td><input type=text name=c></td>
</tr>
<tr>
	<td align=center>Normal &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</td>
	<td><input type=text name=q1 size=6> Peoples</td>
</tr>
<tr>
	<td align=center>Student &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</td>
	<td><input type=text name=q2 size=6> Peoples  </td>
</tr>
<tr>
	<td align=center>Hours &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</td>
	<td><select name=h ><option>3</option><option>6</option></select></td>
</tr>
<tr>	
	<td align=center colspan=2><input type=submit value=Book><input type=reset value=Reset></td>
	
</tr>
</table>";
?>