<?php
$PageSecurity = 2;
include('includes/session.inc');
$title = _('View/Search Items') ;
include('includes/SQL_CommonFunctions.inc');
include('includes/function_lib.php');
$subQuery='';
$subQuery1='';
   if($_POST['dept_id']!=0)
   {
   	$subQuery.=" and department='".$_POST['dept_id']."'";
   	$subQuery1.=" and a.dept_id='".$_POST['dept_id']."'";
   }
    if($_POST['desg_id']!=0)
    {
    $subQuery.=" and designation='".$_POST['desg_id']."'";	
    $subQuery1.=" and a.desig_id='".$_POST['desg_id']."'";
    }


$sql=DB_query("select * from empmaster where emp_site='".$_POST['site']."' ".$subQuery."
 and id NOT IN (SELECT a.emp_id FROM emp_loan_opening a, empmaster b WHERE a.emp_id=b.id ".$subQuery1." )",$db);
?>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="3">
<tr class="row1">
 <td class="tabledata1" style="width:8%"><strong>Sr.No.</strong></td>
 <td class="tabledata1" style="width:15%"><strong>Employee Code</strong></td>
 <td class="tabledata1" style="width:32%"><strong>Employee Name</strong></td>
 <td class="tabledata1" style="width:32%"><strong>Loan Opening</strong></td>
 <td class="tabledata1" style="width:32%"><strong>Advance Opening</strong></td>
</tr>
<?php
$i=1;
$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>
<td><input type="text" name="loan_opening[]" ><input type="hidden" name="emp_id[]" value="<?php echo $row['id']; ?>" ></td>
<td><input type="text" name="advance_opening[]" ></td>
</tr>
<?php $i++; } ?>
<tr><td colspan="5" style="text-align:center;"><input type="submit" name="save" value="Save" class="search" onclick="return validate();"></td></tr>

<?php } else { ?>
<tr><td colspan="5">No Record Found</td></tr>
<?php } ?>
</table>
