<?php $PageSecurity = 3;
ini_set('session.bug_compat_42', 0);
$table_name='empmaster';
$table_name1='empmaster_revised_sal';

  global $db; 
  //include ('includes/session.inc');

include('config.php');
include('includes/ConnectDB.inc');
include('includes/function_lib.php');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
include('includes/fun-php.php');
include('includes/fun-HRClass.php');

  //include ('includes/function_lib.php');
  
  
  /**********************  Getting Records From Emp Tables ************************************************/
              
			   $check=DB_query("select * from empmaster_revised_sal where empid='".$_GET['q']."'",$db);
			   $numrow1=DB_num_rows($check);
			   if($numrow1<=0)
			   {
			    $condition="id='".$_GET['q']."'";
				$result=$s->GetRecordById($table_name,  $condition);
				$get_row1=DB_fetch_array($result);
				$empcode=$get_row1['emp_code'];
				$empdept=$get_row1['department'];
				$empdeg=$get_row1['designation'];
				$employment_type=$get_row1['employment_type'];
				
				$basic_perc=$get_row1['basic_perc'];
				$basic_salary=$get_row1['basic_salary'];
				$allow_tot=$get_row1['allow_tot'];
				$deduct_tot=$get_row1['deduct_tot'];
				$gross_sal=$get_row1['gross_sal'];
				$gross=$get_row1['gross'];
				$net_sal=$get_row1['net_sal'];
				 $table2='emp_salary';
			   
			   }
			   else
			   {
			     $condition="empid='".$_GET['q']."' and log_type='revise'  order by id DESC limit 0,1 ";
				$result=$s->GetRecordById($table_name1,  $condition);
				$get_row1=DB_fetch_array($result);
				$empcode=$s->getField('empmaster','id',$_GET['q'],'emp_code');
				$dept=$s->getField('empmaster','id',$_GET['q'],'department');
				$desi=$s->getField('empmaster','id',$_GET['q'],'designation');
				$desi1=$s->getField('empmaster','id',$_GET['q'],'employment_type');
				$basic=$s->getField('empmaster','id',$_GET['q'],'basic_perc');
				$id1=$get_row1['id'];
				$empdept=$dept;
				$empdeg=$desi;
				$employment_type=$desi1;
				
				$basic_perc=$basic;
				$basic_salary=$get_row1['basic_salary'];
				$allow_tot=$get_row1['allow_tot'];
				$deduct_tot=$get_row1['deduct_tot'];
				$gross_sal=$get_row1['gross_sal'];
				$gross=$get_row1['gross_sal'];
				$net_sal=$get_row1['net_sal'];
			   $table2='emp_salary_revise';
			   }
			    
               if($numrow1>0)
			   {
				$get_sql3=DB_query("Select * from $table2 where emp_id='".$_GET['q']."' and all_ded_prefix='A' 
				and mst_revid='".$id1."'",$db);
				$k=1;
				while($get_row3=DB_fetch_array($get_sql3))
				{
					$aperc[$k]=$get_row3['percentage'];  
					$allow[$k]=$get_row3['percentage_value'];
					$k++;
				}
				
				$get_sql4=DB_query("Select * from $table2 where emp_id='".$_GET['q']."' and all_ded_prefix='D'
				and mst_revid='".$id1."'",$db);
				$K=1;
				while($get_row4=DB_fetch_array($get_sql4))
				{
					$dperc[$K]=$get_row4['percentage'];  
					$deduction[$K]=$get_row4['percentage_value'];
					$K++;
				}
				$get_sql10=DB_query("Select * from $table2 where emp_id='".$_REQUEST['q']."'
				 and all_ded_prefix='A' and allowance_deduction=100 and mst_revid='".$id1."'",$db);
				$get_row10=DB_fetch_array($get_sql10);
				$spc_allow=$get_row10['percentage'];  
				$special_allow=$get_row10['percentage_value'];
				
				
				
				
				$get_LTA=DB_query("Select * from $table2 where emp_id='".$_REQUEST['q']."' 
				and all_ded_prefix='A' and allowance_deduction=101 and mst_revid='".$id1."'",$db);
				$get_LTAVAl=DB_fetch_array($get_LTA);
				$LTA_allow_Per=$get_LTAVAl['percentage'];  
				$LTA_allow_Val=$get_LTAVAl['percentage_value'];
				
				
				
				$get_LWF=DB_query("Select * from $table2 where emp_id='".$_REQUEST['q']."' 
				and all_ded_prefix='A' and allowance_deduction=102 and mst_revid='".$id1."'",$db);
				$get_LWFVAl=DB_fetch_array($get_LWF);
				$LWF_allow_Per=$get_LWFVAl['percentage'];  
				$LWF_allow_Val=$get_LWFVAl['percentage_value'];
				$get_LWF=DB_query("Select * from $table2 where emp_id='".$_REQUEST['q']."'
				 and all_ded_prefix='A' and allowance_deduction=103 and mst_revid='".$id1."'",$db);
				$get_LWFVAl=DB_fetch_array($get_LWF);
				$esi_per=$get_LWFVAl['percentage'];  
				$esi_value=$get_LWFVAl['percentage_value'];
	
                }
				else
				{
				$get_sql3=DB_query("Select * from $table2 where emp_id='".$_GET['q']."' and all_ded_prefix='A'",$db);
				$k=1;
				while($get_row3=DB_fetch_array($get_sql3))
				{
					$aperc[$k]=$get_row3['percentage'];  
					$allow[$k]=$get_row3['percentage_value'];
					$k++;
				}
				
				$get_sql4=DB_query("Select * from $table2 where emp_id='".$_GET['q']."' and all_ded_prefix='D'",$db);
				$K=1;
				while($get_row4=DB_fetch_array($get_sql4))
				{
					$dperc[$K]=$get_row4['percentage'];  
					$deduction[$K]=$get_row4['percentage_value'];
					$K++;
				}
				$get_sql10=DB_query("Select * from $table2 where emp_id='".$_REQUEST['q']."'
				 and all_ded_prefix='A' and allowance_deduction=100",$db);
				$get_row10=DB_fetch_array($get_sql10);
				$spc_allow=$get_row10['percentage'];  
				$special_allow=$get_row10['percentage_value'];
				
				
				
				
				$get_LTA=DB_query("Select * from $table2 where emp_id='".$_REQUEST['q']."' 
				and all_ded_prefix='A' and allowance_deduction=101",$db);
				$get_LTAVAl=DB_fetch_array($get_LTA);
				$LTA_allow_Per=$get_LTAVAl['percentage'];  
				$LTA_allow_Val=$get_LTAVAl['percentage_value'];
				
				
				
				$get_LWF=DB_query("Select * from $table2 where emp_id='".$_REQUEST['q']."' 
				and all_ded_prefix='A' and allowance_deduction=102",$db);
				$get_LWFVAl=DB_fetch_array($get_LWF);
				$LWF_allow_Per=$get_LWFVAl['percentage'];  
				$LWF_allow_Val=$get_LWFVAl['percentage_value'];
				$get_LWF=DB_query("Select * from $table2 where emp_id='".$_REQUEST['q']."'
				 and all_ded_prefix='A' and allowance_deduction=103",$db);
				$get_LWFVAl=DB_fetch_array($get_LWF);
				$esi_per=$get_LWFVAl['percentage'];  
				$esi_value=$get_LWFVAl['percentage_value'];
				}  
	
 ?>
<fieldset class="fieldset_normal"><legend><strong>Salary Details</strong></legend>
 <table width="100%" border="0" cellpadding="0" cellspacing="0">
 <tr>
   <td width="13%" class="tabledata">Emp Code</td>
    <td width="20%"><input type="text" style="width:100%;" value="<?php echo $empcode;?>" /></td>
    <td width="13%" align="right" class="tabledata">Department :</td>
    <td width="20%"><input type="text" style="width:100%;" value="<?php echo $s->GetFieldValue('deptmaster','id="'.$empdept.'"','deptname');?>" /></td>
    <td width="13%" align="right" class="tabledata">Designation :</td>
    <td><input type="text" value="<?php echo  $s->GetFieldValue('desigmaster','id="'.$empdeg.'"','designame');?>" /></td>
    
  </tr>
 <tr>
   <td class="tabledata">Emp Type</td>
   <td><input type="text" style="width:100%;" value="<?php echo $employment_type;?>" /></td>
   <td class="tabledata">&nbsp;</td>
   <td class="tabledata">&nbsp;</td>
   <td class="tabledata">&nbsp;</td>
   <td class="tabledata">&nbsp;</td>
   <td class="tabledata">&nbsp;</td>
   <td class="tabledata">&nbsp;</td>
 </tr>
  </table>
</fieldset>
 <table width="100%" border="0" cellpadding="0" cellspacing="0">
 <tr>
 <td> 
<fieldset class="fieldset_normal"><legend><strong>Old salary</strong></legend>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
	  <td class="tabledata" style="text-align:center;"><strong>Monthly Revise CTC<font color="#FF0000" size="-1">*</font></strong>
	    <input name="gross" type="text" id="gross" value="<?php if(isset($gross))echo $gross; else echo $_REQUEST['gross'];?>" style="width:150px;"></td>
	  <td class="tabledata" style="text-align:center;"><span class="tabledata" style="text-align:center;"><strong>Monthly CTC<font color="#FF0000" size="-1">*</font></strong>
	      <input name="gross2" type="text" id="gross2" value="<?php if(isset($gross))echo $gross; else echo $_REQUEST['gross'];?>" style="width:150px;" readonly="true" />
	  </span></td>
</tr>
  <tr>
    <td valign="top">
	<table width="100%" border="0" cellpadding="3" cellspacing="0">
      <tr>
        <td class="tabledata" colspan="4"><div align="center"><strong>Allowances Part</strong><strong>(A) </strong></div><input type="hidden" name="prefix1" id="prefix1" value="A" /></th>      </tr>
      <tr>
        <td width="33%" class="tabledata"><strong>DESCRIPTION</strong></th>
        <td width="33%" class="tabledata"><strong>%</strong></th>
        <td width="17%" class="tabledata"><strong>Revise VALUE</strong></th>      
        <td width="17%" class="tabledata"><strong>Current        </strong>      </tr>
	  <tr>
	  <td class="tabledata"><strong>BASIC</strong></th>
	  <td><input type="text" name="basic_perc" id="basic_perc" value="<?php echo $basic_perc;?>" size="5" tabindex="47"/></td>
	  <td><input type="text" name="basic_salary" id="basic_salary" value="<?php echo trim($basic_salary);?>" size="10"  class="number" onfocus="calculate_basic()"/></td>
	  <td><input type="text" name="basic_salary2" id="basic_salary2" value="<?php echo trim($basic_salary);?>" size="10"  class="number" /></td>
	  </tr>
	 
      <?php
	  $all_sql=DB_query("Select * from allowmaster",$db); 
	 $i=1;
	  while($all_row=DB_fetch_array($all_sql))
	  {
	  ?>
	  <tr>
        <td class="tabledata"><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'];?>" />
		  </th>
<td><input name="aperc[<?php echo $i;?>]" type="text" id="aperc_<?php echo $i;?>" value="<?php echo $aperc[$i];?>" size="5" tabindex="48+<?php echo (2*$i);?>" onkeyup="cal_allvalue(this.value,<?php echo $i;?>)"  onblur="cal_allvalue(this.value,<?php echo $i;?>);" /></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="48+<?php echo $i;?>"  /></td>
		<td><input name="allow2[<?php echo $i;?>]2" type="text" id="allow2[<?php echo $i;?>]" value="<?php echo $allow[$i];?>" size="10" class="number" tabindex="48+<?php echo $i;?>"></td>
		<!--onkeyup="reversecal_allvalue(this.value,<?php //echo $i; ?>)"-->
      </tr>
	  <?php $i++;} ?>
	  <input type="hidden" name="ctr" id="ctr" value="<?php echo $i;?>" />
	
	 <tr>
	 <td class="tabledata"><strong>Special Allowance</strong></th>
	 <td><input name="spc_allow" type="text" id="spc_allow" value="<?php echo $spc_allow; ?>" size="5"  tabindex="48+<?php echo (2*$i);?>" /></td>
	  <td><input type="text" name="special_allow" id="special_allow" value="<?php echo $special_allow; ?>" size="10"  class="number" tabindex="48+<?php echo $i;?>"/></td>
	  <td><input type="text" name="special_allow2" id="special_allow2" value="<?php echo $special_allow; ?>" size="10"  class="number" tabindex="48+<?php echo $i;?>"/></td>
	 </tr>
	   <tr>
	 <td class="tabledata"><strong>Gross Salary  </strong></th>
	 <td><input name="allow_tot" type="text" id="allow_tot" value="<?php echo $allow_tot;?>" size="15" onfocus="cal_alltot();cal_esi(this.value);data_str(this.value);" readonly="true" tabindex="53"/></td>
	 <td colspan="2"><input name="allow_tot2" type="text" id="allow_tot2" value="<?php echo $allow_tot;?>" size="15"  readonly="true" tabindex="53"/></td>
	 </tr>
	<tr>
		 <td class="tabledata" colspan="4"><div align="center"><strong>Allowances Part</strong><strong>(B) </strong></div></td>
		 </tr>
		 <tr>
		 	<td><strong>LTA</strong></td>
			<td><input type="text" name="ltaper" id="ltaper" onblur="calltaAll(this.value)" size="5" value="<?php echo $LTA_allow_Per; ?>" /></td>
			<td><input type="text" name="lta" id="lta" size="10" value="<?php echo $LTA_allow_Val; ?>" /></td>
		    <td><input type="text" name="lta2" id="lta2" size="10" value="<?php echo $LTA_allow_Val; ?>" /></td>
		 </tr>
		 <tr>
		 	<td><strong>LWF</strong></td>
			<td><input type="text" name="LWFper" id="LWFper" onblur="calLWFAll(this.value)" size="5" value="<?php echo $LWF_allow_Per; ?>" /></td>
			<td><input type="text" name="LWF" id="LWF" size="10" value="<?php echo $LWF_allow_Val; ?>" onfocus="calagainspecial()" /></td>
	        <td><input type="text" name="LWF2" id="LWF2" size="10" value="<?php echo $LWF_allow_Val; ?>" onfocus="calagainspecial()" /></td>
		 </tr>
	<tr>
		 	<td class="tabledata"><strong>ESI(Employer).</strong></td>
			<td><input type="text" name="ESI_employer" id="ESIemployer" style="width:50px;" value="<?php echo $esi_per; ?>" onkeyup="calculate_esi(this.value);"
			  onblur="calculate_esi(this.value);" readonly=""/></td>
			<td><input type="text" name="ESI_employer_value" id="esimployervalue" size="10" value="<?php echo $esi_value; ?>" /></td>
		    <td><input type="text" name="ESI_employer_value2" id="ESI_employer_value" size="10" value="<?php echo $esi_value; ?>" /></td>
	</tr>
	  <tr>
		 	<td class="tabledata"><strong>Monthly CTC</strong></td>
			<td><input type="text" name="monthelyctc1" id="monthelyctc1" onfocus="calmothellysal()" size="15" value="<?php echo $gross; ?>" /></td>
		    <td colspan="2"><input type="text" name="monthelyctc12" id="monthelyctc12" size="15" value="<?php echo $gross; ?>" /></td>
		    </tr>
    </table></td>
    <td valign="top"><table width="100%" border="0" cellpadding="3" cellspacing="0">
      <tr>
        <td class="tabledata" colspan="4"><strong>DEDUCTION(D)</strong><input type="hidden" name="prefix2" id="prefix2" value="D" /></th>      </tr>
      <tr>
        <td class="tabledata"><strong>DESCRIPTION</strong></th>
        <td class="tabledata"><strong>%</strong></th>
        <td class="tabledata"><strong>Revise VALUE</strong></th>
        <td class="tabledata"><strong>Current        </strong>      </tr>
     <?php
	  $ded_sql=DB_query("Select * from deduction_master",$db); 
	 $j=1;
	  while($ded_row=DB_fetch_array($ded_sql))
	  {
	  
	  ?>
<tr>
        <td class="tabledata"><strong><?php echo $ded_row['name'];?>
		<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'];?>" />	  
		  </th>
<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="54+<?php echo (2*$j);?>"  /></td>
        <td><input name="deduction[<?php echo $j;?>]" type="text" id="deduction_<?php echo $j;?>" value="<?php echo $deduction[$j];?>" size="10" class="number" tabindex="54+<?php echo $j;?>" readonly="true" /></td>
        <td><input name="deduction2[<?php echo $j;?>]" type="text" id="deduction2[<?php echo $j;?>]" value="<?php echo $deduction[$j];?>" size="10" class="number" tabindex="54+<?php echo $j;?>" readonly="true" /></td>
</tr>
	  <?php $j++;} ?>
	  <input type="hidden" name="dctr" id="dctr" value="<?php echo $j;?>" />
	  <tr>
	 <td class="tabledata"><strong>TOTAL DEDUCTION </strong></th>
	 <td><input name="deduct_tot" type="text" id="deduct_tot" value="<?php echo $deduct_tot;?>" size="15" onfocus="cal_dedtot()" readonly="true" tabindex="56"/></td>
	 <td colspan="2"><input name="deduct_tot2" type="text" id="deduct_tot2" value="<?php echo $deduct_tot;?>" size="15" onfocus="cal_dedtot()" readonly="true" tabindex="56"/></td>
	 </tr>
    </table>	</td>
  </tr>
  
  
  
  
  <tr>
		<td colspan="2">
		<table width="100%" border="0" cellpadding="3" cellspacing="0" align="left">
		<tr>
		<td class="tabledata"><strong>Salary Effective From </strong></th>
		<td colspan="2"><input name="eff_sal_date" type="text" onClick="javascript:NewCal(this.id,'ddmmyyyy')" id="eff_sal_date" value="<?php if(isset($eff_sal_date)){echo $eff_sal_date;}else echo date('d/m/Y');?>" style="width:150px;" /></td>
		<td class="tabledata"><strong>Gross Salary<font color="#FF0000" size="-1">*</font></strong></th>
		<td><input name="gross_sal" type="text" id="gross_sal" value="<?php echo $gross_sal;?>"  style="width:150px;" onfocus="cal_gross()" readonly="true"/></td>
		<td><input name="gross_sal2" type="text" id="gross_sal2" value="<?php echo $gross_sal;?>"  style="width:150px;" onfocus="cal_gross()" readonly="true"/></td>
		</tr>
		<tr>
		<td class="tabledata"><strong>Net Salary (Gross-D) </strong></th>
		<td><input name="net_sal" type="text" id="net_sal" value="<?php echo $net_sal;?>"  style="width:150px;" onfocus="cal_net()" readonly="true"/></td>
		<td><input name="net_sal2" type="text" id="net_sal2" value="<?php echo $net_sal;?>"  style="width:150px;" onfocus="cal_net()" readonly="true"/></td>
		</tr>
		</table>		</td>
	  </tr>
</table>
</fieldset>		  
 </td>
    
  </tr>
</table>




<div style="clear:both; margin:0px;"></div>
</div><!-- Table close 2 -->

<!-- Table close 3 --><div>
<br />

<fieldset class="fieldset_normal">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr><td width="17%" nowrap="nowrap" class="tabledata">Applicable From Month</td>
	<td width="6%">
	<select name="applicable_month"  style="width:100%">
          <?php
 $arr=array(01=>"Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec");
 foreach ($arr as $key => $value) {
 	$p='';
 	if( $key==$_REQUEST['applicable_month'])
	$p='selected';
   ?>
          <option value="<?php echo $key;?>" <?php echo $p;?> ><?php echo $value;?></option>
          <?php } ?>
        </select>	</td>
	
	 
	<td>
	 
		<select name="applicable_year"  style="width:100%">
          <?php
 
 for($i=date('Y');$i>2000;$i--)
 {
 	$p='';
 	if( $i==$_REQUEST['applicable_year'])
	$p='selected';
 ?>
          <option value="<?php echo $i;?>" <?php echo $p;?>><?php echo $i;?></option>
          <?php 
 }
 ?>
        </select>	</td>
    <td nowrap="nowrap" class="tabledata">Increment Type</td>
	<td><select style="width:auto;" name="increment_type">
		<option value="Annual">Annual</option>
		<option value="Promotional">Promotional</option>
		<option value="Other">Other</option>
			</select>
	</td>
	</tr>
</table>
</fieldset>
</div><!-- Table close 3 -->

<p align="center">
 	<input type="submit" value="Save"  name="Save" class="search"/>&nbsp;&nbsp;	<input type="button" value="Cancel"  class="search" />
 </p>


<script>


</script>


 