<?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."adm1n/functions/php_functions.php";
	include ($tmp);
	$tmp = $thisUrl."adm1n/functions/getUrl.php";
	include ($tmp);

	$sql  = "select * from exhibitor_list order by exhibitorID";
	$sql2 = "select distinct(country) from buyer_register";
	$maxCountry = mysql_num_rows(mysql_query($sql2));
	
	$max = mysql_num_rows(mysql_query($sql));

	$perhalaman = 15;
	$page = $_SESSION["page"];
	if ($page){
		$start=($page - 1) * $perhalaman;
	} else {
		$start=0;
	}
	
	$sql  .= " LIMIT $start, $perhalaman";
	
	if ($max > 0) {
		echo '
		<div id="tab-content-1">
			<h3>
				Exhibitor List
			</h3>
			<p>';
				echo '
				<div class="tabel font15">
					<div class="head-column border-both">
						<div class="tabel5 padding10 alignCenter">
							<strong>No</strong>
						</div>
						<div class="tabel60 border-left padding10">
							<strong>Company Name</strong>
						</div>
						<div class="tabel15 border-left padding10 alignCenter">
							<strong>Published</strong>
						</div>
						<div class="tabel20 border-left padding10 alignCenter">
							<strong>Action</strong>
						</div>
					</div>';
					$nomor = $start;
					if ($hasil = mysql_query($sql)) {
						while ($data = mysql_fetch_array($hasil)) {
							$nomor ++;
							$tablink  = 'onclick="';
							$tablink .= "location='".$thisPage.'adm1n/pages/registered-buyer/?regID='.$data["buyerRegID"]."'";
							$tablink .= '"';
							
							echo '
							<div '.$tablink.' class="content-column border-right border-bottom border-left">
								<div class="tabel5 padding10 alignCenter">
									'.$nomor.'
								</div>
								<div class="tabel60 border-left padding10">
									'.$data["companyName"].'
								</div>
								<div class="tabel15 border-left padding10 alignCenter">
									'.($data["isPosted"] == 0 ? "NO" : "YES").'
								</div>
								<div class="tabel20 border-left padding10 alignCenter">
									Delete
								';
									
								echo '	
								</div>
							</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>
				</div>
			</p>
		</div>
		<div id="tab-content-2">
			<h3>Exhibitor List - Add Record</h3>
			<p>
				Registered Buyer: '.$max.' <br>
				Number of Countries: '.$maxCountry.' <br>
			</p>
		</div>
		<div id="tab-content-3">
			<h3>Country List</h3>
			<p>';
			$sql3 = "select * from buyer_register, form_element_value where valueID=country order by country";
			$cek = 0;
			if ($hasil3 = mysql_query($sql3)) {
				$nomor=0;	
				$negara = array();
				while ($data3 = mysql_fetch_array($hasil3)) {
					if ($cek != $data3["country"]) {
						$sql4 = "select country from buyer_register where country=".$data3["country"];
						$max4 = mysql_num_rows(mysql_query($sql4));
						//$data[] = array('volume' => 67, 'edition' => 2);
						$negara[] = array('nmNegara' => $data3["valueName"], 'jmNegara' => $max4);
						$cek = $data3["country"];
					}
				}
				foreach ($negara as $key => $row) {
					$nmNegara[$key] = $row['nmNegara'];
					$jmNegara[$key] = $row['jmNegara'];
				}											
				array_multisort($jmNegara, SORT_DESC, $nmNegara, SORT_ASC, $negara);
				//echo "max4 : ".$nmNegara;
				
				echo '
				<table width="100%" cellpadding="5" cellspacing="1" bgcolor="#666666" border="0">
					<tr bgcolor="#e6e6e6">
						<td align="center"><strong>No</strong></td>
						<td><strong>Nama Negara</strong></td>
						<td align="center"><strong>Jumlah</strong></td>
					</tr>';
					foreach ($negara as $key => $value) {
						$nomor++;
						echo '
						<tr bgcolor="#ffffff">
							<td align="center">'.$nomor.'</td>
							<td>'.$value["nmNegara"].'</td>
							<td align="center">'.$value["jmNegara"].'</td>
						</tr>';
					}
					echo '
				</table>';
			}
			echo '
			</p>
		</div>';
	} 
	?>
