<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.creation {display:none;}
</style>

<link rel="stylesheet" href="css/w3.css">
<link rel="stylesheet" href="css/new_mxerp.css">
</head>

<?php 
$PageSecurity = 2;
$title = _('Employee Master') ;
include('includes/SQL_CommonFunctions.inc');
include('includes/othrs.php');
date_default_timezone_set('Asia/calcutta');
$today=date('d/m/Y');

if($_REQUEST['Update']!='')
{
	$EmpCode=$s->GetFieldValue('empmaster',"id='".$_REQUEST['id']."'",'emp_code');
	function extension($filename)
	{
	$name_brk=explode('.',$filename);
	return  $name_brk[1];
	}
	
	if(!empty($_FILES['docmnt']['name']) && $_FILES['docmnt']['name'][0]!='')
	{
	$flag=0;
	$qty=$_FILES['docmnt']['name'];
	if($_REQUEST['docmnt1']!=''){
	$TAS=explode(",",$_REQUEST['docmnt1']);
	$new_name1=$TAS;
	}	
	
	//print_r($new_name1);
	
	for($i=0;$i<count($qty);$i++)
	{ 
	$name=$_FILES['docmnt']['name'][$i];
	$type=extension($name);	


	/*if($type!='pdf' && $type!='doc' && $type!='txt' && $type!='docx' && $type!='rtf' && $type!='jpg' && $type!='jpeg' && $type!='JPEG' && $type!='JPG' && $type!='png' && $type!='gif' && $type!='gif')
	{
	echo "<strong>Invalid Extension! Kindly please check the image before uploading</strong>";
	$flag=1;
	}
	else
	{
	$tmp_name=$_FILES['docmnt']['tmp_name'][$i];
	//echo $tmp_name;
	
	//echo $_FILES['photo']['size'];
	$new_name1[]=$EmpCode.'_'.$name;
	$new_name2[]=$EmpCode.'_'.$name;
	 $path="uploaded_docs/".$new_name2[$i];
	
	$file_copy=copy($tmp_name,$path);
	if(!$file_copy)
	{
	echo "<strong>Copy Unsuccessful</strong>";
	$flag=1;
	}
	}    */
    
    $tmp_name=$_FILES['docmnt']['tmp_name'][$i];
	//echo $tmp_name;
	
	//echo $_FILES['photo']['size'];
	//$new_name1[]=$EmpCode.'_'.$name;
	$new_name1[]=$name;
   // $new_name2[]=$EmpCode.'_'.$name;
	$new_name2[]=$name;
	$path="uploaded_docs/".$new_name2[$i];
	//$file_copy=move_uploaded_file($tmp_name,$path);
	$file_copy=copy($tmp_name,$path);
	if(!$file_copy)
	{
	echo "<strong>Copy Unsuccessful</strong>";
	$flag=1;
	}

	}
	//print_r($new_name1);
	//exit;
	if(!empty($new_name1))
	{
	$new_name=implode(",",$new_name1);
	}
	
	if(!empty($new_name))
	{
	$doc_sql="Update empmaster SET document='".$new_name."' where id='".$_REQUEST['id']."'";
	$doc_res=DB_query($doc_sql,$db);
	}
	}
	
	$name=$_FILES['photo']['name'];
	$type=extension($name);
	if($type!='')
	{


		/*if($type!='jpg' && $type!='jpeg' && $type!='JPEG' && $type!='JPG' && $type!='png' && $type!='gif' && $type!='gif')
		{
		echo "<strong>Invalid Extension! Kindly please check the image before uploading</strong>";
		$flag=1;
		}
		else
		{
		$tmp_name=$_FILES['photo']['tmp_name'];
		
		$new_name2=$_FILES['photo']['name'];
		$path="uploaded_images/".$new_name2;
		$file_copy=move_uploaded_file($tmp_name,$path);
		if(!$file_copy)
		{
		echo "<strong>Copy Unsuccessful</strong>";
		$flag=1;
		}
		} */
        $tmp_name=$_FILES['photo']['tmp_name'];
		
		$new_name2=$_FILES['photo']['name'];
		$path="uploaded_images/".$new_name2;
		$file_copy=move_uploaded_file($tmp_name,$path);
		if(!$file_copy)
		{
		echo "<strong>Copy Unsuccessful</strong>";
		$flag=1;
		}

	}
	
	if($name==''){
	$newname4=$_REQUEST['image_name'];
	}else{
	$newname4=$new_name2;
	}
	
	
	if($_REQUEST['emp_name_old']==$_REQUEST['emp_name'])
	{
		$FinempCode=$_REQUEST['emp_code'];
	}
	else
	{
		/*$EmpName=$_REQUEST['emp_name'];
		$FirstChar=substr($EmpName,0,1);
		$FirstChar1=strtoupper($FirstChar);
		$maxempcode=DB_query("SELECT MAX(emp_code) AS EMPCD FROM empmaster WHERE emp_code LIKE '$FirstChar1%'",$db);
		$MaxCodeEmp=DB_fetch_array($maxempcode);
		if($MaxCodeEmp['EMPCD']!='')
		{
			$numericval=substr($MaxCodeEmp['EMPCD'],1);
			$nextdigit=$numericval+1;
			$FinempCode=$FirstChar1.str_pad($nextdigit,4,"0",STR_PAD_LEFT);
		}
		else
		{
			$FinempCode=$FirstChar1.'0001';
		}*/

		$FinempCode=$_REQUEST['emp_code'];
	}	
	
	$data['emp_site']=$_REQUEST['emp_site'];
	$data['employment_type']=$_REQUEST['employment_type'];  
	$data['employee_type']=$_REQUEST['emp_shift'];
	$data['emp_code']=$FinempCode;
	$data['bloodgroup']=$_REQUEST['bloodgroup'];
	$data['emp_name']=$_REQUEST['emp_name'];
	$data['fh_name']=$_REQUEST['fh_name'];		 
	$data['nationality']=$_REQUEST['nationality'];
	$data['religion']=$_REQUEST['religion'];
	$data['dob']=FormatDateForSQL($_REQUEST['dob']);
	$data['doj']=FormatDateForSQL($_REQUEST['doj']);
	$data['dol']=FormatDateForSQL($_REQUEST['dol']);			
	$data['department']=$_REQUEST['department'];
	$data['emp_weekly_off']=$_REQUEST['emp_weekly_off'];
	if(count($_REQUEST['emp_weekly_off'])>1)
	$weekly_off=implode(",",$_REQUEST['emp_weekly_off']);
	else
	$weekly_off=$_REQUEST['emp_weekly_off'][0];	
	$data['emp_weekly_off']=$weekly_off;
	$data['designation']=$_REQUEST['designation'];
	$data['marital_status']=$_REQUEST['marital_status'];
	$data['marriage']=FormatDateForSQL($_REQUEST['marriage']);
	$data['wh_name']=$_REQUEST['wh_name'];
	$data['sons']=$_REQUEST['sons'];
	$data['daughters']=$_REQUEST['daughters'];
	$data['sex']=$_REQUEST['sex'];
	$data['grade']=$_REQUEST['grade'];
	$data['personalEmail']=$_REQUEST['personalEmail']; 
	$data['offEmail']=$_REQUEST['offEmail'];
	$data['PFno']=$_REQUEST['PFno'];
	$data['ESIno']=$_REQUEST['ESIno'];
	$data['bank_name']=$_REQUEST['bank_name'];
	$data['bank_account']=$_REQUEST['bank_account'];
	$data['payment_mode']=$_POST['payment_mode'];   
	$data['leave_eff_date']=FormatDateForSQL($_REQUEST['leave_eff_date']);
	$data['bachelor']=$_REQUEST['bachelor'];
	$data['course3']=$_POST['course3']; 
	$data['course1']=$_POST['course1'];
	$data['course2']=$_POST['course2'];
	$data['tenth_standard']=$_REQUEST['tenth_standard'];
	$data['tenthplus2_standard']=$_REQUEST['tenthplus2_standard'];
	$data['master']=$_REQUEST['pgcourse'];
	$data['other_master']=$_POST['othercourse'];	
	$data['bac_college_name']=$_REQUEST['bac_college_name'];
	$data['bac_year_passing']=$_REQUEST['bac_year_passing'];
	$data['pg_college_name']=$_REQUEST['pg_college_name'];
	$data['pg_year_passing']=$_REQUEST['pg_year_passing'];
    $data['other_college_name']=$_REQUEST['other_college_name'];
	$data['other_year_passing']=$_REQUEST['other_year_passing'];
	$data['basic_perc']=$_POST['basic_perc'];
	$data['basic_salary']=$_REQUEST['basic_salary'];
	$data['allow_tot']=$_REQUEST['allow_tot'];
	$data['deduct_tot']=$_REQUEST['deduct_tot'];
	$data['gross']=$_REQUEST['gross'];
	$data['gross_sal']=$_REQUEST['gross_sal'];
	$data['net_sal']=$_REQUEST['net_sal'];
	$data['eff_sal_date']=FormatDateForSQL($_REQUEST['eff_sal_date']);
	$data['pf_calculation']=$_REQUEST['pf_calculation'];
	$data['adv_amount']=$_REQUEST['adv_amount'];
	$data['adv_date']=FormatDateForSQL($_REQUEST['adv_date']);
	$data['over_time']=$_REQUEST['over_time']; 
	$data['pan_no']=$_REQUEST['pan_no'];
	//$data['uan_no']=$_REQUEST['uan_no'];
	$data['pf_type']=$_REQUEST['pftype'];
	$data['uid_type']=$_REQUEST['uid_type'];
	$data['uid_no']=$_REQUEST['uid_no'];
    $data['emp_shift']=$_REQUEST['emp_shift'];
	if($_REQUEST['otapplicable']!='')
	$otapplicable='Y';
	else
	$otapplicable='N';
	$data['otapplicable']=$otapplicable;
	$data['ottype']=$_REQUEST['ottype'];
	$data['overtime_salary']=$_REQUEST['overtime_salary'];
	$data['image']=$newname4;
	$data['pending_wo']=$_REQUEST['weekly_off'];
	$data['multi_site_att']=$_REQUEST['multi_site_att'];
	$data['loan_ledger']=$_REQUEST['loan_mapping'];
	$data['advance_ledger']=$_REQUEST['advance_mapping'];
	$data['yearly_ctc']    =$_REQUEST['yearlyctc'];
	$data['monthly_ctc']   =$_REQUEST['monthelyctc'];
	$data['incometax']=$_REQUEST['incometax'];
	$data['emp_shift']=$_REQUEST['emp_shift'];
	if($_REQUEST['govt'])
	$govtnom='Y';
	else
	$govtnom='N';
	$data['govt_nom_pf']=$govtnom;
	$Condi="id='".$_REQUEST['id']."'";
	//echo "<pre>";
	//print_r($data);
	//exit;
	$s->RecordEdit('empmaster',$data,$Condi);	
	
		   $dataArr['per_address1']=$_REQUEST['per_address1'];
			$dataArr['per_address2']=$_REQUEST['per_address2'];
			$dataArr['per_address3']=$_REQUEST['per_address3'];
			if($_REQUEST['per_country']!=''){
			$dataArr['per_country']=$_REQUEST['per_country'];}
			if($_REQUEST['per_state']!=''){
			$dataArr['per_state']=$_REQUEST['per_state'];}
			$dataArr['per_city']=$_REQUEST['per_city'];
			$dataArr['per_pincode']=$_REQUEST['per_pincode'];
			$dataArr['per_mobile']=$_REQUEST['per_mobile'];
			$dataArr['per_phone']=$_REQUEST['per_phone'];
			$dataArr['per_alt_phone']=$_REQUEST['per_alt_phone'];
			$dataArr['per_alt_mobile']=$_REQUEST['per_alt_mobile'];
			$dataArr['pre_address1']=$_REQUEST['pre_address1'];
			$dataArr['pre_address2']=$_REQUEST['pre_address2'];
			$dataArr['pre_address3']=$_REQUEST['pre_address3'];
			if($_REQUEST['pre_country']!=''){
		    $dataArr['pre_country']=$_REQUEST['pre_country'];}
		    if($_REQUEST['pre_state']!=''){
		    $dataArr['pre_state']=$_REQUEST['pre_state'];} 
			$dataArr['pre_city']=$_REQUEST['pre_city'];
			$dataArr['pre_pincode']=$_REQUEST['pre_pincode'];
			$dataArr['pre_mobile']=$_REQUEST['pre_mobile'];
			$dataArr['pre_phone']=$_REQUEST['pre_phone'];
			$dataArr['pre_alt_phone']=$_REQUEST['pre_alt_phone'];
			$dataArr['pre_alt_mobile']=$_REQUEST['pre_alt_mobile'];
	        $check=DB_query("select id from employee_address where emp_id='".$_REQUEST['id']."'",$db);
		  if(DB_num_rows($check)<=0)
		  {
            $dataArr['emp_id']=$_REQUEST['id'];           
	        $s->RecordInsert('employee_address',$dataArr);	

		  }
		  else
		  {
           $Condi1="emp_id='".$_REQUEST['id']."'";           
	       $s->RecordEdit('employee_address',$dataArr,$Condi1);	  
		  }	
	
	$dataWeof['pending_wo']=$_REQUEST['weekly_off'];
	$Cond2="emp_id='".$_REQUEST['row_id']."'";
	$s->RecordEdit('weekly_off_emp',$dataWeof,$Cond2);	
	
	
	//exit;
	
	
	
	
	


	





  

 
//************************DEDUCTION PART*************AS*************START HERE************12-06-2013*****************	
	
	

//************************DEDUCTION PART*************AS*************END HERE************12-06-2013*****************
	
	
	//exit;
	$s->pageLocation("index.php?route=HRModule/Master/labour_list".$rurl);
}

