<?php
	include ("../koneksi.php");
	$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">
		<script language="JavaScript" type="text/javascript" src="richtext.js"></script>
		<script language="JavaScript" type="text/javascript">
		<!--
		function submitForm() {
			//make sure hidden and iframe value are in sync before submitting form
			//to sync only 1 rte, use updateRTE(rte)
			//to sync all rtes, use updateRTEs
			updateRTE('deskripsi');
			//updateRTEs();
			//alert("rte1 = " + document.RTEDemo.content.value);
			
			//change the following line to true to submit form
			return true;
		}
		
		//Usage: initRTE(imagesPath, includesPath, cssFile)
		initRTE("images/", "", "");
		//-->
		</script>		
	</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>ABOUT US --> ADD ABOUT US</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="text" name="title" size="35" value="<?php echo $data["title"];?>"></td>
												</tr>
												<tr valign="top">
													<td>Descriptions</td>
													<td>:</td>
													<td>
														<script language="JavaScript" type="text/javascript">
															<!--
																//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
																writeRichText('deskripsi', '<?php echo $deskripsi; ?>', 10, 300, true, false);
															//-->
														</script>															
													</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">														
													</td>
												</tr>
											</table>											
										</form>
									</td>
								</tr>
							</table>															
							<?php						
						} else if ($action=="edit") {
							$id = $_REQUEST["id"];
							$query="select * from about where id='".$id."'";
							$hasil=mysql_query($query);												
							while($data=mysql_fetch_array($hasil)){	
								$deskripsi=$data["deskripsi"];
								$deskripsi = str_replace("'", "&acute;", $deskripsi);	
								$deskripsi = str_replace(chr(13), "", $deskripsi);
								$deskripsi = str_replace(chr(10), "", $deskripsi);							
								?>
								<table cellpadding="5" cellspacing="0" border="0">
									<tr><td><strong>ABOUT US --> EDIT ABOUT US</strong></td></tr>
									<tr valign="top">
										<td bgcolor="#FFFFFF">									
											<form method="post" action="proses.php" enctype="multipart/form-data" name="form1" onSubmit="return submitForm();">
												<table cellpadding="3">
													<tr>
														<td width="11%">Title</td>
														<td width="2%">:</td>
														<td><input type="text" name="title" size="35" value="<?php echo $data["title"];?>"></td>
													</tr>
													<tr valign="top">
														<td>Descriptions</td>
														<td>:</td>
														<td>
															<script language="JavaScript" type="text/javascript">
																<!--
																	//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
																	writeRichText('deskripsi', '<?php echo $deskripsi; ?>', 10, 300, true, false);
																//-->
															</script>															
														</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">
															<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 about 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>ABOUT US --> DELETE ABOUT US</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>Title</td>
																	<td>:</td>
																	<td><?php echo $data["title"];?></td>
																</tr>
																<tr valign="top">
																	<td>Descriptions</td>
																	<td>:</td>
																	<td><?php echo $data["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">
																		<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>ABOUT US</strong></td></tr>
								<tr valign="top">
									<td>									
										<!-- <div align="right"><a href="about.php?menu=2&action=add"><strong>Add New About Us</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="25%"><strong>Title</strong></td>
												<td width="60%"><strong>Descriptions</strong></td>
												<td width="10%" align="center"><strong>Action</strong></td>
											</tr>										
											<?php 
											if ($koneksi){
												@ $nomor = 0;
												$query="select * from about 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><a href="about.php?menu=2&id=<?=$data["id"];?>" <?php if($data["id"]==$id) echo "id='active'"; ?> ><?php echo $data["title"]; ?></a></td>
														<td><?php echo strip_tags(substr(stripslashes($data["deskripsi"]),0,60))."..." ?></td>
														<td align="center">
															<a href="about.php?menu=2&action=edit&id=<?php echo $data["id"]; ?>">Edit</a> 
															<!-- 
															&nbsp;|&nbsp; 
															<a href="about.php?menu=2&action=delete&id=<?php //echo $data["id"]; ?>">Delete</a>
															-->
														</td>
													</tr>
													<?php
												}
											}	
											?>
										</table>
									</td>
								</tr>
								<?php 
								if($id) {
									?>
									<tr><td>&nbsp;</td></tr>
									<tr><td><strong>SUB ABOUT US</strong></td></tr>
									<tr>
										<td>
											<div align="right"><a href="about_detil.php?menu=2&action=add&parentid=<?=$id;?>"><strong>Add New Sub Gallery</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="10%" align="center"><strong>Status</strong></td>
													<td width="33%"><strong>Title</strong></td>
													<td width="37%"><strong>Descriptions</strong></td>
													<td width="15%" align="center"><strong>Action</strong></td>
												</tr>										
												<?php 
												if ($koneksi){
													@ $nomor = 0;
													$query="select * from about_detil where parent_id='".$id."' order by id desc";
													$hasil=mysql_query($query);												
													while($data=mysql_fetch_array($hasil)){													
														$nomor=$nomor+1;
														?>
														<tr bgcolor="#FFFFFF">
															<td align="center"><?php echo $nomor; ?> </td>
															<td align="center"><?php echo $data["stat"]; ?> </td>
															<td><a href="about_gambar.php?menu=2&parentid=<?=$id;?>&id=<?=$data["id"];?>"><?php echo $data["title"]; ?></a></td>
															<td><?php echo strip_tags(substr(stripslashes($data["deskripsi"]),0,45))."..." ?></td>
															<td align="center">
																<a href="about_detil.php?menu=2&action=edit&parentid=<?php echo $id; ?>&id=<?php echo $data["id"]; ?>">Edit</a>&nbsp;|&nbsp;
																<a href="about_detil.php?menu=2&action=delete&parentid=<?php echo $id; ?>&id=<?php echo $data["id"]; ?>">Delete</a>
															</td>
														</tr>
														<?php
													}
												}	
												?>
											</table>									
										</td>
									</tr>
									<?php
								}
								?>
							</table>								
							<?php
						}
						?>
						<!-- Begin Kanan -->
					</td>
				</tr>
			</table> <br><br>
		</center>
	</body>
</html>	