 
<?php  $table="emp_openingbalance";
 
$table1="emp_leave";
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];

 
 
if($_REQUEST['Search'])
{
  
 $filter='';
 if($_REQUEST['emp_designation']!='' )
 {
   $filter[]="A.designation  ='".$_REQUEST['emp_designation']."'"	 ;
 }
  if($_REQUEST['empid']!='' )
 {
   $filter[]="A.id='".$_REQUEST['empid']."'"	 ;
 }
  
  if(count($filter)>0)
  {
	  $fdata=implode(" and ",$filter)  ;
	  //echo $fdata;
   }
	
	 
	 
}
 ?>
 <script src="js/function-ajax.js" type="text/javascript">
 </script>
<p>&nbsp;</p>
<form action="" method="post">
<table border="0" cellpadding="3" cellspacing="3">
	<tr><td colspan="2"><h2> Employee Leave Opening Details</h2></td></tr>
	<tr><th class="tabledata1">Designation</th>
		<td>
        <select name="emp_designation" onchange="ShowDiv(this.value,'hid_emp_div','emplist.php');">
      <option value="000">---Select---</option>
      <?php 
	$query3=DB_query("select * from desigmaster",$db);
	while($result3=DB_fetch_array($query3))
	{
		  $p='';
		  if($result3['desigcode']==$_REQUEST['emp_designation'])
		  $p="selected";   
	?>
      <option value="<?php echo $result3['id'];?>" <?php echo $p; ?>><?php echo $result3['designame'];?></option>
      <?php } ?>
    </select>
      </td>
    <tr><th class="tabledata1">Employee Name </th>
		<td>
        <div id="hid_emp_div">
       
        <input type="text" name="empid"  value="<?php echo $s->getField('empmaster','id',$_REQUEST['empid'],'emp_name');   ?>"></div>
        
</td>	
	</tr>
  
   <tr><th class="tabledata1">From </th>
		<td><input type="text" name="fin_end_date"  class="datepicker"value="<?php  echo $fin_end_date;?>"></td>	
	</tr>   
 <tr><th class="tabledata1">To  </th>
		<td><input type="text" name="fin_start_date" class="datepicker" value="<?php  echo $fin_start_date;?>"></td>	
	</tr>
    
		
	</tr>
   
    
  <tr>
		<td colspan="2">
		 <input name="Search" type="submit" value="Search" />
	    </td></tr>
	
</table>
</form>
<table width="80%" border="0" cellspacing="1" cellpadding="2">
  <tr>
    <th scope="col"><span style="font-weight: bold">Sn.  </span></th>
      <th scope="col"><span style="font-weight: bold">Emp Name  </span></th>
	  <th scope="col"><span style="font-weight: bold">Emp designation  </span></th>
	  <!-- <th scope="col">AccountsType</th>-->
	    <th scope="col"><span style="font-weight: bold">Opening balance</span></th>
     
  
  </tr>
 
  <tr>
   <?php 
   if($fdata!=''){
       $GetRecord = "Select A.id,A.emp_name as Empname,A.designation   as Designation   ,sum(B.leave_days) as OB from empmaster A, emp_leave B where $fdata and A.id=B.emp_id  group by emp_id ";}
	   else{
       $GetRecord = "Select A.id,A.emp_name as Empname,A.designation   as Designation   ,sum(B.leave_days) as OB from empmaster A, emp_leave B where   A.id=B.emp_id  group by emp_id "; 
		   
		   }
   $ResultData = DB_query($GetRecord,$db);
   $i=1;
   if(DB_num_rows($ResultData)==0)
   echo "<td colspan='3'>--No Record--</td>";
   
   while($RowData = DB_fetch_array($ResultData))
   {?>
   <td><div align="center"><?php echo $i; ?></div></td>
    <td><?php
	echo $RowData['Empname'];
	//echo $RowData['empid']; ?>	  </td>
	 <td><?php  
	   echo $RowData['Designation']
	 //echo $RowData['emp_designation']; ?>	  </td> 
	 <td><?php  echo $RowData['OB']; ?>	  </td> 
    
    
   
  </tr>
	<?php $i++;}   
   ?> 
</table>