<?
session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
include("../opendb.php");
include("../test.php");
if($del)
{
 $sql="delete from emp_pay where empcode='$empcode' and ondate='$dt' and brcode='$brcode' limit 1";
 mysqli_query($db,$sql) or die(mysqli_error());
 $sql="delete from emp_pay_allow where empcode='$empcode' and ondata='$dt'";
 mysqli_query($db,$sql) or die(mysqli_error());
 $sql="delete from emp_pay_ded where empcode='$empcode' and ondata='$dt'";
 mysqli_query($db,$sql) or die(mysqli_error());
}
?>
<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>

<?

print "<center> <b>PSN".$branch."<br>WAGE HISTORY<bR>";


if($show && $pswd=='please')
{
log_entry($brcode,$user,$REMOTE_ADDR,"wagehistory viewed - ".$pswd."-".$br."-".$divi);

PRINT "Branch : $br, Division: $divi<hr><br>&nbsp;";

 $sql="select empcode,empname from empmaster where divi='$divi' and br='$br' and emp_status='Active' and brcode='$brcode' order by empname";

$empcderes=mysqli_query($db,$sql) or die(mysqli_error());
while($emprow=mysqli_fetch_array($empcderes))
{
 print "\n<fieldset><legend>Employee : $emprow[1]</legend>";
 print "\n<table cellspacing=1 cellpadding=1 bgcolor='gray'>";
 print "<th width=100>On Date <th  width=150>Total Salary <th  width=150>Basic <th  width=100>TA <th  width=100>DA <th  width=100>Rent<th  width=100>CCA<th>Action";
 $sql="select * from emp_pay where empcode='$emprow[0]' order by ondate";
 $pres=mysqli_query($db,$sql) or die(mysqli_error());
  while($prow=mysqli_fetch_array($pres))
  {
    print "\n\n<tr bgcolor='aliceblue'><form action='$PHP_SELF' method=post>";
    print "<input type=hidden name='empcode' value='$prow[empcode]'>";
    print "<input type=hidden name='dt' value='$prow[ondate]'>";
    print "<input type=hidden name='br' value='$br'>";
    print "<input type=hidden name='divi' value='$divi'>";

    print "\n<td align=center>".datetohtml($prow[ondate])."</td>";
    print "<td align=right>$prow[totsal]</td>";
    print "<td align=right>$prow[basic]</td>";
    print "<td align=right>$prow[ta]</td>";
    print "<td align=right>$prow[da]</td>";
    print "<td align=right>$prow[rent]</td>";
    print "<td align=right>$prow[hra]</td>";
    print "\n<td align=right><input type=submit value='Del' name='del'></td>";
    print "<tr><td colspan=20 bgcolor='ivory'><table bgcolor='ivory'>";
    $r=mysqli_query($db,"select * from emp_pay_allow where empcode='$prow[empcode]' and ondata='$prow[ondate]'")or die('err'.mysqli_error());
    while($dr=mysqli_fetch_array($r))
   {
     print "<tr><td>$dr[allow]</td><td>$dr[amt]</td></tr>";
  }
   print "</table> </td></tr>";
  print "</form></tr>";

  }
 print "</table></fieldset>";
}
 return;
}
elseif($show && $pswd!='please')
{
log_entry($brcode,$user,$REMOTE_ADDR,"wagehistory tried to view - ".$pswd."-".$br."-".$divi);

}
?>
<center>
<FORM name='f1' ACTION='<?print $PHP_SELF?>' method='post'>
<h2>	WAGE HISTORY</H2>
<table width=50%>
 <th>Division<th>Branch
<?
$result=mysqli_query($db,"select * from divmast where brcode='$brcode' order by divname");
$i=1;
print "<tr><td height='30'><center><select name='divi'>";
while($row=mysqli_fetch_array($result))
{
 print "\n<option>$row[divname]</option>";
}
?>

<?
$result=mysqli_query($db,"select * from br_master where brcode='$brcode' order by brname");
$i=1;
print "<td><select name='br'>";
while($row=mysqli_fetch_array($result))
{
 print "\n<option>$row[brname]</option>";
}
?>
</select>
</td></tr>
<tr ><td align=center>Password </td><td><input type=password name='pswd'></td></tr>
<TH COLSPAN=2><input type=submit value='Show' name='show'></th>
</table>
</form>

