<?php 
if($_REQUEST['save'])
{
	$data['emp_type']     =$_REQUEST['employment_type'];
	$data['range_from']   =$_REQUEST['salfrom'];
	$data['range_to']     =$_REQUEST['salto'];
	$data['pf_per']       =$_REQUEST['pfper'];
	$data['pf_act1_per']  =$_REQUEST['ac1_per'];
    $data['pf_act10_per'] =$_REQUEST['ac10_per'];
	$data['pf_act2_per']  =$_REQUEST['ac2_per'];
    $data['pf_act21_per'] =$_REQUEST['ac21_per'];
	$data['pf_act22_per'] =$_REQUEST['ac22_per'];
	$data['created_by']   =$_SESSION['UserID'];
	$data['created_date'] =date('Y-m-d');	
	$data['companyid']    =$_SESSION['ACGCompanyId'];	
	if($_REQUEST['action']!='Edit')
	{
		$data['modified_by']    =$_SESSION['UserID'];
	    $data['modified_date']  =date('Y-m-d');
		$s->RecordInsert('hr_pf_contrbution_master',$data);
	}
	else
	{
		$cond="id='".$_REQUEST['EID']."'";
		$s->RecordEdit('hr_pf_contrbution_master',$data,$cond);
	}
	$s->pageLocation("index.php?route=HRModule/pf_master".$rurl);
}

if($_REQUEST['EID']!='')
{
	$SQLGet=DB_query("select * from hr_pf_contrbution_master where id='".$_REQUEST['EID']."'",$db);
	$GetDeatails=DB_fetch_array($SQLGet);
	extract($GetDeatails);
}

if($_REQUEST['action']=='Delete')
{
	$condition="id='".$_REQUEST['DELID']."'";
	$s->DeleteRecord('hr_pf_contrbution_master', $condition);
	$s->pageLocation("index.php?route=HRModule/pf_master".$rurl);
}
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<h1><?php echo $s->getField('modules_form','id',$_REQUEST['frmid'],'frm_name'); ?></h1>	
<form method="post">
<table width="100%" cellpadding="3" cellspacing="0" border="0">
<tr class="row1">
	<td width="16%" align="right">Employee Type</td>
	<td width="20%"><select id="employment_type"  name="employment_type">
		<option value="0">Select</option>
<option value="Permanent" <?php if($emp_type=='Permanent') { ?> selected <?php } ?>>Permanent</option>
<option value="Temporary" <?php if($emp_type=='Temporary') { ?> selected <?php } ?>>Temporary</option>
</select></td>
	<td width="13%" align="right">Range From</td>
	<td width="20%"><input type="text"  value="<?php echo $range_from; ?>" name="salfrom" id="salfrom" onkeypress="return isNumberKey(event)"></td>
	<td width="13%" align="right">Range To</td>
	<td><input type="text"  value="<?php echo $range_to; ?>" name="salto" id="salto" onkeypress="return isNumberKey(event)"></td>
</tr>

<tr class="row1">
	<td align="right">Employee PF Contribution %</td>
	<td><input type="text" name="pfper" value="<?php echo $pf_per; ?>" id="pfper" onkeypress="return isNumberKey(event)"></td>
	<td colspan="4"></td>
</tr>
<tr class="row1">
	<td colspan="2" valign="top">
		<h3>Employer PF Contribution</h3>
		<table width="100%" cellpadding="3" cellspacing="0" border="0">
			<tr class="row1">
				<td width="39%" style="text-align:right;">A/C 1 PF</td>
				<td><input type="text" name="ac1_per" value="<?php echo $pf_act1_per; ?>" id="ac1_per" 
					onkeypress="return isNumberKey(event)"></td>
			</tr>
			<tr class="row1">
				<td style="text-align:right;">A/C 10 EPS</td>
				<td><input type="text" name="ac10_per" value="<?php echo $pf_act10_per; ?>" id="ac10_per" 
					onkeypress="return isNumberKey(event)"></td>
			</tr>
		</table>
	</td>
	<td colspan="2" valign="top">
		<h3>Admin Expenses</h3>
		<table width="100%" cellpadding="3" cellspacing="0" border="0">
			<tr class="row1">
				<td width="39%" style="text-align:right;">A/C 2 PF</td>
				<td><input type="text" name="ac2_per"  value="<?php echo $pf_act2_per; ?>" id="ac2_per"
				 onkeypress="return isNumberKey(event)"></td>
			</tr>
			<tr class="row1">
				<td style="text-align:right;">A/C 21 PF</td>
				<td><input type="text" name="ac21_per"  value="<?php echo $pf_act21_per; ?>" id="ac21_per" 
					onkeypress="return isNumberKey(event)"></td>
			</tr>
			<tr class="row1">
				<td style="text-align:right;">A/C 22 PF</td>
				<td><input type="text" name="ac22_per"  value="<?php echo $pf_act22_per; ?>" id="ac22_per" 
					onkeypress="return isNumberKey(event)"></td>
			</tr>
		</table>
	</td>
	<td colspan="2" valign="top"></td>
