<?
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");
?>

<head>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;font-size:13}
th{background-color:c1d799}
.mnu{margin-left:5}
body{BACKGROUND-COLOR:fcfff1}
</style>
<fieldset>
<legend>Search</legend>
<center>
<form action='<?print $PHP_SELF?>' method='post'>
<table border=0>
<th colspan=8 style={filter:flipH;}>SEARCH EMPLOYEE</TH>
<tr><td>Employee Name </td><td><input type=text name='empname'> </td>
<td>Branch</td><td>
<select name='br'>
<option>All</option>

<?
 $re=mysqli_query($db,"select code,brname from br_master where brcode='$brcode' order by brname");
 while($brrw=mysqli_fetch_array($re))
  {
    print "<option>$brrw[1]</option>";
  }
?>
</select>
</td>
<td>Password <input type=password name='pswd'> <input type=submit value='Search' name='sea'></td>
<tr><td colspan=7 bgcolor='orange'></td></tr>
</table>
</form>     
</fieldset>
<?
if($sea)
{
 if($pswd!='history')
  {
   print "<center><font color=red>Invalid Password</font>";
   return;
  }
 if($br=="All")
  $sql="select * from empmaster where empname like '%$empname%' and brcode='$brcode' order by empname";
 else
  $sql="select * from empmaster where empname like '%$empname%' and br='$br' and brcode='$brcode'  order by empname";
 $re=mysqli_query($db,$sql);
 print "<center><table><th>Name <th>Sex <th>Division <th>Branch <th>Designation <th>D_Conf <th>D_Ret<th>Print";
  $i=1;
 while($row=mysqli_fetch_array($re))
 {
  if($i%2==0)
  print "\n<tr bgcolor='#FFF5D2'><form action='prnhis.php' method='post'><input type=hidden name='empcode' value='$row[empcode]'>";
  else
  print "\n<tr bgcolor=white><form action='prnhis.php' method='post'><input type=hidden name='empcode' value='$row[empcode]'>";
 
  print"\n<td>$row[empname]</td><td>$row[sex]</td><td>$row[divi]</td><td>$row[br]</td><td>$row[design]</td>";
 print "<td>".datetohtml($row[doconf])."</td>";
 if($row[doret]!='0000-00-00')
   print "<td>".datetohtml($row[doret])."</td>";
 else
  print "<td></td>";
  //print "<td>$row[oallow]</td>";
  print "<td><input type=submit value='Print' name='prn'></td></form></tr>";
 $i++;
 }
 print "</table>";
}
?>
