<?
session_start();
include("../opendb.php");
include("../test.php");

$re=mysqli_query($db,"select * from itemmaster where code='$code'");
$rerow=mysqli_fetch_array($re);

if($save)
{

$sql="update itemmaster set subgp='$subgp',pno='$pno',pname='$pname',unit='$unit',pcat='$pcat' where code='$code'";
mysqli_query($db,$sql) or die('Insert Err:'.mysqli_error());

print "<script> opener.document.location='itemmaster1.php?'; window.close()</script>";
return;
}
//$re=mysqli_query($db,"select * from configmaster");
//$row=mysqli_fetch_array($re);
?>
<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
th{background-color:steelblue;color:white}
</style>
<script>
this.resizeTo(750,180);
function valid()
{
 
 /*if(document.f1.tax.value.length<=0)
 {
   alert("Invalid Tax.");
   document.f1.tax.focus();
   return false;
 }*/

}
</script>

<center>
<table cellspacing=1 cellpadding=1 bgcolor=black>
<tr><td align=center bgcolor='white'>
<form name='f1' action='<?print $PHP_SELF?>' method='post' onSubmit="return valid()">
<input type=hidden name='code' value='<?print $code?>'>
<table cellspacing=1 cellpadding=3 >
<th colspan=4><font size=3>EDIT ITEM MASTER</th>
<tr><td>Sub Group</td><td><select name='subgp' size=1>
<option><?print $rerow[subgp]?></option>
<?
$sb=mysqli_query($db,"select subname from subgroupmaster where gname='$gp'");
while($sbrow=mysqli_fetch_array($sb))
{
print "<option>$sbrow[0]</option>";
}
?>
</select>
</td>
    
 <td>Part No. </td><td><input type=text name='pno'  size=20 value='<?print $rerow[pno]?>' readonly></td>
    </tr>
<tr><td>Part Name </td><td><input type=text name='pname'  size=20 value='<?print $rerow[pname]?>'></td>
    
<td>Unit </td><td><input type=text name='unit'  size=20 value='<?print $rerow[unit]?>'></td>
    </tr>
<tr><td>Part Category </td><td><input type=text name='pcat'  size=20 value='<?print $rerow[pcat]?>'></td>
    </tr>
<th colspan=4><input type=submit value='Save' name='save'> <input type=button value='Cancel' onClick=window.close()></td></tr>
</table>
</form>
</td></tr>
</table>
