<?php
	include ("../koneksi.php");
	$parentid = $_REQUEST["parentid"];
	$oldparentid = $_REQUEST["oldparentid"];
	$id = $_REQUEST["id"];
?>
<!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>
						<table><tr height="25"><td></td></tr></table>
						<?php 
						@ $action = $_REQUEST["action"];
						if ($action=="add") {
							?>
							<table width="100%" cellpadding="5" cellspacing="0" border="0">
								<tr><td><strong>ABOUT US GAMBAR --> ADD ABOUT US GAMBAR</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%">Title</td>
													<td width="2%">:</td>
													<td><input type="file"  name="gambar" size="15"></td>
												</tr>
												<tr valign="top">
													<td>Descriptions</td>
													<td>:</td>
													<td><textarea name="gambar_deskripsi" cols="56" rows="8"></textarea></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="about_gambar">
														<input type="hidden" name="parentid" value="<?=$parentid;?>">
														<input type="hidden" name="oldparentid" value="<?=$oldparentid;?>">
													</td>
												</tr>
											</table>											
										</form>
									</td>
								</tr>
							</table>								
							<?php
						} else if ($action=="edit") {
							$query="select * from about_gambar where id = ".$id." and parent_id = ".$parentid;
							$hasil=mysql_query($query);												
							while($data=mysql_fetch_array($hasil)){	
								?>
								<table width="100%" cellpadding="5" cellspacing="0" border="0">
									<tr><td><strong>ABOUT US DETAIL --> EDIT ABOUT US DETAIL</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 valign="top">
														<td width="11%">Title</td>
														<td width="2%">:</td>
														<td>
															<input type="file" name="gambar" value="<?=$data["gambar"];?>" size="25">
															<table cellpadding="0" cellspacing="2" border="0">
																<tr height="3"><td></td></tr>
																<tr><td><img src="../images/gallery/<?=$data["gambar"];?>" width="250" border="0"></td></tr>
															</table>
														</td>
													</tr>
													<tr valign="top">
														<td>Descriptions</td>
														<td>:</td>
														<td><textarea name="gambar_deskripsi" cols="56" rows="8"><?php echo $data["gambar_deskripsi"]; ?></textarea></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="about_gambar">
															<input type="hidden" name="parentid" value="<?=$parentid;?>">
															<input type="hidden" name="oldparentid" value="<?=$oldparentid;?>">
															<input type="hidden" name="id" value="<?=$data["id"];?>">
															<input type="hidden" name="oldgambar" value="<?=$data["gambar"];?>">
														</td>
													</tr>
												</table>											
											</form>
										</td>
									</tr>
								</table>															
								<?php
							}
						} else if ($action=="delete") {
							$query="select * from about_gambar where id = ".$id." and parent_id = ".$parentid;
							$hasil=mysql_query($query);												
							while($data=mysql_fetch_array($hasil)){	
								?>
								<table width="100%" cellpadding="5" cellspacing="0" border="0">
									<tr><td><strong>ABOUT US GAMBAR --> DELETE ABOUT US GAMBAR</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>Gambar</td>
																	<td>:</td>
																	<td><?php echo $data["gambar"];?></td>
																</tr>
																<tr valign="top">
																	<td>Descriptions</td>
																	<td>:</td>
																	<td><?php echo $data["gambar_deskripsi"];?></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="about_gambar">
																		<input type="hidden" name="parentid" value="<?=$parentid;?>">
																		<input type="hidden" name="oldparentid" value="<?=$oldparentid;?>">
																		<input type="hidden" name="id" value="<?php echo $data["id"];?>">
																		<input type="hidden" name="gambar" value="<?php echo $data["gambar"];?>">
																	</td>
																</tr>
															</table>
														</td>
													</tr>
												</table>											
											</form>
										</td>
									</tr>
								</table>																							
								<?php						
							}	
						} else {
							?>
							<table width="100%" cellpadding="5" cellspacing="0" border="0">
								<tr><td><strong>ABOUT US --> LIST GAMBAR</strong></td></tr>
								<tr>
									<td>
										<?php
										if ($koneksi){
											$query="select a.id, b.id, a.title as parent, b.title as child from about as a, about_detil as b
													where a.id=b.parent_id and a.id=".$parentid." and b.id=".$id."  order by a.id";
											$hasil=mysql_query($query);												
											while($data=mysql_fetch_array($hasil)){
												?>
												Gallery Location : <a href="about.php?menu=2&id=<?=$parentid;?>"><?=$data["parent"];?></a> --> <?=$data["child"];?>
												<?php
											}
										}											
										?>
									</td>
								</tr>
								<tr valign="top">
									<td>									
										<div align="right"><a href="about_gambar.php?menu=2&action=add&oldparentid=<?=$parentid;?>&parentid=<?=$id;?>"><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>Image Name</strong></td>
												<td width="40%"><strong>Descriptions</strong></td>
												<td width="15%" align="center"><strong>Action</strong></td>
											</tr>										
											<?php 
											if ($koneksi){
												@ $nomor = 0;
												$query="select * from about_detil as a, about_gambar as b 
												        where a.id=b.parent_id and a.id=".$id." order by a.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["gambar"]; ?> </td>
														<td><?php echo $data["gambar_deskripsi"]; ?> </td>
														<td align="center">
															<a href="about_gambar.php?menu=2&action=edit&oldparentid=<?=$parentid;?>&parentid=<?=$id;?>&id=<?=$data["id"];?>">Edit</a>&nbsp;|&nbsp;
															<a href="about_gambar.php?menu=2&action=delete&oldparentid=<?=$parentid;?>&parentid=<?=$id;?>&id=<?=$data["id"];?>">Delete</a>
														</td>
													</tr>
													<?php
												}
											}	
											?>
										</table>
									</td>
								</tr>
							</table>								
							<?php
						}
						?>
						<!-- Begin Kanan -->
					</td>
				</tr>
			</table>
		</center>
	</body>
</html>	