
<style>
.creation {display:none;}
</style>

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

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


<?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(mainid!='')
{
$q=DB_query("select * from hr_applcnt_rgstn_doc where hr_applcnt_rgstn_id='".$_REQUEST['mainid']."' and status='accept'",$db);
while($r1=DB_fetch_array($q))
{
	$document1[]=$r1['document'];
}
//print_r($document1);
}

   
     if(isset($_POST['Submit']))
     {
     if($_REQUEST['mainid']!='')
	 {
	 $new_name2=array($new_name2);
     }

		//$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';
                //	
		//}
	
		
		$max_size='2000';
		$flag=0;
		function extension($filename)
		{
			$name_brk=explode('.',$filename);
			return  $name_brk[1];
		}
		
		$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_name=$_FILES['photo']['name'];
			$path="uploaded_images/".$new_name;
			$file_copy=copy($tmp_name,$path);
			if(!$file_copy)
			{
				echo "<strong>Copy Unsuccessful</strong>";
				$flag=1;
			}
		} */
        
            $tmp_name=$_FILES['photo']['tmp_name'];
			$new_name=$_FILES['photo']['name'];
			$path="uploaded_images/".$new_name;
			$file_copy=copy($tmp_name,$path);
			if(!$file_copy)
			{
				echo "<strong>Copy Unsuccessful</strong>";
				$flag=1;
			}
		}



		$flag=0;
		
	    $qty=$_FILES['docmnt']['name'];
		
		for($i=0;$i<count($qty);$i++)
		{ 

		$name=$_FILES['docmnt']['name'][$i];
		$type=extension($name);
		
			if($type!='')
			{

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

				
				 $file_copy=move_uploaded_file($tmp_name,$path);
				if(!$file_copy)
				{
					echo "<strong>Copy Unsuccessful</strong>";
					$flag=1;
				}
			}*/
			
            $tmp_name=$_FILES['docmnt']['tmp_name'][$i];
			//echo $_FILES['photo']['size'];
			$new_name2[]=$name;
			$path="uploaded_docs/".$new_name2[$i]; 
			$file_copy=move_uploaded_file($tmp_name,$path);
		    if(!$file_copy)
			{
			echo "<strong>Copy Unsuccessful</strong>";
			$flag=1;
			}
			}

		}
		

		if($_REQUEST['mainid']!='')
		{
			
			foreach ($document1 as $key => $value)
			{
			copy('uploaded_docs/HR/applicants/'.$value, 'uploaded_docs/'.$value);
			}
	        $result = array_merge($document1, $new_name2);
			$newname1=implode(",",$result);
			}
			else
			{
		    if($new_name2!=''){		
			$newname1=implode(",",$new_name2);
		    }
		    }
			 $sql="SELECT * FROM empmaster WHERE employment_type='Worker' ORDER BY emp_code DESC LIMIT 0,1";
             $result=DB_query($sql,$db);

             $prefix= $s->getField("manufacturing_advice","id",$_REQUEST['emp_site'],"advice_no");
             
            //print_r($num); exit;
            //$number=$num[3]+1;
            if(DB_num_rows($result)>0){
            $row=DB_fetch_array($result);
            $row['emp_code'];
            //echo $_REQUEST['emp_site'];
            $num=explode('/',$row['emp_code']);
            $final=$num[3]+1;
            }
            else{
            $final=1;
            }
            $string=$prefix.'/';
           $final_string=$string.str_pad($final,1,"0",STR_PAD_LEFT);
            
		$esi = $_REQUEST['ESI_employer_value'];
		$dataP['emp_site']=$_REQUEST['emp_site'];
		$dataP['employment_type']=$_REQUEST['employment_type'];
		$dataP['employee_type']=$_REQUEST['emp_shift'];
		//$dataP['emp_code']=$_REQUEST['emp_code'];
		$dataP['emp_code']=$final_string;
		$dataP['emp_name']=$_REQUEST['emp_name'];
		$dataP['fh_name']=$_REQUEST['fh_name'];
		$dataP['nationality']=$_REQUEST['nationality'];
		$dataP['religion']=$_REQUEST['religion'];
		$dataP['dob']=FormatDateForSQL($_REQUEST['dob']);
		$dataP['bloodgroup']=$_REQUEST['bloodgroup'];
		$dataP['doj']=FormatDateForSQL($_REQUEST['doj']);
		$dataP['dol']=FormatDateForSQL($_REQUEST['dol']);
		$dataP['department']=$_REQUEST['department'];
		$dataP['designation']=$_REQUEST['designation'];
		if(count($_REQUEST['emp_weekly_off'])>1)
		$weekly_off=implode(",",$_REQUEST['emp_weekly_off']);
		else
		$weekly_off=$_REQUEST['emp_weekly_off'][0];	
		$dataP['emp_weekly_off']=$weekly_off;
		$dataP['marital_status']=$_REQUEST['marital_status'];
		$dataP['marriage']=FormatDateForSQL($_REQUEST['marriage']);
		$dataP['wh_name']=$_REQUEST['wh_name'];
		$dataP['sons']=$_REQUEST['sons'];
		$dataP['daughters']=$_REQUEST['daughters'];
		$dataP['sex']=$_REQUEST['sex'];
		$dataP['grade']=$_REQUEST['grade'];
		$dataP['personalEmail']=$_REQUEST['personalEmail'];
		$dataP['offEmail']=$_REQUEST['offEmail'];
		$dataP['PFno']=$_REQUEST['PFno'];
		$dataP['ESIno']=$_REQUEST['ESIno'];
		$dataP['bank_account']=$_REQUEST['bank_account'];
		$dataP['bank_name']=$_REQUEST['bank_name'];
		$dataP['payment_mode']=$_REQUEST['payment_mode'];
		$dataP['leave_eff_date']=FormatDateForSQL($_REQUEST['leave_eff_date']);
		$dataP['bachelor']=$_REQUEST['bachelor'];
		$dataP['bac_college_name']=$_REQUEST['bac_college_name'];
		$dataP['bac_year_passing']=$_REQUEST['bac_year_passing'];
		$dataP['pg_college_name']=$_REQUEST['pg_college_name'];
		$dataP['pg_year_passing']=$_REQUEST['pg_year_passing'];
        $dataP['other_college_name']=$_REQUEST['other_college_name'];
		$dataP['other_year_passing']=$_REQUEST['other_year_passing'];
		$dataP['course1']=$_REQUEST['course1'];
		$dataP['course2']=$_REQUEST['course2'];
		$dataP['course3']=$_REQUEST['course3'];
		$dataP['master']=$_REQUEST['pgcourse'];
		$dataP['other_master']=$_REQUEST['othercourse'];
		$dataP['basic_perc']=$_REQUEST['basic_perc'];
		$dataP['basic_salary']=$_REQUEST['basic_salary'];
		$dataP['pf_Reimbursement_per']=$_REQUEST['pf_Reimbursement_per'];
		$dataP['pf_Reimbursement']=$_REQUEST['pf_Reimbursement'];
		$dataP['medical_Reimbursement_per']=$_REQUEST['medical_Reimbursement_per'];
		$dataP['medical_Reimbursement']=$_REQUEST['medical_Reimbursement'];
		$dataP['allow_tot']=$_REQUEST['allow_tot'];
		$dataP['deduct_tot']=$_REQUEST['deduct_tot'];
		$dataP['gross_sal']=$_REQUEST['gross_sal'];
		$dataP['gross']=$_REQUEST['gross']+$esi;
	///////////....................................//////////////////
		$dataP['net_sal']=$_REQUEST['net_sal'];
		$dataP['eff_sal_date']=FormatDateForSQL($_REQUEST['eff_sal_date']);
		$dataP['pf_calculation']=$_REQUEST['pf_calculation'];
		$dataP['adv_amount']=$_REQUEST['adv_amount'];
		$dataP['adv_date']=FormatDateForSQL($_REQUEST['adv_date']);
		$dataP['emp_shift']=$_REQUEST['emp_shift'];
		if($_REQUEST['otapplicable']!='')
		$otapplicable='Y';
		else
		$otapplicable='N';
		$datap['otapplicable']=$otapplicable;
		$dataP['ottype']=$_REQUEST['ottype'];
		
		$dataP['over_time']=$_REQUEST['over_time'];
		$dataP['overtime_salary']=$_REQUEST['overtime_salary'];
		$dataP['tenth_standard']=$_REQUEST['tenth_standard'];
		$dataP['tenthplus2_standard']=$_REQUEST['tenthplus2_standard'];
		$dataP['image']=$new_name;
		$dataP['document']=$newname1;
		$dataP['created_by']=$_SESSION['UserID'];
		$dataP['created_date']=FormatDateForSQL(date('d/m/Y'));
		$dataP['pending_wo']=$_REQUEST['weekly_off'];
		$dataP['CompanyId']=$_SESSION['ACGCompanyId'];
		$dataP['multi_site_att']=$_REQUEST['multi_site_att'];
		$dataP['loan_ledger']=$_REQUEST['loan_mapping'];
		$dataP['advance_ledger']=$_REQUEST['advance_mapping'];
		$dataP['yearly_ctc']    =$_REQUEST['yearlyctc'];
		$dataP['monthly_ctc']   =$_REQUEST['monthelyctc'];
		$dataP['pan_no']=$_REQUEST['pan_no'];
		$dataP['uid_type']=$_REQUEST['uid_type'];
		$dataP['uid_no']=$_REQUEST['uid_no'];
		$dataP['incometax']=$_REQUEST['incometax'];
		//$dataP['uan_no']=$_REQUEST['uan_no'];
		$dataP['pf_type']=$_REQUEST['pftype'];
		$dataP['emp_shift']=$_REQUEST['emp_shift'];
		if($_REQUEST['govt'])
		$govtnom='Y';
		else
		$govtnom='N';
		$dataP['govt_nom_pf']=$govtnom;
	//////////////////////////.....................................................//////////////////////			 
		
		//echo "<pre>";
		//print_r($dataP);
		//exit;
		$s->RecordInsert('empmaster',$dataP);
		$Lastemp_id = DB_Last_Insert_ID($db,'empmaster','id');
				
		if($Lastemp_id!='')
		{
			$dataArr['emp_id']=$Lastemp_id;
			$dataArr['per_address1']=$_REQUEST['per_address1'];
			$dataArr['per_address2']=$_REQUEST['per_address2'];
			$dataArr['per_address3']=$_REQUEST['per_address3'];
			$dataArr['per_country']=$_REQUEST['per_country'];
			$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'];
			$dataArr['pre_country']=$_REQUEST['pre_country'];
			$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'];
			
			$s->RecordInsert('employee_address',$dataArr);

			$monthwo=date("n");
			$yearswo=date("Y");
			if($monthwo==01 || $monthwo==1)
			{
				$monthwo1=12;
				$yearwo1=$yearswo-1;
			}
			else
			{
				$monthwo1=$monthwo-1;
				$yearwo1=$yearswo;
			}				
				
			$dataWOff['emp_id']=$Lastemp_id;
			$dataWOff['year']=$yearwo1;
			$dataWOff['month']=$monthwo1;
			$dataWOff['pending_wo']=$_REQUEST['weekly_off'];
			
			$s->RecordInsert('weekly_off_emp',$dataWOff);
			
			
			
			
			
			
			
			

			



			
//////////////////////////////////////////........ESI(Employer)..../////////////////////////////			
	
			
			$cnt=$_REQUEST['cnt'];
			
			// code for update log table  and registration table**********************************
				
			   if($_REQUEST['mainid']!='')
				{
				$dataArr15['status']='empid';
			    $dataArr15['conf_int_app_details_seq']=0;
			    //$dataArr1['conf_int_app_details_id']=$_REQUEST['id'];
			    $dataArr15['awd_application_id']=$_REQUEST['mainid'];
			    $dataArr15['created_by']=$_SESSION['UserID'];    
			    $dataArr15['datetime']=date('Y-m-d H:i:s');
			    $s->RecordInsert('hr_applcnt_rgstn_log_status',$dataArr15);
				$qt=DB_query("update hr_applcnt_rgstn set status='empid' where id='".$_REQUEST['mainid']."'",$db);
				}
				
			//        end  code for update log table  and registration table**********************************

		}