</tr>
<tr class="row1">
	<td colspan="6" style="text-align:center;"><input type="submit" name="save" value="Save" class="search"  onclick="return validate()"
		<?php if($_SESSION['frmcreate']=='0'){?>disabled<?php } ?> ></td>
</tr>
</table> 
</form>
<br/>
<table width="100%" border="0" cellpadding="3" cellspacing="0" class="thborder">
<tr>
	<th rowspan="2" width="5%">S. No.</th>
	<th rowspan="2" width="10%">Employee Type</th>
	<th rowspan="2" width="10%">Range From</th>
	<th rowspan="2" width="10%">Range to</th>
	<th rowspan="2">Employee PF Contribution %</th>
	<th style="text-align:center;" colspan="2" width="20%">Employee PF Contribution</th>
	<th style="text-align:center;" colspan="3" width="20%">Admin Expenses</th>
	<th style="text-align:center;" colspan="2" width="6%">Action</th>
</tr>
<tr>
	<th style="text-align:center;">A/C 1 PF</th>
	<th style="text-align:center;">A/C 10 EPS</th>
	<th style="text-align:center;">A/C 2 PF</th>
	<th style="text-align:center;">A/C 21 PF</th>
	<th style="text-align:center;">A/C 22 PF</th>
	<th style="text-align:center;">Edit</th>
	<th style="text-align:center;">Delete</th>
</tr>
<?php $i=0; $SQL=DB_query("SELECT * FROM hr_pf_contrbution_master
              where companyid='".$_SESSION['ACGCompanyId']."'",$db);
             while($GetRec=DB_fetch_array($SQL)) {?>
<tr>
	<td><?php echo $i+1; ?></td>
	<td><?php echo  $GetRec['emp_type'];?></td>
	<td><?php echo  $GetRec['range_from'];?></td>	
	<td><?php echo  $GetRec['range_to'];?></td>
	<td><?php echo  $GetRec['pf_per'];?></td>
	<td><?php echo  $GetRec['pf_act1_per'];?></td>
	<td><?php echo  $GetRec['pf_act10_per'];?></td>
	<td><?php echo  $GetRec['pf_act2_per'];?></td>
	<td><?php echo  $GetRec['pf_act21_per'];?></td>
	<td><?php echo  $GetRec['pf_act22_per'];?></td>	
	<td style="text-align:center;">
			<?php if($_SESSION['frmEdit']=='1'){?><a href="index.php?route=HRModule/pf_master<?php echo $rurl; ?>&action=Edit&EID=<?php echo $GetRec['id']; ?>"><img src="images/icon-edit.png" height="15" width="15" title="Edit Document" /></a><?php }else{echo "No Permission";} ?></td>
	<td style="text-align:center;">
			<?php if($_SESSION['frmDelete']=='1'){?><a href="index.php?route=HRModule/pf_master<?php echo $rurl; ?>&action=Delete&DELID=<?php echo $GetRec['id']; ?>"><img src="images/Icon_Delete.png" height="15" width="15" title="Delete Document" /></a><?php }else{echo "No Permission";} ?></td>
</tr>
<?php $i++;}?>
</table>
</div>
</div>
<script type="text/javascript">
function isNumberKey(evt)
       {
          var charCode = (evt.which) ? evt.which : evt.keyCode;
          if (charCode != 46 && charCode > 31 
            && (charCode < 48 || charCode > 57))
             return false;

          return true;
       } 

       function validate()
       {
	        if(document.getElementById("employment_type").value=='0') {
	        	alert("Must Select Employee Type First");
	        	document.getElementById("employment_type").focus();
	        	return false;
	        }

	        if(document.getElementById("salfrom").value=='')  {
	        	alert("Enter Range From Value");
	        	document.getElementById("salfrom").focus();
	        	return false;
	        }
            
            if(document.getElementById("salto").value=='') {
	        	alert("Enter Range To Value");
	        	document.getElementById("salto").focus();
	        	return false;
	        }
	        if(document.getElementById("pfper").value=='') {
	        	alert("Enter Employee PF Value");
	        	document.getElementById("pfper").focus();
	        	return false;
	        }
	      return true;
       }

</script>