<?php
	$conn = @mysql_connect("localhost","geoide5_joom340","34WP[59[5S");
	if(!$conn){
		echo "<h1>Cannot Access Database?</h1>";
		exit();
	}
	mysql_select_db("geoide5_joom340");
	
	if(isset($_POST['submit'])){
	
		if($_POST['tModuleName']!=""){
			$t1 = $_POST['tModuleName'];
			$t2 = $_POST['tTaskDescription'];
			$t3 = $_POST['tStatus'];
			$t4 = $_POST['tCompletionDate'];
			$t5 = $_POST['tCompletionTime'];
			$t6 = $_POST['tDateStarted'];
			
			$sql  = "";
			$sql  = "INSERT INTO tb_project(ModuleName,TaskDesc,Status,CompletionDate,CompletionTime,DateStarted)";
			$sql .= " VALUES ('$t1','$t2','$t3','$t4','$t5','$t6')";
			
			$result = mysql_query($sql);
			if(!$result){
				echo "<h4>Cannot Save Data. Please review Data.</h4>";
			}
		}
		
	}
	
	if(isset($_REQUEST['action'])){
		if($_REQUEST['action']=="del"){
			$t1 = $_REQUEST['num'];
			$sql  = "DELETE FROM tb_project WHERE ID = '$t1'";
			
			$result = mysql_query($sql);
			if(!$result){
				echo "<h4>Cannot Delete Data</h4>";
			}
		}
	}
?>
<html>
<head>
	<title>LAN project status - For viewing</title>
	
	<meta name="author" content="Dexter Grageda" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="robots" content="noindex,nofollow" />
	
	<script language="javascript" type="text/javascript">
		function confirmAdd()
		{
			var n;
			var msg;
			
			n = confirm("Submit New Data?");
			if(n==1){
				return true;
			}else{
				return false;
			}
		}		
	</script>
</head>
<body>
<form action="inputing.php" method="POST">
<table border="0" align="center">
<tr>
	<td colspan="6"><img src="components/com_jumi/files/_banner.jpg" align="center"/></td>
</tr>
<tr>
		<td bgcolor="#88ff88">Module name</td>
		<td bgcolor="#88ff88">Status</td>
		<td bgcolor="#88ff88">Completion date</td>
		<td bgcolor="#88ff88">Completion time</td>
		<td bgcolor="#88ff88">Date started</td>
		<td bgcolor="#88ff88">Task description</td>
</tr>
<tr>
		<td><input type="text" name="tModuleName" /></td>
		<td><input type="text" name="tStatus" size="10" /></td>
		<td><input type="text" name="tCompletionDate" /></td>
		<td><input type="text" name="tCompletionTime" /></td>
		<td><input type="text" name="tDateStarted" /></td>
		<td>
			<textarea name="tTaskDescription">
			</textarea>
		</td>
</tr>
</table>
<table border="0" align="center">
<tr>
	<td><input type="submit" name="submit" value="Submit Data" onClick="return confirmAdd();" /></td>
	<td><input type="reset" value="Reset" onClick="return confirm('Linisin ang lagayan?');" /></td>
</tr>
</table>
</form>

<hr color="#88ff88" />

<table border="0" align="center">
<tr>
		<td bgcolor="#88ff88">ID</td>
		<td bgcolor="#88ff88">Module name</td>
		<td bgcolor="#88ff88">Status</td>
		<td bgcolor="#88ff88">Completion date</td>
		<td bgcolor="#88ff88">Completion time</td>
		<td bgcolor="#88ff88">Date started</td>
		<td bgcolor="#88ff88" width="400">Task description</td>
</tr>
<?php
	$sql = "SELECT * FROM tb_project";
	$query = mysql_query($sql);
	while($row = mysql_fetch_array($query))
	{
?>
	<tr>
		<td bgcolor="#ff9944"><?php echo $row['ID'];?></td>
		<td><?php echo $row['ModuleName'];?></td>
		<td><?php echo $row['TaskDesc'];?></td>
		<td bgcolor="#568f57"><?php echo $row['Status'];?></td>
		<td><?php echo $row['CompletionDate'];?></td>
		<td><?php echo $row['CompletionTime'];?></td>
		<td><?php echo $row['DateStarted'];?></td>
		<td>
			<a href="?action=del&num=<?php echo $row['ID'];?>" onClick="return confirm('Tangalin and record?');">
			Delete
			</a>
		</td>
	</tr>
<?php
	}
?>
<tr>
		<td bgcolor="#88ff88" colspan="7">&nbsp;</td>
</tr>

</table><br /><br />
<a href="index_programs.php">Back</a>

</body>
</html>
<?php
	mysql_close($conn);
?>