<?php session_start();
	error_reporting(E_ERROR | E_WARNING | E_PARSE);
	include_once("../../functions/init.php"); 

	$tmp = $thisUrl."adm1n/functions/access.php";
	include ($tmp);

	$tmp = $thisUrl."adm1n/functions/koneksi.php";
	include_once ($tmp);

	$tmp = $thisUrl."functions/indonesian_date.php";
	include_once ($tmp);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<?php
		$tmp = $thisUrl."adm1n/functions/head_section.php";
		include ($tmp);
		?>
    </head>	
	<body>
    	<div class="se-pre-con"></div>
		<center>
			<table width="1024">
				<tr valign="top">
					<td width="207" class="bg">
						<?php 
						$tmp = $thisUrl."adm1n/functions/kiri.php";
						include ($tmp);
						?>
					</td>
					<td width="10"></td>
					<td width="807">
						<?php 
						$tmp = $thisUrl."adm1n/functions/logo.php";
						include ($tmp);
						
						$tmp = $thisUrl."adm1n/functions/getUrl.php";
						include ($tmp);
						
						$tmp = $thisUrl."adm1n/functions/php_functions.php";
						include ($tmp);

						//echo '<div>'.$txt_legend.'</div>';
						
						$tmp = $thisUrl."adm1n/functions/request_data.php";
						include ($tmp);
						//echo "tglNAMA: ".$tglNAMA;
						$action12 = (isset($_REQUEST["action12"]) ? $_REQUEST["action12"] : null);
						//echo "<br>action12: ".$action12; 
						//echo "<br>action: ".$action;

						if ($action12 == "deleteData") {
							echo '
							<form name="formSubmit" id="formSubmit" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" method="post">
								<input type="hidden" name="action" id="action" value="entryForm" />
							</form>';
							$transaksiID = $_REQUEST["transaksiID"];
							$sql = 
							"DELETE FROM kontak_dagang_transaksi WHERE transaksiID = ".$transaksiID;
							if (mysqli_query($conn, $sql)) {
								echo '
								<script type="text/javascript">
									document.getElementById(\'formSubmit\').submit(); 
								</script>';
							} else {
								die("Error: ".$sql);
							}							 
						} else if ($action == "entryForm") {
							include ("entry_Form.php");
						} else if ($action == "Edit Kelengkapan Data") {
							include ("edit_kelengkapan_data.php");
						} else if ($action == "Input Kelengkapan Data") {
							include ("input_kelengkapan_data.php");
						} else if ($action == "Add New Record") {
							include ("addnewrecord.php");
						} else if ($action == "viewKontakDagang") {
							include ("viewKontakDagang.php");
						} else if ($action == "Edit Transaction") {
							include ("EditKontakDagang.php");
						} else {
							echo '						
							<div style="display:block;">
								<div style="margin-top:15px; margin-bottom: 15px;">';									
									echo '
									<style>
										.cssForm {
											height: 188px;
										}
									</style>
								</div>
								<div style="float:left">
									<form name="Searchform" id="Searchform" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" onsubmit="return validate(this)" method="post">
										<table width="100&">
											<tr>
												<td>
													<select name="fromMonth">
														<option value=""> - Pilih - </option>';													
														foreach ($bulan as $key => $value) {
															$fromSelected = "";
															if($fromMonth) {
																if ($fromMonth == $value)
																$fromSelected = " selected ";
															} else{
																if ($month == $value)
																$fromSelected = " selected ";
															}
															echo '
															<option class="cssForm" "'.$fromSelected.'" value="'.$value.'">'.$key.'</option>';
														}
														echo '
													</select>
												</td>
												<td>
													<select name="fromDay">
														<option value=""> - Pilih - </option>';
														for($i=1; $i<=31; $i++) {
															$fromSelected = "";
															if($fromDay) {
																if ($fromDay == $i)
																	$fromSelected = " selected ";
															} else{
																if ($day == $i)
																	$fromSelected = " selected ";
															}
															echo '
															<option "'.$fromSelected.'" value="'.$i.'">'.sprintf('%02d', $i).'</option>';
														}
													echo '
													</select>									
												</td>
											</tr>
										</table>									
										<strong>Company Name</strong>: <br>
										<input type="text" name="s_text" size="50" value="'.$s_text.'">
										<input type="submit" name="s_submit" class="button1" value="Search">
									</form>
								</div>
							</div>';
							echo '
							<div style="clear:both; margin-top:15px">&nbsp;</div>
								<div class="tabel font15">
									<div class="head-column border-both">
										<div class="tabel10 padding10 alignCenter">
											<strong>No</strong>
										</div>
										<div class="tabel50 border-left padding10">
											<strong>Company Name</strong>
										</div>
										<div class="tabel20 border-left padding10" style="text-align:center">
											<strong>Tanggal Transaksi</strong>
										</div>
										<div class="tabel20 border-left padding10 alignCenter">
											<strong>Action</strong>
										</div>
									</div>';
									if ($s_text) {					
										$sql  = 
										" SELECT * FROM exhibitor_list ";
										//" WHERE tglNAMA = '".$data["tglNAMA"]."' ";
										if ($s_text) 
											$sql .= " WHERE UPPER(companyName) like '%".strtoupper($s_text)."%' ";
										$sql .= " order by companyName ";								
										//$max = mysqli_num_rows(mysqli_query($conn, $sql));
										//echo $sql; 
										$sql  .= " LIMIT $start, $perhalaman";
										//echo "<br>sql: ".$sql;
								
										if ($hasil = mysqli_query($conn, $sql)) {
											if (mysqli_num_rows($hasil) > 0) {
												if ($page){
													$start=($page - 1) * $perhalaman;
												} else {
													$start=0;
												}
												$counter = $start;
												//echo "<br>start: ".$start;
												echo '
												<form name="formManageForm" id="formManageForm" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" onsubmit="return validate(this)" method="post">';
													while ($data = mysqli_fetch_array($hasil)) {
														$sql2 =
														" SELECT * FROM kontak_dagang_header, kontak_dagang_transaksi ".
														" WHERE to_exhibitor_id = '".$data["exhibitorID"]."' ".
														" AND to_kontak_dagang_header = header_id ".
														" AND tgl_transaksi = '".$tglNAMA."' ";
														//echo $sql2;
														$StatusTransaksi = "Belum Ada";	
														$bgColor = "#ffcccc";	
												
														if ($hasil2 = mysqli_query($conn, $sql2)) {
															if (mysqli_num_rows($hasil2) > 0) {
																$StatusTransaksi = "Sudah Ada"; 
																$bgColor = "#ccffcc";	
															}
														}
												
														$counter++;
														//<div id="'.$counter.'-listCompany" style="background-color:'.$bgColor.'" class="content-column border-right border-bottom border-left">
														echo '
														<div id="'.$data["exhibitorID"].'-listCompany" style="background-color:'.$bgColor.'" class="content-column border-right border-bottom border-left">
															<div class="tabel10 padding10 alignCenter" style="vertical-align:middle;">
																'.$counter.'
															</div>
															<div class="tabel50 border-left padding10" style="vertical-align:middle;">
																'.strtoupper($data["companyName"]).'
															</div>
															<div class="tabel20 border-left padding10" style="vertical-align:middle; text-align:center">
																'.indonesian_date($tglNAMA).'													
															</div>
															<div class="tabel30 border-left padding10 alignCenter" style="vertical-align:middle;">';
																echo '
																'.$StatusTransaksi.'
															</div>
														</div>';
													}
												echo '
												</form>';
											}
										}
										echo '
									</div>';
									echo '	
									<div align="center" style="margin:15px 0px 35px 0px">';
										$tmp = $thisUrl."functions/fungsi_paging.php";
										include($tmp);
										halaman($max, $perhalaman, 3, "&s_text=$s_text&");
										echo '
									</div>';	
							}														
						}
						?>
					</td>
				</tr>
			</table>
		</center>
	</body>
</html>	