if($_REQUEST['id']!='' && $_REQUEST['action']=='edit')
{	
	$get_sql1=DB_query("Select * from empmaster where id='".$_REQUEST['id']."' ",$db);
	$get_row1=DB_fetch_array($get_sql1);
	 
	$get_sql2=DB_query("Select * from employee_address where emp_id='".$_REQUEST['id']."' ",$db);
	$get_row2=DB_fetch_array($get_sql2);	
	
	$get_sql3=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='A'
	and allowance_deduction not in('100','101','102','103','104','105','106','107','108','109','110','111') order by allowance_deduction ASC",$db);
	$k=1;
	while($get_row3=DB_fetch_array($get_sql3))
	{
		$aperc[$get_row3['allowance_deduction']]=$get_row3['percentage'];  
		$allow[$get_row3['allowance_deduction']]=$get_row3['percentage_value'];
		$k++;
	}	
	
	$get_sql10=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' 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 emp_salary where emp_id='".$_REQUEST['id']."' 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'];	
	$LTA_allow_Val_non=$get_LTAVAl['non_taxable_amt'];
	
	$get_LWF=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='A' 
		and allowance_deduction=102",$db);
	$get_LWFVAl=DB_fetch_array($get_LWF);
	$medicalper=$get_LWFVAl['percentage'];  
	$medicalamount=$get_LWFVAl['percentage_value'];
	$medicalamount_non=$get_LWFVAl['non_taxable_amt'];
	
	$get_LWF2=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='A' and allowance_deduction=105",$db);
	$get_LWFVAl2=DB_fetch_array($get_LWF2);
	$mediclaim_per=$get_LWFVAl2['percentage'];  
	$mediclaim_amt=$get_LWFVAl2['percentage_value'];
	$mediclaim_amt_non=$get_LWFVAl2['non_taxable_amt'];
	
	$get_LWF2=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='A' 
		and allowance_deduction=104",$db);
	$get_LWFVAl2=DB_fetch_array($get_LWF2);
	$supperannuation_per=$get_LWFVAl2['percentage'];  
	$supperannuation_amt=$get_LWFVAl2['percentage_value'];
	$supperannuation_nontaxableamt=$get_LWFVAl2['non_taxable_amt'];

	$get_LWF2=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='A'
	 and allowance_deduction=106",$db);
	$get_LWFVAl2=DB_fetch_array($get_LWF2);
	$gratuity_per=$get_LWFVAl2['percentage'];  
	$gratuity_amt=$get_LWFVAl2['percentage_value'];
	$gratuity_nontaxableamt=$get_LWFVAl2['non_taxable_amt'];


	//echo "Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='A' and allowance_deduction=103";
	$get_LWF=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' 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'];

	$get_LWF1=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='A' and allowance_deduction=107",$db);
	$get_LWFVAl1=DB_fetch_array($get_LWF1);
	$pf_ac1=$get_LWFVAl1['percentage'];  
	$pf_ac1_amt=$get_LWFVAl1['percentage_value'];

	$get_LWF2=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='A' and allowance_deduction=108",$db);
	$get_LWFVAl2=DB_fetch_array($get_LWF2);
	$pf_ac10_per=$get_LWFVAl2['percentage'];  
	$pf_ac10_amt=$get_LWFVAl2['percentage_value'];

	$get_LWF3=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='A' and allowance_deduction=109",$db);
	$get_LWFVAl3=DB_fetch_array($get_LWF3);
	$pf_ac2_per=$get_LWFVAl3['percentage'];  
	$pf_ac2_amt=$get_LWFVAl3['percentage_value'];

	$get_LWF4=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='A' and allowance_deduction=110",$db);
	$get_LWFVAl4=DB_fetch_array($get_LWF4);
	$pf_ac21_per=$get_LWFVAl4['percentage'];  
	$pf_ac21_amt=$get_LWFVAl4['percentage_value'];

   $get_LWF4=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='A' and allowance_deduction=111",$db);
	$get_LWFVAl4=DB_fetch_array($get_LWF4);
	$pf_ac22_per=$get_LWFVAl4['percentage'];  
	$pf_ac22_per=$get_LWFVAl4['percentage_value'];

	
	$get_sql4=DB_query("Select * from emp_salary where emp_id='".$_REQUEST['id']."' and all_ded_prefix='D' order by id ASC",$db);
	$K=1;
	while($get_row4=DB_fetch_array($get_sql4))
	{
		$dperc[$K]=$get_row4['percentage'];  
		$deduction[$K]=$get_row4['percentage_value'];
		$K++;
	}	


 	$emp_site=$get_row1['emp_site'];

 	$uploadimage=$get_row1['image'];
 
	$emp_code=$get_row1['emp_code'];
    $emp_name=$get_row1['emp_name'];
    $fh_name=$get_row1['fh_name'];
	$nationality=$get_row1['nationality'];
	$religion=$get_row1['religion'];
	$emp_shift=$get_row1['emp_shift'];
	$bloodgroup=$get_row1['bloodgroup'];
    $dob=ConvertSQLDate($get_row1['dob']);
    $doj=ConvertSQLDate($get_row1['doj']);
    $dol=ConvertSQLDate($get_row1['dol']);
    $department=$get_row1['department'];
    $designation=$get_row1['designation'];
    $marital_status=$get_row1['marital_status'];
    $uid_type=$get_row1['uid_type'];
    $uid_no=$get_row1['uid_no'];
	$marriage=ConvertSQLDate($get_row1['marriage']);
	$wh_name=$get_row1['wh_name'];
	$sons=$get_row1['sons'];
	$daughters=$get_row1['daughters'];
    $sex=$get_row1['sex'];
    $grade=$get_row1['grade'];
	$personalEmail=$get_row1['personalEmail'];
	$offEmail=$get_row1['offEmail'];
	$PFno=$get_row1['PFno'];
	$ESIno=$get_row1['ESIno'];
	$bank_name=$get_row1['bank_name'];
	$bank_account=$get_row1['bank_account'];
	$payment_mode=$get_row1['payment_mode'];
    $leave_eff_date=ConvertSQLDate($get_row1['leave_eff_date']);
	$bachelor=$get_row1['bachelor'];
	$course1=$get_row1['course1'];
	$course2=$get_row1['course2'];
    $tenthplus2_standard=$get_row1['tenthplus2_standard'];
	$tenth_standard=$get_row1['tenth_standard']; 
	$master=$get_row1['master'];
	$course3=$get_row1['course3'];
	$other_master=$get_row1['other_master'];
	$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'];
	$eff_sal_date=ConvertSQLDate($get_row1['eff_sal_date']);
	$pf_calculation=$get_row1['pf_calculation'];
	$adv_amount=$get_row1['adv_amount'];
	$adv_date=ConvertSQLDate($get_row1['adv_date']);
 	$new_name=$get_row1['image']; 
	$document=$get_row1['document'];
	$over_time=$get_row1['over_time'];
	$overtime_salary=$get_row1['overtime_salary'];
	$employment_type=$get_row1['employment_type'];
 	$emp_shift=$get_row1['employee_type'];
	$emp_weekly_off=$get_row1['emp_weekly_off'];
	$per_address1=$get_row2['per_address1'];
    $per_address2=$get_row2['per_address2'];
    $per_address3=$get_row2['per_address3'];
    $per_country=$get_row2['per_country'];
    $per_state=$get_row2['per_state'];
    $per_city=$get_row2['per_city'];
    $per_pincode=$get_row2['per_pincode'];
    $per_mobile=$get_row2['per_mobile'];
    $per_phone=$get_row2['per_phone'];
    $per_alt_phone=$get_row2['per_alt_phone'];
	$per_alt_mobile=$get_row2['per_alt_mobile'];
    $pre_address1=$get_row2['pre_address1'];
    $pre_address2=$get_row2['pre_address2'];
    $pre_address3=$get_row2['pre_address3'];
    $pre_country=$get_row2['pre_country'];
    $pre_state=$get_row2['pre_state'];
    $pre_city=$get_row2['pre_city'];
    $pre_pincode=$get_row2['pre_pincode'];
    $pre_mobile=$get_row2['pre_mobile'];
    $pre_phone=$get_row2['pre_phone'];
    $pre_alt_phone=$get_row2['pre_alt_phone'];
	$pre_alt_mobile=$get_row2['pre_alt_mobile'];
	$pending_wo=$get_row1['pending_wo'];
	$multi_site_att=$get_row1['multi_site_att'];
	$otapplicable=$get_row1['otapplicable'];
	$loan_ledger=$get_row1['loan_ledger'];
	$adv_ledger=$get_row1['advance_ledger'];
	$incometax=$get_row1['incometax'];
	$ottype=$get_row1['ottype'];
	if($get_row1['govt_nom_pf']=='Y')
	$checked1="checked";
	else
	$checked1='';
    $monthly_ctc=$get_row1['monthly_ctc'];
    $yearly_ctc=$get_row1['yearly_ctc'];
     $pftype=$get_row1['pf_type'];
     $uan_no=$get_row1['uan_no'];
	
    $get_sql4=DB_query("Select * from emp_leave where emp_id='".$_REQUEST['id']."' ",$db);
	$j=0;
	while($get_row4=DB_fetch_array($get_sql4))
	{
		$id[$j]=$get_row4['id'];
		$leave_type[$j]=$get_row4['leave_type'];
    	$leave_days[$j]=$get_row4['leave_days'];
		$j++;
	}
}

