<?
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 allomast where allname='$allname' and brcode='$brcode'");
  if(mysqli_num_rows($r)>0)
  {
    print "<script> alert('Duplicate Allowance'); </script>";
    return;
  }
 $sql="insert into allomast (brcode,allname,esi,pf,lop) values('$brcode','$allname','$esi','$pf','lop')";
 mysqli_query($db,$sql) or die(mysqli_error());
 print "<font color=green> Data has been saved</font>";
}
if($del)
{
 mysqli_query($db,"delete from allomast 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=6>ALLOWANCE MASTER</th>
<tr><td>Allowance Name</td><td colspan=5><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>
<td align=right> Loss of Pay</td><td><input type=checkbox name='lop' value='y' checked></td>
</tr>

<tr><td colspan=6 align=center bgcolor=c1d799> <input type=submit name='save' value='Save'></td></tr>
</table>
</form>
<HR>
EXISTING ALLOWANCES
<HR>
<table width=50%>
<th width=12>No <th>Allowance <th>ESI<th>PF<th>LOP<TH width=50>Action
<?
$result=mysqli_query($db,"select * from allomast 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>";

  if($row[lop]=='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;
