<?
	require("config.inc");
	$AdminID = $_SESSION['AdminID'];
	$changeID = $_GET['changeID'];
	$checkID = $_GET['checkID'];
	$checkValue = $_POST['chooseType2'];
?>
<Script>
function changeV(val){
	//document.getElementByName('chooseType2').value = val.value;
		window.location=val;
}

</Script>
<? //echo "<script>alert('".$changeID."');</script>"; ?>
<html>
	<head>
		<title>Android System</title>
		<script language="JavaScript" src="script\calendar_us.js"></script>
	</head>
	
	<body>
	<center>
		<a href="http://www.tnchemie.com.my"><img src="pic/projectTitle.JPG" border="0px"></a>
		</center>
	<table width="100%" height="5px" bgcolor="#66FF66">
	<tr><td align="left">Welcome, <a href="editAdmin.php?adminID=<?echo "$AdminID"; ?>"><?echo "$AdminID"; ?></a>, <a href="logout.php">Logout</a></td></tr>
	</table><br/>
		<center>
		<h1><u>View Old Notice</u></h1>
		
			<?
			echo "<table>";
			echo "<tr><td>";
			if($changeID=='AdminID'){
				echo "<form method='POST' action='testingDatabase.php?checkID=1&changeID=AdminID'>";
				?>
				<select name="chooseType" id="chooseType" onchange="changeV('testingDatabase.php?changeID='+this.value)">
				<?
				echo "<option value ='AdminID'>Admin ID</option>";
				echo "<option value ='dateD'>Date</option>";
				echo "</select>";
				echo "</td><td>";
				echo "<input type='text'  id='chooseType2' name='chooseType2' value=''>";	
				echo "<td><input type='submit' value='check'></td>";
				echo "</form>";
			}
			else if($changeID=='dateD'){
				echo "<form name='form1' method='POST' action='testingDatabase.php?checkID=2&changeID=dateD'>";
				?>
				<select name="chooseType" id="chooseType" onchange="changeV('testingDatabase.php?changeID='+this.value)">
				<?
				echo "<option value ='AdminID'>Admin ID</option>";
				echo "<option value ='dateD' selected>Date</option>";
				echo "</select>";
				echo "</td><td>";
				echo "<input type='text'  id='chooseType2' name='chooseType2' value=''>";
				echo "<script language=JavaScript>new tcal ({'formname': 'form1','controlname': 'chooseType2'});</script>";
				echo "<td><input type='submit' value='check'></td>";
				echo "</form>";
			}
			else{
				echo "<form method='POST' action='testingDatabase.php?checkID=1&changeID=AdminID'>";
				?>
				<select name="chooseType" id="chooseType" onchange="changeV('testingDatabase.php?changeID='+this.value)">
				<?
				echo "<option value ='AdminID'>Admin ID</option>";
				echo "<option value ='dateD'>Date</option>";
				echo "</select>";
				echo "</td><td>";
				echo "<input type='text'  id='chooseType2' name='chooseType2' value=''>";	
				echo "<td><input type='submit' value='check'></td>";
				echo "</form>";
			}
			echo "</td></tr>";
			echo "</table>";
			//echo "<script language='JavaScript' src='script\OrderTable.js'></script>";
			if($checkID == 1){
				$result = mysql_query("select * from noticehistory where userID like '$checkValue%'");
										
						echo "<table border='1'><tr><td>Admin ID</td>";
						echo "<td>Delete Date</td>";
						echo "<td>Delete Time</td>";
						echo "<td>Content</td></tr>";
						while ($row=mysql_fetch_array($result))
						{
							echo "<tr><td>".$row['userID']."</td>";
							echo "<td>".$row['date']."</td>";
							echo "<td>".$row['time']."</td>";
							echo "<td>".$row['content']."</td></tr>";
						}
			}
			else if($checkID == 2){
				$result = mysql_query("select * from noticehistory where date = '$checkValue'");						
										
						echo "<table border='1'><tr><td>Admin ID</td>";
						echo "<td>Delete Date</td>";
						echo "<td>Delete Time</td>";
						echo "<td>Content</td></tr>";
						while ($row=mysql_fetch_array($result))
						{
							echo "<tr><td>".$row['userID']."</td>";
							echo "<td>".$row['date']."</td>";
							echo "<td>".$row['time']."</td>";
							echo "<td>".$row['content']."</td></tr>";
						}
			}
			else {
			$result = mysql_query("Select * from noticehistory");
						$i = 1;
						
										
						echo "<table border='1'><tr><td>Admin ID</td>";
						echo "<td>Delete Date</td>";
						echo "<td>Delete Time</td>";
						echo "<td>Content</td></tr>";
						while ($row=mysql_fetch_array($result))
						{
							echo "<tr><td>".$row['userID']."</td>";
							echo "<td>".$row['date']."</td>";
							echo "<td>".$row['time']."</td>";
							echo "<td>".$row['content']."</td></tr>";
						}
				}
						echo "</table>";
			?>
			<h4><a href="intro.php">BACK</a></h4>
		</center>
	</body>
</html>