<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  
<script language="JavaScript" src="../jscript/gen_validatorv4_2.js"  type="text/javascript" xml:space="preserve"></script>
<script language="javascript" src="../jscript/chainedselects.js"></script>
<script language="javascript"  src="../jscript/chainedselectconfig_receive.js"></script>
<script language="javascript"  src="../jscript/neg_number.js"></script>
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script> 

<?php

//include('../include/db.php');
include('../include/session.php');	


$category=$_GET['category'];
$sub_category=$_GET['sub_category'];
$type=$_GET['type'];

$table_name = $_SESSION['db_prefix']."_store_items";
$dropDownQuery = "SELECT store_item_id, item_name, unit, quantity FROM $table_name WHERE category= '".$category."' AND subCategory = '".$sub_category."' ORDER BY item_name ASC";

$dropDownResult = execsql($dropDownQuery);
	$num = mysql_num_rows($dropDownResult);
	$a = 0;
	$arrId = array ();
	$arrName = array ();
	while ($a < $num) {
		$arrId[$a] = mysql_result($dropDownResult, $a, "store_item_id");
		$arrName[$a] = mysql_result($dropDownResult, $a, "item_name");
		$arrUnit[$a] = mysql_result($dropDownResult, $a, "unit");
		$arrQuantity[$a] = mysql_result($dropDownResult, $a, "quantity");
		$a++;
	}
?>

<style>
label.label_std{
	margin-left:5px;
    line-height:20px;
	padding-top:6px;
    color:#000;
    text-shadow:1px 1px 1px #fff;
    font:bold 12px Arial;
}

input.imagebutton{
	background-color:#E1E1E1;
	width: 100px;
	height: 24px;
	border:solid;
	border-width:1px;
	border-color:#FB6808;
	cursor:pointer;
	color:#000000;
	font:bold 12px Arial;
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;
	-moz-box-shadow:0px 0px 0px #CCC;
	-webkit-box-shadow:0px 0px 0px #CCC;
	box-shadow:0px 0px 0px #CCC;
	
}

input.imagebutton:hover{
	background-color:#E4E4E4;
	width: 100px;
	height: 24px;
	border:solid;
	border-width:2px;
	border-color:#FB6808;
	cursor:pointer;
	color:#000000;
	font:bold 12px Arial;
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;
	-moz-box-shadow:5px 5px 5px #666;
	-webkit-box-shadow:5px 5px 5px #666;
	box-shadow:5px 5px 5px #666;
	
}
</style>


<script language="JavaScript">
    <!--
    function submitForm(){
         document.form1.mySubmit.click();
    }
    -->
</script>
</head>

<body onLoad="initListGroup('Direct materials', document.forms[0].category, document.forms[0].sub_category);<?php if ($category=='') { ?>MM_showHideLayers('select_table','','hide')<?php } else { ?> MM_showHideLayers('category_table','','hide', 'cancel_button','','hide'); <?php } ?> " >
<form action="job_supply_add.php" method="get" name="form1" target="_self" id="form1">
  <table width="450" border="0" align="left" cellpadding="0" cellspacing="0" class="list2"  id='category_table'>
    <tr>
      <td colspan="3" align="center"><label class="label_std">Select category and sub category:</label>        
      <label class="std">&nbsp;</label></td>
    </tr>
    <tr>
      <td width="160" height="29" align="center" valign="top"><select name="category" id="category" style="width:160px;" autofocus >
        <option value="<?php echo $category?>" selected="selected"><?php echo $category?></option >
      </select></td>
      <td width="181" align="center" valign="top"><select name="sub_category" id="sub_category" style="width:160px;" onchange="this.form.submit()" >
        <option value="<?php echo $sub_category?>" selected="selected"><?php echo $sub_category?></option>
        <input name="type" type="hidden" value="<?php echo $type?>" />
      </select>
      </td>
      <td width="107" align="center" valign="top"><input name="mySubmit" type="image" src="../images/continue_icon.gif"alt="" /></td>
    </tr>
    <tr>
      <td height="29" colspan="3" align="center" valign="top"><hr />
      <input name="button" type="button" id="button" class="imagebutton" onclick="<?php if ($type=='job') { ?>MM_goToURL('parent','../store/additionalOrderWizbase.php?p=2&amp;s=');<?php } ?><?php if ($type=='cash') { ?>MM_goToURL('parent','../store/supplyOrderWizbase.php?p=2&s=');<?php } ?>return document.MM_returnValue" value="Cancel" /></td>
    </tr>
    
    </table>
    </form>
    
    <form action=<?php if ($type=='job') { ?>'../store/additionalOrderWizbase.php?p=2&s='<?php } ?><?php if ($type=='cash') { ?>'../store/supplyOrderWizbase.php?p=2&s='<?php } ?> method="get" name="form2" target="_top" id="form2">
    <table width="450" border="0" align="left" cellpadding="0" cellspacing="0" class="list2" id="select_table">
    <tr>
      <td height="38" align="center"><span class="wizard_frame">
        <label class="label_std"><?php echo $category." --- ".$sub_category?></label>
        
        <select name="store_item_select" id="store_item_select" style="width:250px;"  >
          <option value=" " selected="selected"> </option>
          
          <?php
    	for ($i = 0; $i < count($arrId); $i++) {
		echo "<option value=" . "\"" . $arrId[$i] . "\"" . ">" . $arrName[$i] .'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'. $arrQuantity[$i] . "</option>";
		$_SESSION['productName'] = $arrName[$i];
		//foreach($arrId as $key=>$value){
			//echo "<option value=\"delivery.php?store_item_id=".$arrId[$i]."&cat=$cat&formEnabled2=1&date=$date" . "\"" . ">" . $arrName[$i] . "</option>";	
	    }
     ?>
        </select>
        <br />
        <br />
       
      </span></td>
    </tr>
    <tr>
      <td align="center"><label class="label_std">Quantity:</label>&nbsp;
  <input name="quantity_text" type="text" id="quantity_text"  onkeypress='return numbersOnly(this,event,false,true);' size="15" autocomplete="off"  />
      <br /><br />
      <?php if ($type=='job') { ?><label class="label_std">Reason:</label>&nbsp;<input type="text" name="reason_text" id="reason_text" maxlength="50" /><?php } ?></td>
      </tr>
    <tr>
      <td align="center"><br />
        <input name="next_add_button" id="next_add_button" type="submit" value="Next" class="imagebutton"  />
        <input name="finish_add_button" id='finish_add_button' type="submit" value="Finish" class="imagebutton"  />
        <input name="button2" type="button" id="button2" class="imagebutton" onclick="<?php if ($type=='job') { ?>MM_goToURL('parent','../store/additionalOrderWizbase.php?p=2&amp;s=');<?php } ?><?php if ($type=='cash') { ?>MM_goToURL('parent','../store/supplyOrderWizbase.php?p=2&amp;s=');<?php } ?>return document.MM_returnValue" value="Cancel" />
<input type="hidden" name="category" id="category" value="<?php echo $category?>" />
        <input type="hidden" name="sub_category" id="sub_category" value="<?php echo $sub_category?>" />
        <input type="hidden" name="p" id="p" value="2" />
      <input type="hidden" name="s" id="s" value="10" /></td>
    </tr>
  </table>
  <div align="center"></div>
</form>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form2");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("store_item_select","req","Please select an item.");
  frmvalidator.addValidation("quantity_text","req","Please enter quantity.");
  
</script>
</body>
</html>