<?
session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
include("../opendb.php");
if($save)
{
 $r=mysqli_query($db,"select * from dedmast where allname='$allname' and brcode='$brcode'");
  if(mysqli_num_rows($r)>0)
  {
    print "<script> alert('Duplicate Division'); </script>";
    return;
  }
 $sql="insert into dedmast (brcode,allname,esi,pf) values('$brcode','$allname','$esi','$pf')";
 mysqli_query($db,$sql) or die(mysqli_error($db));
 print "<font color=green> Data has been saved</font>";
}
if($del)
{
 mysqli_query($db,"delete from dedmast where code='$code' and brcode='$brcode'");
}
?>

<head>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
tr{background-color:e3ecd2}
th{background-color:c1d799}
.mnu{margin-left:5}
body{BACKGROUND-COLOR:fcfff1}
</style>
<script>
function chkey(abc)
{
 yy=abc.value
 if(yy.indexOf('  ')>-1) 
  {
    alert('Multiple space is not allowed');
    abc.value='';
  }
 if(yy.indexOf("'")>-1) 
  {
    alert("\' is not allowed");
    abc.value='';
  }
 if(yy.indexOf("&")>-1) 
  {
    alert("& is not allowed");
    abc.value='';
  }
}
</script>
</head>
<center>
<form action='<?print $PHP_SELF ?>'>
<table>
<th colspan=4>DEDUCTION MASTER</th>
<tr><td> Name</td><td colspan=3><input type=text name='allname' size=40 onKeyDown=chkey(this)></td>
</tr>
<tr><td> Include In ESI</td><td><input type=checkbox name='esi' value='y'></td>
<td align=right> Include In PF</td><td><input type=checkbox name='pf' value='y'></td></tr>

<tr><td colspan=4 align=center bgcolor=c1d799> <input type=submit name='save' value='Save'></td></tr>
</table>
</form>
<HR>
EXISTING DEDUCTIONS
<HR>
<table width=50%>
<th width=12>No <th>Allowance <th>ESI<th>PF<TH width=50>Action
<?
$result=mysqli_query($db,"select * from dedmast where brcode='$brcode' order by allname");
$i=1;
while($row=mysqli_fetch_array($result))
{
 print "\n<form action='$PHP_SELF'><input type=hidden name=code value='$row[code]'>";
 print "\n<tr><td>".$i++."</td><td>$row[allname]</td>";
  if($row[esi]=='y')
   print "<td align=center><img src='../img/yes-bl.gif'></td>";
  else
   print "<td align=center><img src='../img/x-bl.gif'></td>";

  if($row[pf]=='y')
   print "<td align=center><img src='../img/yes-bl.gif'></td>";
  else
   print "<td align=center><img src='../img/x-bl.gif'></td>";

print "<td><input type=submit value='Del' name='del'></td></tr></form>";
}
?>
</table>

<br>&nbsp;
