<?php
require_once("dompdf/dompdf_config.inc.php");
include_once("class/class.MySQL.php");
$db		= new MySQL();

if($_POST['form'] =='form3a'){
	$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>';
	  $cond="";
	$emp_id	 = $_POST['emp'];
	/*$emp_id=23;
	 $cond = 'AND e_id IN('.$emp_id.')';*/
	if(!empty($emp_id))$cond = 'AND e_id IN('.implode(',',$emp_id).')';
	
		$str="SELECT *,CONCAT(e_fname,e_lname)as emp_name FROM employee where emp_basic_pay!=0 $cond ";
	
	 if(isset($_POST["type_sort"]) && !empty($_POST["type_sort"])){
			$str.=" order by $_POST[type_sort] ASC";	
		}
	$userdetails = $db->fetchQuery($str); 
	
	
	//$userdetails = $db->fetchQuery("SELECT *,CONCAT(e_fname,e_lname)as emp_name FROM employee where emp_basic_pay!=0 $cond "); 
	foreach ($userdetails as $details) {
		
	 $html .='
	  <div class="content" style="page-break-after:always;">
	  <h4><div  style="text-align:center;">There is no payroll in the selected period !</div>
	  <div style="padding-left:165px;">( For Unexempted Establishments Only )</div></h4>
	  <table style="width:100%;">
		<tr>
		<td style="text-align:center;width:90%;"><h3 style="margin:0px 0px 5px 0px;">EMPLOYEES\' PROVIDENT FUND ORGANISATION <br>
			THE EMPLOYEES\' PROVIDENT FUND SCHEME, 1952 [Paras 35 & 42 ]<br>
			AND THE EMPLOYEES\' PENSION SCHEME, 1995 [Para 19]</h3> 
			<h4 style="text-align:center;margin-top:5px;">Contribution Card for currency period from '.date('d M Y',strtotime($_POST['from_date'])).' to '.date('d M Y',strtotime($_POST['to_date'])).'</h4>
		</td>
		<td style="width:15%;text-align:center;padding:0px 5px;vertical-align:top;"><div style="border:2px #000 solid;padding:5px 10px;"">Form - 3A<br>
			(Revised)</div>
		</td>
		</tr>
			
	   </table>	
	  
		<table width="100%" border="0" cellspacing="2" cellpadding="2" >
		  <tr>
			<td>1.</td>
			<td class="title">Account No.</td>
			<td>'.$details['e_accountno'].'</td>
			<td>5.</td>
			<td  class="title">Statutory Rate of Contributuion</td>
			<td>10%</td>
		  </tr>
		  <tr>
			<td>2.</td>
			<td class="title">Name / Surname</td>
			<td>'.$details['emp_name'].'</td>
			<td>6.</td>
			<td class="title">Voluntary Higher Rate of Employees\' Contribution if any</td>
			<td></td>
		  </tr>
		  <tr>
			<td>3.</td>
			<td class="title">Father\'s / Husband\'s name.</td>
			<td>'.$details['e_mname'].'</td>
			<td>7.</td>
			<td class="title">Employees\' Contribution on higher wages to EPF</td>
			<td>Yes/No</td>
		  </tr>
		  <tr>
			<td>4.</td>
			<td class="title">Name and Address of the Factory / Establishment</td>
			<td></td>
			<td>8.</td>
			<td class="title">Voluntary Contribution to Pension Fund on higher wages</td>
			<td>Yes/No</td>
		  </tr>
		</table>  
		 
		
		<table width="100%" border="1" cellspacing="2" cellpadding="2" class="table">
		  <tr>
			<td class="title">Month</td>
			<td colspan="2" class="title">MEMBER\'S SHARE</td>
			<td colspan="2"  class="title">EMPLOYER\'S SHARE</td>
			<td rowspan="2" class="title">Ref. of Advance</td>
			<td rowspan="2" class="title">Period of non contributory service (if any) No of days</td>
			<td rowspan="2" class="title">Remarks</td>
		  </tr>
		  <tr>
			<td>&nbsp;</td>
			<td class="title">Amount of Wages</td>
			<td class="title">E.P.F </td>
			<td class="title">E.P.F Contribution</td>
			<td class="title">Pension Fund Contribution 8 1/3 %</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>
		  </tr>';
		  $employee_id=$details['e_id'];
		    $sqlstring="SELECT sum(total_paid) as total_paid,MONTHNAME(`payment_date`) AS month_name,c.percentage,d.amount,(d.amount*(c.percentage/100)) as pf FROM payroll_salary_pay a left join salary_structure_employee b on a.userid=b.employee_id left join salary_structure c on b.salary_structure_id=c.id left join( select id,amount from salary_structure) as d on d.id=c.parent_id where 1 ";
		 
		  if(!empty($employee_id)){
		   	$sqlstring.=" and userid = ".$employee_id." ";
		   } 
		   
	    if(isset($_REQUEST["from_date"]) && !empty($_REQUEST['from_date'])){
		$sqlstring.=" and payment_date >= '$_REQUEST[from_date]' ";
		}
		if(isset($_REQUEST["to_date"]) && !empty($_REQUEST['to_date'])){
			$sqlstring.=" and '$_REQUEST[to_date]' >= payment_date ";
		}
		
		
		$sqlstring.=" group by MONTHNAME(`payment_date`) order by MONTH(`payment_date`) ASC";		
		
		$i=1;
		$userdetailss = $db->fetchQuery($sqlstring);
	
		foreach ($userdetailss as $details2) {
			 $html .=  '<tr>					
					<td>'.$details2['month_name'].'</td>
					<td>'.round($details2['total_paid'],2).'</td>
					<td>'.round($details2['pf'],2).'</td>
					<td></td>					
					<td></td>				
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				  </tr>';
				  
		}
		  
		  $html .=' <tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		  </tr>
		  <tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		  </tr>
		  <tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		  </tr>
		</table>
		<div>
		Certified that the total amount of contribution (both shares) indicated in this card i.e., Rs. 0 has already been remitted in full in E.P.F A/c No. 1 and 
		Pension Fund A/c No. 10 Rs. 0<br>
		Certified that the difference between the total of contribution shown under Cols. 3 & 4 of the above table and that arrived at on the total wages shown 
		in Column 2 at the prescribed rate is solely due to rounding off of the contributions to the nearest rupee under the rules.
		</div>
		<strong>NOTE:</strong><br>
		<table>
		<tr>
		<td>1</td>
		<td>In respect of the Form3-A sent to the Regional Office during the course of the currency period for the purpose of the final settlement of 
		the accounts of the member who has left service, details of date and reasons for leaving service should be furnished under Co.7(a) & 
		(b).</td>
		</tr>
		<tr>
		<td>2</td>
		<td>In respect of the members who are not members of the Pension Fund, the employer\'s share of contribution to Employees\' Provident 
		Fund is to be shown under Co, 4(a)</td>
		</tr>
		</table>
		<div style="position: fixed; left: 0px; bottom: -140px; right: 0px; height: 150px;">Date : '.date('d-M-Y').'
		<span style="padding-left:400px;">Signature of Employer with Office Seal</span></div>
		</div>
	  ';
	}
	$html  .= '</body></html>';
	$dompdf = new DOMPDF();
	$dompdf->load_html($html);
	$dompdf->render();
	$dompdf->stream("PF-Form3A.pdf");
}

