 <?php include('Class-EmpMaster.php');
 include('./includes/fun-php.php');
 ?>
 <h2>PF And ESI Contribution Summary </h2>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
 <tr><td align="center">
	
	<form action="" method="post">
	<table border="0" cellpadding="1" cellspacing="1"  width="90%" style="border:solid 1px #CCC;" align="center">
	
	<tr>
	<th>Branch</th>
	<th>Employment Type</th>
	<th>Employee</th>
	<th>Month</th>
	<th>Year</th>
	<th>&nbsp;</th>
	</tr>
	<tr bgcolor="#FFFFFF">
	<td><select name="site" id="site" style="width:auto;">
<option value="">---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 ($_REQUEST['site']==$site_row['loccode']?'selected':'');?>><?php echo $site_row['locationname'];?></option>
<?php } ?>
</select></td>
		<td><select name="emptype" id="emptype" style="width:100%">
		<option value="">All</option>
		<option value="Permanent"<?php echo($_REQUEST['emptype']=='Permanent'?'selected':'')?>>Permanent</option>
		<option value="Temporary"<?php echo($_REQUEST['emptype']=='Temporary'?'selected':'')?>>Temporary</option>
	</select>	
</td> 
		<td><select name="empcode" id="empcode" style="width:100%">
		<option value="">All</option>
		<?php 
		$emp_sql=DB_query("Select id,emp_name from empmaster",$db);
		while($emp_row=DB_fetch_array($emp_sql))
		{?>
			<option value="<?php echo $emp_row['id'];?>"<?php if($_REQUEST['empcode']==$emp_row['id'])echo "selected";?>><?php echo $emp_row['emp_name'];?></option>
		<?php 	
		}
		?>
	</select>	