?>
<!--<script language="javascript" type="text/javascript" src="datetimepicker.js"></script>-->

<link rel="stylesheet" href="css/new_mxerp.css">
<link rel="stylesheet" href="js/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- <link rel="stylesheet" href="js/jquery-ui.css">-->
<!--<script src="js/jquery-1.10.2.js"></script>
<script src="js/jquery-ui.js"></script> -->

 <script>
var jss=$.noConflict();

jss(function() {
jss( "#dob" ).datepicker({ dateFormat: 'dd/mm/yy',changeMonth: true,
            changeYear: true,
    yearRange: "1910:2055" });
jss( "#doj" ).datepicker({ dateFormat: 'dd/mm/yy',changeMonth: true,
            changeYear: true,
    yearRange: "1910:2055" });
jss( "#dol" ).datepicker({ dateFormat: 'dd/mm/yy',changeMonth: true,
            changeYear: true,
    yearRange: "1910:2055" });
jss( "#marriage" ).datepicker({ dateFormat: 'dd/mm/yy',changeMonth: true,
            changeYear: true,
    yearRange: "1910:2055" });

jss( "#leave_eff_date" ).datepicker({ dateFormat: 'dd/mm/yy',changeMonth: true,
            changeYear: true,
    yearRange: "1910:2055" });



});




</script>
<!--<script type="text/javascript" src="js/function-ajax.js"></script> -->
<script src="empcal.js" language="javascript"></script>

<script>
//function cal_esi(str)
//{
//	var gross_sal = str;
//	if(gross_sal == 'NaN')
//	{
//	}
//	else
//	{
//		var net_esi = ((4.75*(str))/100);
//		document.getElementById("esimployervalue").value=net_esi;		
//	}
//}


	
	function chkbachlor(id){
 			if(id!='')
			{			document.getElementById("other_bachelor").value='';		
			} 
		
	}
	function chkmaster(id){
 			if(id!='')
			{			document.getElementById("other_master").value='';		
			} 
		
	}
	function chkother_master(id){
		  
		if(id!='')
		{
			document.getElementById("masterMA").checked=false
			document.getElementById("masterMSC").checked=false
			document.getElementById("masterMCOM").checked=false
			document.getElementById("masterMBA").checked=false
			document.getElementById("masterME").checked=false
			 
		}else{
			document.getElementById("masterMA").checked=true
			document.getElementById("masterMSC").checked=true
			document.getElementById("masterMCOM").checked=true
			document.getElementById("masterMBA").checked=true
			document.getElementById("masterME").checked=true			 
		}
	}
	function chkother_bachelor(id){
		  
		if(id!='')
		{
			document.getElementById("bachelorBA").checked=false
			document.getElementById("bachelorBSC").checked=false
			document.getElementById("bachelorBCOM").checked=false
			document.getElementById("bachelorBBA").checked=false
			document.getElementById("bachelorLLB").checked=false
			document.getElementById("bachelorBE").checked=false
			 //document.getElementById("other_bachelor").value=id;
		}else{
			document.getElementById("bachelorBA").checked=true
			document.getElementById("bachelorBSC").checked=true
			document.getElementById("bachelorBCOM").checked=true
			document.getElementById("bachelorBBA").checked=true
			document.getElementById("bachelorLLB").checked=true
			document.getElementById("bachelorBE").checked=true			 
		}
	}
			
