<?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);
?>
<!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>';
						
						$action = (isset($_POST["action"]) ? $_POST["action"] : isset($_REQUEST["action"]) ? $_REQUEST["action"] : null);
						$s_text = (isset($_POST["s_text"]) ? $_POST["s_text"] : isset($_REQUEST["s_text"]) ? $_REQUEST["s_text"] : null);
						$elementSubID = (isset($_POST["elementSubID"]) ? $_POST["elementSubID"] : isset($_REQUEST["elementSubID"]) ? $_REQUEST["elementSubID"] : null);

						//$action = (isset($_POST["action"]) ? $_POST["action"] : isset($_REQUEST["action"]) ? $_REQUEST["action"] : null);
						//echo "<br> Action: ".$action;
						
						//$exhibitorID = (isset($_POST["exhibitorID"]) ? $_POST["exhibitorID"] : null);
						//$action = $_POST["action"];
						
						if ($action == "addRecord"){
							include ("add_record.php");
						} else if ($action == "Manage Company Info"){
							include ("edit_record.php");
						} else if ($action == "addProduct" || $action == "editProduct"){
							include ("add_product.php");	
						} else if ($action == "delete"){
						} else {
							$addRecord = "location='?action=addRecord'";
							echo '						
							<div style="display:block;">
								<div style="margin-top:20px"></div>
								<div style="float:left">
									<form name="form" id="form" class="form" action="'.$thisPage.'adm1n/pages/product-list/" method="post">
										<strong>Product Category</strong>: <br>
										<input type="text" name="s_text" size="50" value="'.(isset($_POST["s_text"]) ? $_POST["s_text"] : "").'">
										<input type="hidden" name="action" id="action" value="search" />
										<input type="submit" name="s_submit" class="button1" value="Search">
									</form>
								</div>
								<div style="float:right">
									<div style="margin-top:12px"></div>
									<div  style="margin:0;" id="tab1" class="button" onClick="'.$addRecord.'">
										ADD PRODUCT\'S CATEGORY
									</div>
								</div>
							</div>
							<div style="clear:both; margin-top:15px">&nbsp;</div>
							<table width="100%" cellpadding="10" cellspacing="1" border="0" bgcolor="#222222">
								<tr bgcolor="#DDDDDD">
									<td width="5%" align="center"><strong>NO</strong></td>
									<td width="35%"><strong>PRODUCT\'S CATEGORY</strong></td>
									<td width="40%"><strong>PRODUCT\'S SUB CATEGORY</strong></td>
									<td width="20%" align="center"><strong>ACTION</strong></td>
								</tr>';
								
								/** 
								$sql  = 
								" SELECT * FROM form_element_link, form_element_sub, form_element_value " .
								" WHERE linkDesignID = '41' AND linkElementSubID = elementSubID ".
								" AND elementSubID = elementSubParentID ";
								if ($action=="search") {
									$sql .= 
									" AND UPPER(elementSubDescription) like '%".strtoupper($_POST["s_text"])."%' " .
									" OR UPPER(valueName) like '%".strtoupper($_POST["s_text"])."%' ";
								}
								$sql .= 
								" ORDER BY elementSubID DESC ";
								**/
								
								$sql = 
								" SELECT * FROM form_element_link, form_element_sub " .
								" WHERE linkDesignID = '41' AND linkElementSubID = elementSubID ";
								if ($action=="search") {
									$sql .= 
									" AND UPPER(elementSubDescription) like '%".strtoupper($_POST["s_text"])."%' ";
								}
								$sql .= 
								" ORDER BY elementSubDescription ASC ";
								
								$max = mysql_num_rows(mysql_query($sql));
								$perhalaman = 15;
								$page = (isset($_SESSION['page']) ? $_SESSION['page'] : (isset($_REQUEST["page"]) ? $_REQUEST["page"] : null));
								//$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)) {
									$counter = $start;
									while ($data = mysql_fetch_array($hasil)) {
										$counter++;
										$addProduct  = 'onclick="';
										$addProduct .= "location='?action=addProduct&elementSubID=".$data["elementSubID"]."'";
										$addProduct .= '"';
										echo '
										<tr valign="top" bgcolor="#FFFFFF">
											<td align="center">'
												.$counter.'
											</td>
											<td>
												'.strtoupper($data["elementSubDescription"]).'
											</td>
											<td>
												'.FindDataRepeatProdukList("form_element_value", "elementSubParentID", $data["elementSubID"], "").'
											</td>
											<td align="center">
												<div style="cursor:pointer;" '.$addProduct.'>
													Edit Sub Category
												</div>
											</td>
										</tr>';
									}
								}
								echo '
							</table> 
							<div align="center" style="margin:30px 0px">';
								$tmp = $thisUrl."functions/fungsi_paging.php";
								include($tmp);
								halaman($max, $perhalaman, 3, "?");
								echo '
							</div>';
						}
						?>
					</td>
				</tr>
			</table>
		</center>
	</body>
</html>	