
<link rel="stylesheet" href="css/new_mxerp.css">
<script>
function chk_type_employee()
{
if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if (xmlhttp.readyState==4 && xmlhttp.status==200)
	{
           //alert(xmlhttp.responseText);
	  document.getElementById("employee_code").innerHTML=xmlhttp.responseText;
	}
	}
	var site=document.getElementById("site").value;
	var month=document.getElementById("paymonth").value;
	var year=document.getElementById("payyear").value;
	var type=document.getElementById("emptype").value;
	xmlhttp.open("GET","check_data_ajax.php?section=chk_type_employee&site="+site+"&month="+month+"&year="+year+"&type="+type,true);
	xmlhttp.send();
}

function chk_type_dept_employee()
{
if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if (xmlhttp.readyState==4 && xmlhttp.status==200)
	{
           //alert(xmlhttp.responseText);
	  document.getElementById("employee_code").innerHTML=xmlhttp.responseText;
	}
	}
	var site=document.getElementById("site").value;
	var month=document.getElementById("paymonth").value;
	var year=document.getElementById("payyear").value;
	var type=document.getElementById("dept").value;
	xmlhttp.open("GET","check_data_ajax.php?section=dept_wise_employee&site="+site+"&month="+month+"&year="+year+"&type="+type,true);
	xmlhttp.send();
}

</script>

<?php
function floor_dec($number,$precision,$separator)
{
    $numberpart=explode($separator,$number);
    $numberpart[1]=substr_replace($numberpart[1],$separator,$precision,0);
    if($numberpart[0]>=0)
    {$numberpart[1]=floor($numberpart[1]);}
    else
    {$numberpart[1]=ceil($numberpart[1]);}

     $ceil_number= $numberpart[1];
    return $ceil_number;
}
function floor_dec1($number,$precision,$separator)
{
    $numberpart=explode($separator,$number);
    $numberpart[1]=substr_replace($numberpart[1],$separator,$precision,0);
    if($numberpart[0]>=0)
    {$numberpart[1]=floor($numberpart[1]);}
    else
    {$numberpart[1]=ceil($numberpart[1]);}

     $ceil_number= $numberpart[0];
    return $ceil_number;
}