if($_POST['form'] =='form6a'){
	$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>';
	 $cond="";
	$emp_id	 = $_POST['emp'];
	/*$emp_id=23;
	 $cond = 'AND e_id IN('.$emp_id.')';*/
	 
	if(!empty($emp_id))$cond = 'AND e_id IN('.implode(',',$emp_id).')';
	
			$str="SELECT *,CONCAT(e_fname,e_lname)as emp_name FROM employee where emp_basic_pay!=0 $cond ";
	
	 if(isset($_POST["type_sort"]) && !empty($_POST["type_sort"])){
			$str.=" order by $_POST[type_sort] ASC";	
		}
	$userdetails = $db->fetchQuery($str); 	
	
	///$userdetails = $db->fetchQuery("SELECT * FROM employee where emp_basic_pay!=0");
	foreach ($userdetails as $details) {
		
	 $html .='
	  <div class="content" style="page-break-after:always;">
	  <table style="width:100%;">
		<tr>
		<td style="text-align:center;width:90%;"><h3 style="margin:0px 0px 5px 0px;">EMPLOYEES\' PROVIDENT FUND SCHEME, 1952 (PARAGRAPH 43) <br>
			AND<br>
			THE EMPLOYEES\' PENSION SCHEME, 1995 [PARAGRAPH 20(4)]</h3> 
		</td>
		<td style="width:15%;text-align:center;padding:0px 5px;vertical-align:top;"><div style="border:2px #000 solid;padding:5px 10px;"">Form - 6A<br>
			(Revised)</div>
		</td>
		</tr>
	   </table>	
	  
		<table width="100%" border="0" cellspacing="2" cellpadding="2" >
		  <tr>
			<td class="title">Annual Statement of Contribution for the Currency period from </td>
			<td></td>
			<td  class="title">Statutory Rate of Contribution: </td>
			<td>10%</td>
		  </tr>
		  <tr>
			<td class="title">Name and Address of the Establishment : 	</td>
			<td></td>
			<td class="title"></td>
			<td></td>
		  </tr>
		  <tr>
			<td class="title">Code No. of the Establishment : </td>
			<td></td>
			<td class="title"></td>
			<td></td>
		  </tr>
		</table>  
		 
		
		<table width="100%" border="1" cellspacing="2" cellpadding="2" class="table">
		  <tr>
			<td class="title">SI NO</td>
			<td class="title">Account.No.</td>
			<td class="title">Name of the Member </td>
			<td class="title">Wages retaining,allowance(if any)and D.A. including Cash values of food concession paid during the currency period </td>
			<td colspan="3" class="title">Amount of Worker\'s Contributions deducted from the Wages </td>
			<td colspan="3" class="title">Employer\'s Contributions </td>
			<td rowspan="2" class="title">Refund of Advance </td>
			<td rowspan="2" class="title">Rate of Higher Voluntary Contribution if any </td>
			<td rowspan="2" class="title">Remarks </td>
		  </tr>
		  <tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td class="title">EPF <br>a</td>
			<td class="title">EPS <br>b</td>
			<td class="title">Total<br>c</td>
			<td class="title">EPF <br>a</td>
			<td class="title">EPS <br>b</td>
			<td class="title">Total<br>c</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" colspan="3">5</td>
			<td class="title" colspan="3">6</td>
			<td class="title">7</td>
			<td class="title">8</td>
			<td class="title">9</td>
		  </tr>';
		  
		 $employee_id=$details['e_id'];
		    $sqlstring="SELECT e_accountno,CONCAT(e_fname,e_lname)as emp_name,sum(total_paid) as total_paid,MONTHNAME(`payment_date`) AS month_name,c.percentage,d.amount,(d.amount*(c.percentage/100)) as pf FROM payroll_salary_pay a left join salary_structure_employee b on a.userid=b.employee_id left join salary_structure c on b.salary_structure_id=c.id left join( select id,amount from salary_structure) as d on d.id=c.parent_id inner join employee e on e.e_id=a.userid where 1 ";
		   if(!empty($employee_id)){
		   	$sqlstring.=" and userid = ".$employee_id." ";
		   } 
		   
		 if(isset($_REQUEST["from_date"])){
			$sqlstring.=" and DATE_FORMAT(payment_date,'%d-%m-%Y') >= '$_REQUEST[from_date]' ";
		}
		
		
		$sqlstring.=" group by MONTHNAME(`payment_date`) ";
		
		
		$i=1;
		$userdetailss = $db->fetchQuery($sqlstring);
	
		foreach ($userdetailss as $details2) {
			 $html .=  '<tr>
					
					<td>'.$i++.'</td>
					<td>'.$details2['e_accountno'].'</td>
					<td>'.$details['emp_name'].'</td>
					<td>'.round($details2['total_paid'],2).'</td>
					<td>'.round($details2['pf'],2).'</td>
					<td></td>					
					<td></td>				
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				  </tr>';
				  
		}
		  $html .=' <tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>Total</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		  </tr>
		 
		</table>
		<div style="position: fixed; left: 0px; bottom: -140px; right: 0px; height: 150px;">
		<span style="padding-left:400px;">Signature of Employer with Office Seal</span></div>
		<strong>NOTE:</strong><br>
		<table>
		<tr>
			<td>i) </td>
			<td> 
				The names of all members, including those who had left the services during the currency period , should be included in this statement. Where the Form 3A in respect of such
		member had left the service were already sent to the Regional Office for the purpose of final settlement of their accounts,the fact should be stated against the members in the Remarks column above thus "Form 3A already sent in the month 
		of ....................200 ".
			</td>
		</tr>
		<tr>
			<td>ii) </td>
			<td> In case of substantial variation in the wages/contribution of any members as compared to those shown in previous months statement, the reason should be explained adquately in the \'Remarks\' column.
			</td>
		</tr>
		<tr>
			<td>iii) </td>
			<td> In respect of those members who have not opted for Pension Fund their entire employers contribution @ 8 1/3% or 10% as the case may be should be shown under column No. 6..
			</td>
		</tr>
		</table>
	   </div>	
	  ';
	}
	$html  .= '</body></html>';
	$dompdf = new DOMPDF();
	$dompdf->load_html($html);
	$dompdf->render();
	$dompdf->stream("PF-Form6A.pdf");
}

