 <?php include('Class-EmpMaster.php');
 include('./includes/fun-php.php');
 ?>
 <link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>PF And ESI Contribution</h1>
<form action="" method="post">
	<table border="0" cellpadding="3" cellspacing="0"  width="100%" align="center">	
	<tr class="row1">
		<td width="13%" align="right">Branch</td>
		<td width="20%"><select name="site" id="site" >
		<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 width="13%" align="right">Employment Type</td>
		<td width="20%"><select name="emptype" id="emptype" >
			<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 width="13%" align="right">Employee</td>
		<td><select name="empcode" id="empcode" >
		<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> 
    </tr>
    <tr class="row1">
 <td align="right">Month</td> 
 <td><select name="paymonth" >
 <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 align="right">Year</td>
   <td><select name="payyear" >
 <?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 colspan="2"></td>
</tr>
<tr class="row1">     
	<td colspan="6" align="center"><input type="submit" name="Search" value="Search" class="search" /></td>
</tr>
</table>
 	</form>

	<?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'];			
			?>
<br>
<table width="100%" align="center" border="0" cellpadding="3" cellspacing="0" style="border:0;">
 <tr>
    <td width="50%" valign="top">	
	<table width="100%" align="center" border="0" cellpadding="3" cellspacing="0">
      <tr class="row1">
        <td width="40%" align="right"><strong>Salary on which PF is being deducted :</strong></td>
        <td><?php  echo $total_basic;?></td>
      </tr>
      <tr class="row1">
        <td align="right"><strong>P.P. Control (Emplovee 12%) :</strong></td>
        <td><?php echo  round(($total_basic*.12),2);
		$total_amt[]=($total_basic*.12);
		?>&nbsp;</td>
      </tr>
      <tr class="row1">
        <td align="right"><strong>Pension (Emplover 8.33%) :</strong></td>
        <td><?php echo  round(($total_basic*8.33)/100,2);		
		$total_amt[]=($total_basic*8.33)/100;
		?></td>
      </tr>
      <tr class="row1">
        <td align="right"><strong>Employer (3.67%) :</strong></td>
        <td><?php echo  round(($total_basic*3.67)/100,2);		
		$total_amt[]=($total_basic*3.67)/100;
		?></td>
      </tr>
      <tr class="row1">
        <td align="right"><strong>Admin Charges (1.10%) A/c No. 2 :</strong></td>
        <td><?php echo  round(($total_basic*1.10)/100,2);
		$total_amt[]= ($total_basic *1.10)/100;
		?></td>
      </tr>
      <tr class="row1">
        <td align="right"><strong>EDLI (.50%) A/c No. 21 :</strong></td>
        <td><?php echo  round(($total_basic*.50)/100,2);
		$total_amt[]= ($total_basic*.50)/100;
		?></td>
      </tr>
      <tr class="row1">
        <td align="right"><strong>Admin Charges (1.10%) A/c No. 22 :</strong></td>
        <td><?php echo  round(($total_basic*1.10)/100,2);
		$total_amt[]= ($total_basic*.01)/100;
		?></td>
      </tr>
      <tr class="row1">
        <td align="right"><strong>Total Amount :</strong></td>
        <td><strong><?php echo round(array_sum($total_amt),2);?></strong></td>
      </tr>
    </table>
    </td>
    <td valign="top">
	<h3 align="center">ESI Summary For The Month Of <?PHP echo GetMonth($month);?> &nbsp;<?php echo $years;?></h3>
	<table width="100%" align="center" cellpadding="3" cellspacing="0" border="0" style="border:0;">
      <tr class="row1">
        <td width="40%" align="right"><strong>Salalry on which ESI deducted :</strong></td>
        <td><?php echo $total_gross;?></td>
      </tr>
      <tr class="row1">
        <td align="right"><strong>ESI Contribution (1.75%) :</strong></td>
        <td><?php echo  round(($total_gross*1.75)/100,2);
		$total_esiamt[]=($total_gross*1.75)/100;
		?></td>
      </tr>
      <tr class="row1">
        <td align="right"><strong>ESI Contribution (4.75%) :</strong></td>
        <td><?php echo  round(($total_gross*4.75)/100,2);		
		$total_esiamt[]=($total_gross*4.75)/100;
		?></td>
      </tr>
      <tr class="row1">
        <td align="right"><strong>Total Amount :</strong></td>
        <td><strong><?php echo round(array_sum($total_esiamt),2);?></strong></td>
      </tr>
    </table>
</td>
</tr>
</table>
	<?php } ?>
</div>
</div>
 