<?php session_start();
	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 
						
						
						$select = "SELECT * FROM exhibitor_list ";
						if ($hasil = mysql_query($select)) {
							while ($data = mysql_fetch_array ($hasil )) {
								$sql2  = "SELECT * FROM exhibitor_list_hallstand 
								WHERE to_exhibitor_id = '" . $data["exhibitorID"] . "' ";
								
								if ($hasil2 = mysql_query($sql2)) {
									if (mysql_num_rows($hasil2) == 0) {
										$sql3  =  "
										INSERT INTO exhibitor_list_hallstand 
										(hallStandID, to_exhibitor_id, to_hall_id, standNumber)
										values (null, '".$data["exhibitorID"]."', '1', 123456)";
										if ($hasil3 = mysql_query($sql3)) {}									}
									
								}
								
							}	
						}
						
						$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 "<br>action: ".$action; 
						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 {
							echo '						
							<div style="display:block;">
								<div style="margin-top:15px"></div>
								<div style="float:left">
									<form name="Searchform" id="Searchform" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" onsubmit="return validate(this)" method="post">
										<strong>Company Name</strong>: <br>
										<input type="text" name="s_text" size="50">
										<input type="submit" name="s_submit" class="button1" value="Search">
									</form>
								</div>
							</div>
							<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="tabel40 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="tabel30 border-left padding10">
										<strong>Status Transaksi</strong>
									</div>
								</div>
							';

							if (isset ($_POST["s_text"])) {
								$s_text = $_POST["s_text"];
							}

							$sql  = 
							"SELECT * FROM exhibitor_list, kontak_dagang_tanggal ";
							
							if ($s_text) $sql .= "WHERE UPPER(companyName) like '%".strtoupper($s_text)."%' ";
							$sql .= "order by companyName, tglNAMA";
							
							$max = mysql_num_rows(mysql_query($sql));
							$perhalaman = 15;
							$page = $_SESSION['page'];
							if (!$page) $page = $_REQUEST["page"];
							if ($page){
								$start=($page - 1) * $perhalaman;
							} else {
								$start=0;
							}
							
							$sql  .= " LIMIT $start, $perhalaman";
							//echo "<br>sql: ".$sql;
							if ($hasil = mysql_query($sql)) {
								if (mysql_num_rows($hasil) > 0) {
									$counter = $start;
									echo '
									<form name="formManageForm" id="formManageForm" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" onsubmit="return validate(this)" method="post">';
										while ($data = mysql_fetch_array($hasil)) {
											$sql2 =
											"SELECT * FROM kontak_dagang_header ".
											"WHERE to_exhibitor_id = '".$data["exhibitorID"]."' ".
											"AND tgl_transaksi = '".$data["tglNAMA"]."' ";
											
											$StatusTransaksi = "Belum Ada";	
											$bgColor = "#ffcccc";	
											
											if ($hasil2 = mysql_query($sql2)) {
												if (mysql_num_rows($hasil2) > 0) {
													$StatusTransaksi = "Sudah Ada"; 
													$bgColor = "#ccffcc";	
												}
											}

											$counter++;
											echo '
											<div id="'.$data["exhibitorID"].'-'.$data["tglNAMA"].'-entryForm'.'" style="background-color:'.$bgColor.'" class="content-column border-right border-bottom border-left">
												<div class="tabel10 padding10 alignCenter">
													'.$counter.'
												</div>
												<div class="tabel40 border-left padding10">
													'.strtoupper($data["companyName"]).'
												</div>
												<div class="tabel20 border-left padding10" style="text-align:center">
													'.indonesian_date($data["tglNAMA"]).'
												</div>
												<div class="tabel30 border-left padding10">';
													echo $StatusTransaksi;
													echo '
												</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, "?");
							echo '
							</div>';
						}
						?>
					</td>
				</tr>
			</table>
		</center>
	</body>
</html>	