	<script type="text/javascript" src="../functions/cleanhtml.js"></script>
	
	<?php	
	$tipe = $_REQUEST["tipe"];
	$regForm = $_REQUEST["regForm"];
	$idCities = $_REQUEST["id"];	
	if ($action=="add" || $action=="edit" || $action=="delete") {
		if ($regForm == "Submit Data") {
			$idCities = $_POST["idCities"];
			$namaCities = $_POST["namaCities"];
			
			if ($action=="add") {
				$query="insert into direktori_cities values(null, '$namaCities')";		
				// echo "<br>Query Add: ".$query."<br>";
				$hasil=mysql_query($query);
			} else if ($action=="edit") {				
				$query="update direktori_cities set namaCities='$namaCities' where idCities='$idCities' ";		
				$hasil=mysql_query($query);
			} else if ($action=="delete") {				
				$query="delete from direktori_cities where idCities='$idCities' ";		
				$hasil=mysql_query($query);
			}	
			
			$alamat  = '<script language=JavaScript>';
			$alamat .= ' location.href = "?menu='.$menu.'&tipe='.$tipe;
			$alamat .= ' "; ';
			$alamat .= '</script>';
			echo $alamat;
		} 
		else {
			if ($action=="edit" || $action=="delete") {
				$sql = "select * from direktori_cities where idCities='$idCities'";
				// echo $sql;
				if ($hasil = mysql_query($sql)) {
					while ($data = mysql_fetch_array($hasil)) {
						$idCities = $data["idCities"];
						$namaCities = $data["namaCities"];
					}
				}
			}			
			// echo "<br>Sql : ".$title."<br>";
			if ($action=="add" || $action=="edit") {
				?>
				<table width="100%" cellpadding="5" cellspacing="0" border="0">
					<tr><td><strong><?php echo strtoupper($nama_menu); ?> >> <?php echo strtoupper($action)." ".strtoupper($nama_menu); ?></strong></td></tr>
					<tr valign="top">
						<td>									
							<form method="post" action="<?php echo '?menu='.$menu.'&action='.$action;?>" enctype="multipart/form-data" name="form1" onSubmit="submitForm(); cleanHTML();">
								<table cellpadding="7" cellspacing="0" border="0" bgcolor="#999999">
									<tr bgcolor="#f6f6f6">
										<td width="150" align="right"><strong>Nama Kota</strong></td> 
										<td><input type="text" name="namaCities" value="<?php echo $namaCities;?>" size="76"></td>
									</tr>
									<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
									<tr bgcolor="#ffffff">
										<td align="center" colspan="2">
											<div id="spasi1"></div>
											<input type="submit" name="regForm" value="Submit Data">
											<input type="hidden" name="idCities" value="<?php echo $idCities; ?>">
											<input type="hidden" name="tipe" value="<?php echo $tipe; ?>">
											<div id="spasi1"></div>
										</td>
									</tr>
								</table>											
							</form>
						</td>
					</tr>
				</table>																													
				<?php
			} else if ($action=="delete") {
				?>
				<table width="100%" cellpadding="5" cellspacing="0" border="0">
					<tr><td><strong><?php echo strtoupper($nama_menu); ?> >> <?php echo strtoupper($action)." ".strtoupper($nama_menu); ?></strong></td></tr>
					<tr valign="top">
						<td>									
							<form method="post" action="<?php echo '?menu='.$menu.'&action='.$action;?>" enctype="multipart/form-data" name="form1" onSubmit="submitForm(); cleanHTML();">
								<table cellpadding="5" cellspacing="1" border="0" bgcolor="#999999">
									<tr bgcolor="#FFFFFF">
										<td align="center">
											<div style="padding:2px 0px 2px 0px; ">
												Hapus Data dibawah ini?
											</div>
											<table cellpadding="7" cellspacing="0" border="0" bgcolor="#999999">
												<tr bgcolor="#f6f6f6">
													<td width="150" align="right"><strong>Nama Kota </strong></td> 
													<td><input type="text" name="namaCities" value="<?php echo $namaCities;?>" size="76"></td>
												</tr>
												<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
												<tr bgcolor="#ffffff">
													<td align="center" colspan="2">
														<div id="spasi1"></div>
														<input type="submit" name="regForm" value="Submit Data">
														<input type="hidden" name="idCities" value="<?php echo $idCities; ?>">
														<input type="hidden" name="tipe" value="<?php echo $tipe; ?>">
														<div id="spasi1"></div>
													</td>
												</tr>
											</table>											
										</td>
									</tr>
								</table>
							</form>
						</td>
					</tr>
				</table>																													
				<?php
			}
		}
	} 
	else {
		?>
		<table width="100%" cellpadding="5" cellspacing="0" border="0">
			<tr><td><strong>MENU SELECTED >> <?php echo strtoupper($nama_menu); ?></strong></td></tr>
			<tr valign="top">
				<td>
					<div align="right">
						<div id="box" style="width:107px;" onClick="location='?menu=<?php echo $menu; ?>&tipe=<?php echo $tipe;?>&action=add'">
							<strong>Add New Data</strong>
						</div>
					</div>
					<table width="100%" cellpadding="6" cellspacing="1" bgcolor="#CCCCCC">
						<tr bgcolor="#EEEEEE">
							<td width="5%" align="center"><strong>ID</strong></td>
							<td><strong>Nama Kota</strong></td>
							<td width="15%" align="center"><strong>Action</strong></td>
						</tr>										
						<?php 
						if ($koneksi){
							$nomor = 0;
							$query="select * from direktori_cities ";
							if ($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["namaCities"]; ?></td>
										<td align="center">
											<a href="<?php echo "?menu=".$menu."&id=".$data["idCities"]."&action=edit&tipe=".$tipe; ?>">Edit</a>
											&nbsp; | &nbsp; 
											<a href="<?php echo "?menu=".$menu."&id=".$data["idCities"]."&action=delete&tipe=".$tipe; ?>">Delete</a>
										</td>
									</tr>
									<?php
								}
							}
						}	
						?>
					</table>
				</td>
			</tr>
		</table>				
		<?php	
	}
	?>