<!-- <input type="text" name="empcode" value="<?php //echo $_REQUEST['empcode']; ?>">--> </td> 
 <td><select name="paymonth" style="width:100%">
 <option value="">All</option>
 <?php
 $arr=array(1=>"Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec");
 foreach ($arr as $key => $value) {
 	$p='';
 	if( $key==$_REQUEST['paymonth'])
	$p='selected';
   ?><option value="<?php echo $key;?>" <?php echo $p;?> ><?php echo $value;?></option>
 <?php } ?></select>
	  </td> 
  
   <td><select name="payyear"  style="width:100%">
 <?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> 
 	</td></tr>
  <tr>
    <td>
	<?php 
	if($_REQUEST['Search'])
	{	
		$total_amt=array();
	 	$years=$_REQUEST['payyear'];
	 	$month=$_REQUEST['paymonth'];	   
	    $empcode=$_REQUEST['empcode'];
		$emptype=$_REQUEST['emptype'];
		$site=$_REQUEST['site'];
		
	  	$deductionid= $s->getField('deduction_master','code','PF','id');
		$condition="allowance_deduction='".$deductionid."' and all_ded_prefix='D' and  emp_id='".$empcode."'" ;
		$PF_Percent=$s->GetFieldValue('emp_salary',$condition,'percentage');
		
		$filter=array();
		
		if($site!='')
		$filter[]="A.emp_site = '".$site."'";
		if($emptype!='')
		$filter[]="A.employment_type = '".$emptype."'";		
		if($month!='')
		$filter[]="B.payslip_month = '".$month."'";	
		if($years!='')
		$filter[]="B.payslip_year = '".$years."'";	
		
		if($filter!='')
		{$filter=implode(" and ",$filter);}
		
		
		
		if($empcode!='')
		{
			if($month!='')
			{
				$query="Select A.id, B.basic_salary as tot_basic, B.gross_salary as tot_gross from empmaster A, master_process_salary B where A.id=B.emp_id and B.payslip_month='".$month."' and B.payslip_year='".$years."' and B.emp_id='".$empcode."'";
			}
			else
			{
				$query="Select A.id, SUM(B.basic_salary) as tot_basic, SUM(B.gross_salary) as tot_gross from empmaster A, master_process_salary B where A.id=B.emp_id and B.payslip_year='".$years."' and emp_id='".$empcode."'";
			}	
		}	
		else
		{
			$query="Select A.id, SUM(B.basic_salary) as tot_basic, SUM(B.gross_salary) as tot_gross from empmaster A, master_process_salary B where A.id=B.emp_id and $filter";
		}	
		

		//echo $query;
		$result=DB_query($query,$db);
		$myrow=DB_fetch_array($result);
		
		$total_basic=$myrow['tot_basic'];
		$total_gross=$myrow['tot_gross'];
		
			
			?>
	 <h3 style="text-align:right;"><a href="PFsummary_Print.php?site=<?php echo $_REQUEST['site'];?>&emptype=<?php echo $_REQUEST['emptype'];?>&employee_id=<?php echo $_REQUEST['empcode'];?>&paymonth=<?php echo $_REQUEST['paymonth'];?>&payyear=<?php echo $_REQUEST['payyear'];?>" target="_blank">Print</a></h3>
	<table width="500" align="center" cellpadding="1" cellspacing="1" style="border:solid 1px #CCC;">
      <tr class="text" bgcolor="#FFFFFF">
        <th width="247" height="20" align="left">Salary on which PF is being deducted :</th>
        <td width="247" height="20" align="left"> <?php  echo $total_basic;?></td>
      </tr>
      <tr class="text" bgcolor="#FFFFFF">
        <th height="20" align="left">P.P. Control (Emplovee 12%) :</th>
        <td height="20" align="left"><?php echo  round(($total_basic*.12),2);
		$total_amt[]=($total_basic*.12);
		?>&nbsp;</td>
      </tr>
      <tr class="text" bgcolor="#FFFFFF">
        <th height="20" align="left">Pension (Emplover 8.33%)</th>
        <td height="20" align="left"><?php echo  round(($total_basic*8.33)/100,2);
		
		$total_amt[]=($total_basic*8.33)/100;
		?></td>
      </tr>
      <tr class="text" bgcolor="#FFFFFF">
        <th height="20" align="left">Emplover (3.67%) :</th>
        <td height="20" align="left"><?php echo  round(($total_basic*3.67)/100,2);
		
		$total_amt[]=($total_basic*3.67)/100;
		?></td>
      </tr>
      <tr class="text" bgcolor="#FFFFFF">
        <th height="20" align="left">Admin Charges (1.10%) A/c No. 2 :</th>
        <td height="20" align="left"><?php echo  round(($total_basic*1.10)/100,2);
		$total_amt[]= ($total_basic *1.10)/100;
		?></td>
      </tr>
      <tr class="text" bgcolor="#FFFFFF">
        <th height="20" align="left">EDLI (.50%) A/c No. 21</th>
        <td height="20" align="left"><?php echo  round(($total_basic*.50)/100,2);
		$total_amt[]= ($total_basic*.50)/100;
		?></td>
      </tr>
      <tr class="text" bgcolor="#FFFFFF">
        <th height="20" align="left">Admin Charges (0.01%) A/c No. 22 :</th>
        <td height="20" align="left"><?php echo  round(($total_basic*0.01)/100,2);
		$total_amt[]= ($total_basic*.01)/100;
		?></td>
      </tr>
      <tr class="text" bgcolor="#FFFFFF">
        <th height="20" align="left"><strong>Total Amount :</strong></th>
        <th height="20" align="left"><?php echo round(array_sum($total_amt),2);?> </th>
      </tr>
    </table><br>
	<h3 align="center">
	ESI Summary For The Month Of <?PHP echo GetMonth($month);?> &nbsp;<?php echo $years;?></h3>
	<table width="500" align="center" cellpadding="1" cellspacing="1" style="border:solid 1px #CCC;">
      <tr class="text" bgcolor="#FFFFFF">
        <th width="247" height="20" align="left">Salalry on which ESI deducted </th>
        <td width="247" height="20" align="left"> <?php echo $total_gross;?></td>
      </tr>
      <tr class="text" bgcolor="#FFFFFF">
        <th height="20" align="left">ESI Contribution (1.75%) </th>
        <td height="20" align="left"><?php echo  round(($total_gross*1.75)/100,2);
		$total_esiamt[]=($total_gross*1.75)/100;
		?>&nbsp;</td>
      </tr>
      <tr class="text" bgcolor="#FFFFFF">
        <th height="20" align="left">ESI Contribution (4.75%) </th>
        <td height="20" align="left"><?php echo  round(($total_gross*4.75)/100,2);
		
		$total_esiamt[]=($total_gross*4.75)/100;
		?></td>
      </tr>
      <tr class="text" bgcolor="#FFFFFF">
        <th height="20" align="left"><strong>Total Amount :</strong></th>
        <th height="20" align="left"><?php echo round(array_sum($total_esiamt),2);?> </th>
      </tr>
    </table>
	<?php } ?>
	</td>
  </tr>
 
</table>
 