	<?php
	$tmp = $thisUrl."adm1n/functions/php_functions.php";
	include ($tmp);
	
	echo '
	<script src="'.$thisPage.'adm1n/js/jquery.min.js"></script>';
	require_once ($thisUrl.'functions/form_creator.php');

	$id = $_REQUEST["id"];
    if ($id) {
		include ("exhibitor_list_detil.php");
	} else {
		$dis_produk = '';
		$ctr=0;
		$sql = "select * from exhibitor_list, exhibitor_list_products, form_element_sub, form_element_value
				where exhibitorID = exhibitor_id and product_category = elementSubID 
				and product_sub_category = valueID and elementSubID = elementSubParentID 
				";
		$search_text = $_REQUEST["search_text"];
		if ($search_text) {
			$sql .= "
			AND (UPPER(companyName) like '%".strtoupper($search_text)."%' 
			OR UPPER(elementSubDescription) like '%".strtoupper($search_text)."%' 
			OR UPPER(valueName) like '%".strtoupper($search_text)."%' 
			OR UPPER(product_name) like '%".strtoupper($search_text)."%' 
			OR UPPER(brandName) like '%".strtoupper($search_text)."%' 
			OR UPPER(products_detil) like '%".strtoupper($search_text)."%')";	
		}
		
		$max = mysql_num_rows(mysql_query($sql));
		$perhalaman = 9;
		$page = $_SESSION['page'];
		if (!$page) $page = $_REQUEST["page"];
		if ($page){
			$start=($page - 1) * $perhalaman;
		} else {
			$start=0;
		}
		
		
		$sql .= "order by companyName LIMIT $start, $perhalaman";
		//secho "<br>sql: ".$sql;
		if ($hasil = mysql_query($sql)) {
			if (mysql_num_rows($hasil)) {
				while ($data = mysql_fetch_array($hasil)) {
					if ($ctr%3 == 0) {
						if ($ctr>0) {
							$dis_produk .= '	
							</div>';
						}
						$dis_produk .= '
						<div style="margin:0; width:100%;">';	
					}			
					
					if ($ctr % 3 == 0) {
						$marginTable = "marginTable0";
					} else {
						$marginTable = "marginTable15";
					}
					
					$dis_produk .= '
					<div class="col l-col4 m-col12 s-col12 '.$marginTable.' " style="margin-bottom:15px; background-color:#f1f1f1; border-bottom:2px solid #999999;">
						<a href="'.$thisPage.$curPage.'?id='.$data["exhibitorID"].'" data-teaserId="M00601" title="">';
							$dis_produk .= '
							<div class="teaserTextBlock" style="text-align:center; padding-top:16px;">
								<div style="min-height:325px;">
									<div style="min-height:208px;">';
										$sql2 = "select * from exhibitor_list_products, exhibitor_list_image 
												where exhibitor_id='".$data["exhibitorID"]."' and listProductID = productID limit 0,1 ";
										//echo $sql2;		 
										if ($hasil2 = mysql_query($sql2)) {
											if (mysql_num_rows($hasil2)) {
												while ($data2 = mysql_fetch_array($hasil2)) {
													$imageName = $thisPage.'product_image/'.$data["exhibitorID"].'/'.$data2["productID"].'/'.$data2["imageName"];
														$dis_produk .= '
														<img style="max-height:168px;" src="'.$imageName.'" border="0" />';
												}
											} else {
												$dis_produk .= '
												<img style="max-height:188px;" src="'.$thisPage.'images/no-image-slide.png" border="0">';
											}
										}
									$dis_produk .= '
									</div>
									<div style="padding:0px 7px 0px 7px">
										<h3 style="line-height:normal">'.strtoupper($data["companyName"]).'</h3>
										<p>';
											$standNumber = '';
											$sql2 = "select * from exhibitor_list_hallstand, form_element_value where valueID = to_hall_id and to_exhibitor_id = '".$data["exhibitorID"]."'";
											if ($hasil2 = mysql_query($sql2)) {
												while ($data2 = mysql_fetch_array($hasil2)) {
													$standNumber .= '
													'.$data2["valueName"]."<br>";
													$standNumber .= '
													Stand '.$data2["standNumber"]."<br>";
												}
											}
											$dis_produk .= $standNumber;	
										$dis_produk .= '
										</p>
									</div>
								</div>';
								$dis_produk .= '
								<div align="center" style="margin:20px;">
									<div id="box-detail">view detail</div>
								</div>
							</div>
						</a>
					</div>'; 
					$ctr++;
				} $dis_produk .= '</div>';
			} else {
				$dis_produk = '
				<div class="col l-col12 m-col12 s-col12" style="background-color:#cccccc">
					<div class="teaserTextBlock" style="text-align:center; padding:16px 0px 16px 0px;">
						<p>Data not found.</p>
					</div>
				</div>
				';
			}
		}
		

		/** 
		echo '
		<form name="form" id="form" method="post" class="form" action="?" enctype="multipart/form-data" onsubmit="return validate(this)">
			<div class="col l-col12 m-col12 s-col12" style="margin:0; padding:7px 0px; background-color:#999999">
				<div class="col l-col5 m-col12 s-col12">
					<div class="styled-select grey" style="float:left;">
						<select id="search_category">
							<option value="">- Select -</option>
							<option value="1">Product Category</option>
							<option value="2">Product Sub Category</option>
							<option value="3">Hall Number</option>
							<option value="4">Company Name</option>
						</select>
					</div>	
				</div>
				<div class="col l-col7 m-col12 s-col12">
					<div id="sub_search_category" class="styled-select grey" style="float:left;">
						<select>
							<option value="">- Select -</option>
						</select>
					</div>
					<span class="icon" style="float:left; padding:6px 22px; background-color:#999999;"><i class="fa fa-search" style="color:#ffffff;"></i></span>
				</div>
			</div>
		</form />
		<div style="clear:both;height:20px"></div>
		';		
		**/
		echo '
		<form name="form" id="form" method="post" class="form" action="'.$thisPage.$curPage.'" enctype="multipart/form-data" onsubmit="return validate(this)">
			<div class="col l-col12 m-col12 s-col12" style="padding:17px 0px 0px 0px; background-color:#999999">
				<div class="col l-col5 m-col12 s-col12">
					<span class="icon" style="float:left; padding:6px 22px; background-color:#999999;"><i class="fa fa-search" style="color:#ffffff;"></i></span>
					<input type="text" name="search_text" id="search" style="margin-top:2px" placeholder="Search Company or Product" size="25">
					<div class="hide-for-medium-up"><br></div>
				</div>
				<div class="col l-col2 m-col12 s-col12" style="text-align:center">
					<input type="submit" class="button-search" name="action" value="Search">
				</div>
				<div class="col l-col5 m-col12 s-col12"></div>
			</div>
		</form />
		<div style="clear:both;height:20px"></div>
		';		


		echo $dis_produk;		
		echo '
		<div class="col l-col12 m-col12 s-col12" style="margin:0; width:100%;clear:both; background-color:#fff;">
			<div class="col l-col12 m-col12 s-col12">
				<div class="teasers">
					<div style="margin:15px 0px 30px 0px;">';
						$tmp = $thisUrl."functions/fungsi_paging.php";
						include($tmp);
						halaman($max, $perhalaman, 2, 'search_text='.$search_text.'&');
						echo '
					</div>
				</div>
			</div>
		</div>
		';
	}
    ?>
