<!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" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="popup.css" />
<script language="JavaScript" src="gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>

<style>
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>

<?php

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


$store_item_id = $_GET['store_item_id'];
$field =$_GET['field'];


$table_name = $_SESSION['db_prefix']."_store_items";
$item_query = "SELECT $field FROM $table_name WHERE store_item_id ='".$store_item_id."' ";
$item_result = mySQL_query($item_query);
$value = mysql_result($item_result, 0, "$field");


if ($field=="supplier_id") {
$table_name = $_SESSION['db_prefix']."_suppliers";
$supplier_query = "SELECT account_name  FROM $table_name WHERE  supplier_id = '".$value."' ";
$supplier_result = mySQL_query($supplier_query);
$value2 = mysql_result($supplier_result, 0, "account_name");	
	
$table_name = $_SESSION['db_prefix']."_suppliers";
$suppliersQuery = "SELECT supplier_id, account_name FROM $table_name  ORDER BY account_name ASC";
	$suppliersResult = execsql($suppliersQuery);
	$suppliersNum = mysql_num_rows($suppliersResult);
	$w = 0;
	$arrId2 = array ();
	$arrName2 = array ();
	while ($w < $suppliersNum) {
		$arrId2[$w] = mysql_result($suppliersResult, $w, "supplier_id");
		$arrName2[$w] = mysql_result($suppliersResult, $w, "account_name");
		$w++;
	}
}


if ($field=="location") {
	 $table_name2 = $_SESSION['db_prefix']."_list_stores_location"; 
	$page_query = "SELECT item_name FROM $table_name2";
	$arrId2 = array ();
	$arrName2 = array ();
	$page_result = execsql($page_query);
	$page_num = mysql_num_rows($page_result);
	$b = 0;
	while ($b < $page_num) {
		$arrId2[$b] = mysql_result($page_result, $b, "item_name");
		$arrName2[$b] = mysql_result($page_result, $b, "item_name");
		$b++;
	}
}
	
	
if ($field=="class") { 
	$table_name2 = $_SESSION['db_prefix']."_list_timber_class"; 
	$page_query = "SELECT item_name FROM $table_name2";
	$arrId2 = array ();
	$arrName2 = array ();
	$page_result = execsql($page_query);
	$page_num = mysql_num_rows($page_result);
	$b = 0;
	while ($b < $page_num) {
		
		$arrId2[$b] = mysql_result($page_result, $b, "item_name");
		if ($arrId2[$b]=='No Value') { $arrId2[$b]='';}
		$arrName2[$b] = mysql_result($page_result, $b, "item_name");
		$b++;
	}
}

if ($field=="width") { 
	$table_name2 = $_SESSION['db_prefix']."_list_timber_width"; 
	$page_query = "SELECT item_name FROM $table_name2";
	$arrId2 = array ();
	$arrName2 = array ();
	$page_result = execsql($page_query);
	$page_num = mysql_num_rows($page_result);
	$b = 0;
	while ($b < $page_num) {
		$arrId2[$b] = mysql_result($page_result, $b, "item_name");
		$arrName2[$b] = mysql_result($page_result, $b, "item_name");
		$b++;
	}
}

if ($field=="depth") { 
	$table_name2 = $_SESSION['db_prefix']."_list_timber_depth"; 
	$page_query = "SELECT item_name FROM $table_name2";
	$arrId2 = array ();
	$arrName2 = array ();
	$page_result = execsql($page_query);
	$page_num = mysql_num_rows($page_result);
	$b = 0;
	while ($b < $page_num) {
		$arrId2[$b] = mysql_result($page_result, $b, "item_name");
		$arrName2[$b] = mysql_result($page_result, $b, "item_name");
		$b++;
	}
}

if ($field=="length") { 
	$table_name2 = $_SESSION['db_prefix']."_list_timber_length"; 
	$page_query = "SELECT item_name FROM $table_name2";
	$arrId2 = array ();
	$arrName2 = array ();
	$page_result = execsql($page_query);
	$page_num = mysql_num_rows($page_result);
	$b = 0;
	while ($b < $page_num) {
		$arrId2[$b] = mysql_result($page_result, $b, "item_name");
		$arrName2[$b] = mysql_result($page_result, $b, "item_name");
		$b++;
	}
}
	


//$value2 = $value;
?>
<script type="text/javascript">
function stopRKey(evt) {
  var evt = (evt) ? evt : ((event) ? event : null);
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
}
document.onkeypress = stopRKey;
</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)
}
//-->
</script>

</head>
<form action="../store/store_item_edit.php" method="get" name="form1" target="_top" id="form1">
<body onload="document.getElementById(;MM_callJS('document.getElementById(\'quantityText\').focus();')"editText").focus();">
<table width="290" border="0" align="center" cellpadding="0" cellspacing="0" class="list2">
  <tr>
    <td width="290" align="center"><p><label class="std">Edit the value and click "Edit"<br />
If you don't want to change, click "cancel"</label>
        <br />
        <br />
            
        </select>
        
        <select name="editText" class="selectbox160"  >
          <option value="<?php echo $value ?>"><?php echo $value ?></option>
          <option value="">No value</option>
      <?php
        	for ($j = 0; $j < count($arrId2); $j++) {
    		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
	}
?>
    </select>
        <input name="edit" type="hidden" id="edit" value="1"  />
    <input name="store_item_id" type="hidden" id="store_item_id" value="<?php echo $store_item_id ?>" />
    <input name="field" type="hidden" id="field" value="<?php echo $field ?>" />
    <br /></p></td>
  </tr>
  <tr>
    <td align="center">
      <input name="input" type="submit" value="Edit" class="imagebutton"  />
      <input name="button" type="button" class="imagebutton" id="button" onclick="MM_goToURL('parent','../store/store_item_edit.php?store_item_id=<?php echo $store_item_id ?>&edit=0');return document.MM_returnValue"  value="Cancel" /></form>
    </td>
  </tr>
</table>

<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("ProductSelect","req","Please select a product.");
  frmvalidator.addValidation("QuantityText","req","Please enter the quantity.");
    
    
    
   


  
</script>
</body>
</html>