<link rel="stylesheet" href="css/new_mxerp.css">
<script src="js/function-ajax.js" language="javascript"></script>
<script src="empcal.js" language="javascript"></script>
<form name="search" action="" method="post">
<div class="body_contain">
<div class="tab_div">
 
<?php 
	if($_REQUEST['action']=='offer' && $_REQUEST['id']!='')
	{
		$jobtype=array("p"=>"Permanent","c"=>"Temporary");
		//echo $_REQUEST['id'];
		$query=DB_query("select a.*,b.* from hr_applcnt_rgstn a inner join hr_applcnt_rgstn_offer b on a.id=b.hr_applcnt_rgstn_id where a.id='".$_REQUEST['id']."'",$db);
		
		$row=DB_fetch_array($query);
		extract($row);
		//echo $hr_job_created;
		$site=$s->GetFieldValue("hr_job_created","id='".$hr_job_created_id."'","branch");
		 $type=$s->GetFieldValue("hr_job_created","id='".$hr_job_created_id."'","job_type");

		
	}
?>
<?php
if($_REQUEST['save'])
{

//**************************mail functin ***********************************************************
 

//**********************mail function********************************************************
	$sql="select appointment_no from hr_applcnt_rgstn_appointment order by appointment_no desc limit 1";

	 
	//$qyprefix=DB_query("Select prefix from locations Where loccode ='".$_REQUEST['requested_site']."'",$db);
	//$row_prefix=DB_fetch_array($qyprefix);
	//$projectprefix=$row_prefix['prefix'];
	$result = DB_query($sql,$db);
	$numrows = DB_num_rows($result);

	if($numrows>0)
	
	{
		
		$IsuuNo=DB_fetch_array($result);
		$Explo=explode("/",$IsuuNo['appointment_no']);
		$maxval=$Explo[1];
		
		//$strFinal = $maxval+1;
		// $strBothFinal = "GS1".'/'.'APMNT'.'/'.str_pad($strFinal,6,"0",STR_PAD_LEFT);
		 $strFinal = $maxval+1;
		 $strBothFinal = "APMNT".'/'.str_pad($strFinal,6,"0",STR_PAD_LEFT);
	}
	else
	{
		
	// $strBothFinal= "GS1".'/'.'APMNT'.'/'.'000001';
	  $strBothFinal= "APMNT".'/'.'000001';
	}
	$offerid=$s->GetFieldValue("hr_applcnt_rgstn_offer","hr_applcnt_rgstn_id='".$_REQUEST['id']."'","id") ;
	$dataArr1['hr_applcnt_rgstn_id']=$_REQUEST['id'];
	$dataArr1['hr_applcnt_rgstn_offer_id']=$offerid;
	$dataArr1['subject']=$_REQUEST['subject'];
	$dataArr1['location']=$_REQUEST['location'];
	$dataArr1['notice_prd']=$_REQUEST['notice'];
	$dataArr1['joining_date']=ConvertSQLDate($_REQUEST['join_date']);
	
	$dataArr1['employee_type']=$_REQUEST['employee_type'];
	$dataArr1['grade']=$_REQUEST['grade'];
	$dataArr1['reporting']=$_REQUEST['report'];

    $dataArr1['appointment_no']=$strBothFinal;
    $dataArr1['appointment_date']=ConvertSQLDate($_REQUEST['offer_date']);   
   	//$dataArr1['med_claim']=$_REQUEST['mediclaim'];

   	$dataArr1['gross_salary']=$_REQUEST['gross_sal'];
   	$dataArr1['allowance_tot']=$_REQUEST['allowance_tot'];
   	$dataArr1['net_salary']=$_REQUEST['net_sal1'];
   	$dataArr1['deduction']=$_REQUEST['deduct_tot'];
   	$dataArr1['monthly_ctc']=$_REQUEST['monthelyctc'];
   	$dataArr1['yearly_ctc']=$_REQUEST['allow_tot_yearly'];
   	$dataArr1['basic']=$_REQUEST['basic_salary'];
 
   	 $dataArr1['sal_effect']=ConvertSQLDate($_REQUEST['eff_sal_date']);
   	
    $dataArr1['created_by']=$_SESSION['UserID'];    
    $dataArr1['created_date']=date('Y-m-d H:i:s');

    if($_REQUEST['govt'])
		$govtnom='Y';
		else
		$govtnom='N';
		$dataArr1['govt_nom_pf']=$govtnom;
    $s->RecordInsert('hr_applcnt_rgstn_appointment',$dataArr1);

    $Lastemp_id = DB_Last_Insert_ID($db,'hr_applcnt_rgstn_appointment','id');

    $dataArr12['status']='appoint';
    $dataArr12['conf_int_app_details_seq']=0;
    //$dataArr1['conf_int_app_details_id']=$_REQUEST['id'];
    $dataArr12['awd_application_id']=$_REQUEST['id'];
    $dataArr12['created_by']=$_SESSION['UserID'];    
    $dataArr12['datetime']=date('Y-m-d H:i:s');
    $s->RecordInsert('hr_applcnt_rgstn_log_status',$dataArr12);
    $qt=DB_query("update hr_applcnt_rgstn set status='appoint' where id='".$_REQUEST['id']."'",$db);


   
 //			****************************************  annuxure 
for($k=1;$k<$_REQUEST['ctr'];$k++)
			{
				$dataEmpSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
				$dataEmpSal['allowance_deduction']=$_REQUEST['allid'][$k];
				$dataEmpSal['percentage']=$_REQUEST['aperc'][$k];
				$dataEmpSal['percentage_value']=$_REQUEST['allow'][$k];
				$dataEmpSal['all_ded_prefix']=$_REQUEST['prefix1'];
				$s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSal);
			}
			
			// $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='100';
			// $dataEmpSpeSal['percentage']='0.00';
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['special_allow'];			
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);
			
			
			// $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='101';
			// $dataEmpSpeSal['percentage']=$_REQUEST['ltaper'];
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['lta'];
			// $dataEmpSpeSal['non_taxable_amt']=$_REQUEST['lta_nontaxable'];
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);
			
			// $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='102';
			// $dataEmpSpeSal['percentage']=$_REQUEST['medicalper'];
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['medicalamount'];
			// $dataEmpSpeSal['non_taxable_amt']=$_REQUEST['medicalamountent'];
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);

			// $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='104';
			// $dataEmpSpeSal['percentage']=$_REQUEST['supperannuation_per'];
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['supperannuation_amt'];
			// $dataEmpSpeSal['non_taxable_amt']=$_REQUEST['supperannuation_nontaxableamt'];
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);

			// $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='105';
			// $dataEmpSpeSal['percentage']=$_REQUEST['medicalpolicyamt'];
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['medicalpolicyper'];
			// $dataEmpSpeSal['non_taxable_amt']=$_REQUEST['medicalpolicyamountent'];
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);

			// $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='106';
			// $dataEmpSpeSal['percentage']=$_REQUEST['gratuity_per'];
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['gratuity_amt'];
			// $dataEmpSpeSal['non_taxable_amt']=$_REQUEST['gratuity_nontaxableamt'];
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);


			
//////////////////////////////////////////........ESI(Employer)..../////////////////////////////			
			// $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='103';
			// $dataEmpSpeSal['percentage']=$_REQUEST['ESI_employer'];
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['ESI_employer_value'];
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);

			// $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='107';
			// $dataEmpSpeSal['percentage']=$_REQUEST['pf_ac1'];
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['pf_ac1_amt'];
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);

			// $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='108';
			// $dataEmpSpeSal['percentage']=$_REQUEST['pf_ac10_per'];
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['pf_ac10_amt'];
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);

			// $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='109';
			// $dataEmpSpeSal['percentage']=$_REQUEST['pf_ac2_per'];
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['pf_ac2_amt'];
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);

			// $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='110';
			// $dataEmpSpeSal['percentage']=$_REQUEST['pf_ac21_per'];
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['pf_ac21_amt'];
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);

   //          $dataEmpSpeSal['hr_applcnt_rgstn_appointment_id']=$Lastemp_id;
			// $dataEmpSpeSal['allowance_deduction']='111';
			// $dataEmpSpeSal['percentage']=$_REQUEST['pf_ac22_per'];
			// $dataEmpSpeSal['percentage_value']=$_REQUEST['pf_ac22_amt'];
			// $dataEmpSpeSal['all_ded_prefix']='A';
			// $s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSpeSal);
			
			for($K=1;$K<$_REQUEST['dctr'];$K++)
			{
				$dataEmpSalDed['hr_applcnt_rgstn_appointment_id']=$Lastemp_id; 
				$dataEmpSalDed['allowance_deduction']=$_REQUEST['dedid'][$K];
				$dataEmpSalDed['percentage']=$_REQUEST['dperc'][$K]; 
				$dataEmpSalDed['percentage_value']=$_REQUEST['deduction'][$K]; 
				$dataEmpSalDed['all_ded_prefix']=$_REQUEST['prefix2'];
				$s->RecordInsert('hr_applcnt_rgstn_annex',$dataEmpSalDed);
			}
  //****************************************  annuxure 



  $s->pageLocation("index.php?route=HRModule/Master/appointment"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
}

