<?session_start();
include("../opendb.php");
//print sizeof($a);
if($upd)
{
if($ff !="none")
{
   $fl=$HTTP_POST_FILES['ff']['name'];
   $file_dir=".";
  $tmp_name=$_FILES['ff']['tmp_name'];
   move_uploaded_file($tmp_name,"./$file_dir/$ff_name") or die(' err:could not copy file');
 }
$fp=fopen("./$file_dir/$ff_name","r") or die("Cant open file");
$i=1;
print $sql;
$dt=date("Y-m-d H:i:s");
$d=date("Y-m-d");
$i=1;
$tbl1="payrolltmp".$brcode;
?>
<center><span style={letter-spacing:5}>
<U><b>Employee List Verification<?print $br?></b></U>
</SPAN>
<table width=100% BORDER=0>
<th colspan=4>Deduction
<?
$ctr=1;
while(!feof($fp))
{
	$line=fgets($fp,1024);
	$spline=explode("\t",$line);
	if(strlen($spline[1])>0)
	{
		print "\n<tr><td>".$spline[0]."</td><td>".$spline[1]."</td><td>".$spline[2]."</td>";
		$br = trim($spline[2]);
		$empname = trim($spline[0]);
		$listname[$ctr] = $empname; 
		$brname[$ctr] = $br;
		$ctr = $ctr + 1;
		$sq="select * from $tbl1 where month(wgfrom)='$monthfrm' and year(wgfrom)='$yearfrm' and br='$br' and brcode='$brcode' and ename = '$empname'";
		$emppayres=mysqli_query($db,$sq) or die("er2:".mysqli_error());
		if(mysqli_num_rows($emppayres)<=0)
		{
			print "<td> Not Found in Register </tr></td>";
		}
		else
		{
			print "</tr>";
		}
	}
}
$tbl1="payrolltmp".$brcode;
$sq="select distinct * from $tbl1 where month(wgfrom)='$monthfrm' and year(wgfrom)='$yearfrm' and brcode='$brcode' order by ename ";
$emppayres=mysqli_query($db,$sq) or die("er2:".mysqli_error());
$emppayres1=mysqli_query($db,$sq) or die("er2:".mysqli_error());
$i=1;
print "<tr><td><td><td><td> </tr></td>";
while($empayrow=mysqli_fetch_array($emppayres))
{
	$empname= $empayrow[ename];
	$mbr=$empayrow[br];
	for ($i = 1; $i <= $ctr; $i++) 
	{
	    if ($empname==$listname[$i] && $mbr == $brname[$i])
		break;
	}
	if ($i==$ctr+1)
		print "\n<tr><td>".$empname."<td><td>".$mbr."<td> Not in List ";
}
print "</tr></td>";
}
//print "<script> alert('Done');</script>";
?>
<link rel="stylesheet" href="style.css" type="text/css" />
<style>
</td></tr>
</table>
body,td{font-family:'arial narrow';letter-spacing:1;}
tr{background-color:c1d799}
.mnu{margin-left:5}
</style>
<center>
<form action='<?print $PHP_SELF?>' method='post' ENCTYPE="multipart/form-data">
<table border=1>
<tr><td>
<table>
<th colspan=2>Upload Employee List (Emp Name/Designation/Branch)
<br>
<?
print "\nFrom : mnth<select name='monthfrm'>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>";
print "&nbsp;&nbsp;Year<select name='yearfrm'>
<option>2011</option>
<option>2010</option>
<option>2012</option>
<option>2009</option>
<option>2008</option>
<option>2007</option>
<option>2006</option>
<option>2005</option>
<option>2004</option>
<option>2003</option>
<option>2002</option>
<option>2001</option>
<option>2000</option>
</select>";
?>
<tr><td>File </td><td><input type=file name='ff'></td></tr>
<tr><td><input type=submit value='Upload' name='upd'></td></tr>
</table>
</td></tr>
</table>
</form>
