<?
include_once('includes/top.php');
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}

?>
<html>
<body >

<?

if(isset($_POST['save']))
{
			$code=$_REQUEST['code'];
			$gname=$_REQUEST['gname'];
			$subname=$_REQUEST['subname'];
	$code=substr($subname,0,3).substr(time(),7,3).date("s"); 
	$code=str_replace(' ','-',$code);
	$sql="insert into subgroupmaster(code,gname,subname) values('$code','$gname','$subname')";
	mysqli_query($db,$sql) or die('Insert Err:'.mysqli_error($db));
	print "<script> document.location='subgrmaster.php'</script>";
	return;
}
?>
<title>Xpress</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="scripts/jquery-latest.js"></script>
<link type="text/css" href="includes/style1.css" rel="stylesheet" />
<link type="text/css" href="css/form.css" rel="stylesheet" />
<script type="text/javascript">
        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        });        
    </script>
<script>
function valid()
{
}
</script>
<style>
#txt{
font-family: Arial, Helvetica;
background-color: #F2F2F2;

}
table.form{
font-weight: normal;
} 
</style>
<body background="back_ground.jpg">
<?php //include('includes/top.php'); ?>
<form name='f1' action='<?print $PHP_SELF?>' onSubmit="return valid()" method='post'> 
<table class="container"><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;">  &nbsp;&nbsp;Master >>  Sub Group Master</font>
<br>
<style>
th{background-color:steelblue;color:white}

#pg{
       text-decoration:none;
}
#pg button{
       background-color:#3b5998;
}
</style>
<script>
function valid()
{
 
 if(document.f1.subname.value.length<=0)
 {
   alert("Invalid sub group name.");
   document.f1.subname.focus();
   return false;
 }

}

var stax=[];

function settax()
{
  var x= document.f1.gname.selectedIndex ; 
  if(x>0)
	
    document.f1.tax.value=stax[document.f1.gname.selectedIndex];
   else
    document.f1.tax.value='';
}
function pgnfn(str){
            document.getElementById('pgbtn'+str).style.background = "#ccc";
}
</script>
<?
$xx=$_GET['id']+1;
?>
<body onload='getdata(1)'>

<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()">
<table cellspacing=1 cellpadding=3 width='350' class=form>
<th colspan=2><font size=3>SUB GROUP MASTER</th>
<tr><td>Group </td><td><select name='gname' size=1 onchange='getdata(this.value)' >
<option></option>
<?
$gp=mysqli_query($db,"select * from groupmaster");
$i=1;
while($gprow=mysqli_fetch_array($gp))
{
	print "<option>$gprow[gname]</option>";
	print "<script>stax[$i]='$gprow[tax]'</script>";
	$i++;
}
?>
</select>

</tr>
<tr><td>Sub Group Name</td><td><input type=text name='subname' size=25></td></tr>
<th colspan=2><input type=submit value='Save' name='save'></td></tr>
<input type='hidden' name='ptype' id='ptype' value=''>
</table>
</form>
</td></tr>
</table>




<br>

<div id="tabtd"></div>

<script>
 function delfun(x)
 {
  if (confirm('do you want to delete '+x+' ?'))
   document.location='delsubgrmaster.php?code='+x;
 }
 


function getdata(str1)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	document.getElementById("ptype").value=1;
  	document.getElementById("tabtd").innerHTML=xmlhttp.responseText;
 
	
    }
  }
var strurl="getdata.php?prod="+str1;
xmlhttp.open("GET",strurl,true);
xmlhttp.send();
}


   
</script>