$s->pageLocation("index.php?route=HRModule/Master/labour_list".$rurl);		
}
?>
<!--<script language="javascript" type="text/javascript" src="js/datetimepicker.js"></script>-->


<link rel="stylesheet" href="css/new_mxerp.css">
<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>
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 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			 
		}
	}


/*var kj= $.noConflict();
kj(function() {
kj(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' ,changeMonth: true,
		changeYear: true,
		yearRange: '-80:+20'});
});
*/
	
</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 0;
	width:100%; text-align:center;
	}
.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]);
}
</script>

<script language="javascript" type="text/javascript">

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




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_state1').value = document.getElementById('pre_state1').value;
		document.getElementById('per_country1').value = document.getElementById('pre_country1').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_state1').value = '';
		document.getElementById('per_country1').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 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>

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

<script src="empcal.js" language="javascript"></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>

<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-->
			<!--**************************************************************main query-->
			<?php 
			if($_REQUEST['mainid']!='')
			{
			$query=DB_query("select  a.*,b.* from hr_applcnt_rgstn a inner join hr_applcnt_rgstn_appointment b on a.id=b.hr_applcnt_rgstn_id where a.id='".$_REQUEST['mainid']."'",$db);
			
			while($row=DB_fetch_array($query))
			{
				extract($row);
				
			}
		  }
			?>
	<div id="Amount" class="w3-container w3-border creation" style="display:block;">
	<h3>General Details</h3>
	<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border:0;">
	<tr class="row1">
	<td width="80%" valign="top">
	  <table width="100%" border="0" cellpadding="3" cellspacing="0" align="center">
	  <tr class="row1">
		<td><strong>Employment Type <font color="#FF0000" size="-1">*</font></strong></td>
		<td><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><strong>Labor Code</strong></td>
	   <td>
	  <div id="hid-EmployeeID">
	   <input type="text" name="emp_code" id="emp_code"  value="" style="width:98%;" onBlur="check_empcode(this.value);" placeholder="Autogenerated" readonly/><span id="empcode_exists" style="color:red;"></span></div></td>
		<td><strong>Labor Name <font color="#FF0000" size="-1">*</font></strong></td>
		<td><input type="text" name="emp_name" id="emp_name" value="<?php echo $first_name. ''. $middle_name.''. $last_name; ?>" class="cap" style="width:98%;"/></td>
		</tr>
		<tr class="row1">
		  <td><strong>Nationality<font color="#FF0000" size="-1">*</font></strong></td>
		  <td><input type="text" name="nationality" id="nationality" style="width:98%;" value="<?php echo $country; ?>" /></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" class="datepicker"  style="width:98%;"  value="<?php if(isset($dob)){echo $dob;} else {echo date('d/m/Y');}?>">-->	
		<input name="dob" type="text" id="dob" class="datepicker"  style="width:98%;"  value="" readonly onChange="checkDob()">

		<!--onClick="javascript:NewCal(this.id,'ddmmyyyy')"-->	</td>
		</tr>
		<tr class="row1">
		  <td><strong>Gender <font color="#FF0000" size="-1">*</font></strong></td>
		  <td>
		  <input type="radio" name="sex" id="sex" <?php if($gender=='m') { echo 'checked'; } ?>  value="M" />Male
		  <input type="radio" name="sex" id="sex1" <?php if($gender=='f') { echo 'checked'; } ?> value="F" />Female
		</td>
		<td><strong>Blood Group</strong></td>
		<td><select name="bloodgroup" id="bloodgroup" style="width:98%;">
			<option value="A-">A-</option>
			<option value="A+">A+</option>
			<option value="B-">B-</option>
			<option value="B+">B+</option>
			<option value="AB-">AB-</option>
			<option value="AB+">AB+</option>
			<option value="O-">O-</option>
			<option value="O+">O+</option>
		</select></td>
		<td><strong>Date of Joining <font color="#FF0000" size="-1">*</font></strong></td>
		<td><input name="doj" type="text" id="doj"  class="datepicker" style="width:98%;"  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=='u'?'selected':'');?>>Single</option>
		<option value="Married"<?php echo ($marital_status=='m'?'selected':'');?>>Married</option>
	  </select></td>
	<?php 
	
	?>	
	  <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" 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" style="width:48%; float:left; margin-right:3px;" placeholder="Son" value="<?php if($sons=='0'){echo "Sons - N/A";}else echo $sons;?>" <?php echo $r;?> onChange="checkChild(this.value)"/>
		  <input type="text" name="daughters" id="daughters" style="width:48%; float:left;" placeholder="Daughter" value="<?php if($daughters=='0'){echo "Daughters - N/A";}else echo $daughters;?>" <?php echo $r;?> onChange="checkDoughter(this.value)"/></td>
		  <td><strong>Father's Name<font color="#FF0000" size="-1">*</font></strong></td>
		  <td><input type="text" name="fh_name" value="<?php echo $father_name; ?>" id="fh_name"  style="width:98%;" /></td>
		<td><strong>Date of leaving</strong></td>
		<td><input name="dol" id="dol" class="datepicker" type="text" style="width:98%;" value="<?php if(isset($dol)){echo $dol;} else {echo "";}?>" readonly onChange="checkDol()">
			<!-- onClick="javascript:NewCal(this.id,'ddmmyyyy')"-->
		</td>
	</tr>
	  <tr class="row1">
	  <td width="13%"><strong>Project Name <font color="#FF0000" size="-1">*</font></strong></td>
	  <td width="20%"><select name="emp_site" id="emp_site" style="width:98%;" onChange="ShowDiv(this.value,'hid-staffdiv','Empshift.php');">
	  <option value="000">---Select---</option>
	  <?php 
	  	$emp_site=$s->getField('hr_job_created','id',$hr_job_created_id,'branch');
		$site_sql=DB_query("Select id,project_name from manufacturing_advice  where CompanyId='".$_SESSION['ACGCompanyId']."' ",$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 width="13%"><strong>Group</strong></td>	
		<td width="20%"><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 width="13%"><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' 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" style="width:98%;" id="pftype">
        <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') { ?> select <?php } ?>>E : Existing Member with Pension Contribution on higher wages.</option>
         <option value="Existing member whose Pension Contribution is restricted to wage ceiling" <?php if($pftype=='Existing member whose Pension Contribution is restricted to wage ceiling') { ?> select <?php } ?>>R : Existing member whose Pension Contribution is restricted to wage ceiling.</option>
         <option value="Z" <?php if($pftype=='Z') { ?> select <?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 
		
		$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>
		<td><strong>Employee Shift <font color="#FF0000" size="-1">*</font></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 where site='".$emp_site."'",$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">
		  
		  <td></td>
		  <td></td>
		</tr>
	
		
	</table>
	</td>
	<td valign="top">
	<table width="100%" border="0" cellpadding="3" cellspacing="0" style="border:0;">	
			<tr>
			<td style="text-align:center;"><img src="uploaded_images/default.png" width="auto" height="140" id="image1" /></td>
			</tr>
			<tr>
			<td>
			<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" value="<?php echo $present_address; ?>" id="pre_add1" style="width:98%;"/></td>
				</tr>
				<tr class="row1">
					<td><input name="pre_address2" type="text" id="pre_add2" style="width:98%;" /></td>
				</tr>
				<tr class="row1">
					<td><input name="pre_address3" type="text" id="pre_add3" 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 $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" style="width:150px;" />
					<input type="text" value="<?php echo $state; ?>" name="pre_state1" id="pre_state1" 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" style="width:150px;" />
					 <input type="text" value="<?php echo $country; ?>" name="pre_country1" id="pre_country1" 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" value="<?php echo $pincode; ?>" type="text" id="pre_pincode" style="width:98%;" onBlur="checkPincode(this.value,this.id)" maxlength="6" autocomplete="off"/></td>
				</tr>
				<tr class="row1">
					<td><strong>Mobile <font color="#FF0000" size="-1">*</font></strong></td>
					<td><input name="pre_mobile" value="<?php echo $mobile1; ?>" type="text" id="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" value="<?php echo $phone1; ?>"  type="text" id="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></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" value="<?php echo $prmnt_address; ?>" type="text" id="per_add1" style="width:98%;"/></td>
				</tr>
				<tr class="row1">
					<td><input name="per_address2" type="text" id="per_add2" style="width:98%;" /></td>
				</tr>
				<tr class="row1">
					<td><input name="per_address3" type="text" id="per_add3" 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 $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" style="width:150px;" />
					<input type="text" value="<?php echo $state2; ?>" name="per_state1" id="per_state1" style="width:98%;" readonly/></td>
				</tr>
				<tr class="row1">
					<td><strong>Country </strong></td>
					 <td><input type="hidden" name="per_country" id="per_country" style="width:150px;" />
					 <input type="text" value="<?php echo $country2; ?>" name="per_country1" id="per_country1" style="width:98%;" readonly/></td>
				</tr>
				<tr class="row1">
					<td><strong>Pin Code </strong></td>
					<td><input name="per_pincode" value="<?php echo $pincode2; ?>" type="text" id="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" value="<?php echo $mobile2; ?>" type="text" id="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" value="<?php echo $phone2; ?>" type="text" id="per_phone" style="width:98%;" maxlength="10" onBlur="checkPhone(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">
	<?php if($_REQUEST['mainid']!=''){ foreach ($document1 as $key => $value) {  ?>
	<tr class="row1"><td><?php echo $value;?></td><td colspan="2"></td></tr>
	<?php } } ?>
	<tr class="row1">
		<td colspan="3" style="text-align:left;">
		<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="" tabindex="69" style="width:98%;" />
		<input type="hidden" name="docmnt1" id="docmnt1" value="<?php echo $document;?>" tabindex="70"/></td>
	</tr>
	</tbody>
	<input type="hidden" id="hiditemcount" />
	</table>
	</div>

<p align="center">
  <input type="submit" name="Submit" value="Save" class="search" onclick="return validate()"  />
  <input type="reset" name="reset" value="Reset" class="search"   />
  <input type="button" name="Cancel" value="Cancel" class="search"  onclick="window.location.href ='index.php?route=HRModule/Master/labour_list<?php echo $rurl; ?>'" /></p>
  
  </form></div>
  </div></div>

 
<script type="text/javascript">
	Element.cleanWhitespace('content');
	init();
</script>
<?php
include('includes/footer.inc');
?>
<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 !");
		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()=='')
	{
		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("pre_add1").value.trim()=='' || document.getElementById("pre_add1").value.trim()==' ')
	{
    alert("Please Fill Address1!");
    document.getElementById("pre_add1").focus();
    return false;
	}

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

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

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

	if(document.getElementById("pre_pincode").value.trim()=='' || 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()=='' || document.getElementById("pre_mobile").value.trim()==' ')
	{
    alert("Please Fill Mobile No.");
    document.getElementById("pre_mobile").focus();
    return false;
	}

	/*if(document.getElementById("dol").value=='')
	{
		alert("Please Fill Date of leaving !");
		document.getElementById("dol").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 Gender 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("emp_weekly_off").value=='000')
	{
		alert("Please Select The Weekly Off First !");
		document.getElementById("emp_weekly_off").focus();
		return false;
	}
	
	if(document.getElementById("marital_status").value=='000')
	{
		alert("Please Select The Marital Status First !");
		document.getElementById("marital_status").focus();
		return false;
	}
	
	if(document.getElementById("marital_status").value='Married')
	{
		if(document.getElementById("marriage").value=='')
		{
			alert("Please Fill The Marriage Aniversary Date First !");
			document.getElementById("marriage").focus();
			return false;
		}
		if(document.getElementById("wh_name").value=='')
		{
			alert("Please Fill The Wife's/Husband's Name First !");
			document.getElementById("wh_name").focus();
			return false;
		}
	}
	
	if(document.getElementById("tenth_standard").checked==false)
	{
		alert("Please Check 10th Standard First !");
		document.getElementById("tenth_standard").focus();
		return false;
	}
	
	if(document.getElementById("tenthplus2_standard").checked==false)
	{
		alert("Please Check 10+2 Standard First !");
		document.getElementById("tenthplus2_standard").focus();
		return false;
	}
	
	if(document.getElementById("pre_add1").value=='')
	{
		alert("Please Fill The Present Address  First !");
		document.getElementById("pre_add1").focus();
		return false;
	}
	
	if(document.getElementById("pre_city").value=='')
	{
		alert("Please Fill The Present City  First !");
		document.getElementById("pre_city").focus();
		return false;
	}
	
	if(document.getElementById("pre_state1").value=='')
	{
		alert("Please Fill The Present State  First !");
		document.getElementById("pre_state1").focus();
		return false;
	}
	
	if(document.getElementById("pre_country1").value=='')
	{
		alert("Please Fill The Present Country  First !");
		document.getElementById("pre_country1").focus();
		return false;
	}
	
	if(document.getElementById("pre_pincode").value=='')
	{
		alert("Please Fill The Present Pin Code  First !");
		document.getElementById("pre_pincode").focus();
		return false;
	}
	
	if(document.getElementById("pre_mobile").value=='')
	{
		alert("Please Fill The Present Mobile No  First !");
		document.getElementById("pre_mobile").focus();
		return false;
	}
	
	
	if(document.getElementById("per_add1").value=='' || document.getElementById("per_city").value=='' || document.getElementById("per_state1").value=='' || document.getElementById("per_country1").value=='' || document.getElementById("per_pincode").value=='' || document.getElementById("per_mobile").value=='')
	{
		alert("Please Checke If Present Address Same As Permanent Address Or Fill All Permanent Address Details!");
		document.getElementById("copy_add").focus();
		return false;
	}
	
	if(document.getElementById("payment_mode").value=='')
	{
		alert("Please Select The Payment Mode  First !");
		document.getElementById("payment_mode").focus();
		return false;
	}
	
	if(document.getElementById("gross").value=='')
	{
		alert("Please Fill Monthly CTC  First !");
		document.getElementById("gross").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');
    document.getElementById("dob").value='';
    return false;
  }
  }

  function checkDoj(){
  var today=new Date();
  var month=today.getMonth();
  var day  = today.getDate();
  var year  =today.getFullYear();
  current_date=day+'/'+month+'/'+year;


  //alert(current_date);
  var dobs=document.getElementById("dob").value;
  var dojs=document.getElementById("doj").value;
  dob =dobs.split('/');
  doj =dojs.split('/');
  if(doj[2] == year){
  if(dojs > current_date){
  alert('DOJ must be less or equal current date');
   document.getElementById("doj").value='';
   return false;	
   }
   }

  
  
  var dobyear=parseInt(dob[2]) + parseInt(18);
  if(doj[2] < dobyear){
  alert('Date of Joining must be > DOB');
  document.getElementById("doj").value='';
  return false;
  }
  if(doj[2] == dobyear && doj[1] < dob[1]){
  alert('Date of Joining must be > DOB');
  document.getElementById("doj").value='';
  return false;
  }

  if(doj[2] == dobyear && doj[1] == dob[1] && doj[0] < dob[0]){
  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 checkChild(val){
  //alert('welcome');
  if(isNaN(val)){
  alert('plaese enter only numeric values');
  document.getElementById('sons').value='';	
  }
  }

   function checkDoughter(val){
  //alert('welcome');
  if(isNaN(val)){
  alert('plaese enter only numeric values');
  document.getElementById('daughters').value='';	
  }
  }
  	
  function check_uidno(uid_no)
  { 
  //var uid_no=document.getElementById('uid_no').value;
  //alert(uid_no);
  var dataString='&uid_no='+ uid_no;
  if(uid_no==''){
  //alert('blank');
  }
  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 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){
  $('#designation').html(result);
  }	
  });	
  }
  }	

  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 No. must contain 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('phone must be 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('pincode must be 6 digits');
   $('#'+id).val('');
   return false;
   
  }
  }
  </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>