<!--jscript-->
<script language="javascript" src="../jscript/chainedselects.js"></script>
<script language="javascript" src="../jscript/jquery.1.4.2.js"></script>

<?php


$table_name = $_SESSION['db_prefix']."_store_items";
$store_item_query = "SELECT store_item_id, item_name, unit FROM $table_name WHERE subCategory = 'Tiles' AND branch = '".$_SESSION['userbranch']."' ORDER BY item_name ASC";
	$store_item_result = execsql($store_item_query);
	$store_item_num = mysql_num_rows($store_item_result);
	$w = 0;
	$arrId2 = array ();
	$arrName2 = array ();
	while ($w < $store_item_num) {
		$arrId2[$w] = mysql_result($store_item_result, $w, "store_item_id");
		$arrName2[$w] = mysql_result($store_item_result, $w, "item_name");
		$w++;
	}
	
$table_name = $_SESSION['db_prefix']."_store_items";
$store_item_query = "SELECT store_item_id, item_name, unit FROM $table_name WHERE subCategory = 'Accessories'  AND branch = '".$_SESSION['userbranch']."' ORDER BY item_name ASC";
	$store_item_result = execsql($store_item_query);
	$store_item_num = mysql_num_rows($store_item_result);
	$w = 0;
	$arrId3 = array ();
	$arrName3 = array ();
	while ($w < $store_item_num) {
		$arrId3[$w] = mysql_result($store_item_result, $w, "store_item_id");
		$arrName3[$w] = mysql_result($store_item_result, $w, "item_name");
		$w++;
	}

?>

<script>
//var disable_empty_list=true; //uncomment this line to disable empty selection lists

addListGroup("Direct materials", "category0", "store_item_id_select", "items");
//addOption("category0", "", "", "", 1); //Empty starter option
addList("category0", "", "", "");
addList("category0", "Tiles", "Tiles", "Tiles");
addList("category0", "Accessories", "Accessories", "Accessories");

		addList("Tiles", "", "", "");
		<?php 
    	for ($w = 0; $w < count($arrId2); $w++) { ?>
			addList("Tiles", "<?php echo $arrName2[$w]?> ", "<?php echo $arrId2[$w]?> ", "");
		<?php
	    }
     ?>
		addList("Accessories", "", "", "");
		<?php 
        for ($w = 0; $w < count($arrId3); $w++) { ?>
			addList("Accessories", "<?php echo $arrName3[$w]?> ", "<?php echo $arrId3[$w]?> ", "");
		<?php
	    }
		?>
	
</script>

<script language="javascript">

initListGroup("Direct materials", form1.category0, form1.store_item_id_select); 

function initLists() {
  form1.category0.onchange();
  category0.fireEvent("onchange");
}

</script>