if($_POST['form'] =='form5'){
	$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;">
	  <h4><div style="border:2px #000 solid;padding:5px 10px;text-align:center;width:10%;align:center;margin-left:300px;"> FORM 5 </div>
	  <div style="text-align:center;margin-top:5px;">Employees\' Provident Fund Organisation</div>
	  </h4>
	  <table style="width:100%;">
		<tr>
		<td style="text-align:center;width:90%;"><h3 style="margin:0px 0px 5px 0px;">THE EMPLOYEES\' PROVIDENT FUND SCHEME, 1952 [Paragraph 36(2)(a)] AND THE EMPLOYEES\' PENSION SCHEME, 1995 [Paragraph 20(4)]</h3> 
		</td>
		</tr>
		<tr>
		<td>
		Return of Employees\' qualifying for membership of the Employees\' Provident Fund, Employees\' Pension Fund & Employees\' Deposit Linked Insurance Fund for the first time during the month of '.date('M Y',strtotime($_REQUEST['from_date'])).'
		</td>
		</tr>
	   </table>	
	  
		<table width="100%" border="0" cellspacing="2" cellpadding="2" >
		  <tr>
			<td class="title">Name and Address of the Factory / Estt:</td>
			<td></td>
			<td class="title">CODE NO. of the Factory/ Estt:</td>
			<td></td>
		  </tr>
		</table>  
		 
		<table width="100%" border="1" cellspacing="2" cellpadding="2" class="table">
		  <tr>
			<td class="title">SI NO</td>
			<td class="title">Account.No.</td>
			<td class="title">Name of Employee</td>
			<td class="title">Father\'s Name (or Husband\'s Name in case of married woman)</td>
			<td class="title">Date of Birth</td>
			<td class="title">Sex</td>
			<td class="title">Date of joining the Fund</td>
			<td class="title">Total period of previous service as on the date of joining the Fund (Enclose scheme certificate if applicable)</td>
			<td class="title">Remarks </td>
		  </tr>';
	/* $html .=  '<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>
						  </tr>';*/
		$i=1;	
		
	$fromdate='';
	$todate='';
	if(isset($_REQUEST['from_date'])){
	$fromdate=$_REQUEST['from_date'];
	}
	
	if(isset($_REQUEST['to_date'])){
	$todate=$_REQUEST['to_date'];
	}	
				  
	$sqlstring="SELECT CONCAT(e_fname,e_lname)as emp_name, e_accountno,pf_accnum,e_mname,e_dob,e_gender,pf_date_join_fund,pf_service_year,pf_service_month,pf_service_day FROM employee where 1 ";
		 /*if(isset($_REQUEST["from_date"]) && $_REQUEST["from_date"]!=""){
			$sqlstring.=" and DATE_FORMAT(date_join,'%d-%m-%Y') >= '$_REQUEST[from_date]' ";
		}
		if(isset($_REQUEST["to_date"]) && $_REQUEST["to_date"]!=""){
			$sqlstring.=" and '$_REQUEST[to_date]' >= DATE_FORMAT(date_join,'%d-%m-%Y') ";
		}
		if(isset($_REQUEST["from_date"]) && !empty($_REQUEST['from_date'])){
			$sqlstring.=" and date_join >= '$_REQUEST[from_date]' ";
		}
		if(isset($_REQUEST["to_date"]) && !empty($_REQUEST['to_date'])){
			$sqlstring.=" and '$_REQUEST[to_date]' >= date_join ";
		}
		/* if(isset($_REQUEST["emp_id"]) && !empty($_REQUEST['emp_id'])){
			$sqlstring.=" and e_id = '$_REQUEST[emp_id]' ";
		}
		 if(isset($_REQUEST["filter_emp_name"]) && !empty($_REQUEST['filter_emp_name'])){
			$sqlstring.=" and e_fname = '$_REQUEST[filter_emp_name]' ";
		}
		if(isset($_REQUEST["pf_no"]) && !empty($_REQUEST['pf_no'])){
			$sqlstring.=" and pf_no = '$_REQUEST[pf_no]' ";
		}*/
		if($fromdate!="" && $todate!=""){
		$sqlstring.=" and pf_date_join_fund between '$fromdate' and '$todate'";
		}
		
		if(isset($_REQUEST["type_sort"]) && !empty($_REQUEST["type_sort"])){
			$sqlstring.=" order by $_REQUEST[type_sort] ASC";	
		}
		
		$userdetails = $db->fetchQuery($sqlstring);
	
		foreach ($userdetails as $details) {
		  $total_period_previous_service = $details['pf_service_year'].' Years '.$details['pf_service_month'].' Months '.$details['pf_service_day'].' Days';  
			 $html .=  '<tr>
					<td>'.$i++.'</td>
					<td>'.$details['pf_accnum'].'</td>
					<td>'.$details['emp_name'].'</td>
					<td>'.$details['e_mname'].'</td>
					<td>'.date('d M Y', $details['e_dob']).'</td>
					<td>'.$details['e_gender'].'</td>
					<td>'.$details['pf_date_join_fund'].'</td>
					<td>'.$total_period_previous_service.'</td>
					<td>&nbsp;</td>
				  </tr>';
				  
		}
		$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>';
	$dompdf = new DOMPDF();
	$dompdf->load_html($html);
	$dompdf->render();
	$dompdf->stream("PF-Form5.pdf");
}