</script>

<style type="text/css">

.tab a{
color: #fff;
text-decoration: none;
font-weight: bold; display: block;
background-color:#676767;
padding:5px 10px;
border:#373737 solid 1px; border-top-left-radius: 5px;
    border-top-right-radius: 5px;	
}
.tab a:hover{
color: #171717;
text-decoration: none;
background-color:#fff;
}

#wrapper{
width:100%;
margin:auto;
padding:0 10px;
box-sizing:border-box;
}
.box{
background: #fff;

}
.boxholder{
clear: both;
padding:0px;
padding-bottom:15px;

}
.tab{
float: left;
height: auto;
width: auto;
margin: 0 1px 1px 0;
text-align: center;
/*background: #8DC70A url(images/greentab.jpg) no-repeat;*/
}
.tabtxt{
margin: 0;
color: #fff;
font-size: 12px;
font-weight: bold;
padding: 0px 0 0 0;
}

/****************** Start page styles ********************************************/

#wrap {
	max-width: 600px;
	margin: 30px auto;
	background: #fff;
	border: 4px solid #FFD16F;
	-moz-border-radius: 15px;
	-webkit-border-radius: 15px;
	border-radius: 15px;
	padding: 20px;
    }

.field { 
	padding: 0 0 1em;
	width:160px;
	}
.current{color:#FF0000;}

/****************** End page styles ********************************************/
</style>
<link type="text/css" media="screen" rel="stylesheet" href="css/file-upload.css">
<!--<script type="text/javascript" src="js/prototype.lite.js"></script>
<script type="text/javascript" src="js/moo.fx.js"></script>
<script type="text/javascript" src="js/moo.fx.pack.js"></script>
<script type="text/javascript" src="js/min.js"></script>
<script type="text/javascript" src="js/file-upload.js"></script> -->
<script type="text/javascript">
function init(){
	var stretchers = document.getElementsByClassName('box');
	var toggles = document.getElementsByClassName('tab');
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: false, height: true, duration: 600}
	);
	//hash functions
	var found = false;
	toggles.each(function(h4, i){
		var div = Element.find(h4, 'nextSibling');
			if (window.location.href.indexOf(h4.title) > 0) {
				myAccordion.showThisHideOpen(div);
				found = true;
			}
		});
		if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}
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);	
}
</script>

<script language="javascript" type="text/javascript">
//*****************FUNCTION FOR ALLOWNCES**********************************************************************

//function cal_allvalue(j)
//{
//	var basic=document.getElementById("basic_salary").value;
//	var allwper=document.getElementById("aperc_"+j).value;
//	if(basic==''){basic=0;}
//	if(allwper==''){allwper=0;}
//	if(allwper!='' || allwper!='0.00')
//	{
//		var totvalue=basic*((allwper)/100);
//		document.getElementById("allow_"+j).value=totvalue;
//	}
//	else
//	{
//		var allwval=document.getElementById("allow_"+j).value;
//		if(allwval=='')
//		{
//			document.getElementById("allow_"+j).value='0';
//		}
//	}
//}

function reversecal_allvalue(str,j)
{ 
	var basic=document.getElementById("basic_salary").value;
	var totvalue=(100*str)/basic;
	document.getElementById("aperc_"+j).value=Math.round(totvalue);
}

//*****************FUNCTION FOR ALLOWNCES**********************************************************************

//*****************FUNCTION FOR DEDUCTIONS**********************************************************************

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();
}

//*****************FUNCTION FOR DEDUCTIONS**********************************************************************


function check_yn(str)
{
	if(str=='NO')
	{
		document.getElementById("adv_amount").disabled=true;
		document.getElementById("adv_date").disabled=true;
	}
	else
	{
		document.getElementById("adv_amount").disabled=false;
		document.getElementById("adv_date").disabled=false;
	}
}
function check_marriage(str)
{
    if(str=='Single')
   {
		document.getElementById("sons").disabled=true;
		document.getElementById("daughters").disabled=true;
   }
   else
   { 
   		document.getElementById("sons").disabled=false;
		document.getElementById("daughters").disabled=false;
   }
   
}
function addressInfo(){

	if(document.getElementById("copy_add").checked==true)
	{
		document.getElementById('per_add1').value = document.getElementById('pre_add1').value;
		document.getElementById('per_add2').value = document.getElementById('pre_add2').value;
		document.getElementById('per_add3').value = document.getElementById('pre_add3').value;
		document.getElementById('per_city').value = document.getElementById('pre_city').value;
		document.getElementById('per_state').value = document.getElementById('pre_state').value;
		document.getElementById('per_country').value = document.getElementById('pre_country').value;
		document.getElementById('per_pincode').value = document.getElementById('pre_pincode').value;
		document.getElementById('per_mobile').value = document.getElementById('pre_mobile').value;
		document.getElementById('per_phone').value = document.getElementById('pre_phone').value;
		document.getElementById('per_alt_phone').value = document.getElementById('pre_alt_phone').value;
		document.getElementById('per_alt_mobile').value = document.getElementById('pre_alt_mobile').value;
		
	}else{
		document.getElementById('per_add1').value = '';
		document.getElementById('per_add2').value = '';
		document.getElementById('per_add3').value = '';
		document.getElementById('per_city').value = '';
		document.getElementById('per_state').value = '';
		document.getElementById('per_country').value = '';
		document.getElementById('per_pincode').value = '';
		document.getElementById('per_mobile').value = '';
		document.getElementById('per_phone').value = '';
		document.getElementById('per_alt_phone').value = '';
	}
}


