<!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/chainedselects.js"></script>
<script language="javascript" src="../jscript/jquery.1.4.2.js"></script>
<script language="JavaScript" src="../jscript/gen_validatorv4_2.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/alert_message.js"  type="text/javascript"></script>


<?php
include('../include/session.php');

$table_name = $_SESSION['db_prefix']."_product_store";
$product_item_query = "SELECT product_item_id, item_name, unit FROM $table_name WHERE subCategory = 'Sales product' ORDER BY item_name ASC";
	$product_item_result = $con->query($product_item_query);
	$product_item_num = mysqli_num_rows($product_item_result);
	$w = 0;
	$arrId2 = array ();
	$arrName2 = array ();
	while ($w < $product_item_num) {
		$row = mysqli_fetch_assoc($product_item_result);
		$arrId2[$w] = $row['product_item_id'];
		$arrName2[$w] = $row['item_name'];
		$w++;
	}
	
$table_name = $_SESSION['db_prefix']."_product_store";
$product_item_query = "SELECT product_item_id, item_name, unit FROM $table_name WHERE subCategory = 'Other product'  ORDER BY item_name ASC";
	$product_item_result = $con->query($product_item_query);
	$product_item_num = mysqli_num_rows($product_item_result);
	$w = 0;
	$arrId3 = array ();
	$arrName3 = array ();
	while ($w < $product_item_num) {
		$row = mysqli_fetch_assoc($product_item_result);
		$arrId3[$w] = $row['product_item_id'];
		$arrName3[$w] = $row['item_name'];
		$w++;
	}

?>


<style>
input.imagebutton{
	background-color:#E1E1E1;
	width: 100px;
	height: 24px;
	border:solid;
	border-width:1px;
	border-color:#12574E;
	cursor:pointer;
	color:#12574E;
	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:#12574E;
	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;
}

input.text100{
    background:#FFF;
    border: 1px solid #12574E;
    padding: 2px;
    width:100px;
	height:20px;
	color:#000;
}
input.text100:focus{
     border-color:#12574E;
}

select.select120{
    background:#FFF;
    border: 1px solid #12574E;
    padding: 2px;
    width:120px;
	height:24px;
	color:#000;
}
select.select120:focus{
     border-color:#12574E;
}
label.label_std{
	margin-left:5px;
    line-height:20px;
	padding-top:6px;
    color:#000;
    text-shadow:1px 1px 1px #fff;
    font:bold 12px Arial;
}
</style>



<script>
addListGroup("Direct materials", "category", "product_item_id_select", "items");
//addOption("category0", "", "", "", 1); //Empty starter option
addList("category", "", "", "");
addList("category", "Salt products", "Salt products", "Salt products");
addList("category", "Other products", "Other products", "Other products");


addList("Salt products", "", "", "");
		<?php 
    	for ($w = 0; $w < count($arrId2); $w++) { ?>
			addList("Salt products", "<?php echo $arrName2[$w]?> ", "<?php echo $arrId2[$w]?> ", "");
		<?php
	    }
     ?>
addList("Other products", "", "", "");
		<?php 
        for ($w = 0; $w < count($arrId3); $w++) { ?>
			addList("Other products", "<?php echo $arrName3[$w]?> ", "<?php echo $arrId3[$w]?> ", "");
		<?php
	    }
	?>

<?php

$order_reference = $_GET['order_reference'];
?>
</script>

<script language="javascript">
initListGroup("Direct materials", form1.category, form1.product_item_id_select); 

function initLists() {
  form1.category.onchange();
  category.fireEvent("onchange");
</script>

<script type="text/javascript">
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
</script>
</head>

<body onLoad="initListGroup('Direct materials', document.forms[0].category, document.forms[0].product_item_id_select);">
    
    <form action='order_edit_add_line_save.php' method="get" name="form1" target="_top" id="form1">
    <table width="430" border="0" align="left" cellpadding="0" cellspacing="0" class="list2" id="select_table">
      <tr>
        <td width="113">
          <div >
            <select name="category" id="category"  class="select120" style="width:115px;" >
            </select>
            <input type="hidden" name="index" id="index" />
          </div></td>
        <td width="200"><select name="product_item_id_select" id="product_item_id_select" class="select120" style="width:175px;" onchange="document.getElementById('qty_text').disabled = false"
              >
        </select>
        <input name="product_item_id" id="product_item_id" type="hidden" value="" /></td>
        <td width="117"><label class="label_std">Qty:</label>&nbsp;&nbsp;<input type="text" name="qty_text" id="qty_text" style="width:50px;" class="text100"  disabled="disabled"/></td>
       </tr>
    
    <tr>
      <td height="45" colspan="3" align="center">
        <input type="hidden" name="order_reference" id="order_reference"  value="<?php echo $order_reference ?>"/>
        <input name="add_button" id='add_button' type="submit" value="Add product" class="imagebutton" />
        <input name="button2" type="button" id="button2" class="imagebutton" onclick="MM_goToURL('parent','../store/edit_order.php?order_reference=<?php echo $order_reference ?>&e=0'); return document.MM_returnValue" value="Cancel" /></td>
    </tr>
  </table>
</form>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("qty_text","req","Please enter quantity."); 
</script>
</body>
</html>