if($_POST['form'] =='form10'){

	$html =	'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
			<html xmlns="http://www.w3.org/1999/xhtml">
			<head>
			<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
			<title>PF Form 10</title>
			<style type="text/css">
			<!--
			.normal-fonts {
				font-family: Arial, Helvetica, sans-serif;
				font-size: 11px;
				font-weight: normal;
				color: #000000;
			}
			.subtitle-fonts {
				font-family: Arial, Helvetica, sans-serif;
				font-size: 14px;
				font-weight: bold;
			}
			.title-fonts {
				font-family: Arial, Helvetica, sans-serif;
				font-size: 18px;
				font-weight: bold;
				color: #000000;
			}
			.title-fonts-level3 {
				font-family: Arial, Helvetica, sans-serif;
				font-size: 11px;
				font-weight: bold;
				color: #000000;
			}
			
			.borsder-table {
				border-collapse: collapse;
				 border: 1px solid black;
			}
			
			.borsder-table, .borsder-table th, .borsder-table td {
				border: 1px solid black;
				border-collapse: collapse;
			}
			.borsder-table td {
				padding:2px;
			}
			-->
			</style>
			</head>
			
			<body>
			<table width="100%" height="477" border="0" cellpadding="0" cellspacing="0">
			  <tr>
				<td height="46" align="center" valign="bottom" class="title-fonts">
				<table border="0" cellspacing="0" cellpadding="0" align="center" >
				  <tr>
					<td align="center" class="subtitle-fonts" ><div style="border: 1px solid black;padding:5px 10px;">FORM 10<div></td>
				  </tr>
				</table>
				</td>
			  </tr>
			  <tr>
				<td align="center" valign="middle" class="subtitle-fonts">Employees Provident Fund Organization</td>
			  </tr>
			  <tr>
				<td align="center" valign="middle" class="normal-fonts">THE EMPLOYEES\' PROVIDENT FUNDS SCHEME, 1952 [Paragraph 36(2)(a) &amp; (b)] AND THE EMPLOYEES\' PENSION SCHEME, 1995 [Paragraph 20(2)]</td>
			  </tr>
			  <tr>
				<td height="60" align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <tr>
					<td class="normal-fonts"><p>Return of the members leaving service during the month of Oct 2014</p>
					  <p>Name and Address of the Factory / Aadhocc , Prabhul null</p></td>
					<td class="normal-fonts">CODE No. of the Factory/ Estt: PFNOTAVAILABLE</td>
				  </tr>
				</table></td>
			  </tr>
			  <tr>
				<td align="center" valign="middle"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="borsder-table">
				  <tr>
					<td class="title-fonts-level3">SLNO</td>
					<td class="title-fonts-level3">Account No</td>
					<td class="title-fonts-level3">Name of the Member</td>
					<td class="title-fonts-level3"><p>Father\'s Name or Husband\'s<br />
					  Name (in case of married woman)</p>          </td>
					<td class="title-fonts-level3">Date of Leaving Service</td>
					<td class="title-fonts-level3">Reason for Leaving Service</td>
					<td class="title-fonts-level3">Remarks</td>
				  </tr>';
				$fromdate='';
				$todate='';
				if(isset($_REQUEST['from_date'])){
				$fromdate=$_REQUEST['from_date'];
				}
				
				if(isset($_REQUEST['to_date'])){
				$todate=$_REQUEST['to_date'];
				}
				  
				  $sqlstring="SELECT CONCAT(e_fname,e_lname)as emp_name, pf_accnum,e_mname,e_dob,e_gender,pf_leaving_date,reason_leaving_pf,pfremarks FROM employee where 1 ";
		/*if(isset($_REQUEST["from_date"])){
			$sqlstring.=" and STR_TO_DATE(resigned_dat,'%d-%m-%Y') >= STR_TO_DATE('$_REQUEST[from_date]','%d-%m-%Y') ";
		}
		if(isset($_REQUEST["to_date"])){
			$sqlstring.=" and STR_TO_DATE('$_REQUEST[to_date]','%d-%m-%Y') >=STR_TO_DATE(resigned_dat,'%d-%m-%Y') ";
		}*/
		/* if(isset($_REQUEST["from_date"]) && !empty($_REQUEST['from_date'])){
			$sqlstring.=" and resigned_dat >= '$_REQUEST[from_date]' ";
		}
		if(isset($_REQUEST["to_date"]) && !empty($_REQUEST['to_date'])){
			$sqlstring.=" and '$_REQUEST[to_date]' >= resigned_dat ";
		}
		if(isset($_REQUEST["type_sort"]) && !empty($_REQUEST["type_sort"])){
			$sqlstring.=" order by $_REQUEST[type_sort] ASC";	
		}*/
		/*if(isset($_REQUEST["to_date"]) ){
			$sqlstring.=" and resigned_dat<='".$_REQUEST["to_date"]."' ";
		}*/
		
		if($fromdate!="" && $todate!=""){
		$sqlstring.=" and pf_leaving_date between '$fromdate' and '$todate'";
		}	
		
		if(isset($_GET["type_sort"]) && !empty($_GET["type_sort"])){
			$sqlstring.=" order by $_GET[type_sort] ASC";	
		}
		
		$i=1;
		$userdetails = $db->fetchQuery($sqlstring);
	
		foreach ($userdetails as $details) {
			 $html .=  '<tr>
					<td>'.$i++.'</td>
					<td>'.$details['pf_accnum'].'</td>
					<td>'.$details['emp_name'].'</td>
					<td>'.$details['e_mname'].'</td>					
					<td>'.date('d M Y',strtotime($details['pf_leaving_date'])).'</td>				
					<td>'.$details['reason_leaving_pf'].'</td>
					<td>'.$details['pfremarks'].'</td>
				  </tr>';
				  
		}
		
				$html .= '</table></td>
			  </tr>
			  <tr>
				<td height="34" align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <tr>
					<td width="20%" class="normal-fonts">Date : '.date('d-M-Y').'</td>
					<td width="44%" class="normal-fonts">Stamp of Factory / Estt.</td>
					<td width="36%" class="normal-fonts">Signature of the Employeer or other Authorised Officer</td>
				  </tr>
				</table></td>
			  </tr>
			  <tr>
				<td align="left" valign="top"><p class="normal-fonts">*Please state whether the member is (a) retiring according to para (69) (1) (a) or (b) of the scheme (b) leaving India for permanent settlement abroad (c) retrenchment (d) Pt. &amp; total disablement due to employment injury (e) discharged (f) resigning from or leaving service (g) taking up employment elsewhere (The name and address of the Employers should be stated) (h) death (i) attained the age of 58 years</p>    </td>
			  </tr>
			  <tr>
				<td align="left" valign="middle" class="normal-fonts">Certified that the member mentioned at Serial No.............................................Shri.......................................................................................................................was</td>
			  </tr>
			  <tr>
				<td align="left" valign="middle" class="normal-fonts">paid / not paid retrenchment compensation of Rs. ............................................................................................under the Industrial Dispute Act, 1947.</td>
			  </tr>
			  <tr>
				<td align="center" valign="middle">&nbsp;</td>
			  </tr>
			</table>
			</body>
			</html>';
			
			$dompdf = new DOMPDF();
			$dompdf->load_html($html);
			$dompdf->render();
			$dompdf->stream("PF-Form10.pdf");
}	
if($_POST['form'] =='form12a'){
	$html =	'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
			<html xmlns="http://www.w3.org/1999/xhtml">
			<head>
			<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
			<title>PF Form 12A</title>
			<style type="text/css">
			<!--
			.normal-fonts {
				font-family: Arial, Helvetica, sans-serif;
				font-size: 11px;
				font-weight: normal;
				color: #000000;
			}
			.subtitle-fonts {
				font-family: Arial, Helvetica, sans-serif;
				font-size: 13px;
				font-weight: bold;
			}
			.title-fonts {
				font-family: Arial, Helvetica, sans-serif;
				font-size: 15px;
				font-weight: bold;
				color: #000000;
			}
			.title-fonts-level3 {
				font-family: Arial, Helvetica, sans-serif;
				font-size: 11px;
				font-weight: bold;
				color: #000000;
			}
			
			.borsder-table {
				border-collapse: collapse;
				 border: 1px solid black;
			}
			
			.borsder-table, .borsder-table th, .borsder-table td {
				border: 1px solid black;
				border-collapse: collapse;
			}
			.borsder-table td {
				padding:2px;
			}
			-->
			</style>
			</head>
			
			<body>
			<table width="100%" height="504" border="0" cellpadding="0" cellspacing="0">
			  <tr>
				<td colspan="2" align="right" valign="bottom" class="title-fonts">EMPLOYEES\' PROVIDENT FUND ORGANISATION<br />
			FORM 12-A (REVISED)</td>
				<td  align="center" valign="middle" class="normal-fonts">( ONLY FOR ESTABLISHMENT )</td>
			  </tr>
			  <tr>
				<td colspan="3" align="center" valign="middle" class="subtitle-fonts">EMPLOYEES\' PROVIDENT FUND AND MISC. PRO. ACT 1952 - EMPLOYEES\' PENSION SCHEME 1995 [PARA 20(4)]</td>
			  </tr>
			  <tr>
				<td height="87" colspan="3" align="center" valign="top"><table width="100%" height="80" border="0" cellpadding="0" cellspacing="0">
				  <tr>
					<td width="34%" class="normal-fonts">Name and Address of the Establishment</td>
					<td width="47%" class="normal-fonts">Currency period from <span class="title-fonts-level3">01 April 2014 to 31 March 2015</span></td>
					<td width="19%" class="normal-fonts">( To be filled by EPFO)</td>
				  </tr>
				  <tr>
					<td height="37" class="normal-fonts"><span class="title-fonts-level3">Aadhocc</span><br />
					  Prabhul null</td>
					<td class="normal-fonts">Statement of contribution for the month of <span class="title-fonts-level3">Oct 2014</span></td>
					<td class="normal-fonts">Group Code</td>
				  </tr>
				  <tr>
					<td class="normal-fonts">Code No. PFNOTAVAILABLE</td>
					<td class="normal-fonts">Statutory rate of contribution: 12%</td>
					<td class="normal-fonts">Establishment Status</td>
				  </tr>
				</table></td>
			  </tr>
			  <tr>
				<td colspan="3" align="center" valign="middle"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="borsder-table">
				  <tr>
					<td rowspan="2" align="center" class="title-fonts-level3">Particulars</td>
					<td rowspan="2" align="center" class="title-fonts-level3">Wages on which<br />
					  contributions<br />
					  are payable</td>
					<td colspan="2" align="center" class="title-fonts-level3">Amount of contribution</td>
					<td colspan="3" align="center" class="title-fonts-level3">Amount of contribution remitted</td>
					<td rowspan="2" align="center" class="title-fonts-level3">Amount of<br />
					  administrative<br />
					  charges due</td>
					<td rowspan="2" align="center" class="title-fonts-level3">Amount of<br />
					  administrative<br />
					  charges<br />
					  remitted</td>
					<td rowspan="2" align="center" class="title-fonts-level3">Date of remittance<br />
					  (Enclose triple copies<br />
					  of challans)</td>
				  </tr>
				  <tr>
					<td align="center" class="title-fonts-level3">Recovered<br />
					  from the<br />
					  Employees</td>
					<td align="center" class="title-fonts-level3">Payable<br />
					  by the<br />
					  Employer</td>
					<td align="center" class="title-fonts-level3">Employees\'<br />
					  contribution</td>
					<td align="center" class="title-fonts-level3">VPF</td>
					<td align="center" class="title-fonts-level3">Employer\'s<br />
					  contribution</td>
				  </tr>
				  <tr>
					<td align="center" class="normal-fonts">1</td>
					<td align="center" class="normal-fonts">2</td>
					<td colspan="2" align="center" class="normal-fonts">3</td>
					<td colspan="3" align="center" class="normal-fonts">4</td>
					<td align="center" class="normal-fonts">5</td>
					<td align="center" class="normal-fonts">6</td>
					<td align="center" class="normal-fonts">7</td>
				  </tr>
				</table></td>
			  </tr>
			  <tr>
				<td height="34" colspan="3" align="center" valign="middle" class="normal-fonts">Name and Address of the<br />
				  bank in which the amount<br />
				is remitted</td>
			  </tr>
			  <tr>
				<td colspan="3" align="center" valign="middle">&nbsp;</td>
			  </tr>
			  <tr>
				<td colspan="3" align="right" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <tr>
					<td width="7%">&nbsp;</td>
					<td width="61%">&nbsp;</td>
					<td width="32%" align="center" class="normal-fonts">Signature of the Employer<br />
					  (with office seal)</td>
				  </tr>
				</table></td>
			  </tr>
			</table>
			</body>
			</html>';

			$dompdf = new DOMPDF();
			$dompdf->load_html($html);
			$dompdf->render();
			$dompdf->stream("PF-Form12A.pdf");
}		

