<center> <h2>Leave Register Report</h2>
</center>
<?php //error_reporting(0);
include('./includes/fun-php.php');
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
	if($_REQUEST['Search']   )
		{
		  $paystatus=true;  
 		$_SESSION['payyear']=$_REQUEST['payyear'];
		$_SESSION['paymonth']=$_REQUEST['paymonth'];
		$_SESSION['empcode']=$_REQUEST['empcode'];
		$_SESSION['emptype']=$_REQUEST['emptype'];
		$_SESSION['emp_salprocess_site']=$_REQUEST['site'];
		$years=$_SESSION['payyear'];
		$month=$_SESSION['paymonth'];	   
		$empcode=$_SESSION['empcode'];
		$emptype=$_SESSION['emptype'];
		$emp_salprocess_site=$_SESSION['emp_salprocess_site'];
			
    }	 
  
     ?>
<form action="" method="post">
	<table border="0" cellpadding="5" cellspacing="0"  width="80%">
	<tr>
		
<td width="10%">Site <?php echo $_SESSION['emp_salprocess_site'];?>
 <select name="site" id="site" style="width:auto;">
<option value="000">---ALL---</option>
<?php 
  $site_sql=DB_query("Select loccode, locationname from locations where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in('".$_SESSION['AssignedBranch']."')",$db); 
while($site_row=DB_fetch_array($site_sql)){
?>
<option value="<?php echo $site_row['loccode'];?>"<?php echo ($_SESSION['emp_salprocess_site']==$site_row['loccode']?'selected':'');?>><?php echo $site_row['locationname'];?></option>
<?php } ?>
</select></td>
		<td  width="20%">Employee Type: 
<select name="emptype" id="emptype" onchange="ShowDiv(this.value,'hid-empdiv','GetEmployee.php?site='+document.getElementById('site').value)" style="width:200px;" > 
	<option value="0" >---</option>
		<option value="Permanent" <?php echo($_SESSION['emptype']=='Permanent'?'selected':'')?>>Permanent</option>
		<option value="Temporary" <?php echo($_SESSION['emptype']=='Temporary'?'selected':'')?>>Temporary</option>
	</select>	
</td> 

		
		
		
		<td  width="20%"> Employee Code:
		<div id='hid-empdiv'>
	<select name="empcode" id="empcode" style="width:200px">
		<option value="All">All</option>
		<?php 
		$emp_sql=DB_query("Select id, emp_code,emp_name from empmaster order by emp_name",$db);
		while($emp_row=DB_fetch_array($emp_sql))
		{?>
			<option value="<?php echo $emp_row['id'];?>"<?php if($_SESSION['empcode']==$emp_row['id'])echo "selected";?>><?php echo $emp_row['emp_name'].' ( '.$emp_row['emp_code'].' ) ' ;?></option>
		<?php 	
		}
		?>
		
	</select>	</div></td>
<!-- <input type="text" name="empcode" value="<?php //echo $_REQUEST['empcode']; ?>">-->  
 <td  width="10%">Month :<br />
 <select name="paymonth"  style="width:auto;">
 <?php
 $arr=array(1=>"Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec");
 foreach ($arr as $key => $value) {
 	$p='';
 	if( $key==$_SESSION['paymonth'])
	$p='selected';
   ?><option value="<?php echo $key;?>" <?php echo $p;?> ><?php echo $value;?></option>
 <?php } ?></select>
	  </td> 
  
   <td>year :<br />
 <select name="payyear"  style="width:auto;">
 <?php
 
 for($i=date('Y');$i>2000;$i--)
 {
 	$p='';
 	if( $i==$_REQUEST['payyear'])
	$p='selected';
 ?><option value="<?php echo $i;?>" <?php echo $p;?>><?php echo $i;?></option>
 <?php 
 }
 ?></select>
	  </td>       
	<td>	<input type="submit" name="Search"   value="Search"/> </td></tr></table>
	
	
</form>

<?php 
  if($_REQUEST['Search'] )
  {
	 
	  
	 
?> <br />
 <table width="100%" border="1">
  <tr>
    <th><strong>From Date </strong></th>
    <th><strong>Todate</strong></th>
    <th><strong>Leave Tpye </strong></th>
    <th><strong>Description</strong></th>
    <th><strong>Taken Leave  </strong></th>
	  <th><strong>Status  </strong></th>
	 
   </tr>
   <?php $Total_Otamount=	0;
   
  
           $GetRecord = "Select *  from empmaster A, emp_leave_apply B  where  A.id=B.empid   and month(period_from )='".$month."' and year(period_from )='".$years."'  ";	
	 
	 if($empcode!='')
   	$GetRecord= $GetRecord  . " and A.id='".$empcode."'";
	// echo   $GetRecord;		 	   
     $ResultData = DB_query($GetRecord,$db);
	 //echo DB_num_rows($ResultData);
if(DB_num_rows($ResultData)>0)
{
   	 while($RowData = DB_fetch_array($ResultData))
	 {
        
		 ?>
   
  <tr>
    
    <td><?php  echo ConvertSQLDate($RowData['period_from'])?></td>
     <td><?php  echo ConvertSQLDate($RowData['period_to'])?></td>
    <td><?php  echo $RowData['leave_type']?></td>
    <td><?php   echo $RowData['leave_reason'];
	 
	?></td>
		   <td><?php   echo $RowData['total_days'];?></td>
		   <td><?php   echo $RowData['approve_status'];
	 
	?></td>
    <?php }
}else{
  echo "<td colspan='5'> No Record</td>";
}	 ?>
      </tr>
  
</table>
<?php } ?>