<?
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($save&&$pswd=='trans')
{
 $ondate=$y.'-'.$m.'-'.$d;
 $sql="insert into emptransfer values('$empcode','$frombr','$tobr','$fromdivis', '$todivis','$ondate','$brcode')";
 mysqli_query($db,$sql) or die(mysqli_error());
 print "<font color=green>Record has been saved</font>";
}
?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
tr{background-color:e3ecd2}
th{background-color:c1d799}
.mnu{margin-left:5}
.he2{background-color:lightsteelblue}
.tda{background-color:aliceblue}
body{BACKGROUND-COLOR:fcfff1}
</style>
<center>
<form action='<?print $PHP_SELF?>'>
<table>
<th colspan=10>TRANSFER</TH>
<tr><td>Select Employee</td><td colspan=5><select name='empcode'>
<?
$re=mysqli_query($db,"select empcode,empname,br from empmaster where brcode='$brcode' and doret='0000-00-00' order by br,empname") or die("ERR :".mysqli_error());
while($row=mysqli_fetch_array($re))
{
 print "\n<option value='$row[0]'>$row[1]-$row[2]</option>";
}
?>
</select>
</td></tr>
<tr>
<td>From Branch</td><td>
<select name='frombr'>
<?
 $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></tr>

<tr>
<td>To Branch</td><td>
<select name='tobr'>
<?
 $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></tr>
<tr>
   <td>From Division </td><td><select name='fromdivis'>
<?
 $rrr=mysqli_query($db,"select * from divmast order by divname");
  while($div_row=mysqli_fetch_array($rrr))
  {
    print "<option>$div_row[2]</option>";
  }
?>
</select>  
 </td></tr>
<tr>
   <td>To Division </td><td><select name='todivis'>
<?
 $rrr=mysqli_query($db,"select * from divmast order by divname");
  while($div_row=mysqli_fetch_array($rrr))
  {
    print "<option>$div_row[2]</option>";
  }
?>
</select>  
 </td></tr>
<tr><td>On Date </td><td>dd <input type=text name='d' size=2 value='<?print date('d')?>'>
mm <input type=text name='m' size=2 value='<?print date('m')?>'>
yy <input type=text name='y' size=4 value='<?print date('Y')?>'>
</td></tr>
<tr><td>Password</td><td><input type=password name='pswd'></td></tr>
<th colspan=10><input type=submit value='Save' name='save'></th>
</table>
</form>
<?
$sql="select b.empname,a.* from emptransfer a,empmaster b where a.empcode=b.empcode and a.brcode='$brcode' order by b.empname,a.ondate";
$re=mysqli_query($db,$sql);
print "<table> <th class=he2>Name <th class=he2>From Branch <th class=he2>To Branch <th class=he2>From Division <th class=he2>To Division <th class=he2>On Date<th class=he2>Delete";
while($row=mysqli_fetch_array($re))
{
  print "\n<tr><form action='deltrans.php' method='post'>";
  print "<input type=hidden name='empcode' value='$row[empcode]'>";
  print "<input type=hidden name='ondate' value='$row[ondate]'>";
  print "\n<td class=tda>$row[0]</td><td class=tda>$row[2]</td><td class=tda>$row[3]</td><td class=tda>$row[4]</td>";
  print "<td class=tda>$row[4]</td>";
  print "<td class=tda>".datetohtml($row[ondate])."</td>";
  print "<td><input type=submit value='Del' name='del'></td></form></tr>";
}
?>




