    <?php
	$idEvent = "CompletingForm";
	$kontak_dagang_header = kontak_dagang_header($exhibitorID, $idEvent);
	//echo "exhibitorID: ".$exhibitorID;
	echo '
	<form name="formSubmit" id="formSubmit" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" method="post">
		<input type="hidden" name="action" id="action" value="entryForm" />
	</form>';
	if ($kontak_dagang_header["sql_insert"]) {
		if (mysqli_query($conn, $kontak_dagang_header["sql_insert"])) {
			echo '
			<script type="text/javascript">
				document.getElementById(\'formSubmit\').submit(); 
			</script>';
		} else {
			die(mysqli_errno($conn) . ": " . mysqli_error($conn) . "\n");	
		}
	}
	
	//var_dump($kontak_dagang_header);	
	
	$tgl_transaksi = $kontak_dagang_header["tgl_transaksi"];
	$header_id = $kontak_dagang_header["header_id"];
	//echo "<br>header_id: ".$header_id;	
	
	//echo "<br>header_id: ".$header_id;
	
	
	
	$button_label = "Input Kelengkapan Data";
	if ($tglNAMA ==  $tgl_transaksi) {
		$button_label = "Edit Kelengkapan Data";
	}
	?>
    
    <?php
	echo '
	<br>
	<div class="tabel font15">
		<div style="padding-bottom:7px">
			<strong>'.strtoupper("Data Perusahaan").'</strong>
		</div>
		<div class="content-column nopointer border-top border-bottom border-left border-right" style="margin-top:0">
			<div class="tabel25 padding10 alignCenter">
				<strong>Nama Exhibitor</strong>
			</div>
			<div class="tabel75 border-left padding10">
				'.strtoupper($kontak_dagang_header["companyName"]).'
			</div>
		</div>	
		<div class="content-column nopointer border-bottom border-left border-right">
			<div class="tabel25 padding10 alignCenter">
				<strong>Tanggal Transaksi</strong>
			</div>
			<div class="tabel75 border-left padding10">
				'.indonesian_date($tglNAMA).'
			</div>
		</div>';
		echo '
	</div>';
	//echo "header_id: ". $header_id;
	if ($header_id) {
		$button_label = 'Add New Record';
		echo '
			<div style="margin-top:30px;"></div>
			<div class="tabel font15">
				<div style="padding-bottom:7px; display:block;">
					<div style="display:inline-block; float:left">
						<strong>'.strtoupper("Data Komtak Dagang").'</strong>
					</div>
					<div style="display:inline-block; float:right">
						<form name="formNewTransaction" id="formNewTransaction" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" onsubmit="return validate(this)" method="post">
							<div id="submitformNewTransaction" class="hvr-sweep-to-right" style="padding:10px 30px; cursor:pointer;">
								<font style="color:#ffffff; text-align:center"	>
									Add New Record
								</font>
							</div>
							<input type="hidden" name="action" id="action" value="'.$button_label.'" />
							<input type="hidden" name="tglNAMA" id="tglNAMA" value="'.$tglNAMA.'"/>
							<input type="hidden" name="exhibitorID" id="exhibitorID" value="'.$exhibitorID.'"/>
							<input type="hidden" name="button_label" id="button_label" value="'.$button_label.'"/>
							<input type="hidden" name="header_id" id="header_id" value="'.$header_id.'" />
						</form> 
					</div>
				</div>
				<div class="content-column nopointer border-top border-bottom border-left border-right" style="background-color:#666666; color:#ffffff;">';
					//echo '
					//<div class="tabel5 padding10 alignCenter">
						//<strong>No</strong>
					//</div>';
					$col1 = 'tabel20'; $col2 = 'tabel20'; $col3 = 'tabel20'; $col4 = 'tabel5';
					$col5 = 'tabel5';  $col6 = 'tabel15'; $col7 = 'tabel15'; 
					if ($_SESSION['username'] == 'super') {
						echo '
						<div class="'.$col1.' padding10 border-left" style="border-color:#ffffff">
							<strong>Negara</strong>
						</div>
						<div class="'.$col2.' padding10 border-left" style="border-color:#ffffff">
							Jenis Transaksi
						</div>
						<div class="'.$col3.' padding10 border-left" style="border-color:#ffffff">
							<strong>Produk</strong>
						</div>
						<div class="'.$col4.' padding10 border-left alignCenter" style="border-color:#ffffff">
							<strong>R</strong>
						</div>
						<div class="'.$col5.' padding10 border-left alignCenter" style="border-color:#ffffff">
							<strong>P</strong>
						</div>
						<div class="'.$col6.' padding10 alignRight border-left" style="border-color:#ffffff">
							<strong>Total($)</strong>
						</div>';
					} else {
						$col1 = 'tabel20'; $col2 = 'tabel25'; $col3 = 'tabel20'; $col4 = 'tabel20';
						echo '
						<div class="'.$col1.' padding10 border-left" style="border-color:#ffffff">
							<strong>Negara</strong>
						</div>
						<div class="'.$col2.' padding10 border-left" style="border-color:#ffffff">
							Jenis Transaksi
						</div>
						<div class="'.$col3.' padding10 border-left" style="border-color:#ffffff">
							<strong>Produk</strong>
						</div>
						<div class="'.$col4.' padding10 alignRight border-left" style="border-color:#ffffff">
							<strong>Total($)</strong>
						</div>';
					}
					
					echo '
					<div class="'.$col7.' padding10 alignCenter border-left" style="border-color:#ffffff">
						<strong>Action</strong>
					</div>
				</div>';
				$ctr = 0;
				$total = 0;
				$sql = 
				"SELECT * FROM kontak_dagang_transaksi " .
				"WHERE to_kontak_dagang_header = '".$header_id."'";
				//echo $sql;
				if ($hasil = mysqli_query($conn, $sql)) {					
					echo '
					<form name="formKontakDagang" id="formKontakDagang" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" method="post">';
					while ($data = mysqli_fetch_array($hasil)) {
						$ctr++;
						if ($ctr % 2 == 0) 
							$bg = '#ffffff';
						else 
							$bg = '#e6e6e6';
						echo '
						<div style="cursor:default; background-color:'.$bg.'" class="content-column border-right border-bottom border-left">';
							//<div class="tabel5 padding10 alignCenter">
								//'.$ctr.'
							//</div>';
							if ($_SESSION['username'] == 'super') {
								$col1 = 'tabel20'; $col2 = 'tabel20'; $col3 = 'tabel20'; $col4 = 'tabel5';
								echo '
								<div class="'.$col1.' padding10 border-left">';
									FindData($data["to_negara"], "form_element_value", $dataTitle, $dataRecord);
									echo $dataRecord;
									echo '
								</div>
								<div class="'.$col2.' padding10 border-left">';
									if ($data["jn_trans"]) {
										FindData($data["jn_trans"], "form_element_value", $dataTitle, $dataRecord);
										echo $dataRecord;
									} else {
										echo 'N/A';
									}
									echo '
								</div>
								<div class="'.$col3.' padding10 border-left">';
									FindData($data["product_sub_category"], "form_element_value", $dataTitle, $dataRecord);
									echo $dataRecord;
									echo '	
								</div>
								<div class="'.$col4.' padding10 border-left alignCenter" style="border-color:#ffffff">
									'.($data["remark"] ? "1" : "0").'
								</div>
								<div class="'.$col5.' padding10 border-left alignCenter" style="border-color:#ffffff">
									'.($data["pic"] ? "1" : "0").'
								</div>
								<div class="'.$col6.' padding10 alignRight border-left">
									'.number_format($data["estimasi_kontrak"], 2) . '
								</div>';
							} else {
								$col1 = 'tabel20'; $col2 = 'tabel25'; $col3 = 'tabel20'; $col4 = 'tabel20';
								echo '
								<div class="'.$col1.' padding10 border-left">';
									FindData($data["to_negara"], "form_element_value", $dataTitle, $dataRecord);
									echo $dataRecord;
									echo '
								</div>
								<div class="'.$col2.' padding10 border-left">';
									if ($data["jn_trans"]) {
										FindData($data["jn_trans"], "form_element_value", $dataTitle, $dataRecord);
										echo $dataRecord;
									} else {
										echo 'N/A';
									}
									echo '
								</div>
								<div class="'.$col3.' padding10 border-left">';
									FindData($data["product_sub_category"], "form_element_value", $dataTitle, $dataRecord);
									echo $dataRecord;
									echo '	
								</div>
								<div class="'.$col4.' padding10 alignRight border-left">
									'.number_format($data["estimasi_kontrak"], 2) . '
								</div>';
							}
							echo '
							<div class="tabel15 padding10 alignCenter border-left">
								<a id="'.$data["transaksiID"].'-kontakDagang'.'" style="cursor:pointer;"> 
									Edit
								</a>
								&nbsp; | &nbsp;
								<a href="'.$thisPage.'adm1n/'.$curPage1.'?action12=deleteData&transaksiID='.$data["transaksiID"].'"> 
									Delete
								</a>
							</div>
						</div>';
						$total = $total + $data["estimasi_kontrak"];
					}
					if (mysqli_num_rows($hasil) > 0) {
						echo '
						<div class="content-column nopointer border-bottom border-left border-right" style="background-color:#999999; color:#ffffff;">
							<div class="tabel70 padding10 alignRight border-left">
								<strong>Total kontak dagang hari ini</strong>
							</div>
							<div class="tabel15 padding10 alignRight border-left" style="border-color:#ffffff">
								<strong>'.number_format($total, 2) . '</strong>
							</div>
							<div class="tabel20 padding10 alignRight border-right" style="border-color:#ffffff">
							</div>
						</div>';
					}
					
				}					
				echo '
					<input type="hidden" name="exhibitorID" id="exhibitorID" value="'.$exhibitorID.'"/>
					<input type="hidden" name="header_id" id="header_id" value="'.$header_id.'" />
					<input type="hidden" name="transaksiID" id="transaksiID" value="'.$transaksiID.'" />
				</form>
			</div>
		<p>&nbsp;</p>		
		';
	}
	?>
	
