<?php
session_start();  
include_once("class/class.MySQL.php");

$db	=new MySQL();
  ///////////////////////////////////////
 	$action = $_POST['status'];
 if($action == "ar"){
 	$html 	= '<html><head>
	
		<style type="text/css">
		body {font-family: "Trebuchet MS";color: #202020;font-size: 12px;line-height: 16px; background: #fff;}
		.content {
		  padding: 20px 15px;
		  overflow: auto;
		}
		h1,
		h2,
		h3,
		h4,
		h5,
		h6,
		.h1,
		.h2,
		.h3,
		.h4,
		.h5,
		.h6 {
		  font-family: "Source Sans Pro", sans-serif;
		}
		.table{
			border-collapse:collapse;
			margin-bottom:15px;
		}
		.table td{border:2px #F4F4F4 solid; padding-left:5px;}
		.table tr{height:30px;color:#202020;font-size:12px; line-height:20px;}
		.title{font-weight:bold;}
		</style>
	  </head>
	  <body>';
	

	 $html .='
	  <div class="content" style="page-break-after:always;">
	  
	  <table style="width:100%;">
		<tr>
		<td style="text-align:center;width:90%;"><h4 style="margin:0px 0px 5px 0px;"> ACCIDENT REGISTER </h4> </td></tr>
				
		<tr>
		<td style="text-align:center;width:90%;"><h3 style="margin:0px 0px 5px 0px;">EMPLOYEES STATE INSURANCE CORPORATION
</h3> 
		</td>
		</tr>
	   </table>	
	  
		
		 
		<table width="100%" border="1" cellspacing="2" cellpadding="2" class="table">
		  <tr>
			<td class="title" style="vertical-align:middle;">SI NO</td>
			<td class="title" style="vertical-align:middle;">Date of Notice</td>
			<td class="title" style="vertical-align:middle;">Time of Notice</td>
			<td class="title" style="vertical-align:middle;">Name and Address Of Injured Person</td>
			<td class="title" style="vertical-align:middle;">Gender </td>
			<td class="title" style="vertical-align:middle;">Age </td>
			<td class="title" style="vertical-align:middle;">Insurance No</td>
			<td class="title" style="vertical-align:middle;">Shift, Department and Occupation of the employee</td>				<td class="title" colspan="5">Details of Injury</td>
		  </tr>
		  
		  <tr>
			<td class="title"></td>
			<td class="title" ></td>
			<td class="title" ></td>
			<td class="title" ></td>
			<td class="title" ></td>
			<td class="title" ></td>
			<td class="title" ></td>
			<td class="title" ></td>
			<td class="title" >Cause</td>
			<td class="title" >Nature</td>
			<td class="title" >Date</td>
			<td class="title" >Time</td>
			<td class="title" >Place</td>
		  </tr>
		  
		  <tr>
			<td class="title">1</td>
			<td class="title" >2</td>
			<td class="title" >3</td>
			<td class="title" >4</td>
			<td class="title" >5</td>
			<td class="title" >6</td>
			<td class="title" >7</td>
			<td class="title" >8</td>
			<td class="title" >9</td>
			<td class="title" >10</td>
			<td class="title" >11</td>
			<td class="title" >12</td>
			<td class="title" >13</td>
		  </tr>
 
		  ';
	
		$i=1;	
				  
		/*$userdetails = $db->fetchQuery("SELECT *,CONCAT(e_fname,e_lname)as emp_name FROM employee where emp_basic_pay!=0 AND STR_TO_DATE(date_join,'%d-%m-%Y') between STR_TO_DATE('".$_REQUEST[from_date]."','%d-%m-%Y') AND STR_TO_DATE('".$_REQUEST[to_date]."','%d-%m-%Y')");*/
		
		/*$userdetails = $db->fetchQuery("SELECT *,CONCAT(e_fname,e_lname)as emp_name FROM employee where emp_basic_pay!=0 and STR_TO_DATE(date_join,'%d-%m-%Y') between STR_TO_DATE('".$_REQUEST["from_date"]."','%d-%m-%Y') AND STR_TO_DATE('".$_REQUEST["to_date"]."','%d-%m-%Y')");*/
		//$sqlstring="SELECT *,CONCAT(e_fname,e_lname)as emp_name FROM employee where emp_basic_pay!=0 and date_join between '".$_REQUEST["from_date"]."' AND '".$_REQUEST["to_date"]."'";
			
				$cond="";
			/*$emp_id	 = $_POST['emp'];
	if(!empty($emp_id))$cond = 'where e_id IN('.implode(',',$emp_id).')';*/
	$cond=" where 1 ";
				 if(isset($_REQUEST["emp"])  && !empty($_REQUEST['emp'])){
		   	$cond.=" and e_id in (".$_REQUEST['emp'].") ";
	
	 $userdetails =  $db->fetchQuery("SELECT e_add,e_gender,date_join,CONCAT(e_fname,e_lname)as emp_name,desig_name,depart_name from employee em left join designation d on em.e_post=d.desig_id left join department dpt on d.departs_id=dpt.depart_id $cond");
		
			
		
	$i=1;
	$sum_gross=0;
	$sum_esi=0;
		foreach($userdetails as $details) {
			//$age=date_diff(date_create($details['date_join']), date_create('today'))->y;	
			if($details['date_join']!=""){
				$c= date('Y');
$y= date('Y',strtotime($details['date_join']));
$age= $c-$y;
			}else $age="";
			 $html .=  '
			  <tr>
			<td class="title">'.$i++.'</td>
			<td class="title" ></td>
			<td class="title" ></td>
			<td class="title" >'.$details['emp_name'].','.$details['e_add'].'</td>
			<td class="title" >'.$details['e_gender'].'</td>
			<td class="title" >'.$age.'</td>
			<td class="title" ></td>
			<td class="title" >'.$details['depart_name'].', '.$details['desig_name'].'</td>
			<td class="title" ></td>
			<td class="title" ></td>
			<td class="title" ></td>
			<td class="title" ></td>
			<td class="title" ></td>
		  </tr>
		  
				';
			
				
				  
		}
		$html .= ' </table>
		<br/><br/><br/><br/>
		<table width="100%" border="1" cellspacing="2" cellpadding="2" class="table">
		  <tr>
			<td class="title" style="vertical-align:middle;">What exactly was the injured person doing at the time
of accident
</td>
			<td class="title" style="vertical-align:middle;">Name, occupation, address and signature or the thumb impression of the person(s)giving notice</td>
			<td class="title" style="vertical-align:middle;">Signature and designation of the person who makes the entry in the Accident Book</td>
			<td class="title" style="vertical-align:middle;">Name, address and occupation of two witnesses
</td>
			<td class="title" style="vertical-align:middle;">Remarks, if any</td>
		  </tr>
		  
		 	  
		  <tr>
			<td class="title">14</td>
			<td class="title" >15</td>
			<td class="title" >16</td>
			<td class="title" >17</td>
			<td class="title" >18</td>
		  </tr>
 
		  ';
	
		$i=1;	
				  
				
	$i=1;
	$sum_gross=0;
	$sum_esi=0;
		foreach($userdetails as $details) {
			
			 $html .=  '
			  <tr>			
			<td class="title" ></td>
			<td class="title" >'.$details['emp_name'].', '.$details['e_add'].', '.$details['desig_name'].'</td>	
			<td class="title" ></td>
			<td class="title" ></td>
			<td class="title" ></td>
		  </tr>
		  
				';
				$sum_gross+= $details['total_payable'];
				$sum_esi+= $details['dtl_esi'];
				
				  
		}
		$html .= '
		 		 		  
				  
				  </table>
				  
				  
				  
				  
				  
				  
				  
				  
				  
					<div style="position: fixed; left: 0px; bottom: -140px; right: 0px; height: 150px;">Date : '.date('d-M-Y').'
					<span style="padding-left:30px;">Stamp of the Factory / Estt.</span>
					<span style="padding-left:100px;">Signature of the Employer or</span>
					<span style="padding-left:290px;">other Authorised Officer of the Factory / Establishment</span>
					</div>
				   </div>
				   </body></html>';
				   echo $html;
 } 
 else{
 	

	$html 	= '<html><head>
	
		<style type="text/css">
		body {font-family: "Trebuchet MS";color: #202020;font-size: 12px;line-height: 16px; background: #fff;}
		.content {
		  padding: 20px 15px;
		  overflow: auto;
		}
		h1,
		h2,
		h3,
		h4,
		h5,
		h6,
		.h1,
		.h2,
		.h3,
		.h4,
		.h5,
		.h6 {
		  font-family: "Source Sans Pro", sans-serif;
		}
		.table{
			border-collapse:collapse;
			margin-bottom:15px;
		}
		.table td{border:2px #F4F4F4 solid; padding-left:5px;}
		.table tr{height:30px;color:#202020;font-size:12px; line-height:20px;}
		.title{font-weight:bold;}
		</style>
	  </head>
	  <body>';
	
$sql="SELECT month(paysal.pay_period) as month,CONCAT(e_fname,e_lname)as emp_name,dtl_esi as esi,sum(total_payable) as total_wages,sum(worked_days) as days,d.desig_name,date_join,resigned_dat,userid FROM employee as em left join gratuity_table g on g.e_id=em.e_id left join designation d on em.e_post=d.desig_id left join payroll_salary_pay as paysal ON em.e_id = paysal.userid left join pf_esi_details as pfesi on pfesi.emp_id = em.e_id 
left join (select payment_id,amount as dtl_esi from payroll_salary_pay_details where name like '%esi%')as saldtl4 on paysal.id=saldtl4.payment_id  ";
/*$sql="SELECT month(paysal.pay_period) as month,CONCAT(e_fname,e_lname)as emp_name,dtl_esi as esi,total_wages,days,d.desig_name,date_join,resigned_dat,paysal.userid FROM employee as em left join gratuity_table g on g.e_id=em.e_id left join designation d on em.e_post=d.desig_id left join payroll_salary_pay as paysal ON em.e_id = paysal.userid left join pf_esi_details as pfesi on pfesi.emp_id = em.e_id left join (select payment_id,amount as dtl_esi from payroll_salary_pay_details where name like '%esi%')as saldtl4 on paysal.id=saldtl4.payment_id left join (select sum(total_payable) as total_wages,userid from payroll_salary_pay)as wages on wages.userid=em.e_id left join (select sum(worked_days) as days, userid from payroll_salary_pay)as days on days.userid=em.e_id ";*/
		
	if(isset($_REQUEST["half_year"]))
		{
			$y=$_REQUEST["half_year"];
			if($y==1){
				$name="First Half of";
				$m1=4;
				$m2=9;
				$m3="";
				$m4="";
				$sql.="where month(paysal.pay_period) between '".$m1."' and '".$m2."'";
			}
			if($y==2){
				$name="Second Half of";
				$m1=10;
				$m2=12;
				$m3=1;
				$m4=3;
				$sql.="where month(paysal.pay_period) between '".$m1."' and '".$m2."' or month(paysal.pay_period)between '".$m3."' and '".$m4."'";
			}
		}	
			
		$sql.=" group by month(paysal.pay_period),userid ";
		
		
		
	 $html.='
	  <div class="content" >
	  
	  <table style="width:100%;">
		<tr>
		<td style="text-align:center;width:90%;"><h4 style="margin:0px 0px 5px 0px;"> FORM 6 </h4> </td></tr>
		<tr>
		<td style="text-align:center;width:90%;"><h3 style="margin:0px 0px 5px 0px;">ESI Report For '.$name.' '.date('Y').'</h3> 
		</td>
		</tr>
		<tr>
		<td style="text-align:center;width:90%;"><h3 style="margin:0px 0px 5px 0px;">REGISTER OF EMPLOYEES </h3> 
		</td>
		</tr>
		<tr>
		<td style="text-align:center;width:90%;"><h3 style="margin:0px 0px 5px 0px;">EMPLOYEES STATE INSURANCE CORPORATION
</h3> 
		</td>
		</tr>
		<tr>
		<td>
		
		</td>
		</tr>
	   </table>		
		 
		
		  ';
	
		$i=1;					  
		$userdetails =  $db->fetchQuery($sql);
			
		
	$i=1;
	$sum_gross=0;
	$sum_esi=0;
	$m="";
	
	if($y==1){
		$d1=4;
		$d2=5;
		$d3=6;
		$d4=7;
		$d5=8;
		$d6=9;
		
		$month1="April";
		$month2="May";
		$month3="June";
		$month4="July";
		$month5="August";
		$month6="September";
		
	}
	if($y==2){
		$d1=10;
		$d2=11;
		$d3=12;
		$d4=1;
		$d5=2;
		$d6=3;
		
		$month1="October";
		$month2="November";
		$month3="December";
		$month4="January";
		$month5="February";
		$month6="March";
	}
		
		$days=array();
		$total_wages=array();
		$total_esi=array();	
		$datejoin=array();
		
	
		
		$html.='<table width="100%" border="1" cellspacing="2" cellpadding="2" >
		<tr>
			<td class="title"></td>			
			<td class="title"></td>
			<td class="title"></td>
			<td class="title"></td>
			<td class="title"></td>
			<td class="title"></td>
			<td class="title"></td>
			<td colspan="3" class="title" style="text-decoration: underline;" text-align: center;>Month '.$month1.'</td>						
		  </tr>
		  <tr>
			<td class="title">SI NO</td>			
			<td class="title">Insurance No</td>
			<td class="title">Name Of Insured Person</td>
			<td class="title">Name Of dispensary to which attached</td>
			<td class="title">Occupation </td>
			<td class="title">Deptt. and shift, if any</td>
			<td class="title">If appointed or left service during the contribution period, date of appointment/leaving service</td>
			<td class="title">No. of days for which Wages Paid/Payable </td>
			<td class="title">Total amount of wages paid/payable</td>
			<td class="title">Employees share of contribution</td>				
		  </tr>
		 
 			<tr>
			<td class="title">1</td>			
			<td class="title">2</td>
			<td class="title">3</td>
			<td class="title">3(A)</td>
			<td class="title">4</td>
			<td class="title">5</td>
			<td class="title">6</td>
			<td class="title">7</td>
			<td class="title">8</td>
			<td class="title">9</td>				
		  </tr>';
		  
		  $sum_wages1=0;
		  $sum_wages2=0;
		  $sum_wages3=0;
		  $sum_wages4=0;
		  $sum_wages5=0;
		  $sum_wages6=0;
		  
		  $sum_esi1=0;
		  $sum_esi2=0;
		  $sum_esi3=0;
		  $sum_esi4=0;
		  $sum_esi5=0;
		  $sum_esi6=0;
		 
		foreach($userdetails as $details) {	
		for($m=$m1;$m<=$m2;$m++){					
			if($m==$details['month']){				
			
			$days[$m]=$details['days'];
			$total_wages[$m]=$details['total_wages'];
			$total_esi[$m]=$details['esi'];
						
			if(date('m',strtotime($details['date_join']))==$m){
				$datejoin[$m]=$details['date_join'];
			}
			elseif(date('m',strtotime($details['resigned_dat']))==$m){
				$datejoin[$m]=$details['resigned_dat'];
			}			
			
		}
			
		}
		if($y==2){	
			for($j=$m3;$j<=$m4;$j++){
				
				
			if($j==$details['month']){
			
		
			$days[$j]=$details['days'];
			$total_wages[$j]=$details['total_wages'];
			$total_esi[$j]=$details['esi'];
			
			if(date('m',strtotime($details['date_join']))==$j){
				$datejoin[$j]=$details['date_join'];
			}
			elseif(date('m',strtotime($details['resigned_dat']))==$j){
				$datejoin[$j]=$details['resigned_dat'];
			}
		
		}
		}
		}
				
		 $sum_wages1+=$total_wages[$d1];
		 $sum_esi1+=$total_esi[$d1];
		 
		$html.=  '<tr>
					<td class="title">'.$i++.'</td>
					<td class="title"></td>
					<td class="title">'.$details['emp_name'].'</td>
					<td class="title"></td>
					<td class="title">'.$details['desig_name'].'</td>			
					<td class="title"></td>			
					<td class="title">'.$datejoin[$d1].'</td>					
					<td class="title">'.$days[$d1].'</td>						
					<td class="title">'.round($total_wages[$d1],2).'</td>						
					<td align="left" valign="top" class="title">'.round($total_esi[$d1],2).'</td>				
				  </tr>
				';				
			  
		}
		 $html.='<tr><td colspan="8" align="right">Total</td>
		 <td>'.round($sum_wages1,2).'</td>
		 <td></td>
		 </tr>	
		 
		  <tr>
		 <td colspan="9" align="right">Employer Share</td>
		 <td></td>
		 </tr>	
		 
		 <tr>
		 <td colspan="9" align="right">Grand Total</td>
		 <td>'.round($sum_esi1,2).'</td>
		 </tr>	
		 
		 <tr>
		 <td colspan="9" align="right">Paid On</td>
		 <td></td>
		 </tr>	
		 
		 		  
				  </table>
				  
				  <br/><br/>
				  ';
				  
				  
			$html.='<table  border="1" cellspacing="2" cellpadding="2" >
			<tr>
			<td class="title" colspan="3" style="text-decoration: underline;" text-align: center;>Month '.$month2.'  </td>			
			<td class="title" colspan="3" style="text-decoration: underline;" text-align: center;>Month '.$month3.' </td>
			<td class="title" colspan="3" style="text-decoration: underline;" text-align: center;> Month '.$month4.'  </td>		
		  </tr>
		  
		  <tr>
			<td class="title">No. of days for which Wages Paid/Payable </td>
			<td class="title">Total amount of wages paid/payable</td>
			<td class="title">Employees share of contribution</td>
			<td class="title">No. of days for which Wages Paid/Payable </td>
			<td class="title">Total amount of wages paid/payable</td>
			<td class="title">Employees share of contribution</td>	
			<td class="title">No. of days for which Wages Paid/Payable </td>
			<td class="title">Total amount of wages paid/payable</td>
			<td class="title">Employees share of contribution</td>					
		  </tr>
		 
 <tr>
			<td class="title">10</td>			
			<td class="title">11</td>
			<td class="title">12</td>
			<td class="title">13</td>
			<td class="title">14</td>
			<td class="title">15</td>
			<td class="title">16</td>
			<td class="title">17</td>
			<td class="title">18</td>			
		  </tr>';
		
	foreach($userdetails as $details) {	
			 
			 for($m=$m1;$m<=$m2;$m++){					
			if($m==$details['month']){				
			
			$days[$m]=$details['days'];
			$total_wages[$m]=$details['total_wages'];
			$total_esi[$m]=$details['esi'];
						
			if(date('m',strtotime($details['date_join']))==$m){
				$datejoin[$m]=$details['date_join'];
			}
			elseif(date('m',strtotime($details['resigned_dat']))==$m){
				$datejoin[$m]=$details['resigned_dat'];
			}			
			
		}
			
		}
		if($y==2){	
			for($j=$m3;$j<=$m4;$j++){
				
				
			if($j==$details['month']){
			
		
			$days[$j]=$details['days'];
			$total_wages[$j]=$details['total_wages'];
			$total_esi[$j]=$details['esi'];
			
			if(date('m',strtotime($details['date_join']))==$j){
				$datejoin[$j]=$details['date_join'];
			}
			elseif(date('m',strtotime($details['resigned_dat']))==$j){
				$datejoin[$j]=$details['resigned_dat'];
			}
		
		}
		}
		}
			
			 
		  $html.=  '<tr>									
					<td class="title">'.$days[$d2].'</td>						
					<td class="title">'.round($total_wages[$d2],2).'</td>						
					<td align="left" valign="top" class="title">'.round($total_esi[$d2],2).'</td>
					<td class="title">'.$days[$d3].'</td>						
					<td class="title">'.round($total_wages[$d3],2).'</td>						
					<td align="left" valign="top" class="title">'.round($total_esi[$d3],2).'</td>	
					<td class="title">'.$days[$d4].'</td>						
					<td class="title">'.round($total_wages[$d4],2).'</td>						
					<td align="left" valign="top" class="title">'.round($total_esi[$d4],2).'</td>					
				  </tr>
				';	 		
				  $sum_wages2+=$total_wages[$d2]; 
				  $sum_wages3+=$total_wages[$d3]; 
				  $sum_wages4+=$total_wages[$d4]; 
				  
				   $sum_esi2+=$total_esi[$d2];
				    $sum_esi3+=$total_esi[$d3];
				     $sum_esi4+=$total_esi[$d4];
		}
		  $html.='	<tr>
		 <td>Total</td>
		 <td>'.$sum_wages2.'</td>
		 <td></td>
		 <td>Total</td>
		 <td>'.$sum_wages3.'</td>
		 <td></td>
		 <td>Total</td>
		 <td>'.$sum_wages4.'</td>
		 <td></td>
		 </tr>	
		 
		  <tr>
		 <td colspan="2" align="right">Employer Share</td>
		 <td></td>
		 <td colspan="2" align="right">Employer Share</td>
		 <td></td>
		 <td colspan="2" align="right">Employer Share</td>
		 <td></td>
		 </tr>	
		 
		 <tr>
		 <td colspan="2" align="right">Grand Total</td>
		 <td>'.$sum_esi2.'</td>
		 <td colspan="2" align="right">Grand Total</td>
		 <td>'.$sum_esi3.'</td>
		 <td colspan="2" align="right">Grand Total</td>
		 <td>'.$sum_esi4.'</td>
		 </tr>	
		 
		 <tr>
		 <td colspan="2" align="right">Paid On</td>
		 <td></td>
		 <td colspan="2" align="right">Paid On</td>
		 <td></td>
		 <td colspan="2" align="right">Paid On</td>
		 <td></td>
		 </tr>				  
				  </table>
				 
				<br/><br/> ';
				  
				  	$html.='<table width="100%" border="1" cellspacing="2" cellpadding="2" >
			<tr>
			<td class="title" colspan="3" style="text-decoration: underline;" text-align: center;>Month '.$month5.'  </td>			
			<td class="title" colspan="3" style="text-decoration: underline;" text-align: center;>Month '.$month6.' </td>
			<td class="title" colspan="4"  align="center">Summary  </td>				
		  </tr>
		  <tr style="page-break-before:always;">
			<td class="title">No. of days for which Wages Paid/Payable </td>
			<td class="title">Total amount of wages paid/payable</td>
			<td class="title">Employees share of contribution</td>
			<td class="title">No. of days for which Wages Paid/Payable </td>
			<td class="title">Total amount of wages paid/payable</td>
			<td class="title">Employees share of contribution</td>	
			<td class="title">Total No. of days for which Wages Paid/Payable in Contribution period</td>
			<td class="title">Total amount of wages paid/payable in Contribution period</td>
			<td class="title">Total Employees share of contribution in Contribution period</td>					
			<td class="title">Daily Wage (26 – 25)(Rs.)</td>					
		  </tr>
		 
 <tr>
			<td class="title">19</td>			
			<td class="title">20</td>
			<td class="title">21</td>
			<td class="title">22</td>
			<td class="title">23</td>
			<td class="title">24</td>
			<td class="title">25</td>
			<td class="title">26</td>
			<td class="title">27</td>
			<td class="title">28</td>				
		  </tr>';
		
	foreach($userdetails as $details) {		
		for($m=$m1;$m<=$m2;$m++){					
			if($m==$details['month']){				
			
			$days[$m]=$details['days'];
			$total_wages[$m]=$details['total_wages'];
			$total_esi[$m]=$details['esi'];
						
			if(date('m',strtotime($details['date_join']))==$m){
				$datejoin[$m]=$details['date_join'];
			}
			elseif(date('m',strtotime($details['resigned_dat']))==$m){
				$datejoin[$m]=$details['resigned_dat'];
			}			
			
		}
			
		}
		if($y==2){	
			for($j=$m3;$j<=$m4;$j++){
				
				
			if($j==$details['month']){
			
		
			$days[$j]=$details['days'];
			$total_wages[$j]=$details['total_wages'];
			$total_esi[$j]=$details['esi'];
			
			if(date('m',strtotime($details['date_join']))==$j){
				$datejoin[$j]=$details['date_join'];
			}
			elseif(date('m',strtotime($details['resigned_dat']))==$j){
				$datejoin[$j]=$details['resigned_dat'];
			}
		
		}
		}
		}
			  
		  $html.=  '<tr style="page-break-inside:avoid;">									
					<td class="title">'.$days[$d5].'</td>						
					<td class="title">'.round($total_wages[$d5],2).'</td>						
					<td align="left" valign="top" class="title">'.round($total_esi[$d5],2).'</td>
					<td class="title">'.$days[$d6].'</td>						
					<td class="title">'.round($total_wages[$d6],2).'</td>						
					<td align="left" valign="top" class="title">'.round($total_esi[$d6],2).'</td>	
					<td class="title"></td>						
					<td class="title"></td>						
					<td class="title"></td>					
					<td class="title"></td>					
				  </tr>
				';	 		
				 $sum_wages5+=$total_wages[$d5]; 
				  $sum_wages6+=$total_wages[$d6]; 
				 
				   $sum_esi5+=$total_esi[$d5];
				    $sum_esi6+=$total_esi[$d6];
		}
		  $html.='	<tr>
		 <td>Total</td>
		 <td>'.$sum_wages5.'</td>
		 <td></td>
		 <td>Total</td>
		 <td>'.$sum_wages6.'</td>
		 <td></td>
		 <td></td>
		 <td></td>
		 <td></td>
		 <td></td>
		 </tr>	
		 		
		 <tr>
		 <td colspan="2" align="right">Employer Share</td>
		 <td></td>
		 <td colspan="2" align="right">Employer Share</td>
		 <td></td>
		 <td></td>
		 <td></td>
		 <td></td>
		 <td></td>
		 </tr>	
		 
		 <tr>
		 <td colspan="2" align="right">Grand Total</td>
		<td>'.$sum_esi5.'</td>
		 <td colspan="2" align="right">Grand Total</td>
		 <td>'.$sum_esi6.'</td>
		 <td></td>
		 <td></td>
		 <td></td>
		 <td></td>
		 </tr>	
		 
		 <tr>
		 <td colspan="2" align="right">Paid On</td>
		 <td></td>
		 <td colspan="2" align="right">Paid On</td>
		 <td></td>
		 <td></td>
		 <td></td>
		 <td></td>
		 <td></td>
		 </tr>				  
				  </table>
				  <br/>
				  ';
				  
		$html.= '
		<table width="100%" border="0" cellspacing="2" cellpadding="2" >
		  <tr>
			<td class="title">Date : '.date('d-M-Y').'</td>
			<td>Stamp of the Factory / Estt.  </td>
			<td>Signature of the Employer or other Authorised Officer of the Factory / Establishment</td>
			
		  </tr>
		</table> 
				   </div>
				   </body></html>';
				 
	echo $html;
	 }
	
	?>