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

<html>
<body >

<?

if(isset($_POST['save']))
 {
			
     $trnstyp=$_REQUEST['trnstyp'];
     $transid=$_REQUEST['transid'];
     $entrchk=$_REQUEST['entrchk'];
        $sql="insert into transactmast(trnstyp,trnsid,trnrqr,brcode) values('$trnstyp','$transid','$entrchk','$brcode')";
	mysqli_query($db,$sql) or die('Insert Err:'.mysqli_error($db));
	print "<script> document.location='transactmaster.php'</script>";
	return;
}
?>
<title>AMPLC</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 >>  Transaction 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.trnstyp.value.length<=0)
 {
   alert("Invalid transaction type");
   document.f1.trnstyp.focus();
   return false;
 }
if(document.f1.transid.value.length<=0)
 {
   alert("Invalid transaction ID");
   document.f1.transid.focus();
   return false;
 }

}



</script>

<body>

<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>Transaction Master</th>
<tr><td>Transaction Type</td><td>
<input type='text' name='trnstyp'>

</tr>
<tr><td>Transaction ID</td><td><input type=text name='transid' size=25></td></tr>
<tr><td>Require Entry Check?</td><td>
<input type='checkbox' name='entrchk' value='1'>
</td></tr>
<th colspan=2><input type=submit value='Save' name='save'></td></tr>

</table>
</form>
</td></tr>
</table>




<br>

<table cellspacing=1 cellpadding=5 class=report>
<th>No <th>TRANSACTION TYPE<th>TRANSACTION ID<th>Edit
<?
$i=1;
$res=mysqli_query($db,"select * from  transactmast order by trnstyp ASC");
while($row=mysqli_fetch_array($res))
{
?>
<form name='form2' id='form2' method='POST'>
<?
 print "<tr bgcolor='white' onMouseOver=bgColor='b8d7b4'; onMouseOut=bgColor='white'>";
 print "<td>".$i++."</td><td>".$row['trnstyp']."</td><td>".$row['trnsid']."</td>";
print "<td><input type=button value='Edit' name='edt' onClick=edfun('$row[id]')></td>";
 //print "<td><input type=button value='Del' name='del' onClick=delfun('$row[id]')></td></tr>";
print "</tr>";
}
?>
</form>
</table>

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