	<script type="text/javascript" src="../functions/cleanhtml.js"></script>
	<?php	
	include("../functions/tanggal_panjang.php");
	$tipe = $_REQUEST["tipe"];
	$regForm = $_REQUEST["regForm"];
	$idContent = $_REQUEST["id"];	
	if ($action=="add" || $action=="edit" || $action=="delete") {
		if ($regForm == "Submit Data") {
			?>
			<p></p>
			<div align="center">
				<img src="images/loading.gif" border="0"><br>
				<strong>Updating on progress</strong>. <br>
			</div>
			<p></p>
			<?php
			$transStartDate = $_POST["thn1"]."-".$_POST["bln1"]."-".$_POST["tgl1"];
			$transEndDate = $_POST["thn2"]."-".$_POST["bln2"]."-".$_POST["tgl2"];
			$transTitle = $_POST["transTitle"];
			$transVenue = $_POST["transVenue"];
			$transOrganizer = $_POST["transOrganizer"];
			$transOrganizer2 = $_POST["transOrganizer2"];
			$transEmail1 = $_POST["transEmail1"];
			$transEmail2 = $_POST["transEmail2"];
			$transWebsite = $_POST["transWebsite"];

			if ($action=="add") {
				$query="insert into agenda_trans values(null, '$transStartDate', '$transEndDate', '$transTitle', '$transVenue', '$transOrganizer', '$transOrganizer2', '$transEmail1', '$transEmail2', '$transWebsite')";		
				//echo "<br>Query Add: ".$query."<br>";
				if ($hasil=mysql_query($query)) {}
			} else if ($action=="edit") {				
				$query="update agenda_trans set transStartDate='$transStartDate', transEndDate='$transEndDate', transTitle='$transTitle', transVenue='$transVenue', transOrganizer='$transOrganizer', transOrganizer2='$transOrganizer2', transEmail1='$transEmail1', transEmail2='$transEmail2', transWebsite='$transWebsite'  ";		
				$query .= " where transID='$idContent' ";
				// echo "<br>".$query."<br>";
				if ($hasil=mysql_query($query)) {}
			} else if ($action=="delete") {				
				$query="delete from agenda_trans where transID='$idContent'";		
				// echo "<br>".$query."<br>";
				if ($hasil=mysql_query($query)) {}
			}	

			$alamat  = '<script language=JavaScript>';
			$alamat .= ' location.href = "?menu='.$menu.'&tipe='.$tipe;
			$alamat .= ' "; ';
			$alamat .= '</script>';
			echo $alamat;
		} 
		else {
			$sql = "select * from agenda_trans where transID = '$idContent'";
			//echo $sql;
			if ($hasil = mysql_query($sql)) {
				while ($data = mysql_fetch_array($hasil)) {
					$id = $data["transID"];
					$transStartDate = $data["transStartDate"];
					$tgl1 = date("d", strtotime($data["transStartDate"]));
					$bln1 = date("m", strtotime($data["transStartDate"]));
					$thn1 = date("Y", strtotime($data["transStartDate"]));
					
					$transEndDate = $data["transEndDate"];					$tgl2 = date("d", strtotime($data["transEndDate"]));
					$bln2 = date("m", strtotime($data["transEndDate"]));
					$thn2 = date("Y", strtotime($data["transEndDate"]));
					
					$transTitle = $data["transTitle"];
					$transVenue = $data["transVenue"];
					$transOrganizer = $data["transOrganizer"];
					$transOrganizer2 = $data["transOrganizer2"];
					$transEmail1 = $data["transEmail1"];
					$transEmail2 = $data["transEmail2"];
					$transWebsite = $data["transWebsite"];
				}
			}

			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 align="center">									
							<div><strong>Hapus Data Berikut ini? </strong></div>
							<form method="post" action="<?php echo '?menu='.$menu.'&action='.$action;?>" enctype="multipart/form-data" name="form1" onSubmit="submitForm(); cleanHTML();">
								<table width="500" cellpadding="7" cellspacing="1" border="0" bgcolor="#999999">
									<tr bgcolor="#FFFFFF">
										<td>
											<table width="100%" cellpadding="7" cellspacing="0" border="0" bgcolor="#999999">
												<tr bgcolor="#f6f6f6">
													<td width="150" align="right"><strong>Start Date</strong></td> 
													<td>
														<?php echo tanggal($transStartDate, $transEndDate); ?>
													</td>
												</tr>
												<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>								
												<tr bgcolor="#f6f6f6">
													<td align="right"><strong>Nama Event</strong></td>
													<td><?php echo $transTitle; ?></td>
												</tr>
												<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
												<tr valign="top" bgcolor="#f6f6f6">
													<td align="right"><strong>Venue Pameran</strong>s</td>
													<td><?php echo $transVenue; ?></td>
												</tr>
												<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
												<tr bgcolor="#f6f6f6">
													<td align="right"><strong>Nama Organizer</strong></td>
													<td>
														<?php
														$opsi = "";
														$ctr = 0;
														$query4="select * from direktori_trans where id='$transOrganizer' ";
														if ($hasil4 = mysql_query($query4)) {
															while ($data4=mysql_fetch_array($hasil4)) {
																echo ucwords($data4["nama"]);
															}
														}
														?>
													</td>
												</tr>
												<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
												<tr bgcolor="#f6f6f6">
													<td align="right"><strong>Nama Organizer 2</strong></td>
													<td>
														<?php
														$opsi = "";
														$ctr = 0;
														$query4="select * from direktori_trans where id='$transOrganizer2' ";
														if ($hasil4 = mysql_query($query4)) {
															while ($data4=mysql_fetch_array($hasil4)) {
																echo ucwords($data4["nama"]);
															}
														}
														?>
													</td>
												</tr>
												<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
												<tr bgcolor="#f6f6f6">
													<td align="right"><strong>Email 1</strong></td>
													<td><?php echo $transEmail1; ?></td>
												</tr>
												<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
												<tr bgcolor="#f6f6f6">
													<td align="right"><strong>Email 2</strong></td>
													<td><?php echo $transEmail2; ?></td>
												</tr>
												<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
												<tr bgcolor="#f6f6f6">
													<td align="right"><strong>Website Event</strong></td>
													<td><?php echo $transWebsite; ?></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="id" value="<?php echo $id; ?>">
														<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><?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>Start Date</strong></td> 
										<td>
											<select name="tgl1">
												<?php
												for($i=1; $i<=31; $i++) {
													?>
													<option <?php if ($tgl1==$i) echo " selected "; ?> value="<?php echo $i?>"><?php echo $i?></option>
													<?php
												}
												?>
											</select>
											<select name="bln1">
												<?php
												$nmbulan = array (
													1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'Mei', 6 => 'Jun', 7 => 'Jul', 8 => 'Agt', 9 => 'Sep', 10 => 'Okt', 11 => 'Nov', 12 => 'Des',
												);
												for($i=1; $i<=12; $i++) {
													?>
													<option <?php if ($bln1==$i) echo " selected "; ?> value="<?php echo $i?>"><?php echo $nmbulan[$i]?></option>
													<?php
												}
												?>
											</select>
											<select name="thn1">
												<?php
												$startDate = date("Y");
												$endDate = $startDate + 5;
												for($i=$startDate; $i<=$endDate; $i++) {
													?>
													<option <?php if ($thn1==$i) echo " selected "; ?> value="<?php echo $i?>"><?php echo $i?></option>
													<?php
												}
												?>
											</select>														
										</td>
									</tr>
									<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>								
									<tr bgcolor="#f6f6f6">
										<td width="150" align="right"><strong>End Date</strong></td> 
										<td>
											<select name="tgl2">
												<?php
												for($i=1; $i<=31; $i++) {
													?>
													<option <?php if ($tgl2==$i) echo " selected "; ?> value="<?php echo $i?>"><?php echo $i?></option>
													<?php
												}
												?>
											</select>
											<select name="bln2">
												<?php
												$nmbulan = array (
													1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'Mei', 6 => 'Jun', 7 => 'Jul', 8 => 'Agt', 9 => 'Sep', 10 => 'Okt', 11 => 'Nov', 12 => 'Des',
												);
												for($i=1; $i<=12; $i++) {
													?>
													<option <?php if ($bln2==$i) echo " selected "; ?> value="<?php echo $i?>"><?php echo $nmbulan[$i]?></option>
													<?php
												}
												?>
											</select>
											<select name="thn2">
												<?php
												$startDate = date("Y");
												$endDate = $startDate + 5;
												for($i=$startDate; $i<=$endDate; $i++) {
													?>
													<option <?php if ($thn3==$i) echo " selected "; ?> value="<?php echo $i?>"><?php echo $i?></option>
													<?php
												}
												?>
											</select>														
										</td>
									</tr>
									<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>								
									<tr bgcolor="#f6f6f6">
										<td align="right"><strong>Nama Event</strong></td>
										<td><input type="text" name="transTitle" value="<?php echo $transTitle; ?>" size="76"></td>
									</tr>
									<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
									<tr bgcolor="#f6f6f6">
										<td align="right"><strong>Venue Pameran</strong>s</td>
										<td><textarea cols="57" rows="5" name="transVenue"><?php echo $transVenue; ?></textarea></td>
									</tr>
									<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
									<tr bgcolor="#f6f6f6">
										<td align="right"><strong>Nama Organizer</strong></td>
										<td>
											<?php
											$opsi = "";
											$ctr = 0;
											$query4="select * from direktori_link_category, direktori_trans where linkTrans=id and linkCategory='2'";
											if ($hasil4 = mysql_query($query4)) {
												while ($data4=mysql_fetch_array($hasil4)) {
													if ($ctr == 0) {
														$opsi .= '<select name="transOrganizer" id="transOrganizer">';
														$opsi .= '	<option value="0"> Pilih Organizer </option>';
													}
													$opsi .= '<option value="'.$data4["id"].'" ';
													if ($transOrganizer == $data4["id"])
														$opsi .= ' selected ';
													$opsi .= '>'.ucwords($data4["nama"]);
													$opsi .= '</option>';
													$ctr++;
												}
												if ($ctr > 0) {
													$opsi .= '</select>';
													echo $opsi;
												}
											}
											?>
										</td>
									</tr>
									<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
									<tr bgcolor="#f6f6f6">
										<td align="right"><strong>Nama Organizer 2</strong></td>
										<td>
											<?php
											$opsi = "";
											$ctr = 0;
											$query4="select * from direktori_link_category, direktori_trans where linkTrans=id and linkCategory='2'";
											if ($hasil4 = mysql_query($query4)) {
												while ($data4=mysql_fetch_array($hasil4)) {
													if ($ctr == 0) {
														$opsi .= '<select name="transOrganizer2" id="transOrganizer2">';
														$opsi .= '	<option value="0"> Pilih Organizer </option>';
													}
													$opsi .= '<option value="'.$data4["id"].'" ';
													if ($transOrganizer2 == $data4["id"])
														$opsi .= ' selected ';
													$opsi .= '>'.ucwords($data4["nama"]);
													$opsi .= '</option>';
													$ctr++;
												}
												if ($ctr > 0) {
													$opsi .= '</select>';
													echo $opsi;
												}
											}
											?>
										</td>
									</tr>
									<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
									<tr bgcolor="#f6f6f6">
										<td align="right"><strong>Email 1</strong></td>
										<td><input type="text" name="transEmail1" value="<?php echo $transEmail1; ?>" size="75"></td>
									</tr>
									<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
									<tr bgcolor="#f6f6f6">
										<td align="right"><strong>Email 2</strong></td>
										<td><input type="text" name="transEmail2" value="<?php echo $transEmail2; ?>" size="75"></td>
									</tr>
									<tr bgcolor="#f6f6f6"><td colspan="2"><div id="grs-lurus"></div></td></tr>
									<tr bgcolor="#f6f6f6">
										<td align="right"><strong>Website Event</strong></td>
										<td><input type="text" name="transWebsite" value="<?php echo $transWebsite; ?>" size="75"></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="id" value="<?php echo $id; ?>">
											<input type="hidden" name="tipe" value="<?php echo $tipe; ?>">
											<div id="spasi1"></div>
										</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 width="20%"><strong>Start Date</strong></td>
							<td width="20%"><strong>End Date</strong></td>
							<td><strong>Event Title</strong></td>
							<td width="15%" align="center"><strong>Action</strong></td>
						</tr>										
						<?php 
						if ($koneksi){
							$nomor = 0;
							$query="select * from agenda_trans order by transStartDate desc ";
							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 date("F  d,  Y", strtotime($data["transStartDate"])); ?></td>
										<td><?php echo date("F  d,  Y", strtotime($data["transEndDate"])); ?></td>
										<td><?php echo $data["transTitle"]; ?></td>
										<td align="center">
											<a href="<?php echo "?menu=".$menu."&id=".$data["transID"]."&action=edit&tipe=".$tipe; ?>">Edit</a>
											&nbsp; | &nbsp; 
											<a href="<?php echo "?menu=".$menu."&id=".$data["transID"]."&action=delete&tipe=".$tipe; ?>">Delete</a>
										</td>
									</tr>
									<?php
								}
							}
						}	
						?>
					</table>
				</td>
			</tr>
		</table>				
		<?php	
	}
	?>