if($_POST['form'] =='formMst'){
	$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;"> Aadhocc </h4> </td></tr>
		<tr>
		<td style="text-align:center;width:90%;"><h3 style="margin:0px 0px 5px 0px;">Provident Fund Statement For '.date('M Y',strtotime($_REQUEST['from_date'])).'</h3> 
		</td>
		</tr>
		<tr>
		<td>
		
		</td>
		</tr>
	   </table>	
	  
		
		 
		<table width="100%" border="1" cellspacing="2" cellpadding="2" class="table">
		  <tr>
			<td class="title">SI NO</td>
			<td class="title">Employee.No.</td>
			<td class="title">Name</td>
			<td class="title">PF No</td>
			<td colspan="3" class="title">Employees Contribution66666</td>
			
			<td colspan="3" class="title">Employers Contribution</td>
					
		  </tr>
		 
  <tr>
			<td class="title"></td>
			<td class="title"></td>
			<td class="title"></td>
			<td class="title"></td>
			<td class="title">Basic+DA</td>
			<td class="title">PF</td>
			<td class="title">VPF</td>
			<td class="title">PF</td>
			<td class="title">EPS</td>
			<td class="title">Total
</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"]."'";
			
	
		$sqlstring="SELECT *,CONCAT(e_fname,e_lname)as emp_name,dtl_basic,dtl_da,dtl_hra,dtl_pf,dtl_esi,dtl_allowance,dtl_incentive FROM employee as em join payroll_salary_pay as paysal ON em.e_id = paysal.userid join designation as des on des.desig_id = em.e_post left join pf_esi_details as pfesi on pfesi.emp_id = em.e_id 
left join (select payment_id,amount as dtl_basic from payroll_salary_pay_details where name like '%basic%')as saldtl on paysal.id=saldtl.payment_id 
 left join (select payment_id,amount as dtl_da from payroll_salary_pay_details where name like '%da%')as saldtl1 on paysal.id=saldtl1.payment_id 
left join (select payment_id,amount as dtl_hra from payroll_salary_pay_details where name like '%hra%')as saldtl2 on paysal.id=saldtl2.payment_id 
left join (select payment_id,amount as dtl_pf from payroll_salary_pay_details where name like '%pf%')as saldtl3 on paysal.id=saldtl3.payment_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 payment_id,amount as dtl_allowance from payroll_salary_pay_details where name like '%allowance%')as saldtl5 on paysal.id=saldtl5.payment_id 
left join (select payment_id,amount as dtl_incentive from payroll_salary_pay_details where name like '%incentive%')as saldtl6 on paysal.id=saldtl6.payment_id 
where month(paysal.pay_period) = '".date('m',strtotime($_REQUEST['from_date']))."' and year(paysal.pay_period) ='".date('Y',strtotime($_REQUEST['from_date']))."' ";
	if(isset($_REQUEST["type_sort"]) && !empty($_REQUEST["type_sort"])){
			$sqlstring.=" order by $_REQUEST[type_sort] ASC";	
		}	
		
		 $userdetails =  $db->fetchQuery($sqlstring);
		 
	$i=1;
	$sum_basic_da=0;
	$sum_pf=0;
		foreach($userdetails as $details) {
			
			 $html .=  '<tr>
					<td class="title">'.$i++.'</td>
					<td class="title">'.$details['e_id'].'</td>
					<td class="title">'.$details['emp_name'].'</td>
					<td class="title"></td>
				
					  <td align="left" valign="top" class="title">'.($details['dtl_basic']+$details['dtl_allowance']).'</td>
					  <td align="left" valign="top" class="title">'.$details['dtl_pf'].'</td>
					<td class="title"></td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
				  </tr>
				';
				$sum_basic_da+= $details['dtl_basic']+$details['dtl_allowance'];
				$sum_pf+= $details['dtl_pf'];
				  
		}
		$html .= '
		 		 <tr>
					<td class="title"></td>
					<td class="title"></td>
					<td class="title"></td>
					<td class="title">Total</td>
					<td class="title">'.$sum_basic_da.'</td>
					  <td class="title">'.$sum_pf.'</td>
					<td class="title"></td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
				  </tr>
				  
				   <tr>
					<td class="title"></td>
					<td class="title"></td>
					<td class="title">Gross for EPS Calculation</td>
					<td class="title"></td>
					<td class="title" ></td>
					  <td class="title">'.$sum_pf.'</td>
					<td class="title"></td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
				  </tr>
				   <tr>
					<td class="title"></td>
					<td class="title"></td>
					<td class="title">Account No 1 EPF </td>
					<td class="title"></td>
					<td class="title"></td>
					  <td class="title"></td>
					<td class="title"></td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
				  </tr>
				  
				    <tr>
					<td class="title"></td>
					<td class="title"></td>
					<td class="title">Account No 10 EPS </td>
					<td class="title"></td>
					<td class="title"></td>
					  <td class="title"></td>
					<td class="title"></td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
				  </tr>
				  
				    <tr>
					<td class="title"></td>
					<td class="title"></td>
					<td  class="title">Account No 2PF Admin 1.1%</td>
					<td class="title"></td>
					<td class="title"></td>
					  <td class="title"></td>
					<td class="title"></td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
				  </tr>
				  
				   <tr>
					<td class="title"></td>
					<td class="title"></td>
					<td class="title">Account No. 21 E D L I 0.5%</td>
					<td class="title"></td>
					<td class="title"></td>
					  <td class="title"></td>
					<td class="title"></td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
					<td class="title">&nbsp;</td>
				  </tr>
				  
				  <tr>
					<td class="title"></td>
					<td class="title"></td>
					<td class="title">Account No. 22 EDLI Admin 0.005%</td>
					<td class="title"></td>
					<td class="title"></td>
					  <td class="title"></td>
					<td class="title"></td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				  </tr>
				  
				    <tr>
					<td></td>
					<td></td>
					<td>Total</td>
					<td></td>
					<td></td>
					<td>'.$sum_pf.'</td>
					<td></td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				  </tr>
				  
				  
				  
				  </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>';
	$dompdf = new DOMPDF();
	$dompdf->load_html($html);
	$dompdf->render();
	$dompdf->stream("PF-Monthly Statement.pdf");
}


?>