function find_state(str)
{
	if(str.length==0)
	{
	document.getElementById("state_id").innerHTML="";
	return;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if (xmlhttp.readyState==4 && xmlhttp.status==200)
	{
	document.getElementById("state_id").innerHTML=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET","emp_state.php?country="+str,true);
	xmlhttp.send();
}

function find_city(str)
{
	var cntry=document.getElementById("pre_country").value;
	if (str.length==0)
	{
	document.getElementById("city_id").innerHTML="";
	return;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if (xmlhttp.readyState==4 && xmlhttp.status==200)
	{
	document.getElementById("city_id").innerHTML=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET","emp_city.php?state="+str+"&country="+cntry,true);
	xmlhttp.send();
}

function calLWFAll(val)
{
	if(val!='')
	{
	var Basic_SAL=document.getElementById("basic_salary").value;
	var ltaamt=(Basic_SAL*val)/100;
	document.getElementById("LWF").value=Math.round(ltaamt);
	}
	else
	{
		document.getElementById("LWF").value='0';
	}
}

function cal_pf_Reimbursement(str)
{
	var basic=document.getElementById("basic_salary").value;
	//var basic_perc=document.getElementById("basic_perc").value;
	
	var totalbasic=basic*((str)/100);
	document.getElementById("pf_Reimbursement").value=totalbasic.toFixed(2);
	
}
function cal_medical_Reimbursement(str)
{
	var basic=document.getElementById("basic_salary").value;
	//var basic_perc=document.getElementById("basic_perc").value;
	
	var totalbasic=basic*((str)/100);
	document.getElementById("medical_Reimbursement").value=totalbasic.toFixed(2);	
}

function displaySalary(str)
{
	if(str=='Yes')
	{
		document.getElementById('overtime_salary').disabled=false;
	}
	else if(str=='No')
	{
		document.getElementById('overtime_salary').disabled=true;
	}
	
}
function checkMode(str)
{
	if(str=='Cash')
	{
		document.getElementById("bank_name").disabled=true;
		document.getElementById("bank_account").disabled=true;
	}
	else if(str=='Cheque')
	{
		document.getElementById("bank_name").disabled=false;
		document.getElementById("bank_account").disabled=false;
	}
}

function MekeEmpCode(str)
{
	if(str.length=0)
	{
		document.getElementById("emp_name").innerHTML="";
	}
	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
 	}
	else
  	{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange=function()
  	{
  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("hid-EmployeeID").innerHTML=xmlhttp.responseText;
    }
  	}
	var branch=document.getElementById("emp_site").value;
	xmlhttp.open("GET","MakeEmpCode.php?EMPName="+str+"&branch="+branch,true);
	xmlhttp.send();
}

function GetSatateCountry(str)
{
	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
 	}
	else
  	{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange=function()
  	{
  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		var data=xmlhttp.responseText.split("__");
    	document.getElementById("pre_state").value=data[0];
		document.getElementById("pre_country").value=data[1];
		document.getElementById("pre_state1").value=data[2];
		document.getElementById("pre_country1").value=data[3];
    }
  	}
	xmlhttp.open("GET","SateCountryName.php?CityId="+str,true);
	xmlhttp.send();
}

function GetSatateCountry1(str)
{
	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
 	}
	else
  	{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange=function()
  	{
  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		var data=xmlhttp.responseText.split("__");
    	document.getElementById("per_state").value=data[0];
		document.getElementById("per_country").value=data[1];
		document.getElementById("per_state1").value=data[2];
		document.getElementById("per_country1").value=data[3];
    }
  	}
	xmlhttp.open("GET","SateCountryName.php?CityId="+str,true);
	xmlhttp.send();
}
</script>


<style>
.cap{text-transform:capitalize;}
</style>

<script>
function tabFun(evt, creationName) {
  var i, x, tablinks;
  x = document.getElementsByClassName("creation");
  for (i = 0; i < x.length; i++) {
      x[i].style.display = "none";
  }
  tablinks = document.getElementsByClassName("tablink");
  for (i = 0; i < x.length; i++) {
      tablinks[i].className = tablinks[i].className.replace(" w3-red", "");
  }
  document.getElementById(creationName).style.display = "block";
  evt.currentTarget.className += " w3-red";
}
</script>

<body >
<div class="w3-container"> 

<div class="body_contain"> 
<div class="tab_div"> 
<h1>Labor Master</h1>





<form method="post" name="empmasterfrm1" action="" enctype="multipart/form-data">


  
  <ul class="w3-navbar w3-black">
  <li class="box"><a href="#" class="tablink w3-red" onClick="tabFun(event, 'Amount');"><strong>Labor Details</strong></a></li>
  <li class="box"><a href="#" class="tablink" onClick="tabFun(event, 'Commerce');"><strong>Address Details</strong></a></li>
  <li class="box"><a href="#" class="tablink" onClick="tabFun(event, 'General');"><strong>Uploads</strong></a></li>
</ul>

			<!--Employee Detail box-->
	<div id="Amount" class="w3-container w3-border creation " style="display:block;">
<h3>Labor Details</h3>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr class="row1">
	<td width="80%" valign="top">
    <table width="100%" border="0" cellpadding="3" cellspacing="0" align="center">
	    <tr class="row1">
			<td width="13%"><strong>Employment Type </strong></td>
			<td width="20%"><select name="employment_type" id="employment_type" style="width:98%;">
			<option value="Worker"<?php echo($hr_job_created_id=='w'?'selected':'')?>>Worker</option>
		   </select>
			</td>
		    <td width="13%"><strong>Labor Code</strong></td>
		    <td width="20%">
			    <div id="hid-EmployeeID">
			    <input type="text" name="emp_code" id="emp_code" value="<?php if($_REQUEST['action']=='edit'){ echo $emp_code;}else{echo 'Generated';}?>" style="width:98%;" readonly/></div></td>
			<td width="13%"><strong>Labor Name</strong></td>
			<td><input type="text" name="emp_name" id="emp_name" class="cap" style="width:98%;" value="<?php echo $emp_name;?>"/>
			    <input type="hidden" name="emp_name_old" id="emp_name_old" class="cap" style="width:150px;" value="<?php echo $emp_name;?>"/>
			</td>
	    </tr>
		<tr class="row1">
		    <td><strong>Nationality <font color="#FF0000" size="-1">*</font></strong></td>
		    <td><input type="text" name="nationality" id="nationality" value="<?php echo $nationality;?>" style="width:98%;" /></td>
			<td><strong>Religion</strong></td>
			<td><input type="text" name="religion" id="religion" value="<?php echo $religion;?>" style="width:98%;" /></td>	
			<td><strong>Date of Birth <font color="#FF0000" size="-1">*</font></strong></td>
			<td>
	
			<input name="dob" type="text" id="dob" style="width:98%;" class="datepicker"  value="<?php if(isset($dob)){echo $dob;} else {echo date('d/m/Y');}?>" readonly onChange="checkDob()">
			<!-- onClick="javascript:NewCal(this.id,'ddmmyyyy')" -->
			</td>	
	</tr>
	<tr class="row1">
		<td><strong>Gender</strong></td>
		<td>
		  <input type="radio" name="sex" id="sex" <?php echo ($sex=='M'?'checked':'');?> value="M" />Male
		  <input type="radio" name="sex" id="sex1" <?php echo ($sex=='F'?'checked':'');?> value="F" />Female
		</td>
		<td><strong>Blood Group</strong></td>
		<td><select name="bloodgroup" id="bloodgroup" style="width:98%;">
			<option value="A-"<?php if($bloodgroup=='A-'){ echo 'selected';} ?>>A-</option>
			<option value="A+" <?php if($bloodgroup=='A+'){ echo 'selected';} ?>>A+</option>
			<option value="B-" <?php if($bloodgroup=='B-'){ echo 'selected';} ?>>B-</option>
			<option value="B+" <?php if($bloodgroup=='B+'){ echo 'selected';} ?>>B+</option>
			<option value="AB-" <?php if($bloodgroup=='AB-'){ echo 'selected';} ?>>AB-</option>
			<option value="AB+" <?php if($bloodgroup=='AB+'){ echo 'selected';} ?>>AB+</option>
			<option value="O-" <?php if($bloodgroup=='O-'){ echo 'selected';} ?>>O-</option>
			<option value="O+" <?php if($bloodgroup=='O+'){ echo 'selected';} ?>>O+</option>
		</select>
		
		<td><strong>Date of joining</strong></td>
		<td><input name="doj" type="text" id="doj" style="width:98%;" class="datepicker" value="<?php if(isset($doj)){echo $doj;} else {echo date('d/m/Y');}?>" readonly onChange="checkDoj()">
			<!-- onClick="javascript:NewCal(this.id,'ddmmyyyy')" -->
		</td>
	</tr>	
	<tr class="row1">
	    <td><strong>Marital Status</strong></td>
	    <td><select name="marital_status" id="marital_status" onChange="check_marriage(this.value)" style="width:98%;">
				<option value="000">---Select---</option>
				<option value="Single"<?php echo ($marital_status=='Single'?'selected':'');?>>Single</option>
				<option value="Married"<?php echo ($marital_status=='Married'?'selected':'');?>>Married</option>
			</select></td>
	<?php 
	if($marital_status=='Single')
	{
		$r="disabled";
	}
	else{$r='';}
	?>
		<td><strong>UID Type <font color="#FF0000" size="-1">*</font></strong></td>
	  <td><select name="uid_type" id="uid_type" style="width:98%;">
		<option value="000">---Select---</option>
		<option value="Driving License"<?php echo ($uid_type=='Driving License'?'selected':'');?>>Driving License</option>
		<option value="Pan Card"<?php echo ($uid_type=='Pan Card'?'selected':'');?>>Pan Card</option>
		<option value="Govt. issued ID"<?php echo ($uid_type=='Govt. issued ID'?'selected':'');?>>Govt. issued ID</option>
		<option value="Adhaar Card"<?php echo ($uid_type=='Adhaar Card'?'selected':'');?>>Adhaar Card</option>
	  </select></td>
	  <td><strong>UID Number <font color="#FF0000" size="-1">*</font></strong></td>
	  <td><input type="text" name="uid_no" id="uid_no" placeholder="UID Number" value="<?php echo $uid_no;?>" onkeyup="check_uidno(this.value)"/></td>
	</tr>
	<tr class="row1">
	    <td><strong>Number of Children</strong></td>
	    <td><input type="text" name="sons" id="sons" placeholder="Sons" style="width:48%; float:left; margin-right:3px;" value="<?php if($sons=='0'){echo "Sons - N/A";}else echo $sons;?>" <?php echo $r;?> />
		  <input type="text" name="daughters" id="daughters" placeholder="Daughters" style="width:48%; float:left;" value="<?php if($daughters=='0'){echo "Daughters - N/A";}else echo $daughters;?>" <?php echo $r;?> /></td>
		<td><strong>Father's Name <font color="#FF0000" size="-1">*</font></strong></td>
		<td><input type="text" name="fh_name" id="fh_name" value="<?php echo $fh_name;?>" style="width:98%;" /></td>
		<td><strong>Date of leaving</strong></td>
		<td><input name="dol" id="dol" type="text" style="width:98%;" class="datepicker" value="<?php if(isset($dol)){echo $dol;} else {echo "";}?>" readonly onChange="checkDol()"></td>
	</tr>
	  <tr class="row1">
	  <td><strong>Project Name <font color="#FF0000" size="-1">*</font></strong></td>
	  <td><select name="emp_site" id="emp_site" style="width:98%;" onChange="ShowDiv(this.value,'hid-staffdiv','Empshift.php');">
	  <option value="000">---Select---</option>
	  <?php 
		$site_sql=DB_query("Select id,project_name from manufacturing_advice",$db);
		while($site_row=DB_fetch_array($site_sql))
		{
		?>
	   <option value="<?php echo $site_row['id'];?>"<?php echo ($emp_site==$site_row['id']?'selected':'')?>><?php echo $site_row['project_name'];?></option>
			<?php } ?>
		  </select></td>
		<td><strong>Group</strong></td>	
		<td><select name="department" id="department" style="width:98%;" onChange="get_position(this.value,this.id)">
		<option value="000">---Select---</option>
		<?php $qdepart=DB_query("select id, deptcode,deptname from deptmaster WHERE employment_type='Worker' order by deptname ASC",$db); 
				while($rsdepart=DB_fetch_array($qdepart)){
		 ?>
		<option value="<?php echo $rsdepart['id'];?>"<?php echo($department==$rsdepart['id']?'selected':'')?>><?php echo $rsdepart['deptname'];?></option>
		<?php }?>
		</select></td>
		<td><strong>Assign Position <font color="#FF0000" size="-1">*</font></strong></td>
		<td><div id='hid-desig'><select name="designation" id="designation" style="width:98%;"> 
		<option value="000">---Select---</option>
		<?php $qdesig=DB_query("select id ,desigcode,designame from desigmaster WHERE employment_type='Worker' AND mst_departmentid='".$department."' order by designame ASC",$db);
			while ($rsdesig=DB_fetch_array($qdesig)){
		?>
		<option value="<?php echo $rsdesig['id'];?>" <?php echo ($designation==$rsdesig['id']?'selected':'')?>><?php echo $rsdesig['designame'];?></option>
		<?php }?>
		</select></div></td>
	</tr>		
	<tr class="row1">
	    <td><strong>PF Type</strong></td>
		<td><select name="pftype" id="pftype" style="width:98%;">
        <option value="">select</option>
        <option value="Existing Member with Pension Contribution on higher wages" <?php if($pftype=='Existing Member with Pension Contribution on higher wages') { ?> selected <?php } ?>>E : Existing Member with Pension Contribution on higher wages.</option>
        <option value="Q" <?php if($pftype=='Existing member whose Pension Contribution is restricted to wage ceiling') { ?> selected <?php } ?>>R : Existing member whose Pension Contribution is restricted to wage ceiling.</option>
        <option value="New Member with zero Pension Contribution" <?php if($pftype=='New Member with zero Pension Contribution') { ?> selected <?php } ?>>Z : New Member with zero Pension Contribution.</option>
     </select>
		</td>
		<td><strong>Labor Type</strong></td>
		<td><select name="grade" id="grade" style="width:98%;">
			  <?php $grade_sql=DB_query("Select * from emp_grade WHERE employment_type='Worker'",$db);
		while($grade_result=DB_fetch_array($grade_sql))
		{
		?>
			<option value="<?php echo $grade_result['id'];?>"<?php echo ($grade==$grade_result['id']?'selected':'');?>><?php echo $grade_result['grade_name'];?></option>
			  <?php } ?>
		  </select>
		</td>
		<td><strong>Labor Shift</strong></td>
		<td><div id='hid-staffdiv'>
		<select name="emp_shift" id="emp_shift" style="width:98%;">	 
		<?php 
		if($emp_site!='')
		$emp_shift_sql=DB_query("Select * from shift_master",$db);
		while($emp_shift_row=DB_fetch_array($emp_shift_sql))
		{	 
		?>
		<option value="<?php echo $emp_shift_row['id'];?>"<?php echo ($emp_shift==$emp_shift_row['id']?'selected':'')?>>
		<?php echo $emp_shift_row['shift_for'].'('.$emp_shift_row['shift_category'].')-'.$emp_shift_row['shift_start'].$emp_shift_row['start_AMPM'].' to '.$emp_shift_row['shift_end'].$emp_shift_row['end_AMPM']; ?></option>
		<?php } ?>
		</select></div>
		</td>
	</tr>
	
	<tr class="row1">
	
	</tr>	
	</table>
	</td>
	<td valign="top" width="10%">
		<table width="100%" border="0" align="left" cellpadding="3" cellspacing="0">
			<tr>
			<td style="text-align:center;">
			<?php if($new_name==''){ 
			if($sex=='M'){?>
			<img src="uploaded_images/default.png" width="auto" height="140" id="image1" />
			<?php }else{?>
			<img src="uploaded_images/default-girl.png" width="auto" height="140" id="image1" />
			<?php }?>
			<?php }else{?>
			<img src="uploaded_images/<?php echo $new_name; ?>" width="auto" height="140" id="image1" />
			
			<?php } ?>
			</td>
			</tr>
			<tr>
			<td style="text-align:center;">
			<div class="field">
			<label class="file-upload">
				<span><strong>Upload Image</strong></span>
				<input type="file" style="width:98%;" name="photo" id="photo" onChange="imageURL(this,'image1')" />
			</label>
		</div>
			<input type="hidden" name="image_name" value="<?php echo $uploadimage;?>" /></td>
			</tr>
	</table>
	</td>
</tr>
</table>
</div>
<!--end of Employee Detail box-->

			<!--Address box-->
<div id="Commerce" class="w3-container w3-border creation ">
 <h3>Address Details</h3>
	<table width="100%" border="0" cellpadding="3" cellspacing="0">
	<tr>
		<td width="50%" valign="top">
		 <h3><strong>Present Address</strong></h3>
			<table width="100%" border="0" cellpadding="3" cellspacing="0">
				<tr class="row1">
					  <td width="20%" rowspan="3"><strong>Address <font color="#FF0000" size="-1">*</font></strong></td>
					  <td><input name="pre_address1" type="text" id="pre_add1" value="<?php echo $pre_address1;?>" style="width:98%;"/></td>
				</tr>
				<tr class="row1">
					<td><input name="pre_address2" type="text" id="pre_add2" value="<?php echo $pre_address2;?>" style="width:98%;" /></td>
				</tr>
				<tr class="row1">
					<td><input name="pre_address3" type="text" id="pre_add3" value="<?php echo $pre_address3;?>" style="width:98%;" /></td>
				</tr>
				<tr class="row1">
					<td><strong>City <font color="#FF0000" size="-1">*</font></strong></td>
					 <td>
						<select name="pre_city" id="pre_city" style="width:98%;" onChange="GetSatateCountry(this.value)">
						  <option value="">Select</option>
						  <?php 
						  $city_sql=DB_query("select * from city_master order by city ASC",$db);
						  while($city_row=DB_fetch_array($city_sql)) {?>
						  <option value="<?php echo $city_row['id'];?>"<?php echo ($pre_city==$city_row['id']?'selected':'');?>><?php echo $city_row['city'];?></option>
						  <?php } ?>
						</select>
					 </td>
				</tr>
				<tr class="row1">
					<td><strong>State <font color="#FF0000" size="-1">*</font></strong></td>
					<td><input type="hidden" name="pre_state" id="pre_state" value="<?php $pre_state;?>" style="width:98%;" />
					<input type="text" name="pre_state1" id="pre_state1" value="<?php echo $s->GetFieldValue('state_master',"id='".$pre_state."'",'state'); ?>" style="width:98%;" readonly/>
					</td>
				</tr>
				<tr class="row1">
					<td><strong>Country <font color="#FF0000" size="-1">*</font></strong></td>
					<td><input type="hidden" name="pre_country" id="pre_country" value="<?php $pre_country;?>" style="width:98%;" />
					 <input type="text" name="pre_country1" id="pre_country1" value="<?php echo $s->GetFieldValue('country_master',"id='".$pre_country."'",'country'); ?>" style="width:98%;" readonly/>
					</td>
				</tr>
				<tr class="row1">
					<td><strong>Pin Code <font color="#FF0000" size="-1">*</font></strong></td>
					<td><input name="pre_pincode" type="text" id="pre_pincode" value="<?php echo $pre_pincode; ?>" style="width:98%;" maxlength="6" onBlur="checkPincode(this.value,this.id)" autocomplete="off"/></td>
				</tr>
				<tr class="row1">
					<td><strong>Mobile <font color="#FF0000" size="-1">*</font></strong></td>
					<td><input name="pre_mobile" type="text" id="pre_mobile" value="<?php echo $pre_mobile; ?>" style="width:98%;" maxlength="10" onBlur="checkMobile(this.value,this.id)" autocomplete="off"/></td>
				</tr>
				<tr class="row1">
					 <td><strong>Phone </strong></td>
					<td><input name="pre_phone" type="text" id="pre_phone" value="<?php echo $pre_phone; ?>" style="width:98%;" maxlength="10" onBlur="checknumeric(this.value,this.id)" autocomplete="off"/></td>
				</tr>
			</table>	
		</td>
		<td valign="top">
		<h3><strong><input type="checkbox" name="copy_add" id="copy_add" onClick="addressInfo();" /> Check Permanent Address if same as Present Address </strong></strong></h3>
			<table width="100%" border="0" cellpadding="3" cellspacing="0">
				<tr class="row1">
					  <td width="20%" rowspan="3"><strong>Address</strong></td>
					  <td><input name="per_address1" type="text" id="per_add1" value="<?php echo $per_address1;?>" style="width:98%;" /></td>
				</tr>
				<tr class="row1">
					<td><input name="per_address2" type="text" id="per_add2" value="<?php echo $per_address2;?>" style="width:98%;" /></td>
				</tr>
				<tr class="row1">
					<td><input name="per_address3" type="text" id="per_add3" value="<?php echo $per_address3;?>" style="width:98%;" /></td>
				</tr>
				<tr class="row1">
					<td><strong>City</strong></td>
					  <td>
						<select name="per_city" id="per_city" style="width:98%;" onChange="GetSatateCountry1(this.value)">
						  <option value="">Select</option>
						  <?php 
						  $city_sql=DB_query("select * from city_master order by city ASC",$db);
						  while($city_row=DB_fetch_array($city_sql)) { ?>
						  <option value="<?php echo $city_row['id'];?>"<?php echo ($per_city==$city_row['id']?'selected':'');?>><?php echo $city_row['city'];?></option>
						  <?php } ?>
						</select>
					 </td>
				</tr>
				<tr class="row1">
					<td><strong>State</strong></td>
					<td><input type="hidden" name="per_state" id="per_state" value="<?php echo $per_state; ?>" style="width:150px;" />
					<input type="text" name="per_state1" id="per_state1" value="<?php echo $s->GetFieldValue('state_master',"id='".$per_state."'",'state'); ?>" style="width:98%;" /></td>
				</tr>
				<tr class="row1">
					<td><strong>Country</strong></td>
					 <td><input type="hidden" name="per_country" id="per_country" value="<?php echo $per_country; ?>" style="width:150px;" />
					 <input type="text" name="per_country1" id="per_country1" value="<?php echo $s->GetFieldValue('country_master',"id='".$per_country."'",'country'); ?>" style="width:98%;" /></td>
				</tr>
				<tr class="row1">
					<td><strong>Pin Code</strong></td>
					<td><input name="per_pincode" type="text" id="per_pincode" value="<?php echo $per_pincode; ?>" style="width:98%;" onBlur="checkPincode(this.value,this.id)" maxlength="6" autocomplete="off"/></td>
				</tr>
				<tr class="row1">
					<td><strong>Mobile</strong></td>
					<td><input name="per_mobile" type="text" id="per_mobile" value="<?php echo $per_mobile; ?>" style="width:98%;" maxlength="10" onBlur="checkMobile(this.value,this.id)" autocomplete="off"/></td>
				</tr>
				<tr class="row1">
					 <td><strong>Phone</strong></td>
					<td><input name="per_phone" type="text" id="per_phone" value="<?php echo $per_phone; ?>" style="width:98%;" maxlength="10" onBlur="checknumeric(this.value,this.id)" autocomplete="off"/></td>
				</tr>
			</table>
		</td>
	</tr>
	</table>
</div>
			<!--end of Address box-->


			

			<!--Uploads box-->
<div id="General" class="w3-container w3-border creation ">
<h3>Uploads</h3>
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr class="row1">
	<td colspan="3">
	<input type="button" onClick="addRow('dataTable')" class="search" value="Add More" />
	<input type="button" onClick="deleteRow('dataTable')" class="search" value="Delete Row" />
	</td>
</tr>
<tbody id="dataTable">
<tr class="row1">
	<td width="5%"><input type="checkbox" name="chk" /></td>	
	<td width="10%"><strong>Upload Document</strong></td>
	<td><input type="file" name="docmnt[]" id="docmnt" value="" style="width:98%;" />
	</td>
</tr>
</tbody>
<input type="hidden" id="hiditemcount" />
<input type="hidden" name="docmnt1" id="docmnt1" value="<?php echo $document;?>" />
<?php 
if($document!=''){
$img_url = explode(",",$document);
for($im=0;$im<count($img_url);$im++){
$Type=explode(".",$img_url[$im]);

if($Type[1]=='doc')
{
	$DocImg='uploaded_docs/Default-wordpad.jpg';
}
if($Type[1]=='pdf')
{
	$DocImg='uploaded_docs/default-PDF.gif';
}
if($Type[1]=='jpg' || $Type[1]=='png' || $Type[1]=='gif')
{
	$DocImg='uploaded_docs/'.$img_url[$im];
}


?>
<tr class="row1">
	<td><input type="checkbox" name="chk1"  /></td>
	<td><?php echo $img_url[$im];?></td>
	<td><a href="uploaded_docs/<?php echo $img_url[$im];?>" target="_blank">
<img src="<?php echo $DocImg; ?>" height="30" width="30" /></a></td>
</tr>
<?php }} ?>
</table>

<br />

			</div>
            
            <p align="center">
  <input type="submit" name="Update" value="Update" class="search" onClick="return validate()" />
  <input type="hidden" name="row_id" value="<?php echo $_GET['id']?>" />
  <input type="button" name="Cancel" value="Cancel" onClick="window.location.href ='index.php?route=HRModule/Master/labour_list<?php echo $rurl; ?>'" class="search" /></p>
	
    </form></div>
  </div></div>
  </body></html>

<script type="text/javascript">
	Element.cleanWhitespace('content');
	init();
</script>

<script>
function AddPgElements()
{
	document.getElementById("PG_LAYER").style.display='block';
	document.getElementById("pgel").style.display='none';
	
}	
function AddPpgElements()
{
	document.getElementById("doctor").style.display='block';
	document.getElementById("add_ppg").style.display='none';
	
}
function AddDipElements1()
{
	document.getElementById("doctor1").style.display='block';
	document.getElementById("id_addCertAnc1").style.display='none';
	
}
function AddDipElements2()
{
	document.getElementById("doctor2").style.display='block';
	document.getElementById("id_addCertAnc2").style.display='none';
	
}
function AddDipElements3()
{
	document.getElementById("doctor3").style.display='block';
	document.getElementById("id_addCertAnc3").style.display='none';
	
}

	
	function imageURL(input,i) {   

 if (input.files && input.files[0]) {	 
  
           var reader = new FileReader();
            reader.onload = function(e) { 
			  document.getElementById(i).src=e.target.result; 
			 
    			 }
	            reader.readAsDataURL(input.files[0]);
	        }
    }
	
function addRow(tableID) 
{
	if(document)
	var table = document.getElementById(tableID);
	var rowCount = table.rows.length;
	var row = table.insertRow(rowCount);
	document.getElementById("hiditemcount").value=rowCount;
	var colCount = table.rows[0].cells.length;
	for(var i=0; i<colCount; i++) {	
	
	var newcell = row.insertCell(i);
	row.className='row1';
	//newcell.style.background='#e7e7e7';
	newcell.className='tabledata1';
	newcell.innerHTML = table.rows[0].cells[i].innerHTML;
	switch(newcell.childNodes[0].type) 
	{
	case "text":
	newcell.childNodes[0].value = "";
	var nod_id = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
	break;
	case "hidden":
	newcell.childNodes[0].value = "";
	var nod_id_hidden = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
	break;
	case "button":
	var nod_id = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
	break;
	case "checkbox":
	newcell.childNodes[0].checked = false;
	var nod_id_chk = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
	break;
	case "select-one":
	newcell.childNodes[0].selectedIndex = 0;
	var nod_id = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
	break;	
	}
		//document.getElementById("stock_perunit_"+rowCount).value=1;
	}
	document.getElementById("stock_perunit_"+rowCount).value='1';
	}


function validate()
{
	if(document.getElementById("emp_site").value=='000')
	{
		alert("Please Select Project Name First !");
		document.getElementById("emp_site").focus();
		return false;
	}
	if(document.getElementById("emp_name").value.trim()=='' ||document.getElementById("emp_name").value.trim()=='')
	{
		alert("Please Fill The Labor Name First !");
		document.getElementById("emp_name").focus();
		return false;
	}
	if(document.getElementById("fh_name").value.trim()=='' || document.getElementById("fh_name").value.trim()=='')
	{
		alert("Please Fill The Labor Father Name First !");
		document.getElementById("fh_name").focus();
		return false;
	}
	if(document.getElementById("nationality").value.trim()=='' ||document.getElementById("nationality").value.trim()=='')
	{
		alert("Please Fill The Nationality First !");
		document.getElementById("nationality").focus();
		return false;
	}
	/*if(document.getElementById("religion").value=='')
	{
		alert("Please Fill The Religion First !");
		document.getElementById("religion").focus();
		return false;
	} */
	if(document.getElementById("uid_no").value.trim()=='' || document.getElementById("uid_no").value.trim()==' ')
	{
		alert("Please Fill UID no !");
		document.getElementById("uid_no").focus();
		return false;
	}
	
	if(document.getElementById("designation").value=='000')
	{
		alert("Please Select Assign Position First !");
		document.getElementById("designation").focus();
		return false;
	}
	if(document.getElementById("uid_type").value=='000')
	{
		alert("Please Select User Id First !");
		document.getElementById("uid_type").focus();
		return false;
	}

	if(document.getElementById("dob").value.trim()=='' ||document.getElementById("dob").value.trim()=='')
	{
		alert("Please Fill DOB !");
		document.getElementById("dob").focus();
		return false;
	}

	if(document.getElementById("doj").value.trim()=='' || document.getElementById("doj").value.trim()=='')
	{
		alert("Please Fill Date of joining !");
		document.getElementById("doj").focus();
		return false;
	}

	if(document.getElementById("dol").value.trim()=='' ||document.getElementById("dol").value.trim()=='') 
	{
		alert("Please Fill Date of leaving !");
		document.getElementById("dol").focus();
		return false;
	}

	if(document.getElementById("pre_add1").value.trim()=='')
	{
    alert("Please Fill Address1!");
    document.getElementById("pre_add1").focus();
    return false;
	}

	if(document.getElementById("pre_add2").value.trim()=='')
	{
    alert("Please Fill Address2!");
    document.getElementById("pre_add2").focus();
    return false;
	}

	if(document.getElementById("pre_add3").value.trim()=='')
	{
    alert("Please Fill Address3!");
    document.getElementById("pre_add3").focus();
    return false;
	}

	if(document.getElementById("pre_city").value.trim()=='')
	{
    alert("Please Select City");
    document.getElementById("pre_city").focus();
    return false;
	}

	if(document.getElementById("pre_state1").value.trim()=='')
	{
    alert("Please Select State");
    document.getElementById("pre_state1").focus();
    return false;
	}

	if(document.getElementById("pre_pincode").value.trim()=='')
	{
    alert("Please Fill Pin code");
    document.getElementById("pre_pincode").focus();
    return false;
	}

	if(document.getElementById("pre_mobile").value.trim()=='')
	{
    alert("Please Fill Mobile No.");
    document.getElementById("pre_mobile").focus();
    return false;
	}

	var flag=0;
	if(document.getElementById("sex").checked==true || document.getElementById("sex1").checked==true)
	{
		flag=1;
	}
	if(flag==0)
	{
		alert("Please Select Sex First !");
		return false;
	}
	if(document.getElementById("dob").value=='')
	{
		alert("Please Select The Date Of Birth First !");
		document.getElementById("dob").focus();
		return false;
	}

	var flag1=0;
	
	if(document.getElementById("bloodgroup").checked==true || document.getElementById("bloodgroup1").checked==true || document.getElementById("bloodgroup2").checked==true || document.getElementById("bloodgroup3").checked==true || document.getElementById("bloodgroup4").checked==true || document.getElementById("bloodgroup5").checked==true || document.getElementById("bloodgroup6").checked==true || document.getElementById("bloodgroup7").checked==true)
	{
		flag1=1;
	}
	if(flag1==0)
	{
		alert("Please Select Blood Group First !");
		return false;
	}
	
	if(document.getElementById("doj").value=='')
	{
		alert("Please Select The Date Of Joining First !");
		document.getElementById("doj").focus();
		return false;
	}
	
	if(document.getElementById("department").value=='000')
	{
		alert("Please Select The Department First !");
		document.getElementById("department").focus();
		return false;
	}
	if(document.getElementById("designation").value=='000')
	{
		alert("Please Select The Desgination First !");
		document.getElementById("designation").focus();
		return false;
	}
	
}

function showapplicabe()
{
if(document.getElementById("otapplicable").checked==true)
{
document.getElementById("over_time").disabled =false;
document.getElementById("ottype").disabled =false;
document.getElementById("ottype1").disabled =false;
}
else
{
document.getElementById("over_time").disabled =true;
document.getElementById("ottype").disabled=true;
document.getElementById("ottype1").disabled=true;
}

}
</script>
<!--<script src="ui/jquery.min.js"></script>
<script src="ui/jqueryui.min.js"></script> -->

<script>
var kj= $.noConflict();
kj(function() {
kj(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' ,changeMonth: true,
		changeYear: true,
		yearRange: '-80:+20'});
});


 function checkDob(){
  var dob=document.getElementById("dob").value;
  var doj=document.getElementById("doj").value;
  if(doj<=dob){
  //alert('Date of Joining must be > DOB');
  document.getElementById("doj").value='';
  }
  var birthday=dob.split('/');
  var birthDate = new Date(birthday[2],birthday[1],birthday[0]);
  var today = new Date();
  if (today >= new Date(birthDate.getFullYear() + 18, birthDate.getMonth(), birthDate.getDate())) {
  } else {
  alert('age of the labor shall be >18 years');
  }
  }

  function checkDoj(){
  var dob=document.getElementById("dob").value;
  var doj=document.getElementById("doj").value;
  if(doj<=dob){
  alert('Date of Joining must be > DOB');
  document.getElementById("doj").value='';
  return false;
  }
  }

  function checkDol(){
  var dol=document.getElementById("dol").value;
  var doj=document.getElementById("doj").value;
  if(dol<=doj){
  alert('Date of Leaving must be > DOJ');
  document.getElementById("dol").value='';
  return false;
  }
  }

  function check_uidno(uid_no)
  {
  var dataString='&uid_no='+ uid_no;
  if(document.getElementById('uid_no').value.trim()=='' || document.getElementById('uid_no').value.trim()==' '){
  }
  else{
  $.ajax({
  url:'ajax_get_uidno.php',
  type:'POST',
  data:dataString,
  cache:false,
  success:function(result){
  if(result>0){
  alert('UID number Exist');
  document.getElementById('uid_no').value='';
  }
  
  }	
  });	
  }
  }

  function checknumeric(val,id){
  if(isNaN(val)){
  alert('please enter only numeric values');
  $('#'+id).val('');	
  }
  }	

   function checkMobile(val,id){
  if(isNaN(val)){
  alert('please enter only numeric values');
  $('#'+id).val('');	
  }
  if(val.length<10){
   alert('mobile must be 10 digits');
   $('#'+id).val('');
   return false;
   
  }
  }

   function checkPhone(val,id){
  if(isNaN(val)){
  alert('please enter only numeric values');
  $('#'+id).val('');	
  }
  if(val.length<10){
   alert('Mobile No. must contain 10 digits.');
   $('#'+id).val('');
   return false;
   
  }
  }

  function checkPincode(val,id){
  if(isNaN(val)){
  alert('please enter only numeric values');
  $('#'+id).val('');	
  }
  if(val.length < 6){
   alert('pin code must be 6 digits');
   $('#'+id).val('');
   return false;
   
  }
  }

  function get_position(group)
  { //alert(group);
  var dataString='&group='+ group;
  if(group==''){
  //alert('blank');
  }
  else{
  $.ajax({
  url:'ajax_get_position.php',
  type:'POST',
  data:dataString,
  cache:false,
  success:function(result){
  //alert(result);
  $('#designation').html(result);
  }	
  });	
  }
  }
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>