if(isset($_POST['Reset']))
{
unset($_SESSION['emp_data']);
unset($_SESSION['emp_allowance']);
unset($_SESSION['emp_deduction1']);
unset($_SESSION['emp_addtion']);
}
?>
<div class="body_contain">
<div class="tab_div">
<h1>Salary Register</h1>
<?php //error_reporting(0);
include('includes/fun-HRClass.php');
include('includes/fun-php.php');
?>
 <form action="" method="post">
  <table width="100%" align="center" border="0" cellspacing="0" cellpadding="3">
  <tr class="row1">
  	<td width="13%" align="right">Branch</td>
  	<td width="20%"><select name="site" id="site" onchange="chk_type_employee();">			
			<?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">Month</td>
  	<td width="20%"><select name="paymonth" id="paymonth" onchange="chk_type_employee();">
 		<?php	$arr=array(1=>"Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec");
 				foreach ($arr as $key => $value) {
 				
 				?>
			<option value="<?php echo $key;?>" <?php if($key==$_REQUEST['paymonth']){ ?> selected="selected"; <?php } ?> ><?php echo $value;?></option>
 		<?php } ?>
		</select></td>
  	<td width="13%" align="right">Year</td>
  	<td><select name="payyear" id="payyear" onchange="chk_type_employee();">
 		<?php for($i=date('Y');$i>2000;$i--){
 			  $p='';
 	          if( $i==$years)
	          $p='selected';?>
			<option value="<?php echo $i;?>" <?php echo $p;?>><?php echo $i;?></option>
 		<?php }?>
		</select>
   </td>
 </tr>
 <tr class="row1">
    <td align="right">Grade</td>
	<td><select name="grade" id="grade" > 
      <option value="0">Select</option>
      <?php 
       $sql_dept=DB_query("select * from emp_grade ",$db);
       while($row_dept=DB_fetch_array($sql_dept))
       {
       	$dep='';
       	if($_REQUEST['grade']==$row_dept['id'])
       		$dep='selected';
      ?>
      <option value="<?php echo $row_dept['id']; ?>" <?php echo $dep; ?>><?php echo $row_dept['grade_name']; ?></option>
      <?php } ?>
			</select></td>
    <td align="right">Department</td>
	<td><select name="dept" id="dept" onchange="chk_type_dept_employee();" > 
      <option value="0">Select</option>
      <?php 
       $sql_dept=DB_query("select * from deptmaster where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
       while($row_dept=DB_fetch_array($sql_dept))
       {
       	$dep='';
       	if($_REQUEST['dept']==$row_dept['id'])
       		$dep='selected';
      ?>
      <option value="<?php echo $row_dept['id']; ?>" <?php echo $dep; ?>><?php echo $row_dept['deptname']; ?></option>
      <?php } ?>
			</select></td>
  <td align="right">Employee Type</td>
  <td><select name="emptype" id="emptype" onchange="chk_type_employee();" > 
		<option value="R" <?php echo($emptype=='R'?'selected':'')?>>Regular Employee</option>
		<option value="C" <?php echo($emptype=='C'?'selected':'')?>>Contract Employee</option>
		<option value="P" <?php echo($emptype=='P'?'selected':'')?>>Probation Employee</option>
	  </select></td>
</tr>
<tr class="row1">
  <td align="right">Emp. Code</td>
  <td><div id='hid-empdiv'><select name="employee_code" id="employee_code" >
			<option value="All">All</option>
			<?php if($_REQUEST['paymonth']!='' && $_REQUEST['payyear']!='' && $_REQUEST['emptype']!=''){
                        $chk_date=$_REQUEST['payyear']."-".$_REQUEST['paymonth']."-01";
                        $chk_date1=$_REQUEST['payyear']."-".$_REQUEST['paymonth']."-31";
                        $emp_sql = DB_query("SELECT id,emp_code ,emp_name FROM empmaster WHERE CompanyId='".$_SESSION['ACGCompanyId']."' AND emp_site='".$_REQUEST['site']."' AND staff_type='".$_REQUEST['emptype']."' AND (dol>='".$chk_date."' OR dol='0000-00-00') AND doj<='".$chk_date1."' 
              ORDER BY emp_name ASC",$db);
                        }else{
                        $chk_date=date('Y')."-".date('m')."-01";
                        $chk_date1=date('Y')."-".date('m')."-31";
                        $emp_sql=DB_query("SELECT id,emp_code ,emp_name FROM empmaster WHERE CompanyId='".$_SESSION['ACGCompanyId']."' AND employment_type='Permanent' AND (dol>='".$chk_date."' OR dol='0000-00-00') AND doj<='".$chk_date1."' ORDER BY emp_name ASC",$db);
                        }
			while($emp_row=DB_fetch_array($emp_sql)){?>
			<option value="<?php echo $emp_row['id'];?>"<?php if($_REQUEST['employee_code']==$emp_row['id'])echo "selected";?>><?php echo $emp_row['emp_name'].' ( '.$emp_row['emp_code'].' ) ' ;?></option>
			<?php }?>
		</select></div></td>
 	<td colspan="4"></td>
</tr>
<tr class="row1">
	<td colspan="6" style="text-align:center;"><input type="submit" name="Search" value="Search" class="search" /></td>
</tr>
</table>
</form>
  
<p align="right"><a href="salary_process_new_print_1.php" target="_blank" class="search">Print</a></p> 
<h3>Salary Details</h3>

<?php $q3 =DB_query("Select * from deduction_master",$db); $ded_rows=DB_num_rows($q3) ;?>
<?php $q4 =DB_query("Select * from allowmaster",$db); $all_rows=DB_num_rows($q4);?>
<?php $q5 =DB_query("SELECT * FROM other_deduction_master WHERE status='A' AND type='D'",$db); $other_dd_rows=DB_num_rows($q5) ;?>
<?php $q6 =DB_query("SELECT * FROM other_deduction_master WHERE status='A' AND type='A'",$db); $other_aa_rows=DB_num_rows($q6) ;?>

	<div style="width:1246px; overflow:auto; margin:0 auto;">
	<table width="2100" cellpadding="3" cellspacing="0" border="0" class="thborder">
	<tr>
	    <th colspan="9">&nbsp;</th>
		<th colspan="<?php echo $all_rows+2;?>"><b>EARNINGS</b></th>
		<th style="white-space:nowrap;" valign="top"><b>GROSS WAGES </b></th>
		<th colspan="<?php echo $ded_rows+$other_dd_rows;?>"><b>DEDUCTIONS</b></th>
		<?php if(isset($other_aa_rows) && $other_aa_rows>=1){?>
		<th colspan="<?php echo $other_aa_rows;?>"><b>ADDITIONS</b></th>
		<th colspan="3"></th>
		<?php } ?>
		<!--<th><b>TOTAL</b></th>-->
		<?php if($_REQUEST['emptype']=='Temporary'){ $colspan="colspan='2'";}?>
		<!--<th <?php echo $colspan;?>><?php if($_REQUEST['emptype']=='Temporary'){?>
		<div align="center"><b>OT</b>
		<?php }else  ?>
	    &nbsp;</div></th>-->
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th colspan="4">&nbsp;</th>
	</tr>
	<tr>
    	<th>S. No.</th>
        <th style="white-space:nowrap;">Emp Code</th>
        <th style="white-space:nowrap;">Emp Name</th>
        <th style="white-space:nowrap;">Designation</th>
        <th style="white-space:nowrap;">Month Days</th>
		<th style="white-space:nowrap;">Present Days</th>
	    <th style="white-space:nowrap;">Sal Days</th>
        <th style="white-space:nowrap;">P.F. No.</th>
		<th style="white-space:nowrap;">E.S.I. No.</th>       
        <th style="white-space:nowrap;">Payable Basic</th>
		<?php
	  		$net_earning=0;
	  		$query_allowances =DB_query("Select * from allowmaster",$db); 
	  		$j=1;
	  		$n=DB_num_rows($query_allowances);
	  		$nx= round(70/$n,2);
	  		while($row_allowances=DB_fetch_array($query_allowances))
	  		{ 	
	  		$rowallowance_id[]=$row_allowances['id'];	  
		?> 
    	<th>
    		<?php echo $row_allowances['allowcode'];?><input name="allowmasterid[]" type="hidden"  value="<?php echo $row_allowances['id'];?>"/></th>
		<?php if($row_allowances['allowcode']=='LTA') {?>
		<!--<th>Special Allowance</th>-->
		<?php } ?>
     	<?php } ?>
		<th>Special Allowance</th>
		<th>&nbsp;</th>
        <?php 
		$essi='';
		$query_allowances =DB_query("Select * from deduction_master",$db); 
	 	   	$n=DB_num_rows($query_allowances);
	   	   	$nx1= round(70/($n+3),1);
	  		while($row_allowances=DB_fetch_array($query_allowances)){
			$essi[]=$row_allowances['code'];
			$deductionid[]=$row_allowances['id'];
			?> 
    	<th><?php echo $row_allowances['code'];?><input name="deductionid[]" type="hidden"  value="<?php echo $row_allowances['id'];?>"/></th>       
     	<?php } ?>
     	<?php 
     	$GetOther_Ddmaster = DB_query("SELECT id,name FROM other_deduction_master WHERE status='A' and type='D' AND CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
	  				while($RecOthr_Dd=DB_fetch_array($GetOther_Ddmaster))
	  				{?>
        <th><?php echo ''.$RecOthr_Dd['name'].'';
                   $ddArr[]=$RecOthr_Dd['id'];
					?></th>
			<?php } ?>		
	    <th>Adv</th>   
		<th>Loan</th> 
     	<th style="white-space:nowrap;">Loan Bal</th>    
     	<th style="white-space:nowrap;">Total Deduction</th>
     	<?php 
     	//echo "SELECT id,name FROM other_deduction_master WHERE status='A' and type='A' AND CompanyId='".$_SESSION['ACGCompanyId']."'";
     	$GetOther_Amaster = DB_query("SELECT id,name FROM other_deduction_master WHERE status='A' and type='A' AND CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
	  				while($RecOthr_A=DB_fetch_array($GetOther_Amaster))
	  				{ ?>
        <th><?php echo ''.$RecOthr_A['name'].'';
                   $aaArr[]=$RecOthr_A['id'];
					?></th>
		<?php } ?>
		<th style="white-space:nowrap;">Total Addition</th>
		<th style="white-space:nowrap;">OT amount</th>  
      	<th style="white-space:nowrap;">Gross Wages</th>    	
    	<th style="white-space:nowrap;">TDS Deduction</th>	     
    	<th style="white-space:nowrap;">Reserve Pay</th>	       	
		<th style="white-space:nowrap;">Net Pay</th>
    </tr>

     <?php
     if(isset($_POST['Search']))
     {
        $month = $_REQUEST['paymonth'];
	    $years = $_REQUEST['payyear'];
  	    $filter='';
	    if($_REQUEST['site']!='000')
   		$filter[]="emp_site='".$_REQUEST['site']."'";		
 	    if($_REQUEST['employee_code']!='All')
   		$filter[]="id='".$_REQUEST['employee_code']."'";	
   	    if($_REQUEST['emptype']!='')
    	$filter[]="  staff_type='".$_REQUEST['emptype']."'";
	    if($_REQUEST['dept']!='0')
	   	$filter[]="  department='".$_REQUEST['dept']."'";
	   if($_REQUEST['grade']!='0')
	   $filter[]="  grade='".$_REQUEST['grade']."'";	
	if($filter!='')
	{
	$filter=implode(' and ',$filter);
	}			
     $GetRecord = "Select * from empmaster where  $filter  and blocked!='1'";
    $ResultData = DB_query($GetRecord,$db);
	if(DB_num_rows($ResultData))
	{
		$k=1;
		while($RowData = DB_fetch_array($ResultData))
   	  	 {
           $dedamt='';$addamt='';
   	     $emp_query = "select * from master_process_salary where emp_id='".$RowData['id']."' 
			and payslip_month='".$_REQUEST['paymonth']."' and payslip_year='".$_REQUEST['payyear']."' and status='Y'";
			$emp_res = DB_query($emp_query,$db) or die(DB_error());
			if(DB_num_rows($emp_res)>0)
			{
			$emp_result = DB_fetch_array($emp_res);
		$workingdays1= cal_days_in_month(CAL_GREGORIAN, $_REQUEST['paymonth'], $_REQUEST['payyear']);
		$weeklyoff= worker_holiday_wl($RowData['id'],$_REQUEST['paymonth'], $_REQUEST['payyear'],'WL',$RowData['doj']);
		 $holiday=worker_holiday_wl($RowData['id'],$_REQUEST['paymonth'], $_REQUEST['payyear'],'HO',$RowData['doj']);
		 $workingdays=$workingdays-($weeklyoff+$holiday);

		  $payable_day = payable_day($RowData['id'],$_REQUEST['paymonth'], $_REQUEST['payyear'],'P',$RowData['doj']);
     ?>
    <tr>
    <td><?php echo $k++; ?></td>	
    <td><?php echo $RowData['emp_code']; ?></td>	
    <td><?php echo $RowData['emp_name']; ?></td>	
    <td><?php echo $desg=$s->getField('desigmaster','id',$RowData['designation'],'designame'); ?></td>   
    <td><?php echo $workingdays1; ?></td> 
    <td><?php echo $payable_day; ?></td> 
    <td><?php echo $emp_result['workingdays']; ?></td> 
    <td><?php echo $RowData['PFno'] ?></td>
    <td><?php echo $RowData['ESIno'] ?></td>
    <td><?php echo $basic[]=$emp_result['basic_salary'];?></td>
    <?php if(!empty($rowallowance_id)) { 
     foreach($rowallowance_id as $key=>$value)
    {
    ?>    
    <td><?php  echo $total= $s->GetFieldValue("payslip_salary","mst_prosal='".$emp_result ['id']."' and emp_id='".$RowData['id']."' and allowance_id='".$value."' and allowance_type='A'","allowance_amount"); 
    $data_allowance[$RowData['id']][$value]=$total; $earning[$value][]=$total;?></td>
    <?php } } ?>
    <td><?php  echo $special_allowance= $s->GetFieldValue("payslip_salary","mst_prosal='".$emp_result ['id']."' and emp_id='".$RowData['id']."' 
    	and allowance_id='100' and allowance_type='A'","allowance_amount"); 
      $earning_special[]=$special_allowance;
    ?></td>
    <td><?php echo $gross_amt= $emp_result['gross_salary']; $earning_gross[]=$gross_amt; ?></td>
    <?php
if(!empty($deductionid)) { 
     foreach($deductionid as $key=>$val)
    {
    ?>
    <td><?php echo  $ded1= $s->GetFieldValue("payslip_salary","mst_prosal='".$emp_result ['id']."' and emp_id='".$RowData['id']."' and allowance_id='".$val."' and allowance_type='D'","allowance_amount"); 
       $data_deducation[$RowData['id']][$val]=$ded1; $dedamt[]=$ded1; $earning_deducation[$val][]=$ded1;
    ?></td>
    <?php } } ?>
    <?php
     if(!empty($ddArr)) { 
     foreach($ddArr as $key1=>$val1){?>
    <td>
    <?php $sql_mont=DB_fetch_array(DB_query("SELECT B.amount as amount
           FROM monthly_other_deducation AS A INNER JOIN monthly_other_deducation_details AS B
		   ON A.id=B.parentid 	WHERE B.other_ded_type='D' AND A.empid='".$RowData['id']."' 
		   AND A.MONTH='".$_REQUEST['paymonth']."' AND A.YEAR='".$_REQUEST['payyear']."' AND B.other_ded='".$val1."'",$db));
		   $dedamt[]= $sql_mont['amount'];
           $data_deducation1[$RowData['id']][$val1]=$sql_mont['amount'];
           $earning_deducation_part2[$val1][]=$sql_mont['amount'];
		    ?>	
    </td>
    <?php }  } ?>
    <td><?php echo $dedamt[]= $emp_result['advance_balance']; $advance_amt[]=$emp_result['advance_balance']; ?></td>
    <td><?php echo $dedamt[]=$emp_result['loan']; $loan_addition_amt[]=$emp_result['loan']; ?></td>
    <td><?php echo $emp_result['balance_loanamt']; $load_balance_amt[]=$emp_result['balance_loanamt'];  ?></td>
    <td><?php echo $deductionamt= array_sum($dedamt); $total_deduction_amt[]=$deductionamt; ?></td>
    <?php error_reporting("0");
    foreach($aaArr as $key2=>$val2){
    	?>
    <td><?php 

    $GetOther_A =DB_fetch_array(DB_query("SELECT B.amount FROM monthly_other_deducation AS A
			INNER JOIN monthly_other_deducation_details AS B ON A.id=B.parentid
			WHERE B.other_ded_type='A' AND A.empid='".$RowData['id']."' 
			AND A.MONTH='".$_REQUEST['paymonth']."'	AND A.YEAR='".$_REQUEST['payyear']."'
			AND B.other_ded='".$val2."'",$db));
         $addamt[]= $GetOther_A['amount'];
        $data_addtion[$RowData['id']][$val2]=$GetOther_A['amount'];
        $other_addtion_amt[$val2][]=$GetOther_A['amount'];
			 ?>			  		
    </td>
    <?php } ?>
    <td><?php echo $addition_amt=array_sum($addamt); $addition_amt_total[]=$addition_amt;?></td>
   <td><?php echo $othe_ded=$s->GetFieldValue('ot_management',"emp_id='".$RowData['id']."' AND month1='".$_REQUEST['paymonth']."' AND year1='".$_REQUEST['payyear']."'",'ot_amr'); $total_other_ded[]=$othe_ded; ?></td>
    <td><?php echo $gross_wases=($gross_amt+$addition_amt-$deductionamt); $total_gross_amt[]=$gross_wases;  ?></td>    
     <td><?php echo $tds_deduction= $emp_result['tds_deduction']; $total_tds_deduction[]=$tds_deduction; ?></td>
     <td><?php echo $resveramt[]= $emp_result['rev_sal_amt']; ?></td>
    <td><?php echo $netpayble= $emp_result['net_earning']; $total_net_payable[]=$netpayble; ?></td>
    
     </tr>
 <?php 
 $data_array[]=array("empid"=>$RowData['id'],"emp_code"=>$RowData['emp_code'],"emp_name"=>$RowData['emp_name'],"desgination"=>$desg,"pfno"=>$RowData['PFno'],"ESI"=>$RowData['ESIno'],"basic_sal"=>$emp_result['basic_salary'],"special_allowance"=>$special_allowance,"gross_amt"=>$gross_amt,"advance_amt"=>$emp_result['advance_balance'],"loan"=>$emp_result['loan'],"bal_loan"=>$emp_result['balance_loanamt'],"total_deduction"=>$deductionamt,"addtion_amt"=>$addition_amt,"total_gross"=>$gross_wases,"other_ded"=>$othe_ded,"netpayble"=>$netpayble,"monthdays"=>$workingdays,"paydays"=>$payable_day,"working_days"=>$emp_result['workingdays'],"tds_ded"=>$tds_deduction,"reverse"=>$emp_result['rev_sal_amt']);
   }
  }

 ?> 
 <tr>
 <td></td>
 <td></td>
 <td></td>
 <td></td>
 <td></td>
 <td></td>
 <td></td>
 <td></td>
 <td><strong>Total</strong></td>
 <td><?php if(!empty($basic)) echo array_sum($basic); ?></td>
 <?php foreach($rowallowance_id as $key=>$value)
 {
 ?>
 <td><?php  if(!empty($earning[$value])) echo array_sum($earning[$value]); ?></td>
 <?php } ?>  
 <td><?php if(!empty($earning_special)) echo array_sum($earning_special); ?></td>
 <td><?php if(!empty($earning_gross)) echo array_sum($earning_gross); ?></td>
 <?php foreach($deductionid as $key=>$val)
  {
  ?>
  <td><?php if(!empty($earning_deducation[$val])) echo array_sum($earning_deducation[$val]); ?></td>
  <?php } ?>

  <?php 
if(!empty($ddArr)){
  foreach($ddArr as $key1=>$val1){?>
 
  <td><?php if(!empty($earning_deducation_part2[$val1])) echo array_sum($earning_deducation_part2[$val1]); ?></td>
  <?php } } ?>
</td>
<td><?php if(!empty($advance_amt)) echo array_sum($advance_amt); ?></td>
<td><?php if(!empty($loan_addition_amt)) echo array_sum($loan_addition_amt); ?></td>
<td><?php if(!empty($load_balance_amt)) echo array_sum($load_balance_amt); ?></td>
<td><?php error_reporting("0");
if(!empty($total_deduction_amt)) echo array_sum($total_deduction_amt); ?></td>
 <?php foreach($aaArr as $key2=>$val2){?>
 <td><?php if(!empty($other_addtion_amt[$val2])) echo array_sum($other_addtion_amt[$val2]); ?></td>
 <?php } ?>
 <td><?php if(!empty($addition_amt_total)) echo array_sum($addition_amt_total); ?></td>
 <td><?php if(!empty($total_other_ded)) echo array_sum($total_other_ded); ?></td>
 <td><?php if(!empty($total_gross_amt)) echo array_sum($total_gross_amt); ?></td> 
 
 <td><?php if(!empty($total_tds_deduction)) echo array_sum($total_tds_deduction); ?></td> 
 <td><?php if(!empty($resveramt)) echo array_sum($resveramt); ?></td>
 <td><?php if(!empty($total_net_payable)) echo array_sum($total_net_payable); ?></td>
 </tr>
 <?php
 } 
$_SESSION['emp_data']=$data_array;
$_SESSION['emp_allowance']=$data_allowance;
$_SESSION['emp_deduction1']=$data_deducation;
$_SESSION['emp_deduction2']=$data_deducation1;
$_SESSION['emp_addtion']=$data_addtion;
}
?>
</table>
</div>
</div>
</div>