?>
<?php
if($_REQUEST['calcel'])
{
 $s->pageLocation("index.php?route=HRModule/Master/proposed_offer"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']); 
}
?>
<h1>Appointment</h1>
<input type="hidden" name="grade1" id="grade1" value="4" style="width:98%;">
<input type="hidden" id="emp_site" value="<?php echo $site; ?>">
<input type="hidden" id="employment_type" value="<?php echo $jobtype[$type]; ?>">
<div style="width:1100px; height:auto; margin:0 auto;">
<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
<tr class="row1">
<td><strong>Appointment No.&nbsp;:&nbsp;</strong><input type="text" disabled="disabled" value="Auto Generated"></td>
<td></td>
<td style="text-align:right;"><strong>Date&nbsp;:&nbsp;</strong><input id="" value="<?php echo date('d/m/Y');?>" class="datepicker" type="text"  name="offer_date"></td>
<input type="hidden" id="pftype" value='P'>
</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
<tr class="row1">
<th colspan="2"><strong>Name & Address</strong></th>
</tr>
<tr class="row1">
<td width="10%"><strong>Name</strong></td>
<td><b><?php echo $first_name.'&nbsp;&nbsp;'.$middle_name.'&nbsp;&nbsp;'.$last_name; ?></b></td>
</tr>

</table>
	<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
	
<tr class="row1">
<td><strong>Subject:</strong>&nbsp;&nbsp;&nbsp;<input type="text" name="subject"></td>
</tr>
	
</table>
		<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
		<!--
		<tr class="row1">
		<td><strong>Remuneration:</strong></td>
		<td>The Gross remuneration shall be Rs&nbsp;&nbsp;&nbsp;<input type="text" readonly name="salary">&nbsp;&nbsp;per annum. 
								The details of the same are attached at Annexure - I.</td>
		
	    
		</tr>-->
		<tr class="row1">
		<td><strong>Notice Period:</strong></td>
		<td>The notice period will be&nbsp;&nbsp;&nbsp;<input type="text" name="notice">&nbsp;&nbsp;&nbsp;days on either side.</td>
		</tr>
		<tr class="row1">
		<td><strong>Location:</strong></td>
		<td>The notice period will be&nbsp;&nbsp;&nbsp;<input type="text" name="location">&nbsp;&nbsp;&nbsp;days on either side.</td>
		</tr>
		<tr class="row1">
		<td><strong>Joining date:</strong></td>
		<td>On&nbsp;&nbsp;&nbsp;<input type="text" name="join_date" class="datepicker"></td>
		</tr>
		
		<tr class="row1">
		<td><strong>Reporting:</strong></td>
		<td>You shall report to the&nbsp;&nbsp;&nbsp;<input type="text" name="report">&nbsp;&nbsp;&nbsp; who would assign you job responsibilities from
		 time to time or such other person as directed from time to time.</td>
		</tr>




				<tr class="row1">


				<td><strong>Employee Type<font color="#FF0000" size="-1">*</font></strong></td>	

				<td><select name="employee_type" id="employee_type" onchange="finGrd(),rsetfun()"   style="width:98%" >
				<option value="">Select</option>
				<option value="worker" <?php echo($employee_type=='worker'?'selected':'')?>>Worker</option>
				<option value="employee" <?php echo($employee_type=='employee'?'selected':'')?>>Employee</option>
				</select>
				</td>
				</tr>


				<tr class="row1">
				<td><strong>Salary Grade:</strong></td>
			 <td><select name="grade" id="grade" style="width:98%;" onchange="finGrd1()" >
			 <option value="">Select</option><?php
			 $query = DB_query("SELECT `eg`.`id`,`eg`.`grade_name` FROM `emp_grade` `eg` WHERE `eg`.`employment_type`='".trim($employee_type)."'",$db);
				while($resultD = DB_fetch_assoc($query))
				{
					echo $grade_id.'=='.$resultD['id'];
			?>
					<option value='<?php echo $resultD['id'];?>' <?php if($grade_id==$resultD['id']){ echo "selected"; }?> ><?php echo $resultD['grade_name'];?></option>
			<?php
				}?>
			
		  </select></td>
				</tr>



		<tr><td>&nbsp;</td></tr>			
		</table>
<!--*****************************************************   salary details box-->

		<!--Salary box-->
	<div class="box">
	<div class="box">
<h3>Salary Details</h3>
<table width="100%" border="0" cellpadding="3" cellspacing="0">

  <tr class="row1">
    <td valign="top" width="50%">
    <h3><strong>Allowances Part</strong><strong>(A) </strong><input type="hidden" name="prefix1" id="prefix1" value="A" /></h3>
	<table width="100%" border="0" cellpadding="3" cellspacing="0" id="tableDataProduction">
        <tr class="row1">
        <td width="24%"><strong>DESCRIPTION</strong></td>
        <td width="36%" style="text-align:center;"><strong></strong></td>
        <td style="text-align:center;"><strong>VALUE</strong></td>
        </tr>
	    <tr class="row1">
		<td><strong>BASIC</strong></td>
		<td></td>
		<td><input type="text" name="basic_salary" id="basic_salary" value="<?php echo $basic;?>" size="10" class="number" onkeyup="calculate_basic(this)" style="width:98%;" tabindex="1" /></td>
	    </tr>
	 
      <?php
	  $all_sql=DB_query("Select * from allowmaster",$db); 
	 $i=1;
	  while($all_row=DB_fetch_array($all_sql))
	  {
	  ?>
	  <tr class="row1">
        <td><strong><?php echo $all_row['allowname'];?></strong>
          <input type="hidden" name="allow_code[<?php echo $i;?>]" id="allow_code_<?php echo $i;?>" value="<?php echo $all_row['allowcode'];?>" />
		  <input type="hidden" name="allid[<?php echo $i;?>]"   id="allid_<?php echo $i;?>" value="<?php echo $all_row['id'];?>" />
		  </td>
       <td></td>
        <td>		
		<input name="allow[<?php echo $i;?>]" type="text" id="allow_<?php echo $i;?>" value="<?php echo $allow[$i];?>" size="10" class="number"   tabindex="<?php echo $j1= $i+1; ?>" onkeyup="cal_allvalue(this,<?php echo $i;?>);" style="width:98%;" abc="areaSum" /></td>
		<!--onkeyup="reversecal_allvalue(this.value,<?php //echo $i; ?>)"-->
      </tr>
	  <?php $i++;} ?>
	  <input type="hidden" name="ctr" id="ctr" value="<?php echo $i;?>" />
	
	<!--  <tr class="row1">
	 <td><strong>Special Allowance</strong></td>
	 <td></td>
	  <td><input type="text" name="special_allow" id="special_allow" value="<?php echo $special_allow; ?>" size="10"  class="number" tabindex="<?php echo $j1= $j1+1;?>" style="width:98%;"  onkeyup="cal_special_allow()" /></td>
	 </tr> -->
 <tr class="row1">
 <td><strong>Total Allowance</strong></td>
	 <td></td>
	 <td ><input id="allowance_tot" type="text" tabindex="142" style="width:98%;" readonly="true"  value="<?php echo $allowance_tot;?>" name="allowance_tot"></td>
</tr>
	 	 <tr class="row1">
		<td ><strong>Gross Salary (monthly)<font color="#FF0000" size="-1">*</font></strong></td>
		<td></td>
		<td><input name="gross_sal" type="text" id="gross_sal" tabindex="<?php echo $j1= $j1+1;?>" value="<?php echo $gross_sal;?>"  style="width:98%;"  readonly="true" /></td>
		</tr>
	   <tr class="row1">
	   	 <td><strong>Gross Salary (yearly)<font color="#FF0000" size="-1">*</font></strong></th>
		  <td><input name="allow_tot" type="hidden"  id="allow_tot" value="<?php echo $allow_tot;?>" tabindex="<?php echo $j1= $j1+1;?>"  readonly="true" style="width:98%;" onblur="data_str(this.value);" /></td>

		 <td><input name="allow_tot_yearly" type="text"  id="allow_tot_yearly" readonly tabindex="<?php echo $j1= $j1+1;?>"  readonly="true" style="width:98%;"/></td>	
	 </tr>



	<!--  <tr class="row1">
		 <td colspan="3"><h3><strong>Allowances Part (B)</strong></h3></td>
	</tr>
	<tr class="row1">
		 	<td><strong>ESIC</strong></td>
			<td><input type="text" name="ESI_employer" id="ESIemployer" style="width:98%;" value="<?php echo $esi_per ?>" onkeyup="calculate_esi(this.value);" readonly="" tabindex="<?php echo $j1= $j1+1;?>"/></td>
			<td><input type="text" name="ESI_employer_value" id="esimployervalue" size="10" value="<?php echo $esi_value ?>" readonly="" tabindex="<?php echo $j1= $j1+1;?>" style="width:98%;" /></td>
		 </tr>
		 <tr class="row1">
		 	<td><strong>PF A/C 1</strong></td>
			<td><input type="text" name="pf_ac1" id="pf_ac1" style="width:98%;" value="<?php echo $pf_ac1 ?>" readonly="" tabindex="<?php echo $j1= $j1+1;?>"/></td>
			<td><input type="text" name="pf_ac1_amt" id="pf_ac1_amt" size="10" value="<?php echo $pf_ac1_amt ?>"  readonly="" tabindex="<?php echo $j1= $j1+1;?>" style="width:98%;" /></td>
		 </tr>
		  <tr class="row1">
		 	<td><strong>PF A/C 10 EPS</strong></td>
			<td><input type="text" name="pf_ac10_per" id="pf_ac10_per" style="width:98%;" value="<?php echo $pf_ac10_per; ?>"  readonly="" tabindex="<?php echo $j1= $j1+1;?>"/></td>
			<td><input type="text" name="pf_ac10_amt" id="pf_ac10_amt" size="10" value="<?php echo $pf_ac10_amt; ?>" readonly="" tabindex="<?php echo $j1= $j1+1;?>" style="width:98%;" /></td>
		 </tr>
		 	<tr class="row1">
		 	<td><strong>PF A/C 2  </strong></td>
			<td><input type="text" name="pf_ac2_per" id="pf_ac2_per" style="width:98%;" value="<?php echo $pf_ac2_per; ?>" readonly="" tabindex="<?php echo $j1= $j1+1;?>"/></td>
			<td><input type="text" name="pf_ac2_amt" id="pf_ac2_amt" size="10" value="<?php echo $pf_ac2_amt; ?>" readonly="" tabindex="<?php echo $j1= $j1+1;?>" style="width:98%;" /></td>
		 </tr>
		  <tr class="row1">
		 	<td><strong>PF A/C 21  </strong></td>
			<td><input type="text" name="pf_ac21_per" id="pf_ac21_per" style="width:98%;" value="<?php echo $pf_ac21_per; ?>"  readonly="" tabindex="<?php echo $j1= $j1+1;?>"/></td>
			<td><input type="text" name="pf_ac21_amt" id="pf_ac21_amt" size="10" value="<?php echo $pf_ac21_amt; ?>" readonly="" tabindex="<?php echo $j1= $j1+1;?>" style="width:98%;" /></td>
		 </tr>
		  <tr class="row1">
		 	<td><strong>PF A/C 22 </strong></td>
			<td><input type="text" name="pf_ac22_per" id="pf_ac22_per" style="width:98%;" value="<?php echo $pf_ac22_per; ?>"  readonly="" tabindex="<?php echo $j1= $j1+1;?>"/></td>
			<td><input type="text" name="pf_ac22_amt" id="pf_ac22_amt" size="10" value="<?php echo $pf_ac22_amt; ?>" readonly="" tabindex="<?php echo $j1= $j1+1;?>" style="width:98%;" />
         
			</td>
		 </tr>	 -->

	<!-- <tr class="row1">
		 <td colspan="3"><h3><strong>Allowances Part (C)</strong></h3></td>
	</tr> -->
	<!--   <tr class="row1">
		 	<td><strong>LTA</strong></td>
			<td><input type="hidden" name="ltaper" id="ltaper" onkeyup="calltaAll(this)" size="2"  tabindex="<?php echo $j1= $j1+1;?>" value="<?php echo $LTA_allow_Per; ?>" style="width:28%;" /><input type="text" name="lta" id="lta" size="10" onkeyup="calltaAll(this)"   value="<?php echo $LTA_allow_Val; ?>"  tabindex="<?php echo $j1= $j1+1;?>" style="width:96%;" /></td>
			<td><input type="text" name="lta_nontaxable" id="lta_nontaxable" size="10"  tabindex="<?php echo $j1= $j1+1;?>" style="width:97%;" value="<?php echo $LTA_allow_Val_non; ?>" /></td>
		 </tr> -->
		<!--  <tr class="row1">
		 	<td><strong>Medical</strong></td>
			<td><input type="hidden" name="medicalper" id="medicalFper" onkeyup="calltaAll1(this)" size="2" value="<?php echo $medicalper; ?>" tabindex="<?php echo $j1= $j1+1;?>" style="width:28%;" /><input type="text" name="medicalamount" id="medicalamt" onkeyup="calltaAll1(this)"  size="10" tabindex="<?php echo $j1= $j1+1;?>" style="width:96%;" value="<?php echo $medicalamount; ?>" />
			</td>
			<td><input type="text" name="medicalamountent" id="medicalamountent" onkeyup="calltaAll1(this)"  size="10" tabindex="<?php echo $j1= $j1+1;?>" value="<?php echo $medicalamount_non; ?>" style="width:97%;" /></td>
		 </tr>
		   <tr class="row1">
		 	<td><strong>Medical Policy</strong></td>
			<td><input type="hidden" name="medicalpolicyper" id="medicalpolicyper" size="2" value="<?php echo $mediclaim_per; ?>" tabindex="<?php echo $j1= $j1+1;?>" style="width:28%;" /><input type="text" name="medicalpolicyamt" id="medicalpolicyamt" onkeyup="calltaAll3(this)" value="<?php echo $mediclaim_amt; ?>"  size="10" tabindex="<?php echo $j1= $j1+1;?>" style="width:96%;" />
			</td>
			<td><input type="text" name="medicalpolicyamountent" id="medicalpolicyamountent"   size="10" tabindex="<?php echo $j1= $j1+1;?>" style="width:97%;" value="<?php echo $mediclaim_amt_non; ?>" /></td>
		 </tr> -->
		<!--   <tr class="row1">
		 	<td><strong>Superannuation</strong></td>
		<td><input type="hidden" name="supperannuation_per" id="mediclaimper"  size="2" 
				value="<?php echo $supperannuation_per; ?>" readonly tabindex="<?php echo $j1= $j1+1;?>" style="width:28%;" /><input type="text" name="supperannuation_amt" id="mediclaimamt" onkeyup="calltaAll3(this)" size="10" tabindex="<?php echo $j1= $j1+1;?>" value="<?php echo $supperannuation_amt; ?>" style="width:96%;" /></td>
		<td><input type="text" name="supperannuation_nontaxableamt" id="supperannuation_nontaxableamt"  size="10" tabindex="<?php echo $j1= $j1+1;?>" style="width:97%;" value="<?php echo $supperannuation_nontaxableamt; ?>" /></td>
		 </tr>
		  <tr class="row1">
		 	<td><strong>Gratuity</strong></td>
			<td><input type="hidden" name="gratuity_per" id="gratuity_per"  size="2" 
				value="<?php echo $gratuity_per; ?>" readonly tabindex="<?php echo $j1= $j1+1;?>" style="width:28%;" /><input type="text" name="gratuity_amt" id="gratuity_amt" onkeyup="calltaAll3(this)" size="10" tabindex="<?php echo $j1= $j1+1;?>" style="width:96%;" value="<?php echo $gratuity_amt; ?>"  /></td>
			<td><input type="text" name="gratuity_nontaxableamt" id="gratuity_nontaxableamt"  size="10" tabindex="<?php echo $j1= $j1+1;?>" style="width:97%;" value="<?php echo $gratuity_nontaxableamt; ?>" /></td>
		 </tr>  -->   
    </table></td>
    <td valign="top">
    <h3><strong>DEDUCTION (D)</strong> <input type="hidden" name="prefix2" id="prefix2" value="D" /></h3>
    <table width="100%" border="0" cellpadding="3" cellspacing="0">
      <tr class="row1">
        <td width="24%"><strong>DESCRIPTION</strong></td>
        <td width="38%"><strong>%</strong></td>
        <td><strong>VALUE</strong></td>
      </tr>
     <?php
	  $ded_sql=DB_query("Select * from deduction_master",$db); 
	 $j=1;
	  while($ded_row=DB_fetch_array($ded_sql))
	  {
	  
	  ?>
<tr class="row1">
        <td><strong><?php echo $ded_row['name'];?>	

        <?php if($ded_row['code']=='raw_PF'){ ?>

		<br />
		<input type="checkbox" name="govt"  id="govt" <?php echo $checked1; ?>
		 onclick="cal_dedvalue1(<?php echo $j;?>)" />
		Govt Standard </strong>
		<?php } ?>	
		<input name="empdedtype[<?php echo $j;?>]" id="empdedtype_<?php echo $j;?>" type="hidden" value="<?php echo $ded_row['code'];?>" />
</strong>
   <input type="hidden" name="ded_code[<?php echo $j;?>]" id="ded_code_<?php echo $j;?>" value="<?php echo $ded_row['code'];?>" />
	<input type="hidden" name="dedid[<?php echo $j;?>]" id="dedid_<?php echo $j;?>" value="<?php echo $ded_row['id'];?>" />	  
		  </td>
<?php if($ded_row['code']!='PT'){ ?>		  
<!-- <td><input name="dperc[<?php echo $j;?>]" type="text" id="dperc_<?php echo $j;?>" value="<?php echo $dperc[$j];?>" size="5" onkeyup="cal_dedvalue(this.value,<?php echo $j;?>)" class="number" tabindex="<?php echo $j1= $j1+$j;?>" style="width:98%;" /></td> -->
<td></td>
      <?php  } else { ?>
	<td>&nbsp;</td>
	<?php } ?>		
	<td><input name="deduction[<?php echo $j;?>]" type="text" id="detection_class_value_<?php echo $j;?>" value="<?php echo $deduction1[$j];?>" size="10" class="number" tabindex="<?php echo $cj=($cj+$j); ?>" style="width:98%;" /></td>
      </tr>
	  <?php $j++; } ?>




	  <input type="hidden" name="dctr" id="dctr" value="<?php echo $j;?>" />
	  <tr class="row1">
	 <td><strong>Total Deduction</strong></td>
	 <td></td>
	 <td ><input id="deduct_tot" type="text" tabindex="142" style="width:98%;" readonly="true" onfocus="cal_dedtot()" value="" name="deduct_tot"></td>
	 </tr>    
       <tr class="row1">
		 <td><strong>CTC (monthly)</strong></td>
		<td></td>
		<td><input type="text" name="monthelyctc" id="monthelyctc1" readonly size="15" tabindex="<?php echo $j1= $j1+1;?>" style="width:98%;" value="<?php echo $gross_salary; ?>" /></td>

 	</tr>
 	 <tr class="row1">
		 <td><strong>CTC (yearly)</strong></td>
		 <td></td>
		 <td><input type="text" name="yearlyctc" id="yearlyctc1" value="<?php echo (floatval($gross_salary)*12); ?>"  size="15" tabindex="<?php echo $j1= $j1+1;?>" style="width:98%;" /></td>
	
		 </tr>
		<tr class="row1">
		<td ><strong>Salary Effective From </strong></td>
		<td></td>
		<td ><input name="eff_sal_date" type="text" class="datepicker" id="eff_sal_date" value="<?php if(isset($eff_sal_date)){echo $eff_sal_date;}else echo date('d/m/Y');?>" style="width:98%;" tabindex="<?php echo $j1= $j1+1;?>" /></td>
	</tr>
	<!-- <tr class="row1">
		<td ><strong>Gross Salary (monthly)<font color="#FF0000" size="-1">*</font></strong></td>
		<td></td>
		<td><input name="gross_sal" type="text" id="gross_sal" tabindex="<?php echo $j1= $j1+1;?>" value="<?php echo $gross_sal;?>"  style="width:98%;"  readonly="true" /></td>
		</tr> -->


		<tr class="row1">
		<td><strong>Net Salary (A-D) (yearly) </strong></td>
		<td></td>
		<td><input name="net_sal1" type="text" id="net_sal" tabindex="<?php echo $j1= $j1+1;?>" value="<?php echo $net_sal;?>"  style="width:98%;"  readonly="true"/></td>		
		</tr>
		
</table></td></tr></table>
			</div>
		<!-- <input name="gross_sal" type="hidden" id="gross_sal"  style="width:98%;" onfocus="cal_gross()" tabindex="<?php echo ($mc1+1); ?>" readonly="true" /> -->
		<!--<input name="net_sal" type="hidden" id="net_sal" style="width:98%;" onfocus="cal_net()" tabindex="<?php echo ($mc1+2); ?>" readonly="true" />-->
		
	</div>

<!--**************************************    end salary details box-->



		<p align="center"><input class="search" type="submit" value="Save" name="save">
		<input class="search" type="submit" value="cancel" name="calcel"></p>
	</div>
</div>
</div>
</form>


<script type="text/javascript">
	Element.cleanWhitespace('content');
	init();
</script>
<?php
include('includes/footer.inc');
?>

<script type="text/javascript">
	$(document).ready(function(){
		//rsetfun();
		//finGrd();
		finGrd1();
	});

function  rsetfun(){
// $("#grade").val('');
document.getElementById('grade').selectedIndex = 0;

}

					function finGrd()
					{//getStore
						
					var e_type = $('#employee_type').val();
					var grade = $('#grade').val();
					var designation = $('#designation').val();

					if(e_type!=''){
					var type='grade';
					}

					if(type!=''){
					//console.log(designation+'=='+grade);
					$.ajax({
					url : "ajaxSalaryDet.php",
					type : "POST",
					data : {emp_type:e_type,grade:grade,designation:designation,type:type},
					success : function(data) {//alert(data);
					console.log(data);
					if(type=='grade'){
					//	console.log(data);
					
					$('#'+type).html(data);
					}
					

					}
					});
					}

					}




					function finGrd1()
					{//getStore
					var e_type = $('#employee_type').val();
					var grade = $('#grade').val();
					var designation = 000;
					console.log(designation);

					// if(e_type!='' && grade==''){
					// 	var type='grade';
						// }else 
						if(e_type!='' && grade!='' ){

						var type='salary';
						}
	                if(type!=''){
					//console.log(designation+'=='+grade);
					$.ajax({
					url : "ajaxSalaryDet.php",
					type : "POST",
					data : {emp_type:e_type,grade:grade,designation:designation,type:type},
					success : function(data) {//alert(data);
					   
                    if(type!='grade'){
                    
					var i=1, j=1, total_deduction=0;
					$('#'+type).empty();
					console.log(data);
					var obj = JSON.parse(data);
					
					$.each(obj, function(key,value) {
						$('#basic_salary').val(value.fixed_pay);
						$('#net_sal').val(value.net_pay);
						$('#net_sal_hid').val(value.net_pay);
						$('#gross_sal').val(value.gross_salary);
						// $('#allow_tot').val(value.gross_salary);

						
					  if(value.all_ded_prefix=='A'){
					  	$('#allowPerc_'+i).val(value.percentage);
					  	$('#allow_'+i).val(value.percentage_value);
					  	i++;
					  }else if(value.all_ded_prefix=='D'){
					  	total_deduction += parseFloat(value.percentage_value);
					  	$('#detection_class_perc_'+j).val(value.percentage);
					  	$('#detection_class_value_'+j).val(value.percentage_value);
					  	j++;
					  }
					  $('#deduct_tot').val(total_deduction);
					  $('#deduct_tot_hid').val(total_deduction);
					});
				}
						calculateGrossSal();

					}
					});
}

					}


function calculateGrossSal(){
	var fixedPay = $('#basic_salary').val();
	var grossal = $('#gross_sal').val();

	// var netsal = $('#net_sal').val();
	var todeduc = $('#deduct_tot').val();

	if(fixedPay=='' || isNaN(fixedPay)){fixedPay=0;}
	if(grossal=='' || isNaN(grossal)){grossal=0;}
	
	if(todeduc=='' || isNaN(todeduc)){todeduc=0;}

	// var sum = parseFloat(fixedPay)+parseFloat(toda);
	// $('#allow_tot').val(sum);


		var allow_tot = parseFloat(grossal)*12;
	$('#allow_tot_yearly').val(allow_tot);

var ctc_tot = parseFloat(grossal)+parseFloat(todeduc);
var allw_tot = parseFloat(grossal)-parseFloat(fixedPay);

	$('#monthelyctc1').val(ctc_tot);

	var ctc_yearly =  parseFloat(ctc_tot)*12;

	$('#yearlyctc1').val(ctc_yearly);
	$('#allowance_tot').val(allw_tot);
}




	function cal_esi(str1)
{
	var gross_sal = str1;
	if(gross_sal>=0 && gross_sal<=15000)
	{
		var net_esi = ((4.75*(str1))/100);
		document.getElementById("esimployervalue").value=Math.round(net_esi);
		document.getElementById("ESIemployer").value="4.75";
		document.getElementById("esimployervalue").removeAttribute("readonly"); 
		document.getElementById("ESIemployer").removeAttribute("readonly"); 		
	}
	else
	{
		document.getElementById("esimployervalue").value="0";
		document.getElementById("ESIemployer").value="0";
		document.getElementById("esimployervalue").setAttribute("readonly",true);
		document.getElementById("ESIemployer").setAttribute("readonly",true);
	}
}
function calculate_esi(esi_percentage)
{
	var gross_sal = document.getElementById("allow_tot").value;
	var net_esi = ((esi_percentage*gross_sal)/100);
	document.getElementById("esimployervalue").value=Math.round(net_esi);	
}

function cal_dedvalue(str,j)
{
	
 a=document.getElementById("empdedtype_"+j).value;
 
 var basic=document.getElementById("basic_salary").value;
 var grosssal=document.getElementById("allow_tot").value;
 
 	var basic=document.getElementById("gross").value;
	var totvalue=basic*((str)/100);
	document.getElementById("deduction_"+j).value=Math.round(totvalue);

cal_dedtot();
}

</script>


