<div class="overpanel">
<?php
$PageSecurity = 2;
include('includes/session.inc');
$title = _('View/Search Items') ;
include('includes/SQL_CommonFunctions.inc');
include('includes/function_lib.php');
$empid='';
$sql_check=DB_query("select empid from hr_leave_opening where site='".$_REQUEST['site']."'",$db);
while($row1=DB_fetch_array($sql_check))
{
$empid[]=$row1['empid'];
}

$sql_leave=DB_query("select * from leavemaster",$db);
while($row1=DB_fetch_array($sql_leave))
{
	$leaveid[]=$row1['id'];
	$leavename[]=$row1['leavename'];
}


if(!empty($empid))
{
$emp_id_data=implode("','",$empid);	

$sql=DB_query("select * from empmaster where emp_site='".$_REQUEST['site']."' and id not in('".$emp_id_data."')",$db);	
}
else
$sql=DB_query("select * from empmaster where emp_site='".$_REQUEST['site']."'",$db);
?>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="0" class="thborder">
<tr>
 <th style="width:8%">S. No.</th>
 <th style="width:15%">Employee Code</th>
 <th style="width:32%">Employee Name</th>
 <?php foreach($leavename as $leave1) { ?>
  <th><?php echo $leave1;  ?> Opening</th>
  <?php } ?> 
</tr>
<?php
$i=0;
$num=DB_num_rows($sql);
if($num>0)
{
while($row=DB_fetch_array($sql))
{
?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $row['emp_code']; ?></td>
<td><?php echo $row['emp_name']; ?></td>
 <?php $t=0; 
 foreach($leaveid as $leave2) { ?>
<td><input type="text" name="leave_opening[<?php echo $leave2; ?>][<?php echo $row['id']; ?>][<?php echo $t; ?>]" >
<input type="hidden" name="leave[<?php echo $row['id']; ?>][]" value="<?php echo $leave2; ?>">
</td><?php $t++; } ?>

<input type="hidden" name="emp_id[]" value="<?php echo $row['id']; ?>">



</tr>
<?php $i++; } ?>

<?php } else { ?>
<tr><td colspan="5">No Record Found</td></tr>
<?php } ?>
</table>
</div>
<div style="text-align:center; width:100%; float:left;"><p align="center"><input type="submit" name="save" value="Save" class="search" onclick="return validate();"></p></div>