<?php
ini_set('session.bug_compat_warn', 0);
ini_set('session.bug_compat_42', 0);
session_name('CAKEPHP'); session_start();
ob_start();
$PageSecurity = 1;
include('config.php');
include('includes/ConnectDB.inc');
include('includes/function_lib.php');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
include('./includes/fun-php.php');
include('./includes/fun-HRClass.php');
$Compamies=DB_query("select * from companies",$db);
$CompamiesRow=DB_fetch_array($Compamies);
?>
<style type="text/css">
.f11{font-family:Arial; font-size:11px; color:#000000;}
.fill2{font-family:Arial; font-size:12px; color:#000000;}
</style>
<center>
<div style="width:700px;">
	<h3><div style="width:auto; color:#006699; font-size:16px; font-weight:900; padding:10px; text-align:center;"><?php echo $CompamiesRow['CompanyName']?> <br />
</div></h3>
</div>
	<div width="100%">
	<h4>
		<?php 
		$site = $_REQUEST['site'];
		if(isset($site))
		{
			$branch = $s->getField('locations','loccode',$_REQUEST['site'],'locationname');
			echo "Branch:"." ".$branch."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		}
		$emptype = $_REQUEST['emptype'];
		if(isset($emptype))
		{
			echo "Employee Type:"." ".$emptype."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		}
		$paymonth = $_REQUEST['paymonth'];
		if(isset($paymonth))
		{
		?>
		<?php 
			echo "Month:"." ";
			if($paymonth=='1')
			echo "Jan"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			if($paymonth=='2')
			echo "Feb"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			if($paymonth=='3')
			echo "March"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			if($paymonth=='4')
			echo "April"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			if($paymonth=='5')
			echo "May"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			if($paymonth=='6')
			echo "June"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			if($paymonth=='7')
			echo "July"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			if($paymonth=='8')
			echo "Augst"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			if($paymonth=='9')
			echo "Sep"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			if($paymonth=='10')
			echo "Oct"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			if($paymonth=='11')
			echo "Nov"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			if($paymonth=='12')
			echo "Dec"."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		}
		$payyear = $_REQUEST['payyear'];
		if(isset($payyear))
		{
			echo " "."Year:"." ".$payyear."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		}
		?>
		</h4>
		</div>
	


</center>
<center>
<form action="" method="post" name="myform">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr class="row1">
		<td class="tabledata1">
		<table width="100%" align="center" style="margin-top:-20px;">
			<tr>
				<td width="61%" align="right"><span style="padding-top:-10px;">
			  <h3>PF And ESI Contribution</h3></span></td>
				<td width="39%" align="right"><div>
	<p id="foo" align="right" style="padding-right:10px;width:155px;"><a href="#" id="fis" onClick="javascript:toggle_visibility('foo');" >Print</a> </p>
</div></td>
			</tr>
		</table>
		
		</td>
</tr>
	</table>
	<table width="100%" cellpadding="3" cellspacing="0" border="1" style="border-collapse:collapse; border:0px solid #333333; font: normal 11px Arial;">
	<tr style="height:40px;">
    	<td class="tabledata"><strong>SL</strong></td>
        <td class="tabledata" style="white-space:nowrap;"><strong>Emp Code</strong></td>
        <td class="tabledata" style="white-space:nowrap;"><strong>Emp Name</strong></td>
        <td class="tabledata" style="white-space:nowrap;"><strong>Salary on which</strong></td>
        <td class="tabledata" style="white-space:nowrap;"><strong>P.P. Control</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>Pension</strong></td>
	    <td class="tabledata" style="white-space:nowrap;"><strong>Emplover </strong></td>
        <td class="tabledata" style="white-space:nowrap;"><strong>Admin<br /> Charges</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>EDLI (.50%)</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>Admin <br />Charges</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>Total Amount</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>Salalry on<br /> which</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>ESI <br />Contribution</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>ESI<br /> Contribution</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>Total Amount</strong></td>
        
    </tr>
	<tr style="height:40px;">
    	<td class="tabledata"><strong>&nbsp;</strong></td>
        <td class="tabledata" style="white-space:nowrap;"><strong>&nbsp;</strong></td>
        <td class="tabledata" style="white-space:nowrap;"><strong>&nbsp;</strong></td>
        <td class="tabledata" style="white-space:nowrap;"><strong>PF is being <br />deducted</strong></td>
        <td class="tabledata" style="white-space:nowrap;"><strong>(Emplovee<br /> 12%)</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>(Emplover<br /> 8.33%)</strong></td>
	    <td class="tabledata" style="white-space:nowrap;"><strong>(3.67%)</strong></td>
        <td class="tabledata" style="white-space:nowrap;"><strong>A/c No. 2</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>A/c No. 21</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>A/c No. 22</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>&nbsp;</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>ESI deducted </strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>(1.75%) </strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>(4.75%)</strong></td>
		<td class="tabledata" style="white-space:nowrap;"><strong>&nbsp;</strong></td>
        
    </tr>
    <?php $total_amt=array();$sal_on_pf=array();$pp_control=array();$pension=array();$empl=array();$ac2=array();$edli21=array();$ac22=array();$totpf=array();$gss=array();$esi_contribution1=array();$esi_contribution2=array();$totgs=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($empcode!='')
   		$filter[]=" A.id='".$_REQUEST['empcode']."' ";
   	else
   		$filter[]=" 1=1 ";
		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,A.emp_code,A.emp_name,A.bank_name,A.bank_account,B.basic_salary as tot_basic, B.gross_salary as tot_gross from empmaster AS A INNER JOIN master_process_salary AS B on A.id=B.emp_id where B.payslip_month='".$month."' and B.payslip_year='".$years."' and B.emp_id='".$empcode."'";
			}
			else
			{
			
		$query="Select A.id,A.emp_code,A.emp_name,A.bank_name,A.bank_account,SUM(B.basic_salary) as tot_basic, SUM(B.gross_salary) as tot_gross from empmaster AS A INNER JOIN master_process_salary AS B on A.id=B.emp_id where B.payslip_year='".$years."' and emp_id='".$empcode."'";
			}	
		}	
		else
		{
			$query="Select A.id,A.emp_code,A.emp_name,A.bank_name,A.bank_account,B.basic_salary as tot_basic, B.gross_salary as tot_gross from empmaster AS A INNER JOIN master_process_salary AS B on A.id=B.emp_id where $filter";
		}	
	  $ResultData = DB_query($query,$db);
	  if(DB_num_rows($ResultData))
	{
	$i=0;
   	  	while($RowData = DB_fetch_array($ResultData))
   	  	{
		$total_basic=$RowData['tot_basic'];
	    $total_gross=$RowData['tot_gross'];
  ?>
				 <tr style="height:90px;">
    				<td>
    				<?php echo $i+1;?></td>
        			<td style=""><?php echo $RowData['emp_code']; ?></td>
       				<td>
					<?php 
	   					if($RowData['payment_mode']=='Cash')
	   						{echo $RowData['emp_name'];}
	   					else
	   						{echo $RowData['emp_name']."<br/><br/>".$RowData['bank_name']." A/C No. ".$RowData['bank_account'];}
					?>					</td>
       				<td><?php  echo $spf=$total_basic;
					$sal_on_pf[]=$spf;?></td>
        			<td><?php echo  $ppc=round(($total_basic*.12),2);
					$total_amt[]=($total_basic*.12);
					$pp_control[]=$ppc;
					?></td>
		   			
					<td><?php echo  $pen=round(($total_basic*8.33)/100,2);
					$total_amt[]=($total_basic*8.33)/100; 
					$pension[]=$pen;?></td>
		   			<td><?php echo  $emp=round(($total_basic*3.67)/100,2);
					$total_amt[]=($total_basic*3.67)/100; 
					$empl[]=$emp;?></td>
           			<td><?php echo  $ac=round(($total_basic*1.10)/100,2); 
					$total_amt[]= ($total_basic *1.10)/100;
					$ac2[]=$ac;?></td>
              		<td><?php echo  $edli=round(($total_basic*.50)/100,2); 
					$total_amt[]= ($total_basic*.50)/100;
					$edli21[]=$edli;?>&nbsp;</td>
					
       							<td>
         					<?php echo  $acc=round(($total_basic*0.01)/100,2);
							$total_amt[]= ($total_basic*.01)/100;
							$ac22[]=$acc;?></td>
		<td><?php echo $ta1=round(array_sum($total_amt),2);
		$totpf[]=$ta1;?></td>
		<td><?php echo $gs=$total_gross;
		if($gs>15000){
	     $total_gross=0;
		}
		$gss[]=$gs;?></td>
		<td><?php echo $esi_con1=round(($total_gross*1.75)/100,2);
		$total_esiamt[]=($total_gross*1.75)/100;
		$esi_contribution1[]=$esi_con1;?></td>
		<td><?php echo  $esi_con2=round(($total_gross*4.75)/100,2);
		$total_esiamt[]=($total_gross*4.75)/100;
		$esi_contribution2[]=$esi_con2;
		?></td>
		<td><?php echo $ta2=round(array_sum($total_esiamt),2);
		$totgs[]=$ta2;?></td>
      			</tr>
       			
		
	<?php $i++;}?>
	<tr style="height:40px;">
    	<td >&nbsp;</td>
        <td >&nbsp;</td>
        <td ><strong>Total</strong></td>
        <td ><strong><?php echo round(array_sum($sal_on_pf),2);?></strong></td>
		<td ><strong><?php echo round(array_sum($pp_control),2);?></strong></td>
	    <td ><strong><?php echo round(array_sum($pension),2);?></strong></td>
        <td ><strong><?php echo round(array_sum($empl),2);?></strong></td>
		<td ><strong><?php echo round(array_sum($ac2),2);?></strong></td>
		<td ><strong><?php echo round(array_sum($edli21),2);?></strong></td>
		<td ><strong><?php echo round(array_sum($ac22),2);?></strong></td>
		<td ><strong><?php echo round(array_sum($totpf),2);?></strong></td>
		<td ><strong><?php echo round(array_sum($gss),2);?></strong></td>
		<td ><strong><?php echo round(array_sum($esi_contribution1),2);?></strong></td>
		<td ><strong><?php echo round(array_sum($esi_contribution2),2);?></strong></td>
		<td ><strong><?php echo round(array_sum($totgs),2);?></strong></td>
        
    </tr>
   <?php }else{
		echo "<tr><td colspan=30>No Record Found</td></tr>";
	} 
  
?>
    </table>
	</div>
	
  
  </form>
    
</center> 
       
<script language="javascript">
function LeadData()
{	
	//var test=document.getElementById("SalaryProcessed").value;
	myCheckboxArray = document.myform.elements["SalaryProcessed[]"];
	var t=myCheckboxArray.length;
	if(document.getElementById('SalaryProcessed').checked==true)
	{	
		if(t==undefined)
		document.getElementById('SalaryProcessed_'+0).checked=true;		
		for (var i = 0; i < t; i++)
		{
			//if(document.getElementById('process_status_'+i).value=='N'){
				document.getElementById('SalaryProcessed_'+i).checked=true;
			//}else{
			//	document.getElementById('SalaryProcessed_'+i).disabled=true;
			//}
		}	
	}
	else
	{
		if(t==undefined)		
		document.getElementById('SalaryProcessed_'+0).checked=false;		
	
		for (var i = 0; i < t; i++)
		{
			document.getElementById('SalaryProcessed_'+i).checked=false;	
		}
	}
}

function chksalprocess()
{
		var today = new Date();
		var dd = today.getDate();
		var currmonth = today.getMonth()+1; //January is 0!
		var CurrentYear=today.getFullYear();
		
		var selmonth=document.getElementById("paymonth").value;
		var selyear=document.getElementById("payyear").value;
		
		if(selmonth>=currmonth)
		{
			alert("You Can Process Only Previous Month Salary");
			return false;
		}
		
	//return false;
}
</script>
<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
       var e = document.getElementById(id);
	      e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }
  
</script>
</div>
</div>
	