<?php
	include ("../koneksi.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>PENTAWIRA Official Website</title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<link href="style.css" rel="stylesheet" type="text/css">
	</head>	
	<body>
		<center>
			<table width="800">
				<tr valign="top">
					<td width="162" class="bg">
						<?php include("kiri.php"); ?>
					</td>
					<td>
						<!-- Begin Kanan -->
						<table width="166">
							<tr height="28"><td></td></tr>
							<tr>
								<td align="right">
									<img src="images/LOGO_PENTA_putih.jpg" border="0"><br>
									<font size="3"><strong>WEBSITE BACKOFFICE</strong></font>
								</td>
							</tr>
						</table>
						<hr color="#EEEEEE" size="1">
						<table><tr height="9"><td></td></tr></table>
						<?php 
						@ $action = $_REQUEST["action"];
						if ($action=="add") {
							?>
							<table width="100%" cellpadding="5" cellspacing="0" border="0">
								<tr><td><strong>LINKS --> ADD NEW LINKS</strong></td></tr>
								<tr valign="top">
									<td>									
										<form method="post" action="proses.php" enctype="multipart/form-data" name="form1" onSubmit="return submitForm();">
											<table width="100%" cellpadding="3">
												<tr>
													<td width="11%">Url Name</td>
													<td width="2%">:</td>
													<td><input type="text" name="urlname" size="35"></td>
												</tr>
												<tr>
													<td>Url Address</td>
													<td>:</td>
													<td><input type="text" name="urladdress" size="35"></td>
												</tr>
												<tr>
													<td colspan="2"></td>
													<td>
														<input type="submit" value="Submit">
														<input type="button" value="Cancel" onclick="javascript:history.go(-1)">
														<input type="hidden" name="action" value="add">
														<input type="hidden" name="module" value="links">
													</td>
												</tr>
											</table>											
										</form>
									</td>
								</tr>
							</table>								
							<?php
						} else if ($action=="edit") {
							$id = $_REQUEST["id"];
							$query="select * from links where id='".$id."'";
							$hasil=mysql_query($query);												
							while($data=mysql_fetch_array($hasil)){	
								?>
								<table width="100%" cellpadding="5" cellspacing="0" border="0">
									<tr><td><strong>LINKS --> Edit Links</strong></td></tr>
									<tr valign="top">
										<td>									
											<form method="post" action="proses.php" enctype="multipart/form-data" name="form1" onSubmit="return submitForm();">
												<table width="100%" cellpadding="3">
													<tr>
														<td width="11%">Url Name</td>
														<td width="2%">:</td>
														<td><input type="text" name="urlname" size="35" value="<?php echo $data["urlname"];?>"></td>
													</tr>
													<tr>
														<td>Url Address</td>
														<td>:</td>
														<td><input type="text" name="urladdress" size="35" value="<?php echo $data["urladdress"];?>"></td>
													</tr>
													<tr>
														<td colspan="2"></td>
														<td>
															<input type="submit" value="Submit">
															<input type="button" value="Cancel" onclick="javascript:history.go(-1)">
															<input type="hidden" name="action" value="edit">
															<input type="hidden" name="module" value="links">
															<input type="hidden" name="id" value="<?php echo $data["id"];?>">
														</td>
													</tr>
												</table>											
											</form>
										</td>
									</tr>
								</table>															
								<?php
							}
						} else if ($action=="delete") {
							$id = $_REQUEST["id"];
							$query="select * from links where id='".$id."'";
							$hasil=mysql_query($query);												
							while($data=mysql_fetch_array($hasil)){	
								?>
								<table width="100%" cellpadding="5" cellspacing="0" border="0">
									<tr><td><strong>LINKS --> Delete Links</strong></td></tr>
									<tr valign="top">
										<td>									
											<form method="post" action="proses.php" enctype="multipart/form-data" name="form1" onSubmit="return submitForm();">
												Are you sure you want to delete the following data
												<table cellpadding="3" cellspacing="1" bgcolor="#666666">
													<tr bgcolor="#FFFFFF">
														<td>
															<table cellpadding="6">
																<tr>
																	<td>Url Name</td>
																	<td>:</td>
																	<td><?php echo $data["urlname"];?></td>
																</tr>
																<tr>
																	<td>Url Address</td>
																	<td>:</td>
																	<td><?php echo $data["urladdress"];?></td>
																</tr>
																<tr>
																	<td colspan="2"></td>
																	<td>
																		<input type="submit" value="&nbsp;&nbsp;Yes&nbsp;&nbsp;">
																		<input type="button" value="&nbsp;&nbsp; No &nbsp;&nbsp;" onclick="javascript:history.go(-1)">
																		<input type="hidden" name="action" value="delete">
																		<input type="hidden" name="module" value="links">
																		<input type="hidden" name="id" value="<?php echo $data["id"];?>">
																	</td>
																</tr>
															</table>
														</td>
													</tr>
												</table>											
											</form>
										</td>
									</tr>
								</table>																							
								<?php						
							}	
						} else {
							?>
							<table width="100%" cellpadding="5" cellspacing="0" border="0">
								<tr><td><strong>LINKS</strong></td></tr>
								<tr valign="top">
									<td>									
										<div align="right"><a href="links.php?menu=5&action=add"><strong>Add New Link(s)</strong></a></div>
										<table width="100%" cellpadding="6" cellspacing="1" bgcolor="#CCCCCC">
											<tr bgcolor="#EEEEEE">
												<td width="5%" align="center"><strong>ID</strong></td>
												<td width="40%"><strong>URL Name</strong></td>
												<td width="40%"><strong>URL Address</strong></td>
												<td width="15%" align="center"><strong>Action</strong></td>
											</tr>										
											<?php 
											if ($koneksi){
												@ $nomor = 0;
												$query="select * from links order by id";
												$hasil=mysql_query($query);												
												while($data=mysql_fetch_array($hasil)){													
													$nomor=$nomor+1;
													?>
													<tr bgcolor="#FFFFFF">
														<td align="center"><?php echo $nomor; ?> </td>
														<td><?php echo $data["urlname"]; ?> </td>
														<td><?php echo $data["urladdress"]; ?> </td>
														<td align="center">
															<a href="links.php?menu=5&action=edit&id=<?php echo $data["id"]; ?>">Edit</a>&nbsp;|&nbsp;
															<a href="links.php?menu=5&action=delete&id=<?php echo $data["id"]; ?>">Delete</a>
														</td>
													</tr>
													<?php
												}
											}	
											?>
										</table>
									</td>
								</tr>
							</table>								
							<?php
						}
						?>
						<!-- Begin Kanan -->
					</td>
				</tr>
			</table>
		</center>
	</body>
</html>	