<?
session_start();
include("../opendb.php");
include("../test.php");
$res=mysqli_query($db,"select * from taxmaster where code='$code'");
$resrow=mysqli_fetch_array($res);

if($save)
{

/*$re=mysqli_query($db,"select * from taxmaster where tax='$tax'");
if(mysqli_num_rows($re)>0)
{
 print "<script> alert('Duplicate Entry'); </script>";
 return;
}*/


$sql="update taxmaster set tax='$tax',descpt='$descpt',type='$type',purledger='$purledger',saleledger='$saleledger' where code='$code'";
mysqli_query($db,$sql) or die('Insert Err:'.mysqli_error($db));

print "<script> opener.document.location='taxmaster.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(800,170);
function valid()
{
 
 if(document.f1.tax.value.length<=0)
 {
   alert("Invalid Tax.");
   document.f1.tax.focus();
   return false;
 }
/*if(document.f1.purledger.selectedIndex<=0 && document.f1.saleledger.selectedIndex<=0)
{
   alert("Invalid Ledger");
   document.f1.purledger.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 TAX MASTER</th>
<tr> <td>Tax %</td><td><input type=text name='tax'  size=7 value='<?print $resrow[tax]?>' ></td><td>Description</td><td><input type=text name='descpt'  size=50  value='<?print $resrow[descpt]?>'></td>
</tr>
<tr><td>Type</td><td><Select name='type'  size=1>
   	<option><?print $resrow[type]?></option>
	<option>CST</option>
	<option>Local</option>
	</select>
</td>
 <td>Purchase Ledger </td><td><select name='purledger'>
<option><?print $resrow[purledger]?></option>
<option>Purchase 12%</option>
<option>Purchase 12.5%</option>
<option>Purchase 8%</option>

</select></td>
</tr>
<tr><td></td><td></td><td>Sales Ledger </td><td colspan=4><select name='saleledger'>
<option><?print $resrow[saleledger]?></option>
<option>Sale 12%</option>
<option>Sale 12.5%</option>
<option>Sale 8%</option>
</select></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>
