<?



	$login=mysql_connect('localhost', 'wauhaha_karaoke', 'cross123','wauhaha_karaoke');
	
	mysql_selectDB("wauhaha_karaoke",$login);


$d = date('Y-m-d');
$time_offset ="240"; 
$time_a = ($time_offset * 120);

$t = date("H:i:s" );

	$RoomNo = $_GET['RoomNo'];
	$result = mysql_query("select * from room where RoomNo='$RoomNo'");
	$row2= mysql_fetch_array($result);
	$RoomNum = $row2['RoomNum'];
	$n = $_POST['n'];
	$s = $_POST['s'];
	$r = $_POST['r'];
	$st= $_POST['st'];
	$et= $_POST['et'];
	if($s == "Maintenance"){
	
		if(($n == "")||($st == "")){
		echo "<script>alert('Please Fill The Note And The Maintaince Date')</script>";
		echo "<script language='javascript'>window.location='editroom1.php?RoomNo=$RoomNo'</script>";die;
		
		}else
		
		$query = mysql_query("insert into roomproblem(RoomNum,RoomNo,status,note,sdate,edate,time)value('$RoomNum','$RoomNo','$s','$n','$st','$et','$t')");
		$query2= mysql_query("Update room set status='$s' where RoomNo='$RoomNo'");
		
		if(($query)||($query2)){
		echo "<script>alert('Edit Successful')</script>";
		echo "<script language='javascript'>window.location='editroom.php'</script>";die;
		}
	}else
	
	
	$query=mysql_query("Update room set status='$s',RoomNum='$r',time=' ', User='',stime='' where RoomNo='$RoomNo' ");
		
		echo "<script>alert('Edit Successful')</script>";
		echo "<script language='javascript'>window.location='editroom.php'</script>";die;
	
	
	
	
	