var basicPATH =localStorage['basicPATH'];
var serviceURLHR =localStorage['serviceURLHR'];
var itemCount =0;
var k=1;
var pageLimit = 15;
var state_selected;
var country_selected;
var language_selected;
var lang_index;
$(window).load(function(){
    $('#light-pagination').pagination({
        itemsOnPage: pageLimit,
        cssStyle: 'light-theme',
        onPageClick : recruitment_list
    });						   
});

function removeCurrentPage(){

$('.paymentMethod').remove();
$('#tablelist table').hide('blind',500,function(){ $(this).remove(); }) 
}

jQuery('.searchPdt').live('click',function(){ productivity_list('1','') });
jQuery('.searchRecuit').live('click',function(){ recruitment_list('1','') });



jQuery('.showdetaildoclist').live('click',productivity_detailshw);
jQuery('.showperformdoclist').live('click',performance_detailshw);
jQuery('.showperformremarkdoclist').live('click',performance_Remarkdetailshw);



//jQuery('.interview_schd').live('click',function(){ interview_schedule_list('1','') });
jQuery('.resume_List').live('click',resume_List);
jQuery('.interview_schd').live('click',interview_schd);
jQuery('.shortlist_form').live('click',shortlist_form);
jQuery('.selected_List_form').live('click',selected_List_form);


function resume_List(){
	window.location="recruitment-list.php";
}

function interview_schd(){
	window.location="interview-schedule-list.php";
}

function fninterviewSchdule(){
	var datastring = $("#formrate").serialize();	
	$.post(serviceURLHR + "interview_schedule_insert.php?action=updateprofile",datastring,function(data){   
		alert("Item successfully inserted.");
		//$('.performance-grid').hide('blind',300);  
		window.location="interview-schedule-list.php";
		
 },'json');
}

function shortlist_form(){
	window.location="shortlisted-page-list.php";
}

function fnShortlisted(){
	var datastring = $("#frm_short").serialize();	
	$.post(serviceURLHR + "shortlist_insert.php?action=updateprofile",datastring,function(data){   
		alert("Item successfully inserted.");
		$('.performance-grid').hide('blind',300);  
		
 },'json');
}

function selected_List_form(){
	window.location="selected-page-list.php";
}

function fnSelectedlisted(){
	var datastring = $("#frm_select").serialize();	
	$.post(serviceURLHR + "selectedlist_insert.php?action=updateprofile",datastring,function(data){   
		alert("Item successfully inserted.");
		$('.performance-grid').hide('blind',300);  
		
 },'json');
}




$('.edit_form_date').live('click',function(){
								
		 $(this).datepicker({
							dateFormat:"dd-mm-yy",
							yearRange: "1950:2020",
							changeMonth: true, 
							changeYear: true
							})
		 		.focus();	
	});






function productivity_detailshw(){
	$this = $(this);
	$('.productivity-grid').hide("blind",300,function(){ $(this).remove() });
	//alert($this);
	$currentRow = $this.parent();
	//alert($currentRow);
	console.log($currentRow);
	var did = $(this).attr('data-id');
	
	if($('.Grid_'+did).length){
		
	}else{
	
	$currentRow.after('<div class="testdiv" style="display:none"><table width="100%" border="0" cellspacing="0" class="productivity-grid Grid_'+did+'" cellpadding="0">'+
					  '<tr>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>No</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Document No</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Wt Carried</translate></td>'+
					  '</tr>'+
					  '</table></div>');
	
	$.getJSON(serviceURLHR+"getproductivity_details.php?prd_id="+did,function(data){
		imdsupervisor = data.getproductivitydts;
		//alert(imdsupervisor);
		var k = 1;
		$.each(imdsupervisor, function(index, imdsupervisor) {
									 
				    	$('.Grid_'+did).append('<tr>'+
					   '<td align="center" valign="middle" class="employee-row-01">'+ k + '</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">'+imdsupervisor.prd_docno+'</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">'+imdsupervisor.prd_wt_carry+'</td>'+
					  '</tr>');
			k++;				
		});		
		$('.testdiv').show('blind',300);
	});
	}
	
}



loadimediatesupervisor();

function loadimediatesupervisor(){
	$.getJSON(serviceURLHR + 'immediatesupervisor.php?action=load',function(data){
		imdsupervisor = data.imdsupervisor;
		
		$.each(imdsupervisor, function(index, imdsupervisor) {
									 
				$('#imdatesupervisor').append('<option value="'+imdsupervisor.e_id+'">'+imdsupervisor.e_fname	+'</option>');
							
		});	
	});
}

loadperformanceimediatesupervisor();

function loadperformanceimediatesupervisor(){
	//alert('rrrr');
	$.getJSON(serviceURLHR + 'immediateperformancesupervisor.php?action=load',function(data){
		imdsupervisor = data.imdsupervisor;
		$.each(imdsupervisor, function(index, imdsupervisor) {
									 
							$('#imdateperformancesupervisor').append('<option value="'+imdsupervisor.e_id+'">'+imdsupervisor.e_fname	+'</option>');
							
		});	
	});
}

//////////////////////////////////////////////////////////////Profile//////////////////////////////////////////////////////////////////////////

function interview_schedule_list(pageno,e){
		
		 var searchString = $('.recuitSearchForm').serialize(); 
		 if(pageno == 1 ){
			k=1; 
		 }else{
			k= ((pageno-1) * pageLimit)+1;
		 }
		
		$.getJSON(serviceURLHR+"getinterview_schedule.php?page="+pageno+"&"+searchString,function(data){
																						   
																		    
					$('.recruitmentGrid').html('');						
				   profile = data.getinterview;
					
					$('.recruitmentGrid').append('<table width="100%" border="0" cellspacing="0" class="Grid" cellpadding="0">'+
					'<tr>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>No</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Candidate</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Position</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Location</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Qualification</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Experience</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Contact Details</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Interview Schedules</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Status</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Remarks</translate></td>'+
					  '</tr></table>');
			
					$.each(profile, function(index, profile) 
					{
						$('.Grid').append('<tr class="catmenuitems">'+
							  '<td align="center" scope="col" >'+ k + '</td>'+
							  '<td align="center" scope="col" >'+ profile.name_cand+ '</td>'+
							  '<td align="center" scope="col" >'+profile.interv_pos+ '</td>'+
							  '<td align="center" scope="col" >'+profile.interv_loc+ '</td>'+
							  '<td align="center" scope="col" >'+profile.interv_qual+ '</td>'+
							  '<td align="center" scope="col" >'+ profile.interv_exp + '</td>'+
							  '<td align="center" scope="col" >'+ profile.interv_contdt + '</td>'+
							  '<td align="center" scope="col" >'+ profile.interv_schd + '</td>'+
							  '<td align="center" scope="col" >'+ profile.interv_status + '</td>'+
							  '<td align="center" scope="col" >'+ profile.interv_remark + '</td>'+
							  '</tr>');	
						
					itemCount = profile.totalrows;
										
					k++;
					});	//'</tbody></table>';
					  $('#light-pagination').pagination( 'updateItems',itemCount );
					  
					 // $('#light-pagination').pagination( 'selectPage', 3 );


	       });
	  
	
}

function shortlisted_list(pageno,e){
		
		 var searchString = $('.recuitSearchForm').serialize(); 
		 if(pageno == 1 ){
			k=1; 
		 }else{
			k= ((pageno-1) * pageLimit)+1;
		 }
		
		$.getJSON(serviceURLHR+"getshortlisted.php?page="+pageno+"&"+searchString,function(data){
																						   
																		    
					$('.recruitmentGrid').html('');						
				   profile = data.getshortlist;
					
					$('.recruitmentGrid').append('<table width="100%" border="0" cellspacing="0" class="Grid" cellpadding="0">'+
					'<tr>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>No</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Candidate</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Interviewed date</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Position</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Location</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Qualification</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Experience</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Contact Details</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Status</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Remarks</translate></td>'+
					  '</tr></table>');
			
					$.each(profile, function(index, profile) 
					{
						$('.Grid').append('<tr class="catmenuitems">'+
							  '<td align="center" scope="col" >'+ k + '</td>'+
							  '<td align="center" scope="col" >'+ profile.getshortlist+ '</td>'+
							  '<td align="center" scope="col" >'+profile.interv_pos+ '</td>'+
							  '<td align="center" scope="col" >'+profile.sht_pos+ '</td>'+
							  '<td align="center" scope="col" >'+profile.sht_loc+ '</td>'+
							  '<td align="center" scope="col" >'+ profile.sht_qual + '</td>'+
							  '<td align="center" scope="col" >'+ profile.sht_exp + '</td>'+
							  '<td align="center" scope="col" >'+ profile.sht_contdt + '</td>'+
							  '<td align="center" scope="col" >'+ profile.sht_status + '</td>'+
							  '<td align="center" scope="col" >'+ profile.sht_remarks + '</td>'+
							  '</tr>');	
						
					itemCount = profile.totalrows;
										
					k++;
					});	//'</tbody></table>';
					  $('#light-pagination').pagination( 'updateItems',itemCount );
					  
					 // $('#light-pagination').pagination( 'selectPage', 3 );


	       });
	  
	
}

function selected_candiate_list(pageno,e){
		 var searchString = $('.recuitSearchForm').serialize(); 
		 if(pageno == 1 ){
			k=1; 
		 }else{
			k= ((pageno-1) * pageLimit)+1;
		 }
		 
		$.getJSON(serviceURLHR+"getselectedlisted.php?page="+pageno+"&"+searchString,function(data){
					$('.recruitmentGrid').html('');						
				   profile = data.getselectedlist;
					
					$('.recruitmentGrid').append('<table width="100%" border="0" cellspacing="0" class="Grid" cellpadding="0">'+
					'<tr>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>No</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Candidate</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Designation</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Location</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Salary</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Date of Join</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Probation Period</translate></td>'+
					  '</tr></table>');
			
					$.each(profile, function(index, profile) 
					{
						$('.Grid').append('<tr class="catmenuitems">'+
							  '<td align="center" scope="col" >'+ k + '</td>'+
							  '<td align="center" scope="col" >'+ profile.sel_name_cand+ '</td>'+
							  '<td align="center" scope="col" >'+profile.sel_desg+ '</td>'+
							  '<td align="center" scope="col" >'+profile.sel_loc+ '</td>'+
							  '<td align="center" scope="col" >'+profile.sel_sal+ '</td>'+
							  '<td align="center" scope="col" >'+ profile.sel_doj + '</td>'+
							  '<td align="center" scope="col" >'+ profile.sel_prb_prd + '</td>'+
							  '</tr>');	
						
					itemCount = profile.totalrows;
										
					k++;
					});	//'</tbody></table>';
					  $('#light-pagination').pagination( 'updateItems',itemCount );
					  
					 // $('#light-pagination').pagination( 'selectPage', 3 );


	       });
	  
	
}

function recruitment_list(pageno,e){
		 var searchString = $('.recuitSearchForm').serialize(); 
		 if(pageno == 1 ){
			k=1; 
		 }else{
			k= ((pageno-1) * pageLimit)+1;
		 }
		 
		$.getJSON(serviceURLHR+"getrecruitment.php?page="+pageno+"&"+searchString,function(data){
					$('.recruitmentGrid').html('');						
				   profile = data.getrecruitment;
					
					$('.recruitmentGrid').append('<table width="100%" border="0" cellspacing="0" class="Grid" cellpadding="0">'+
					'<tr>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>No</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Date</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Source</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>No of Resumes</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01" style="width:5%;"><translate>No of Candidate Attend the interview</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Selected Candidate</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Cost</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Cost Ratio</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Designation</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Download Resume</translate></td>'+
					  '</tr></table>');
			
					$.each(profile, function(index, profile) 
					{
						$('.Grid').append('<tr class="catmenuitems">'+
							  '<td align="center" scope="col" >'+ k + '</td>'+
							  '<td align="center" scope="col" >'+ new Date(profile.rect_date).format("dd-mm-yyyy")+ '</td>'+
							  '<td align="center" scope="col" >'+ profile.rect_source+ '</td>'+
							  '<td align="center" scope="col" >'+profile.rect_resume+ '</td>'+
							  '<td align="center" scope="col" >'+profile.rect_num_cand+ '</td>'+
							  '<td align="center" scope="col" >'+profile.rec_sel_cand+ '</td>'+
							  '<td align="center" scope="col" >'+ profile.rect_cost + '</td>'+
							  '<td align="center" scope="col" >'+ profile.rect_costratio + '</td>'+
							  '<td align="center" scope="col" >'+ profile.rect_desg + '</td>'+
							  '<td align="center" scope="col" ><a  href="'+serviceURLHR+'download_resume.php?filename='+profile.rect_resumeup+'" title="'+profile.rect_resumeup+'</td>" style="height:5px,width:5px" class="pro-icon-02">Resume</a></td>'+
					  '</tr>');	
						
					itemCount = profile.totalrows;
										
					k++;
					});	//'</tbody></table>';
					  $('#light-pagination').pagination( 'updateItems',itemCount );
					  
					 // $('#light-pagination').pagination( 'selectPage', 3 );


	       });
	  
	
}

function employee_list_delete(pageno,e){
		 var searchString = $('.recuitSearchForm').serialize(); 
		 if(pageno == 1 ){
			k=1; 
		 }else{
			k= ((pageno-1) * pageLimit)+1;
		 }
		 
		$.getJSON(serviceURLHR+"getempoyeelist_delete.php?page="+pageno+"&"+searchString,function(data){
					$('.recruitmentGrid').html('');						
				   profile = data.getemp_delete;
					
					$('.recruitmentGrid').append('<table width="100%" border="0" cellspacing="0" class="Grid" cellpadding="0">'+
					'<tr>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>No</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Employee name</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Branch</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Department</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Designation</translate></td>'+
					  '</tr></table>');
			
					$.each(profile, function(index, profile) 
					{
						$('.Grid').append('<tr class="catmenuitems">'+
							  '<td align="center" scope="col" >'+ k + '</td>'+
							  '<td align="center" scope="col" >'+ profile.e_fname+ '</td>'+
							  '<td align="center" scope="col" >'+ profile.branch_name+ '</td>'+
							  '<td align="center" scope="col" >'+ profile.depart_name+ '</td>'+
							  '<td align="center" scope="col" >'+ profile.desig_name+ '</td>'+
							 '</tr>');	
						
					itemCount = profile.totalrows;
										
					k++;
					});	//'</tbody></table>';
					  $('#light-pagination').pagination( 'updateItems',itemCount );
					  
					 // $('#light-pagination').pagination( 'selectPage', 3 );


	       });
	  
	
}

	function productivity_list(pageno,e)
	  {
		  var searchString = $('.pdtSearchForm').serialize(); 
		 if(pageno == 1 ){
			k=1; 
		 }else{
			k= ((pageno-1) * pageLimit)+1;
		 }
		 var tot = 0;
		
				   	/*$.getJSON(serviceURLHR+"getproductivity.php?action=load+"&"+page="+pageno+"&"+searchString,function(data){
																										
																										});*/
					 $.getJSON(serviceURLHR+"getproductivity.php?page="+pageno+"&"+searchString,function(data){
				   $('.productivityGrid').html('');						
				   profile = data.getproductivity;
					$('.productivityGrid').append('<div class="productivity_list">'+
												 '<ul class="productivity_ul">'+
												<!-- '<li class="employee-row-01" style="width=10px;">No</li>'+-->
												 '<li class="employee-row-01"><translate>Prd No</translate></li>'+
												 '<li class="employee-row-01"><translate>Date</translate></li>'+
												 '<li class="employee-row-01"><translate>Employee Name</translate></li>'+
												 '<li class="employee-row-01"><translate>Branch</translate></li>'+
												 '<li class="employee-row-01"><translate>View</translate></li>'+
												 '</ul>'+
												 '</div>');
					/*'<table width="100%" border="0" cellspacing="0" class="Grid" cellpadding="0">'+
					'<tr>'+
					  '<td align="center" valign="middle" class="employee-row-01">No</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Date</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Employee Name</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Branch</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Wt Carried</td>'+
					  '</tr></table>');*/
				  
					$.each(profile, function(index, profile){ 
							tot = parseInt(tot)+parseInt(profile.prd_wt_carried);
						$('.productivity_list').append('<ul class="productivity_ul">'+
								<!--'<li class="employee-row-01" style="width=10px;">'+ k + '</li>'+-->
								'<li class="employee-row-01">'+ profile.prd_unique+ '</li>'+
								'<li class="employee-row-01">'+ new Date(profile.prd_date).format("dd-mm-yyyy")+ '</li>'+
								'<li class="employee-row-01">'+ profile.e_fname+ '</li>'+
								'<li class="employee-row-01">'+profile.branch_name+ '</li>'+
							    '<li class="employee-row-01 showdetaildoclist" data-id="'+profile.prd_id+'" >'+profile.prd_wt_totcarried+ '</li>'+
							'</ul>');	
					itemCount = profile.totalrows;
					//tot = tot+profile.prd_wt_carried;
					k++;
					});	//'</tbody></table>';
				/*	
					$('.productivity_list').append('<ul class="productivity_list">'+
							  '<td align="center" scope="col" style="width:15%;"></td>'+
							  '<td align="center" scope="col" style="width:15%;"></td>'+
							  '<td align="center" scope="col" style="width:15%;"></td>'+
							  '<td align="center" scope="col" style="width:15%;">Total</td>'+
							  '<td align="center" scope="col" style="width:20%;">'+tot+'</td>/tr>');	*/
					  $('#light-pagination').pagination( 'updateItems',itemCount );
					 // $('#light-pagination').pagination( 'selectPage', 3 );


	       });
	  
}




$('#prdaddate').live('click',function(){
		 $(this).datepicker({dateFormat:"dd-mm-yy"}).focus();	
	});

$('#prd_addate').live('click',function(){
		 $(this).datepicker({dateFormat:"dd-mm-yy"}).focus();	
	});

$('#toaddate').live('click',function(){
		 $(this).datepicker({dateFormat:"dd-mm-yy"}).focus();	
	});

setTimeout(profile,200);

	function profile()
	  {
	
		$.getJSON(serviceURLHR+"profile.php",function(data){
											
				   profile = data.employee;
					
					$('.clear-float').append('<li class="catmenuitems">'+
					'<h1><center> Employee Report</center></h1>'+
					'<table class="Grid" cellspacing="0" cellpadding="6" id="dgOrder" style="border-width:1px;border-style:Solid;width:100%;border-collapse:collapse;">'+
					'<tbody><tr class="GridHeader">'+
					'<th align="center" scope="col" style="width:15%;"><translate>Emp No.</translate></th>'+
					'<th align="center" scope="col" style="width:10%;"><translate>Name</translate></th>'+
					'<th align="center" scope="col" style="width:10%;"><translate>Address</translate></th>'+
					'<th align="center" scope="col" style="width:15%;"><translate>Mobileno</translate></th>'+
					'<th align="center" scope="col" style="width:15%;"><translate>Post</translate></th>'+
					
					'<th align="center" scope="col" style="width:10%;"><translate>Qualification</translate></th>'+
					'<th align="center" scope="col" style="width:15%;"><translate>Edit</translate></th>'+
					'<th align="center" scope="col" style="width:15%;"><translate>Delete</translate></th>'+
					'</tr>');
			
					$.each(profile, function(index, profile) 
					{
												   
										
												   
										$('.Grid').append('<tr class="catmenuitems">'+
											  '<td align="center" scope="col" style="width:15%;">'+ profile.e_id + 
											  '</td><td align="center" scope="col" style="width:15%;">'+ profile.e_fname+'   ' + profile.e_lname +
											  '</td><td align="center" scope="col" style="width:15%;">'+profile.e_add+
											  '</td><td align="center" scope="col" style="width:20%;">'+profile.e_mob+
											  '</td><td align="center" scope="col" style="width:15%;">'+ profile.e_post + 
											 
											  '</td><td align="center" scope="col" style="width:15%;">'+ profile.e_course + 
											  '</td> </tr>');	
					});	'</tbody></table>';
				
				

	
	       });
}




//////////////////////////////////////////////////////////////End Of Profile///////////////////////////////////////////////////////////////////


 //////////////////////////////////////////////////////Employee insertion///////////////////////////////////////////////////////////////



$('#register').live('click',insert);
function insert(){
	//alert('aaaaa');
	
	//var dataString = $('#frm1').serialize();

	var formData = new FormData($('form')[0]);
	//alert(formData);
	//alert(formData);
	//alert(serviceURLHR);
    $.ajax({
        url: serviceURLHR + 'insert.php',  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
				//if(data=='success'){
				alert("Item successfully inserted.");
				//window.location="list.html";
			//}
		}
	});	
}

 //////////////////////////////////////////////////////Employee Listing///////////////////////////////////////////////////////////////
 setTimeout(listEmployees,250);

	function listEmployees()
	  {
	
		$.getJSON(serviceURLHR+"list.php",function(data){
											
				   employeeslist = data.employee;
					
					$('.profile').append('<li class="catmenuitems">'+
					'<h1><center> Employee Report</center></h1>'+
					'<table class="Grid" cellspacing="0" cellpadding="6" id="dgOrder" style="border-width:1px;border-style:Solid;width:100%;border-collapse:collapse;">'+
					'<tbody><tr class="GridHeader">'+
					'<th align="center" scope="col" style="width:15%;"><translate>Emp No.</translate></th>'+
					'<th align="center" scope="col" style="width:10%;"><translate>Name</translate></th>'+
					'<th align="center" scope="col" style="width:10%;"><translate>Address</translate></th>'+
					'<th align="center" scope="col" style="width:15%;"><translate>Mobileno</translate></th>'+
					'<th align="center" scope="col" style="width:15%;"><translate>Post</translate></th>'+
					
					'<th align="center" scope="col" style="width:10%;"><translate>Qualification</translate></th>'+
					'<th align="center" scope="col" style="width:15%;"><translate>Edit</translate></th>'+
					'<th align="center" scope="col" style="width:15%;"><translate>Delete</translate></th>'+
					'</tr>');
			
					$.each(employeeslist, function(index, employeeslist) 
					{
												   
										
												   
										$('.Grid').append('<tr class="catmenuitems">'+
											  '<td align="center" scope="col" style="width:15%;">'+ employeeslist.e_id + 
											  '</td><td align="center" scope="col" style="width:15%;">'+ employeeslist.e_fname+'   ' + employeeslist.e_lname +
											  '</td><td align="center" scope="col" style="width:15%;">'+employeeslist.e_add+
											  '</td><td align="center" scope="col" style="width:20%;">'+employeeslist.e_mob+
											  '</td><td align="center" scope="col" style="width:15%;">'+ employeeslist.e_post + 
											 
											  '</td><td align="center" scope="col" style="width:15%;">'+ employeeslist.e_course + 
											  '</td><td align="center" scope="col" style="width:10%;"><a class="findurl" href="edit.html?employ_id='+employeeslist.e_id+'" data-link="'+ employeeslist.e_id + '"><img src="images/edit.png" alt="Edit" title="Edit"  border="0" /></a></td><td align="left" scope="col" style="width:10%;"><a class="findurl" href="#" id="delete" data-link="'+ employeeslist.e_id + '"><img src="images/imagees.jpg" alt="Delete" title="Delete"  border="0" /></a></td> </tr>');	
					});	'</tbody></table>';
				
				

	
	       });
}// '</td><td align="left" scope="col" style="width:15%;"><img src="'+serviceURL+'upload/thumb/'+ employeeslist.photo+'"/>'+
$(document).ready(function()
{ 
	$('#delete').live('click',function(){
		var employ=confirm("Do you want to delete the Employee.....!!!")
		  $data=$(this).attr('data-link');
if (employ==true)
  {
	$(this).parent().parent().remove();	
 	$.post(serviceURLHR+'list.php?employee_id='+$data,function(o){

															});
  }
		
	});
});




//////////////////////////////////////////////////////Addmore Language(insert page)/////////////////////////////////////////////////////////////// 


//////////////////////////////////////////////////////Addmore Language(Edit page)/////////////////////////////////////////////////////////////// 

$(function() 
{
	//var k=0;
var addDiv = $('#radiodiv1');
var i = $('#radiodiv1 p').size() + 1;
$('#radio1').live('click', function() 
{
	
	
$('<p><td align="left" valign="middle"><span id="lblLName"><td align="left" valign="middle"><span id="lblFName">Level</span></td><td align="left" valign="middle">:</td><td align="left" valign="middle">'+
'<span id="lblLName"><select name="level1[]" id="level1"><option selected="selected">---select---</option><option>Poor</option><option>Average</option>'+
'<option>Good</option></select></span></td></tr><a href="#" id="radio1"><img src="images/icon-add.png" width="20" height="15" title="Add More" /></a></br><a href="#" id="nouse">Remove</a></span></td></p>').appendTo(addDiv);i++;// k++;
return false;
}

);
$('#nouse').live('click', function() 
{
if( i > 1 ) 
{
//alert($("#addinput1").html());
$(this).parents('p').remove();
i--;
}
return false;
}
);
}
);

//////////////////////////////////////////////////////Addmore Language(Edit page)Upa/////////////////////////////////////////////////////////////// 

$('#language').live('click',function(msg){
	getlanguage();
});
function getlanguage()
	  {

	
		$.getJSON(serviceURLHR+'get.php?em_id='+id,function(data){
			
											
				   employeeslist = data.employee2;
					
					
			
					$.each(employeeslist, function(index, employeeslist) 
					{
						
												   
										
												   
										$('#spot').append('<table id="reference'+employeeslist.lan_id+'" class="catmenuitems">'+
											  
	         								 '<p><td align="left" valign="middle"><span id="lblLName"><input type="text" name="other" id="other" value="'+employeeslist.e_lang+'"><td align="left" valign="middle"><span id="lblFName">Level</span></td><td align="left" valign="middle">:</td><td align="left" valign="middle">'+
'<span id="lblLName"><select name="level1" id="level1"><option selected="selected">'+employeeslist.e_level+'</option><option>Poor</option><option>Average</option>'+
'<option>Good</option></select><input type="button" name="up" id="insert1" data-id="'+employeeslist.lan_id+'" class="pushup" value="Save" align="middle" /></a></br> <input type="button" name="dels" id="noneed" data-id="'+employeeslist.lan_id+'" class="pushdel" value="Delete" align="middle" /></span></td></p></table>');	
				});	
				
				

	
	       });
}
$('#noneed').live('click',function(msg){
	$(this).parent().parent().parent().remove();
	var eidd= $(this).attr('data-id');
	Delete2(eidd);
});
function Delete2(eidd){
	//var dataString = $('#updateproduct').serialize();

	//var id=$("#hid").val();
	var formData = new FormData($('form')[0]);
    $.ajax({
        url: serviceURLHR + 'edit.php?delll_id='+eidd,  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
			//alert(data);
			//employeeslist = data.employ1;
				
		}
	});	
}

$('#insert1').live('click',function(msg){
	var eid= $(this).attr('data-id');
	
	updatelanguage(eid);
});
function updatelanguage(eid){
	
	
	var currentRef = $('#reference'+eid);
	
	var other = currentRef.find('#other').val();
	var level1 = currentRef.find('#level1').val();
	
	/*alert(currentRef);
	alert(other);
	alert(level1);*/
   $.ajax({
  type: "POST",
  url: 'edit.php?upd_id='+eid,
  data: { other: other,level1:level1 }
})
  .done(function( msg ) {
	 // alert(msg);
    alert( "Data Saved: " );
  });


}

//////////////////////////////////////////////////////Validation(insert page)/////////////////////////////////////////////////////////////// 




function ValidateEmail(email) {
        var expr = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
        return expr.test(email);
    };


 function fnCheckPage() {
	 
	 /*
	
            if ($("#fname").val().length == 0) {
                alert("Please enter first name");
                return false;
            }
            if ($("#mname").val().length == 0) {
                alert("Please enter your middle name");
                return false;
            }

            if ($("#lname").val().length == 0) {
                alert("Please enter your last name");
                return false;
            }

            if ($("#address").val().length == 0) {
                alert("Please enter your address ");
                return false;
            }
			
            if ($('#country option:selected').val() == '---select---') {
                alert('Please select country');
                return false;
            }

            if ($('#state option:selected').val() == '---select---') {
                alert('Please select state');
                return false;
            }
			 if ($("#zip").val().length == 0) {
                alert("Please enter your zipCode ");
                return false;
            }
			if ($("#zip").val().length != 6) {
                alert("Please enter 6 digit zipCode.");
                return false;
            }
			
			
            
                if ($('#dob').val().length == 0) {
                    alert('Please enter your dob');
                    return false;
                }
           
			if ($("#phone").val().length == 0) {
                alert("Please enter your phone number");
                return false;
            }
			
				var H=$('#phone').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
				alert("Phone Number should contain Numeric Values...!");
				
				return false; 
				}

            if ($("#mobile").val().length == 0) {
                alert("Please enter your mobile");
                return false;
            }
			
				var H=$('#mobile').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
				alert("Mobile Number should contain Numeric Values...!");
				
				return false; 
				}
				

            if ($("#mobile").val().length != 10) {
                alert("Please enter 10 digit mobile no.");
                return false;
            }
			 if ($('#gender option:selected').val() == '---select---') {
                alert('Please select gender');
                return false;
            }
				
			if (!ValidateEmail($("#email").val())) {
				alert("Invalid email address.");
				return false;
			}
				/*if($("#photo").val() !=undefined)
			{
			if ($("#photo").val().length == 0) {
                alert("Please upload your photo");
                return false;
            }
			}
			if($("#resume").val() !=undefined)
			{
		if ($("#resume").val().length == 0) {
                alert("Please upload your resume");
                return false;
            }
			}*/
			
			/*if ($("#proof").val().length == 0) {
                alert("Please enter your Idproof type");
                return false;
            }
	
			if ($("#p_new").val().length == 0) {
                alert("Please upload your Idproof");
                return false;
            }
			if ($("#rname").val().length == 0) {
                alert("Please enter  Reference name");
                return false;
            }
			if ($("#relation").val().length == 0) {
                alert("Please enter  relation");
                return false;
            }
			if ($("#contact").val().length == 0) {
                alert("Please enter your contact no");
                return false;
            }
			if ($("#loc").val().length == 0) {
                alert("Please enter your location");
                return false;
            }*/
			/*if($('input[name=pa]:checked').length<=0)
			{
			 alert("No radio checked")
			 return false;
			}
			if ($("#jloc").val().length == 0) {
                alert("Please Select Workplace");
                return false;
            }
			  if ($('#date').val().length == 0) {
                    alert('Please enter Date');
                    return false;
                }
			if ($("#day").val().length == 0) {
                alert("Please enter your Working Days");
                return false;
            }
			if($('input[name=level]:checked').length<=0)
			{
			 alert("No radio checked")
			 return false;
			}
			if ($("#course").val().length == 0) {
                alert("Please Select your course");
                return false;
            }
			if($('input[name=se]:checked').length<=0)
			{
			 alert("No radio checked")
			 return false;
			}
			if ($("#refer").val().length == 0) {
                alert("Please enter  Company name");
                return false;
            }
			if ($("#phno").val().length == 0) {
                alert("Please enter  Phone Number");
                return false;
            }
			var H=$('#phno').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
				alert("Phone Number should contain Numeric Values...!");
				
				return false; 
				}
				if (!ValidateEmail($("#email1").val())) {
				alert("Invalid email address.");
				return false;
			}
			
			
			if ($("#posi").val().length == 0) {
                alert("Please enter  position");
                return false;
            }
			if ($("#sal").val().length == 0) {
                alert("Please enter  Salary");
                return false;
            }
			if ($("#rfl").val().length == 0) {
                alert("Please enter  Reason for leaving");
                return false;
            }
			alert('rty');*/
            insert();
		}
$('#push').live('click',function(msg){
	updateMenuItems();
});
/*function fnCheckPage1()
{
	  if ($("#mobile").val().length == 0) {
                alert("Please enter your mobile");
                return false;
            }
			
				var H=$('#mobile').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
				alert("Mobile Number should contain Numeric Values...!");
				
				return false; 
				}
				

            if ($("#mobile").val().length != 10) {
                alert("Please enter 10 digit mobile no.");
                return false;
            }
if (!ValidateEmail($("#email").val())) {
				alert("Invalid email address.");
				return false;
			}
		updateMenuItems();	
}*/

function updateMenuItems(){
	//var dataString = $('#updateproduct').serialize();
var id = getUrlVars()["employ_id"];

	//var id=$("#hid").val();
	$('#busy').show();
	var formData = new FormData($('form')[0]); 
    $.ajax({
        url: serviceURLHR + 'update.php?hid='+id,  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
				/*if(data=='success'){*/
				//alert(data);
				$('#busy').hide();
				alert("Item successfully updated.");
				
				//window.location="profile-view.php?employ_id="+id;
			/*}*/
		}
	});	
}



//////////////////////////////////////////////////////country selection///////////////////////////////////////////////////////////////
 selectcountry();

function selectcountry()
{

var serviceUR = 'http://192.168.1.12/addHRM/mookadanadmin/';

$.ajax({
   url: serviceURLHR+"get.php",
   success: function(data){ 
     $("#country").html(data);
	
   }
 });
}




function selectcountry1()
{

var serviceUR = 'http://192.168.1.12/addHRM/mookadanadmin/';

$.ajax({
   url: serviceURLHR+"get.php",
   success: function(data){ 
     $("#country1").html(data);
	setTimeout(function(){ $("#country1").val(country_selected); },100);
	
   }
 });
}

loadBranch();

function loadBranch(){
	$.getJSON(serviceURLHR + 'branch.php?action=load',function(data){
		branch = data.branch;
		
		$.each(branch, function(index, branch) {
									 
							$('#branch').append('<option value="'+branch.branch_id+'">'+branch.branch_name	+'</option>');
							
		});	
	});
}

function selectstatus()
{
		$.getJSON(serviceURLHR + 'branch.php?action=loadstst',function(data){
		branch = data.branch;
		
		$.each(branch, function(index, branch) {
									 
							$('#empstat2').append('<option value="'+branch.id+'">'+branch.emply_stat	+'</option>');
							
		});	
	});
}
function loadXMLDoc(str)
{

var xmlhttp;
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").innerHTML=xmlhttp.responseText;
	$('#state').val(state_selected);
    }
	}
xmlhttp.open("GET",serviceURLHR +"list.php?id="+str,true);
xmlhttp.send();
}

//////////////////////////////////////////////////////////////////////////////////

selectdesig();

function selectdesig()
{ 
$.ajax({
   url: serviceURLHR+"edit.php",
   success: function(data){ 
     $("#pos").html(data);
	
   }
 });
}




//////////////////////////////////////////////////////////////////////////////////




$(function() 
{
	
var addDiv = $('#fetch');
var i = $('#fetch p').size() + 1;
$('#level2').live('click', function() 
{
	
	//alert("hai");
$('<p><label for="course">course</label><input type="text" name="course" id="course" AUTOCOMPLETE=OFF /><a href="#" id="notneed">Remove</a> </p>').appendTo(addDiv);
i++;
return false;
}
);
$('#notneed').live('click', function() 
{
	
if( i > 1 ) 
{
//alert($("#addinput1").html());
$(this).parents('p').remove();
i--;
}
return false;
}
);
}
);
////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
$(function() 
{
	
var addDiv = $('#fetch');
var i = $('#fetch p').size() + 1;
$('#c').live('click', function() 
{
	
	//alert("hai");
$('<p><label for="course">course</label><input type="text" name="course" id="course" AUTOCOMPLETE=OFF /><a href="#" id="notneed1">Remove</a> </p>').appendTo(addDiv);
i++;
return false;
}
);
$('#notneed1').live('click', function() 
{
	
if( i > 1 ) 
{
//alert($("#addinput1").html());
$(this).parents('p').remove();
i--;
}
return false;
}
);
}
);


///////////////////////////////////////////////////


$(function() 
{
	//var k=0;
var addDiv = $('#insert');
var i = $('#insert p').size() + 1;
$('#cert').live('click', function() 
{
	
	
$('<p><label for="course">course</label><input type="text" name="cert[]" id="cert" AUTOCOMPLETE=OFF /><a href="#" id="cert"><img src="images/icon-add.png" width="20" height="15" title="Add More" /></a></br><a href="#" id="drop">Remove</a></span></p>').appendTo(addDiv);i++;// k++;
return false;
}

);
$('#drop').live('click', function() 
{
if( i > 1 ) 
{
//alert($("#addinput1").html());
$(this).parents('p').remove();
i--;
}
return false;
}
);
}
);












///////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////LiSt Item(Edit page)/////////////////////////////////////////////////////////////// 






var id = getUrlVars()["employ_id"];
//alert(id);
function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}




UpdateEmployee();
viewEmployee();
var employeeslist;

	function viewEmployee()
 	{
		
		
		$('#busy').show();
		$.getJSON(serviceURLHR+'edit.php?employ_id='+id,function(data){
											
		   employeeslist = data.employ;
		   $.each(employeeslist, function(index, employeeslist) 
			{
				
								   
				
										   
														//$('#hid').html(id);
														$('#name').html(employeeslist.e_fname+" "+employeeslist.e_lname);
														$('.fname').val(employeeslist.e_fname);
														$('.mname').val(employeeslist.e_mname);
														$('.lname').val(employeeslist.e_lname);
														$('#e_id').val(id);
														$('#deviceid').html(employeeslist.device_id);
														
														$('#address').html(employeeslist.e_add);
														$('#country').html(employeeslist.country_name);
														$('#state1').html(employeeslist.state);
														$('#zip').html(employeeslist.e_zip);
														$('#dob').html(employeeslist.e_dob);
														$('#phone').html(employeeslist.e_phone);
														$('#mobile').html(employeeslist.e_mob); 
														$('#gender').html(employeeslist.e_gender);
														$('#email').html(employeeslist.e_mail);
														$('#branchhidden').val(employeeslist.branchid);
														$('#depthidden').val(employeeslist.departid);
														$('#desighidden').val(employeeslist.e_post);
														$('#immsuperhidden').val(employeeslist.imd_supervisor_id);
														$('#branch').html(employeeslist.branch_name); 
														$('#dept').html(employeeslist.depart_name);
														$('#desig').html(employeeslist.desig_name);
														$('#immsuper').html(employeeslist.immediatesupervisr);
														$('.basicpay').html(employeeslist.emp_basic_pay);
														
														
														$('.overtime').html(employeeslist.over_time);
														selectcountry1();
														country_selected = employeeslist.e_country;
														state_selected =employeeslist.e_state;
														selectstatus();
														//setTimeout(function(){ $('#country1').val(employeeslist.e_country) },800);;
														loadXMLDoc(employeeslist.e_country);
														
													//	setTimeout(function(){ $('#state').val(); },800);
														
														if(employeeslist.photo=='')
				{
					 photo='noimg.jpg';
				}else{ 
				        if(employeeslist.e_gender=='Male' && employeeslist.photo=='noimg.jpg')
				        {
					     photo='noimg.jpg'; 
						  
				        }
				        else if(employeeslist.e_gender=='Female' && employeeslist.photo=='noimg.jpg')
				        { 
					     photo='Female.PNG'; 
				         }
						 else
						 {
			             photo=employeeslist.photo;	}
				}	
														
														$('#images').html('<span id="doc"><a href="'+serviceURLHR+'download_image.php?filename='+employeeslist.photo+'" class="pro-icon-01">Photo</a></span>');
														 $('.profile-photo').html('<img src="'+basicPATH+'addHRM/upload/image/'+photo+'" hei		ght="250" width="220">');
														 $('#profimage').html('<img src="'+basicPATH+'addHRM/upload/image/'+employeeslist.photo+'" height="250" width="220">'+
																			   '<img src="images/edit.png" style="z-index:20; position:absolute; top:10px;left:200px; display:none;" class="edit-profileimage">');
														 $('#resumelists').html('<span><a  href="'+serviceURLHR+'download_resume.php?filename='+employeeslist.resume+'" title="'+employeeslist.resume+'" style="height:5px,width:5px" class="pro-icon-02">Resume</a></span>');
													        $('#filetype').html(employeeslist.filetype);
														  	//$('#proof').val(employeeslist.filetype);
															 $('#id_proofs').html('<span><a  href="'+serviceURLHR+'download_image.php?filename='+employeeslist.file+'" title="'+employeeslist.file+'" style="height:5px,width:5px" class="pro-icon-03">Address Proof</a></span>');
															 $('#rname').html(employeeslist.e_rname);
															 
															 $('#relation').html(employeeslist.e_relation);
															 $('#contact').html(employeeslist.e_contact);
															 $('#loc').html(employeeslist.e_rlocation);
															 $('#e_post').html(employeeslist.desig_name);
																
															 $('#loc1').html(employeeslist.e_plocation);
															 $('#date').html(employeeslist.e_dstart);
															 $('#day').html(employeeslist.e_dweek);
															 $('#e_qualification').html(employeeslist.e_qualification);
																														
															 $('#course').html(employeeslist.e_course);
															 $('#username').html(employeeslist.username);
															 $('#password').html(employeeslist.password);
															  
															
															$('#refer').html(employeeslist.e_english);
															
															 $('#emp').html(employeeslist.refer);
															 $('#address2').html(employeeslist.emp);
															 $('#phno').html(employeeslist.phno);
															 $('#email1').html(employeeslist.email);
															 $('#posi').html(employeeslist.posi);
															
															 $('#sal').html(employeeslist.sal);
															 
															 $('#rfl').html(employeeslist.rfl);
															 $('#from').html(employeeslist.from);
															 $('#to').html(employeeslist.to);
															 
															 $('#emp_id').html(employeeslist.employee_id);
															 $('#dt_join').html(employeeslist.date_join);
															 $('#blood_grp').html(employeeslist.blood_group);
															 $('#pf_ac_no').html(employeeslist.pf_accnum);
															 $('#pf_nominee').html(employeeslist.pf_nominee);
															 $('#esi_details').html(employeeslist.esi_details);
															 
															 $('#history_dt_join').html(employeeslist.hist_dt_join);
															 $('#emptype').html(employeeslist.hist_emptype);															 
															 $('#dt_prev_pay_revision').html(employeeslist.hist_dt_prev_pay);
															 $('#dt_pay_revised').html(employeeslist.hist_dt_pay);
															 $('#comp_probation').html(employeeslist.hist_comp_prob);
															 
															 $('#accountname').html(employeeslist.e_account);
															 
															 $('#bname').html(employeeslist.e_bank);
															 $('#accountno').html(employeeslist.e_accountno);
															  
															 $('#baddress').html(employeeslist.e_bankadd);
															 
															 $('#bankcode').html(employeeslist.e_code);
															 $('#editbtn').html(' <a  href="employee_editform.php?employ_id='+id+'"><button id="registerButton" type="button" class="color-button3">Add Details</button></a>');
							
							
						//if(!employeeslist.e_rname){
							//$('.work-referances').hide();	
						//}
							
										
		});	

		
		loadEducation();
		loadLanguage();
		loadExperience();
		$('#busy').hide();
	});
	}
	
	function loadExperience(){
		$.getJSON(serviceURLHR+'branch.php?employ_id='+id+'&action=exp',function(data){
										
			   explist = data.wk_exp;
			   if(data.wk_exp!=null){
			   $('#addinput2').html('');
			   }
			   $.each(explist, function(index, explist) 
				{
					
					$('#addinput2').append('<div style="border:1px dotted #ddd; margin:10px 0 10px 0; class="exp_bdr" "></div><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Company Name</label></td><td><input type="text" name="refer[]" id="refer"  AUTOCOMPLETE=OFF  value="'+explist.refer+'"/><br /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Address</label></td><td><textarea name="emp[]" id="emp">'+explist.emp+'</textarea></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Contact No</label></td><td><input type="text" name="phno[]" id="phno"  AUTOCOMPLETE=OFF value="'+explist.phno+'"  /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Email</label></td><td><input type="text" name="email1[]" id="email1" AUTOCOMPLETE=OFF value="'+explist.email+'"/></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Position</label></td><td><input type="text" name="posi[]" id="posi" AUTOCOMPLETE=OFF value="'+explist.posi+'" /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Salary</label></td><td><input type="text" name="sal[]" id="sal" AUTOCOMPLETE=OFF value="'+explist.sal+'" /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Reason for leaving</label></td><td><input type="text" name="rfl[]" id="rfl" AUTOCOMPLETE=OFF value="'+explist.rfl+'"/></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">From</label></td><td><input type="text" id="from" name="from[]"  class="edit_form_date" AUTOCOMPLETE=OFF  value="'+explist.from+'"/></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top"  class="form-padd-01"><label for="label">To</label></td><td><input type="text" id="to" name="to[]" class="edit_form_date" AUTOCOMPLETE=OFF value="'+explist.from+'"/></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td colspan="2"><a href="#" id="remNew2">Remove</a></td></tr></table>');
					
					
				});
		});	   
	}
    function loadLanguage()
    {
		var vars = [];
	    $.getJSON(serviceURLHR+'branch.php?employ_id='+id+'&action=lang',function(data){
									
		   langlist = data.lang;
		   if(data.lang==null){
			  selectlanguage(); 
			  var $orDiv = $('.new-category:last').after($('#clone').clone().removeAttr('id').show());
		   }
		   $.each(langlist, function(index, langlist) 
			{
				
				if(langlist.lang_rd==1)
					 var rd_chk	= "checked";
				 else
					 var rd_chk	= " ";
					 
				if(langlist.lang_wt==1)
					 var wt_chk	= "checked";
				 else
					 var wt_chk	= " ";	 
				
				if(langlist.lang_sk==1)
					 var sk_chk	= "checked";
				 else
					 var sk_chk	= " ";
				 
				$('.list_lang').append('<tr><td width="20%" align="left" valign="top">&nbsp;</td><td align="left" valign="top"><select name="lang[]" id="lang'+index+'" ><option value="">--select--</option></select></td><td align="left" valign="middle"><input type="checkbox" name="radio_eng_rd[]" id="radio_eng_rd" value="1"'+rd_chk+'/></td><td align="left" valign="middle"><input type="checkbox" name="radio_eng_wt[]" id="radio_eng_wt" value="1"'+wt_chk+' /></td><td align="left" valign="middle"><input type="checkbox" name="radio_eng_sk[]" id="radio_eng_sk" value="1"'+sk_chk+' /></td><td><a href="#" class="remLang">Remove</a></td></tr>');
				
				selectlanguage();
				
				
				vars.push(langlist.lang_id);
				
				
			});
		   /* showing selected languages*/
			for(var i = 0; i < vars.length; i++)
			{
					//alert("loop");
					language_selected = vars[i];
					lang_index		  = i;
					setTimeout(languageselected(),10000);
			}
			
		}); 
	   
	   
   }
	
	
	function loadEducation(){
		$.getJSON(serviceURLHR+'branch.php?employ_id='+id+'&action=edu',function(data){
										
			   edulist = data.educ;
			   if(data.educ!=null){
			  	 $('#edu').html('');
			   }
			   $.each(edulist, function(index, edulist) 
				{
					
					
					$('#edu').append('<div style="border:1px dotted #ddd; margin:10px 0 10px 0; class="bdr" "></div><table width="100%" border="0" cellspacing="0" cellpadding="0"  ><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Course</label></td><td><input name="course[]" type="text" value="'+edulist.course+'" /><br /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Specialization</label></td><td><input name="spl[]" type="text"  value="'+edulist.spl+'" /></td></tr><tr><td colspan="2" height="8"></td> </tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">University/Institute</label></td><td><input name="unv[]" type="text"  value="'+edulist.unv+'" /></td> </tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Year</label></td><td><input name="yr[]" type="text" value="'+edulist.yr+'" /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Percentage</label></td><td><input name="pcntg[]" type="text"  value="'+edulist.pcntg+'"/></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td colspan="2"><a href="#" id="remEdu">Remove</a></td></tr></table>');
					
				});
		});	   
	}
		   
	function UpdateEmployee()
	  {
		  selectstatus();
		  
		 //alert(id);
		//alert(serviceURLHR);
		$.getJSON(serviceURLHR+'edit.php?employ_id='+id,function(data){
					
					
				   employeeslist = data.employ; 
					
					$.each(employeeslist, function(index, employeeslist) 
					{
							
						// alert('HR/upload/thumb/'+employeeslist.photo);
														$('#hid').val(id);
														$('#fname').val(employeeslist.e_fname);
														$('#mname').val(employeeslist.e_mname);
														$('#lname').val(employeeslist.e_lname);
														$('#address').val(employeeslist.e_add);
														$('#country').val(employeeslist.country_name);
														$('#state').val(employeeslist.state);
														$('#zip').val(employeeslist.e_zip);
														$('#dob').val(employeeslist.e_dob);
														$('#phone').val(employeeslist.e_phone);
														$('#mobile').val(employeeslist.e_mob); 
														$('#gender1').val(employeeslist.e_gender);
														$('#email').val(employeeslist.e_mail);
														
														if(employeeslist.overtime_status=='1')
														{
															$('#overtime').prop('checked', true);
														}
														
														$('#image').html('<img src="'+basicPATH+'addHRM/upload/thumb/'+employeeslist.photo+'" style="height:5px,width:5px">');
														 $('#resumelist').html('<a style="color:#990000" href="'+basicPATH+'addHRM/mookadanadmin/download_resume.php?filename='+employeeslist.resume+'" title="'+employeeslist.resume+'" style="height:5px,width:5px">Download Resume</a><br/>');
													
														  	//$('#proof').val(employeeslist.filetype);
															 //$('#id_proof').html('<a style="color:#990000" href="'+servicesUrlIm+'upload/image/'+employeeslist.file+'" title="'+employeeslist.file+'" style="height:5px,width:5px">Download Proof</a><br/>');
															 $('#rname').val(employeeslist.e_rname);
															 
															 $('#relation').val(employeeslist.e_relation);
															 $('#contact').val(employeeslist.e_contact);
															  $('#loc').val(employeeslist.e_rlocation);
															 
																if(employeeslist.e_post=="manager")
																{
																	 $('#rad').prop('checked', true);
																}
																else if(employeeslist.e_post=="supervisor")
																{
																	
																 $('#radio2').prop('checked', true);
																}
																else if(employeeslist.e_post=="kitchensuper")
																{
																	 $('#radio3').prop('checked', true);
																}
																else if(employeeslist.e_post=="leadcook")
																{
																	
																 $('#radio4').prop('checked', true);
																}
																else if(employeeslist.e_post=="cook")
																{
																	 $('#radio5').prop('checked', true);
																}
																else if(employeeslist.e_post=="Kitchenhelper")
																{
																	 $('#radio6').prop('checked', true);
																}
																else
																{
																	 $('#radio7').prop('checked', true);
																}
															
															  $('#jloc').val(employeeslist.e_plocation);
															  $('#date').val(employeeslist.e_dstart);
																$('#day').val(employeeslist.e_dweek);
																
																if(employeeslist.e_qualification=="10th"){
																	
																	 $('#level').prop('checked', true);
																	 
																}else if(employeeslist.e_qualification=="plus2"){
																	
																 $('#level1').prop('checked', true);
																 
																}else if(employeeslist.e_qualification=="graduation"){
																	
																	 $('#level4').prop('checked', true);
																	 
																}else {
																	$('#level3').prop('checked', true);
																}
																
																
															   $('#course').val(employeeslist.e_course);
															    if(employeeslist.e_eng_rd=="read")
																{
																  $('#radio_eng1').prop('checked', true);
																}
																if(employeeslist.e_eng_wt=="write")
																{
																  $('#radio_eng2').prop('checked', true);
																}
																if(employeeslist.e_eng_sp=="speak")
																{
																  $('#radio_eng3').prop('checked', true);
																}
																if(employeeslist.e_hin_rd=="read")
																{
																	$('#radio_hin1').prop('checked', true);
																}
																if(employeeslist.e_hin_wt=="write")
																{
																  $('#radio_hin2').prop('checked', true);
																}
																if(employeeslist.e_hin_sp=="speak")
																{
																  $('#radio_hin3').prop('checked', true);
																}
																if(employeeslist.e_mal_rd=="read")
																{																	
																  $('#radio_mal1').prop('checked', true);
																}
																if(employeeslist.e_mal_wt=="write")
																{																	
																  $('#radio_mal2').prop('checked', true);
																}
																if(employeeslist.e_mal_sp=="speak")
																{																	
																  $('#radio_mal3').prop('checked', true);
																}
																if(employeeslist.e_tam_rd=="read")
																{																	
																  $('#radio_tam1').prop('checked', true);
																}
																if(employeeslist.e_tam_wt=="write")
																{																	
																  $('#radio_tam2').prop('checked', true);
																}
																else(employeeslist.e_tam_sp=="speak")
																{																	
																  $('#radio_tam3').prop('checked', true);
																}
																
																
														//	$('#se').live('change',function(){
//																$('#se'):checkbox;
//																							   
//																	});
															
													$('#refer').val(employeeslist.refer);
															
															 $('#emp').val(employeeslist.emp);
															 
															 $('#phno').val(employeeslist.phno);
															 $('#email1').val(employeeslist.email);
															 $('#posi').val(employeeslist.posi);
															
															 $('#sal').val(employeeslist.sal);
															 
															 $('#rfl').val(employeeslist.rfl);
															 $('#from').val(employeeslist.from);
															 $('#to').val(employeeslist.to);
															 
															 
															 $('#emp_id').val(employeeslist.employee_id);
															 var hh=employeeslist.emp_status;
															 $('#empstat2').val(hh);
													
														  //$('.empstat2').val('1');
										   //$('#empstat').val(employeeslist.emp_status).attr("selected", "selected");
									
															 $('#dt_join').val(employeeslist.date_join);
															 $('#blood_grp').val(employeeslist.blood_group);
															 $('#pf_ac_no').val(employeeslist.pf_accnum);
															 $('#pf_nominee').val(employeeslist.pf_nominee);
															 $('#esi_details').val(employeeslist.esi_details);
															 
															 $('#history_dt_join').val(employeeslist.hist_dt_join);
															 $('#emptype1').val(employeeslist.hist_emptype);
															 $('#dt_prev_pay_revision').val(employeeslist.hist_dt_prev_pay);
															 $('#dt_pay_revised').val(employeeslist.hist_dt_pay);
															 $('#comp_probation').val(employeeslist.hist_comp_prob);
															 
															 $('#accountname').val(employeeslist.e_account);
															 
															 $('#bank').val(employeeslist.e_bank);
															 $('#accountno').val(employeeslist.e_accountno);
															  
																$('#bankadd').val(employeeslist.e_bankadd);
															 
															 $('#bankcode').val(employeeslist.e_code);
															 
										if(!employeeslist.phno){
											$('.work-experiance').hide();	
										}
		});	
				

	
	       });
}


//////////////////////////////////////////////////////List Idproof(edit page)/////////////////////////////////////////////////////////////// 


	getmore();
	var employees;
function getmore()
	  {

		
		$.getJSON(serviceURLHR+'updateidproof.php?emp_id='+id,function(data){
			
					
				   employees = data.employ;
									
					$.each(employees, function(index, employees) 
					{
										   
										$('#paste').append('<p><span id="lblHeadline"><input type="hidden" name="ptype1" id="proof1" value="'+employees.idid+
											 '"><label for="username">ID Prooftype</label><input type="text" name="ptype[]" id="proof" value="'+employees.filetype+'"/><label for="username">Upload id proof</label><span id="lblHeadline"><a style="color:#990000" href="'+basicPATH+'addHRM/upload/image/'+employees.file+'" title="'+employeeslist.file+'" style="style="color:#3366FF"">Download Proof</a><input type="file" id="idproof" size="40" name="idproof[]" value="'+employees.file+'" placeholder="I am New" /><input type="button" name="sub2" id="push1" data-id="'+employees.idid+'" class="pushbtn1" value="submit" style="width:50px"/><input type="button" name="sub2" id="closs" data-id="'+employees.idid+'" class="pushbtn1" value="Delete" style="width:50px"/></p>');	
							});       
							
				

	
	       });
}
 
	$('#closs').live('click',function(){
		$(this).parent().parent().parent().remove();
	var e_id= $(this).attr('data-id');
	Delete1(e_id);
});

function Delete1(e_id){
	//var dataString = $('#updateproduct').serialize();

	//var id=$("#hid").val();
	var formData = new FormData($('form')[0]);
    $.ajax({
        url: serviceURLHR + 'edit.php?dell_id='+e_id,  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
			//alert(data);
			employeeslist = data.employ1;
				
		}
	});	
}

$('#push1').live('click',function(msg){
	
	var eid= $(this).attr('data-id');
	updateMen(eid);
});


function updateMen(eid){
	//var dataString = $('#updateproduct').serialize();
//alert("hai");
	//var id=$("#hid").val();
	var formData = new FormData($('form')[0]);
    $.ajax({
        url: serviceURLHR + 'addmore.php?upd_id='+eid,  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
			//alert(data);
			employeeslist = data.employ1;
				
		}
	});	
}



$(document).ready(function()
{ 
	$('#van').live('click',function(){
		$(this).parent().remove();
	
			
	})
	 
   		
 	
	 
	
});
$('#up').live('click',function(msg){
	var eid2= $(this).attr('data-id');
	
	update(eid2);
});
function update(eid2){
	
	
	var currentRef = $('#reference'+eid2);
	
	var refer = currentRef.find('#refer').val();
	var emp = currentRef.find('#emp').val();
	var phno = currentRef.find('#phno').val();
	var email = currentRef.find('#email1').val();
	var from = currentRef.find('#from').val();
	var to = currentRef.find('#to').val();
	var posi = currentRef.find('#posi').val();
	var sal = currentRef.find('#sal').val();
	var rfl = currentRef.find('#rfl').val();
	/*alert(refer);
	alert(emp);
	alert(phno);
	alert(email);
	alert(from);
	alert(to);
	alert(posi);
	alert(sal);
	alert(rfl);*/
	
   $.ajax({
  type: "POST",
  url: "edit.php?up_id="+eid2,
  data: { refer: refer,emp:emp, phno:phno,email:email,from:from,to:to,posi:posi,sal:sal,rfl:rfl }
})
  .done(function( msg ) {
	 // alert(msg);
    alert( "Data Saved: " );
  });


}

$('#registerButton').live('click',function(msg){
	
	var eid= $(this).attr('data-id');
	updateMenu1(eid);
});


function updateMenu1(eid){
	//var dataString = $('#updateproduct').serialize();
//alert("hai");
	//var id=$("#hid").val();
	var formData = new FormData($('form')[0]);
    $.ajax({
        url: serviceURLHR + 'addmore.php?upd_id='+eid,  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
			//alert(data);
			employeeslist = data.employ1;
				
		}
	});	
}


//////////////////////////////////////////////////////Addmore (edit page)/////////////////////////////////////////////////////////////// 

$(function() 
{
	
var addDiv = $('#here');
var i = $('#here p').size() + 1;
$('#click').live('click', function() 
{
	
	//alert("hai");
$('<p><input type="text" name="ptype[]" id="proof"/><input type="file" id="idproof[]" size="40" name="idproof[]" value="" placeholder="I am New" /><a href="#" id="cut">Remove</a> </p>').appendTo(addDiv);
i++;
return false;
}
);
$('#cut').live('click', function() 
{
	
if( i > 1 ) 
{
//alert($("#addinput1").html());
$(this).parents('p').remove();
i--;
}
return false;
}
);
}
);
$('#finish').live('click',function(msg){
	proofinsert();
});


function proofinsert(){
	//var dataString = $('#frm1').serialize();
	var formData = new FormData($('form')[0]);
	
    $.ajax({
        url: serviceURLHR + 'edit.php?emp_id='+id,  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
				/*if(data=='success'){
				alert("Item successfully inserted.");
				window.location="list.html";
			}*/
		}
	});	
}


//////////////////////////////////////////////////////Add more Refernce(insert page)/////////////////////////////////////////////////////////////// 

$(function() {

var addDiv = $('#fillup');

var i = $('#fillup p').size() + 1;

 

$('#more').live('click', function() {
	//alert($("#addinput2").html());

$('<p><tr><td>Company Name</td><td>:</td><td><span id="lblGender"><input type="text" name="work[]" id="work"/></span></td></tr><tr><td><span id="lbldb">Address</span></td><td>:</td><td><span id="lblDOB"><textarea name="emp[]" id="emp" /></span></td></tr><tr><td height="28" align="left" valign="middle"><span id="lblcomadd">Telephone</span></td><td align="left" valign="middle">:</td><td align="left" valign="middle"><span id="lblAddress"><input type="text" name="Contact[]" id="Contact" /></span></td></tr><tr><td height="28" align="left" valign="middle"><span id="lblcomadd">Email</span></td><td align="left" valign="middle">:</td><td align="left" valign="middle"><span id="lblAddress"><input type="text" name="send[]" id="send" /></span></td><td height="28" align="left" valign="middle"><span id="lblcomadd">From</span></td><td align="left" valign="middle">:</td><td align="left" valign="middle"><span id="lblAddress"><input type="date" id="source" name="source[]" /></span></td><td width="1%" height="28" align="left" valign="middle"><span id="lblcomadd">To</span></td><td width="0%" align="left" valign="middle">:</td><td width="14%" align="left" valign="middle"><span id="lblAddress"><input type="date" id="dest" name="dest[]" /></span></td></tr><tr><td><span id="lblcityy">Position</span></td><td>:</td><td><span id="lblCity"><input type="text" name="place[]" id="place" /></span></td><td>Salary</td><td>:</td><td><span id="lblPinCode"><input type="text" name="pay[]" id="pay" /></span></td><td><span id="lblpnumber">Reason for leaving</span></td><td>:</td><td><span id="lblPhone"><input type="text" name="leave[]" id="leave" /><a href="#" id="destro"><img src="images/closebox.png" width="20" height="15" title="Delete" /></a></span></td></tr></p>').appendTo(addDiv);
i++;

 

return false;

});

 

$('#destro').live('click', function() {


$(this).parent().parent().remove();


return false;

});

});	 
$('#subnet').live('click',function(msg){
	updateMenu();
});


function updateMenu(){
	//var dataString = $('#updateproduct').serialize();
//alert("hai");
	//var id=$("#hid").val();
	var formData = new FormData($('form')[0]);
    $.ajax({
        url: serviceURLHR + 'edit.php?e_id='+id,  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
			//alert(data);
			employeeslist = data.employ1;
				
		}
	});	
}
$('#del').live('click',function(msg){
	$(this).parent().parent().parent().remove();
	var eid= $(this).attr('data-id');
	Delete(eid);
});
function Delete(eid){
	//var dataString = $('#updateproduct').serialize();

	//var id=$("#hid").val();
	var formData = new FormData($('form')[0]);
    $.ajax({
        url: serviceURLHR + 'edit.php?del_id='+eid,  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
			//alert(data);
			employeeslist = data.employ1;
				
		}
	});	
}


$(function() 
{

var addDiv = $('#addproductinput1');
var i = $('#addproductinput1 p').size() + 1;
$('#addproductNew11').live('click', function() 
{
	
	
$('<p><label for="noofresumes" class="form-fld-width-2">Document No</label><input type="text" name="docnum[]" id="docnum" class="form-fld-width-3"/><label for="website" class="form-fld-width-2">Wt Carried</label><input name="wtcarried[]" id="wtcarried" class="form-fld-width-3"/><a href="#" id="remproductNeww">Remove</a> </p>').appendTo(addDiv);
i++;
return false;
}
);
$('#remproductNeww').live('click', function() 
{
if( i > 1 ) 
{

$(this).parent('p').remove();
i--;
}
return false;
}
);
}
);

$(function() 
{

var addDiv = $('#addinput1');
var i = $('#addinput1 p').size() + 1;
$('#addNew11').live('click', function() 
{
	
	
$('<p><label for="username">Attribute</label><input type="text" id="attributename[]" size="40" name="attributename[]" value="" placeholder="Add Attribute" style="width:150px;"/><select name="attributetype[]" id="attributetype" style="width:150px;"><option value="Personel" >personel</option><option value="functional" >Functional</option></select><a href="#" id="remNeww">Remove</a> </p>').appendTo(addDiv);
i++;
return false;
}
);
$('#remNeww').live('click', function() 
{
if( i > 1 ) 
{

$(this).parent('p').remove();
i--;
}
return false;
}
);
}
);


//////////////////////////////////////////////////////Addmore Language(insert page)/////////////////////////////////////////////////////////////// 

$(function() 
{
	
	//var k=0;
var addDiv = $('#radiodiv');
var i = $('#radiodiv p').size() + 1;
$('#radio').live('change', function() 
{
$('<p><label for="Language">Language</label><input type="text" name="other[]" id="other"/><label for="Level">Level</label>'+

'<select name="level1[]" id="level1"><option selected="selected">---select---</option><option>Poor</option><option>Average</option>'+
'<option>Good</option></select><a href="#" id="radio"><img src="images/icon-add.png" width="20" height="15" title="Add More" /></a></br><a href="#" id="withdrow">Remove</a></span></p>').appendTo(addDiv);i++;// k++;
return false;
}

);
$('#withdrow').live('click', function() 
{
if( i > 1 ) 
{
//alert($("#addinput1").html());
$(this).parents('p').remove();
i--;
}
return false;
}
);
}
);


//////////////////////////////////////////////////////Addmore Reference(insert page)/////////////////////////////////////////////////////////////// 

$(function() {

var addDiv = $('#addinput2');

var i = $('#addinput2 p').size() + 1;

 

$('#addNew2').live('click', function() {
	alert($("#addinput2").html());
	
$('#addinput2').append('<div style="border:1px dotted #ddd; margin:10px 0 10px 0; class="exp_bdr" "></div><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Company Name</label></td><td><input type="text" name="refer[]" id="refer"  AUTOCOMPLETE=OFF /><br /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Address</label></td><td><textarea name="emp[]" id="emp" /></textarea></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Contact No</label></td><td><input type="text" name="phno[]" id="phno"  AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Email</label></td><td><input type="text" name="email1[]" id="email1" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Position</label></td><td><input type="text" name="posi[]" id="posi" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Salary</label></td><td><input type="text" name="sal[]" id="sal" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Reason for leaving</label></td><td><input type="text" name="rfl[]" id="rfl" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">From</label></td><td><input type="text" id="from" name="from[]"  class="edit_form_date" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top"  class="form-padd-01"><label for="label">To</label></td><td><input type="text" id="to" name="to[]" class="edit_form_date" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td colspan="2"><a href="#" id="remNew2">Remove</a></td></tr></table>');

i++;

 

return false;

});

 

$('#remNew2').live('click', function() {

	$(this).parents('table').prev('div').remove();									
		$(this).parents('table').remove();
		var count = $('#addinput2').children('table').length;
		if(count==0)
		{
				$('#addinput2').append('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Company Name</label></td><td><input type="text" name="refer[]" id="refer"  AUTOCOMPLETE=OFF /><br /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Address</label></td><td><textarea name="emp[]" id="emp" /></textarea></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Contact No</label></td><td><input type="text" name="phno[]" id="phno"  AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Email</label></td><td><input type="text" name="email1[]" id="email1" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Position</label></td><td><input type="text" name="posi[]" id="posi" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Salary</label></td><td><input type="text" name="sal[]" id="sal" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Reason for leaving</label></td><td><input type="text" name="rfl[]" id="rfl" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">From</label></td><td><input type="text" id="from" name="from[]"  class="edit_form_date" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top"  class="form-padd-01"><label for="label">To</label></td><td><input type="text" id="to" name="to[]" class="edit_form_date" AUTOCOMPLETE=OFF /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td colspan="2"><a href="#" id="remNew2">Remove</a></td></tr></table>');

		}	

});

});	 


/*$(function() 
{
	
var addDiv = $('#resum');
var i = $('#resum p').size() + 1;
$('#res').live('click', function() 
{
	
	
$('<p> <label for="country">Upload Resume</label><input type="file" id="resume" size="20" name="resume"  value="" placeholder="Input Value" /><a href="#" id="rems">Remove</a> </p>').appendTo(addDiv);
i++;
return false;
}
);
$('#rems').live('click', function() 
{
if( i > 1 ) 
{
//alert($("#addinput1").html());
$(this).parents('p').remove();
i--;
}
return false;
}
);
}
);*/
$(function() 
{
	
var addDiv = $('#poto');
var i = $('#poto p').size() + 1;
$('#changes').live('click', function() 
{
	
	
$('<p><label for="country">Upload Photo</label> <input type="file" name="photo" id="photo"/><a href="#" id="dels">Remove</a> </p>').appendTo(addDiv);
i++;
return false;
}
);
$('#dels').live('click', function() 
{
if( i > 1 ) 
{
//alert($("#addinput1").html());
$(this).parents('p').remove();
i--;
}
return false;
}
);
}
);


function ValidateEmail(email) {
        var expr = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
        return expr.test(email);
    };



function validation_employeeform(){/*
	
	var validations='';
			if ($("#fname").val().length == 0) {
				validations='Please enter first name\n';
               // alert("Please enter first name");
              //  return false;
            }
            if ($("#mname").val().length == 0) {
				validations+='Please enter middle name\n';              
				 // alert("Please enter your middle name");
                //return false;
            }

            if ($("#lname").val().length == 0) {
				validations+='Please enter your last name\n';   
              //  alert("Please enter your last name");
              //  return false;
            }

            if ($("#address").val().length == 0) {
				validations+='Please enter your address\n ';   
              //  alert("Please enter your address ");
              //  return false;
            }
			
            if ($('#country option:selected').val() == '---select---') {
				validations+='Please select country\n ';  
               // alert('Please select country');
                //return false;
            }

            if ($('#state option:selected').val() == '---select---') {
				validations+='Please select state\n '; 
                //alert('Please select state');
                //return false;
            }
			 if ($("#zip").val().length == 0) {
				 validations+='Please select state\n '; 
                //alert("Please enter your zipCode ");
                //return false;
            }
			if ($("#zip").val().length != 6) {
				validations+='Please enter 6 digit zipCode\n ';
                //alert("Please enter 6 digit zipCode.");
                //return false;
            }
			
			
            
                if ($('#dob').val().length == 0) {
					validations+='Please enter your date of birth\n ';
                    //alert('Please enter your date of birth');
                   // return false;
                }
           
			if ($("#phone").val().length == 0) {
				validations+='Please enter your phone number\n ';
               // alert("Please enter your phone number");
                //return false;
            }
			
				var H=$('#phone').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
					 validations+='Phone Number should contain Numeric Values...!\n ';
				//alert("Phone Number should contain Numeric Values...!");
				
				//return false; 
				}

            if ($("#mobile").val().length == 0) {
				validations+='enter your mobile\n ';
                //alert("Please enter your mobile");
                //return false;
            }
			
				var H=$('#mobile').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
					 validations+='Mobile Number should contain Numeric Values...!\n ';
				//alert("Mobile Number should contain Numeric Values...!");
				
				//return false; 
				}
				

            if ($("#mobile").val().length != 10) {
				 validations+='Please enter 10 digit mobile no.\n ';
                //alert("Please enter 10 digit mobile no.");
               // return false;
            }
			 if ($('#gender option:selected').val() == '---select---') {
				 validations+='Please select gender\n ';
                //alert('Please select gender');
               // return false;
            }
			
			if (!ValidateEmail($("#email").val())) {
				 validations+='Invalid email address.\n ';
				//alert("Invalid email address.");
				//return false;
			}
			
			//if($("#photo").val() !=undefined)
//			{
//			if ($("#photo").val().length == 0) {
//				 validations+='Please upload your photo.\n ';
//               // alert("Please upload your photo");
//               // return false;
//            }
//			}
//			if($("#resume").val() !=undefined)
//			{
//		if ($("#resume").val().length == 0) {
//			validations+='Please upload your resume.\n ';
//                //alert("Please upload your resume");
//                //return false;
//            }
//			}
			
			if ($("#proof").val().length == 0) {
				validations+='Please enter your Idproof type.\n ';
                //alert("Please enter your Idproof type");
                //return false;
            }
	
			if ($("#p_new").val().length == 0) {
				validations+='Please upload your Idproof.\n ';
               // alert("Please upload your Idproof");
               // return false;
            }
			if(validations!=''){
				alert(validations);
               return 0;
			}
			
*/}
function validation_employeeform1(){/*
	var validations='';

		if ($("#rname").val().length == 0) {
			validations+='Please enter  Reference name.\n ';
               // alert("Please enter  Reference name");
               // return false;
            }
			if ($("#relation").val().length == 0) {
				validations+='Please enter  relation.\n ';
               // alert("Please enter  relation");
               // return false;
            }
			if ($("#contact").val().length == 0) {
				validations+='Please enter your contact no.\n ';
                //alert("Please enter your contact no");
               // return false;
            }
			
				var H=$('#contact').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
					 validations+='contact Number should contain Numeric Values...!\n ';
				//alert("Phone Number should contain Numeric Values...!");
				
				//return false; 
				}
			if ($("#loc").val().length == 0) {
				validations+='Please enter your location.\n ';
                //alert("Please enter your location");
               // return false;
            }
			  if ($('#pos2 option:selected').val() == '--select--') {
				 validations+='Please select Designation\n ';
                //alert('Please select gender');
               // return false;
            }
			if ($("#Salary").val().length == 0) {
				validations+='Please Select Salary.\n ';
                //alert("Please Select Workplace");
               // return false;
            }
			if ($("#jloc").val().length == 0) {
				validations+='Please Select Workplace.\n ';
                //alert("Please Select Workplace");
               // return false;
            }
			  if ($('#date').val().length == 0) {
				  validations+='Please enter Date.\n ';
                   // alert('Please enter Date');
                    //return false;
                }
			if ($("#day").val().length == 0) {
				validations+='Please enter  your Working Days.\n ';
                //alert("Please enter your Working Days");
               // return false;
            }
			if(validations!=''){
				alert(validations);
               return 0;
			}
*/}

function validation_employeeform2(){/*
	var validations='';


			if ($("#refer").val().length == 0) {
				validations+='Please enter  Company name.\n ';
                //alert("Please enter  Company name");
               // return false;
            }
			if ($("#phno").val().length == 0) {
				validations+='Please enter  your contact Number.\n ';
                //alert("Please enter  Phone Number");
               // return false;
            }
			var H=$('#phno').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
					 validations+='Phone Number should contain Numeric Values...!\n ';
				//alert("Phone Number should contain Numeric Values...!");
				
				//return false; 
				}
				//if (!ValidateEmail($("#email1").val())) {
				//	validations+='Please enter email address.\n ';
				//alert("Invalid email address.");
				//return false;
			//}
			
			
			if ($("#posi").val().length == 0) {
				validations+='Please enter  position.\n ';
               // alert("Please enter  position");
                //return false;
            }
			if ($("#sal").val().length == 0) {
				validations+='Please enter  your Working Days.\n ';
                //alert("Please enter  Salary");
               // return false;
            }
			if ($("#rfl").val().length == 0) {
				validations+='Please enter  Reason for leaving.\n ';
                //alert("Please enter  Reason for leaving");
                //return false;
            }
			if(validations!=''){
				alert(validations);
               return 0;
			}
*/}

 function fnRecruitmentPage() {
	 /*
	
            if ($("#fname").val().length == 0) {
                alert("Please enter first name");
                return false;
            }
            if ($("#mname").val().length == 0) {
                alert("Please enter your middle name");
                return false;
            }

            if ($("#lname").val().length == 0) {
                alert("Please enter your last name");
                return false;
            }

            if ($("#address").val().length == 0) {
                alert("Please enter your address ");
                return false;
            }
			
            if ($('#country option:selected').val() == '---select---') {
                alert('Please select country');
                return false;
            }

            if ($('#state option:selected').val() == '---select---') {
                alert('Please select state');
                return false;
            }
			 if ($("#zip").val().length == 0) {
                alert("Please enter your zipCode ");
                return false;
            }
			if ($("#zip").val().length != 6) {
                alert("Please enter 6 digit zipCode.");
                return false;
            }
			
			
            
                if ($('#dob').val().length == 0) {
                    alert('Please enter your dob');
                    return false;
                }
           
			if ($("#phone").val().length == 0) {
                alert("Please enter your phone number");
                return false;
            }
			
				var H=$('#phone').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
				alert("Phone Number should contain Numeric Values...!");
				
				return false; 
				}

            if ($("#mobile").val().length == 0) {
                alert("Please enter your mobile");
                return false;
            }
			
				var H=$('#mobile').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
				alert("Mobile Number should contain Numeric Values...!");
				
				return false; 
				}
				

            if ($("#mobile").val().length != 10) {
                alert("Please enter 10 digit mobile no.");
                return false;
            }
			 if ($('#gender option:selected').val() == '---select---') {
                alert('Please select gender');
                return false;
            }
				
			if (!ValidateEmail($("#email").val())) {
				alert("Invalid email address.");
				return false;
			}
				/*if($("#photo").val() !=undefined)
			{
			if ($("#photo").val().length == 0) {
                alert("Please upload your photo");
                return false;
            }
			}
			if($("#resume").val() !=undefined)
			{
		if ($("#resume").val().length == 0) {
                alert("Please upload your resume");
                return false;
            }
			}*/
			
			/*if ($("#proof").val().length == 0) {
                alert("Please enter your Idproof type");
                return false;
            }
	
			if ($("#p_new").val().length == 0) {
                alert("Please upload your Idproof");
                return false;
            }
			if ($("#rname").val().length == 0) {
                alert("Please enter  Reference name");
                return false;
            }
			if ($("#relation").val().length == 0) {
                alert("Please enter  relation");
                return false;
            }
			if ($("#contact").val().length == 0) {
                alert("Please enter your contact no");
                return false;
            }
			if ($("#loc").val().length == 0) {
                alert("Please enter your location");
                return false;
            }*/
			/*if($('input[name=pa]:checked').length<=0)
			{
			 alert("No radio checked")
			 return false;
			}
			if ($("#jloc").val().length == 0) {
                alert("Please Select Workplace");
                return false;
            }
			  if ($('#date').val().length == 0) {
                    alert('Please enter Date');
                    return false;
                }
			if ($("#day").val().length == 0) {
                alert("Please enter your Working Days");
                return false;
            }
			if($('input[name=level]:checked').length<=0)
			{
			 alert("No radio checked")
			 return false;
			}
			if ($("#course").val().length == 0) {
                alert("Please Select your course");
                return false;
            }
			if($('input[name=se]:checked').length<=0)
			{
			 alert("No radio checked")
			 return false;
			}
			if ($("#refer").val().length == 0) {
                alert("Please enter  Company name");
                return false;
            }
			if ($("#phno").val().length == 0) {
                alert("Please enter  Phone Number");
                return false;
            }
			var H=$('#phno').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
				alert("Phone Number should contain Numeric Values...!");
				
				return false; 
				}
				if (!ValidateEmail($("#email1").val())) {
				alert("Invalid email address.");
				return false;
			}
			
			
			if ($("#posi").val().length == 0) {
                alert("Please enter  position");
                return false;
            }
			if ($("#sal").val().length == 0) {
                alert("Please enter  Salary");
                return false;
            }
			if ($("#rfl").val().length == 0) {
                alert("Please enter  Reason for leaving");
                return false;
            }
			alert('rty');*/
            insert_recruitment();
		}
		
	
function insert_recruitment(){
	//var dataString = $('#frm1').serialize();
	$('#busy').show();
	var formData = new FormData($('form')[0]);
	//alert(formData);
	//alert(serviceURLHR);
    $.ajax({
        url: serviceURLHR + 'recruitmentinsert.php',  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
				$('#busy').hide();
				//if(data=='success'){
				alert("Item successfully inserted.");
				window.location="recruitment-list.php";
			//}
		}
	});	
}

function fnTimesheetPage() {
	
	  insert_timesheet();
		}
function insert_timesheet(){
	//var dataString = $('#frm1').serialize();
	$('#busy').show();
	var formData = new FormData($('form')[0]);
	//alert(formData);
	//alert(serviceURLHR);
    $.ajax({
        url: serviceURLHR + 'timesheetinsert.php',  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
				$('#busy').hide();
				//if(data=='success'){
				alert("Item successfully Updated.");
				window.location="timesheet-adjustable-form.php";
			//}
		}
	});	
}


function fnProductivityPage() {
	 /*
	
            if ($("#fname").val().length == 0) {
                alert("Please enter first name");
                return false;
            }
            if ($("#mname").val().length == 0) {
                alert("Please enter your middle name");
                return false;
            }

            if ($("#lname").val().length == 0) {
                alert("Please enter your last name");
                return false;
            }

            if ($("#address").val().length == 0) {
                alert("Please enter your address ");
                return false;
            }
			
            if ($('#country option:selected').val() == '---select---') {
                alert('Please select country');
                return false;
            }

            if ($('#state option:selected').val() == '---select---') {
                alert('Please select state');
                return false;
            }
			 if ($("#zip").val().length == 0) {
                alert("Please enter your zipCode ");
                return false;
            }
			if ($("#zip").val().length != 6) {
                alert("Please enter 6 digit zipCode.");
                return false;
            }
			
			
            
                if ($('#dob').val().length == 0) {
                    alert('Please enter your dob');
                    return false;
                }
           
			if ($("#phone").val().length == 0) {
                alert("Please enter your phone number");
                return false;
            }
			
				var H=$('#phone').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
				alert("Phone Number should contain Numeric Values...!");
				
				return false; 
				}

            if ($("#mobile").val().length == 0) {
                alert("Please enter your mobile");
                return false;
            }
			
				var H=$('#mobile').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
				alert("Mobile Number should contain Numeric Values...!");
				
				return false; 
				}
				

            if ($("#mobile").val().length != 10) {
                alert("Please enter 10 digit mobile no.");
                return false;
            }
			 if ($('#gender option:selected').val() == '---select---') {
                alert('Please select gender');
                return false;
            }
				
			if (!ValidateEmail($("#email").val())) {
				alert("Invalid email address.");
				return false;
			}
				/*if($("#photo").val() !=undefined)
			{
			if ($("#photo").val().length == 0) {
                alert("Please upload your photo");
                return false;
            }
			}
			if($("#resume").val() !=undefined)
			{
		if ($("#resume").val().length == 0) {
                alert("Please upload your resume");
                return false;
            }
			}*/
			
			/*if ($("#proof").val().length == 0) {
                alert("Please enter your Idproof type");
                return false;
            }
	
			if ($("#p_new").val().length == 0) {
                alert("Please upload your Idproof");
                return false;
            }
			if ($("#rname").val().length == 0) {
                alert("Please enter  Reference name");
                return false;
            }
			if ($("#relation").val().length == 0) {
                alert("Please enter  relation");
                return false;
            }
			if ($("#contact").val().length == 0) {
                alert("Please enter your contact no");
                return false;
            }
			if ($("#loc").val().length == 0) {
                alert("Please enter your location");
                return false;
            }*/
			/*if($('input[name=pa]:checked').length<=0)
			{
			 alert("No radio checked")
			 return false;
			}
			if ($("#jloc").val().length == 0) {
                alert("Please Select Workplace");
                return false;
            }
			  if ($('#date').val().length == 0) {
                    alert('Please enter Date');
                    return false;
                }
			if ($("#day").val().length == 0) {
                alert("Please enter your Working Days");
                return false;
            }
			if($('input[name=level]:checked').length<=0)
			{
			 alert("No radio checked")
			 return false;
			}
			if ($("#course").val().length == 0) {
                alert("Please Select your course");
                return false;
            }
			if($('input[name=se]:checked').length<=0)
			{
			 alert("No radio checked")
			 return false;
			}
			if ($("#refer").val().length == 0) {
                alert("Please enter  Company name");
                return false;
            }
			if ($("#phno").val().length == 0) {
                alert("Please enter  Phone Number");
                return false;
            }
			var H=$('#phno').val();
				if(isNaN(H)|| H.indexOf(" ")!=-1)
				 {
				alert("Phone Number should contain Numeric Values...!");
				
				return false; 
				}
				if (!ValidateEmail($("#email1").val())) {
				alert("Invalid email address.");
				return false;
			}
			
			
			if ($("#posi").val().length == 0) {
                alert("Please enter  position");
                return false;
            }
			if ($("#sal").val().length == 0) {
                alert("Please enter  Salary");
                return false;
            }
			if ($("#rfl").val().length == 0) {
                alert("Please enter  Reason for leaving");
                return false;
            }
			alert('rty');*/
            insert_productivity();
		}

function insert_productivity(){
	//var dataString = $('#frm1').serialize();
	
	
	var formData = new FormData($('form')[0]);
		
	//alert(serviceURLHR);
    $.ajax({
        url: serviceURLHR + 'productivityinsert.php',  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
				//if(data=='success'){
				alert("Item successfully inserted.");
				//window.location="productivity-list.php";
			//}
		}
	});	
}

/*jQuery('#wtcarried').live('keyup',function(){ 
							 
    alert($(this).val());
  });*/

	

   $(document).ready(function(){
 
        //iterate through each textboxes and add keyup
        //handler to trigger sum event
        $(".form-fld-width-3").live('keyup',function(){
                calculateSum();
            });
    
    });
 
    function calculateSum() { 
	     var sum = 0;
        //iterate through each textboxes and add the values
        $(".form-fld-width-3").each(function() {
 			//alert(this.value);
			//alert(this.value.length);
            //add only if the value is number
            if(!isNaN(this.value) && this.value.length!=0) {
                sum += parseFloat(this.value);
            }
 
        });
        //.toFixed() method will roundoff the final sum to 2 decimal places
		$(".sum").html(sum.toFixed(2));
       	$(".sum").val(sum.toFixed(2));
    }

$('#remproductNeww').live('click', function() 
	{
		calculateSum();	
	});

function fnPerformancePage(){
	insert_performance();
}

function insert_performance(){
	//var dataString = $('#frm1').serialize();

	var formData = new FormData($('form')[0]);
	//alert(formData);
	//alert(serviceURLHR);
    $.ajax({
        url: serviceURLHR + 'performanceinsert.php',  //Server script to process data
        type: 'POST',
        data: formData,
		processData: false,  // tell jQuery not to process the data
  		contentType: false ,  // tell jQuery not to set contentType
		success: function(data){
				//if(data=='success'){
				alert("Item successfully inserted.");
				//window.location="productivity-list.php";
			//}
		}
	});	
}

function fnPerformanceview11(){
	
}

	function fnPerformanceview(){
		
			
		 $('.productivity_list').hide('blind',500,function(){ $(this).remove();})		
		 $('.contentremark').hide('blind',500,function(){ $(this).remove();})	
		 $('#form-wrapper').append('<div class="content">'+
								  '<div id="form-content"><div id="form-wrapper">'+
								  '<div id="steps"><form>'+
								  '<fieldset class="step"><legend><translate>Add Performance Rating & Remark</translate></legend>'+
								  '<div class="view-button-tab">'+
								  '<button id="registerButton2" class="view-button" type="button" style="float:left; clear:inherit; margin-right:15px;" onclick="fnPerformanceadd()">Add Performance Review</button>'+
								  '<button id="registerButton2" class="view-button" type="button" style="float:left;  clear:inherit;" onclick="fnPerformanceRemarkview()">Add Description</button>'+
								  '</div></fieldset></form></div></div></div></div>');
		 $('#form-wrapper').find('#steps').hide('blind',500); 
		 $.getJSON(serviceURLHR+"getperformance.php",function(data){
				   //$('.productivityGrid').html('');	
				   profile = data.getperformance;
				   $('#form-wrapper').append('<div class="productivity_list">'+
												 '<ul class="productivity_ul">'+
												 '<li class="employee-row-01" style="background:#026091; color:#fffff; font-size:15px; font-weight:bold;"><translate>No</translate></li>'+
												 '<li class="employee-row-01" style="background:#026091; color:#fffff; font-size:15px; font-weight:bold;"><translate>Prd No</translate></li>'+
												 '<li class="employee-row-01" style="background:#026091; color:#fffff; font-size:15px; font-weight:bold;"><translate>Daterate</translate></li>'+
												 '<li class="employee-row-01" style="background:#026091; color:#fffff; font-size:15px; font-weight:bold;"><translate>Employee Name</translate></li>'+
												 '</ul>'+
												 '</div>');
					/*'<table width="100%" border="0" cellspacing="0" class="Grid" cellpadding="0">'+
					'<tr>'+
					  '<td align="center" valign="middle" class="employee-row-01">No</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Date</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Employee Name</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Branch</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Wt Carried</td>'+
					  '</tr></table>');*/
				  
					$.each(profile, function(index, profile){ 
							//tot = parseInt(tot)+parseInt(profile.prd_wt_carried);
						$('.productivity_list').append('<ul class="productivity_ul">'+
								'<li class="employee-row-01" style="width=10px;">'+ k + '</li>'+
								'<li class="employee-row-01">'+ profile.perform_unique+ '</li>'+
								'<li class="employee-row-01">'+ new Date(profile.perform_addate).format("dd-mm-yyyy")+ '</li>'+
								'<li class="employee-row-01 showperformdoclist"  data-id="'+profile.perform_unique_id+'">'+ profile.e_fname+ '</li>'+
							'</ul>');	
					itemCount = profile.totalrows;
					//tot = tot+profile.prd_wt_carried;
					k++;
					});	//'</tbody></table>';
					
			});
		 
		 
}

function performance_detailshw(){
	$this = $(this);
	$('.performance-grid').hide("blind",300,function(){ $(this).remove() });
	//alert($this);
	$currentRow = $this.parent();
	//alert($currentRow);
	console.log($currentRow);
	var did = $(this).attr('data-id');
	
	//alert(did);
	if($('.Grid_'+did).length){
		
	}else{
	
	$currentRow.after('<form name="formrate" id="formrate" method="post"><div class="testdiv" style="display:none"><table width="75%" border="0" cellspacing="0" class="performance-grid Grid_'+did+'" cellpadding="0">'+
					  '<tr>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>No</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Attribute Name</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Description</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Rating</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Remark</translate></td>'+
					  '</tr>'+
					  '</table></div></form>');
	
	$.getJSON(serviceURLHR+"getperformance_details.php?prd_id="+did,function(data){
		getperform = data.getperformancedts;
		//alert(imdsupervisor);
		var k = 1;
		var perform_unique_id;
		$.each(getperform, function(index, getperform) {
								//	 
				    	$('.Grid_'+did).append('<tr>'+
					   '<td align="center" valign="middle" class="employee-row-01">'+ k + '</td>'+
					   '<td align="center" valign="middle" class="employee-row-01">'+getperform.attribute_name+'</td>'+
					   '<td align="center" valign="middle" class="employee-row-01">'+getperform.perform_desc+'</td>'+
					   '<td align="center" valign="middle" class="employee-row-01">'+	
					   '<input type="text" name="rateaval_'+k+'" id="rateaval_'+k+'" value="'+getperform.perform_rate+'"/></td>'+
					   '<td align="center" valign="middle" class="employee-row-01">'+	
					   '<input type="hidden" name="performid_'+k+'"" value="'+getperform.perform_id+'"/>'+
					   '<input type="text" style="width:100px;" name="remarkaval_'+k+'" id="remarkaval_'+k+'" value="'+getperform.perform_remark+'"/>'+'</td>'+
					   '</tr>');
						
						
				perform_unique_id	=getperform.perform_unique_id;	
						
			k++;				
		});	
		
		$('.Grid_'+did).append('<tr>'+
							   '<td align="center" valign="middle" class="employee-row-01"></td>'+
							   '<td align="center" valign="middle" class="employee-row-01"></td>'+
					    '<td align="center" valign="middle" class="employee-row-01">'+
						'<td align="center" valign="middle" class="employee-row-01">'+
						'<td align="center" valign="middle" class="employee-row-01">'+
						'<input type="hidden" value="'+k+'" name="perform_totrow"/>'+
						'<input type="button" name="sub2" id="push1" class="pushbtn1" onclick="fnPerformanceupdateRating()" value="submit" style="width:50px"/>'+'</td>'+
					   '</tr>');
		$('.testdiv').show('blind',300);
	});
	}
	
}



function fnPerformanceupdateRating(){
	var datastring = $("#formrate").serialize();	
 $.post(serviceURLHR + "performance_rating_update.php?action=updateprofile",datastring,function(data){   
		alert("Item successfully inserted.");
		$('.performance-grid').hide('blind',300);  
		
 },'json');
}

function fnPerformanceadd(){
	window.location="performance-review-form.php";
}

function fnPerformanceRating(){
	var datastring = $("#formrate").serialize();	
 $.post(serviceURLHR + "performance_rating_insert.php?action=updateprofile",datastring,function(data){   
		alert("Item successfully inserted.");
		$('.performance-grid').hide('blind',300);  
		
 },'json');
}

	function fnPerformanceRemarkview(){
		
		$('.productivity_list').hide('blind',500,function(){ $(this).remove();})	
		$('#steps').hide('blind',500,function(){ $(this).remove();})	
		
		 //$('.contentremark').hide('blind',500,function(){ $(this).remove();})	
		// $('.content').hide('blind',500,function(){ $(this).remove();})	
		// $('.content').hide('blind',500,function(){ $(this).remove();})
		$('#form-wrapper').append('<div class="contentremark">'+
								  '<div id="form-content"><div id="form-wrapper">'+
								  '<div id="steps"><form>'+
								  '<fieldset class="step"><legend><translate>Add Description</translate></legend>'+
								  '<div class="view-button-tab">'+
								  '<button id="registerButton2" class="view-button" type="button" style="float:left; clear:inherit; margin-right:15px;" onclick="fnPerformanceadd()">Add Performance Review</button>'+
								  '<button id="registerButton2" class="view-button" type="button" style="float:left;  clear:inherit;" onclick="fnPerformanceview()">Add Performance Rating & Remark</button>'+
								  '</div></fieldset></form></div></div></div></div>');
		 
		 $('#form-wrapper').find('#steps').hide('blind',500);
		 $.getJSON(serviceURLHR+"getperformance_remark.php",function(data){
				   //$('.productivityGrid').html('');	
				   profile = data.getperformance;
				   $('#form-wrapper').append('<div class="productivity_list" style="padding-left:25px;">'+
												 '<ul class="productivity_ul">'+
												 '<li class="employee-row-01" style="background:#026091; color:#fffff; font-size:15px; font-weight:bold;"><translate>No</translate></li>'+
												 '<li class="employee-row-01" style="background:#026091; color:#fffff; font-size:15px; font-weight:bold;"><translate>Prd No</translate></li>'+
												 '<li class="employee-row-01" style="background:#026091; color:#fffff; font-size:15px; font-weight:bold;"><translate>Date</translate></li>'+
												 '<li class="employee-row-01" style="background:#026091; color:#fffff; font-size:15px; font-weight:bold;"><translate>Employee Name</translate></li>'+
												 '</ul>'+
												 '</div>');
					/*'<table width="100%" border="0" cellspacing="0" class="Grid" cellpadding="0">'+
					'<tr>'+
					  '<td align="center" valign="middle" class="employee-row-01">No</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Date</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Employee Name</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Branch</td>'+
					  '<td align="center" valign="middle" class="employee-row-01">Wt Carried</td>'+
					  '</tr></table>');*/
				  
					$.each(profile, function(index, profile){ 
							//tot = parseInt(tot)+parseInt(profile.prd_wt_carried);
						$('.productivity_list').append('<ul class="productivity_ul">'+
								'<li class="employee-row-01" style="width=10px;">'+ k + '</li>'+
								'<li class="employee-row-01">'+ profile.perform_unique+ '</li>'+
								'<li class="employee-row-01">'+ new Date(profile.perform_addate).format("dd-mm-yyyy")+ '</li>'+
								'<li class="employee-row-01 showperformremarkdoclist"  data-id="'+profile.perform_unique_id+'">'+ profile.e_fname+ '</li>'+
							'</ul>');	
					itemCount = profile.totalrows;
					//tot = tot+profile.prd_wt_carried;
					k++;
					});	//'</tbody></table>';
					
			});
		 
		 
}




function performance_Remarkdetailshw(){
	
	$this = $(this);
	$('.performance-grid').hide("blind",300,function(){ $(this).remove() });
	//alert($this);
	$currentRow = $this.parent();
	//alert($currentRow);
	console.log($currentRow);
	var did = $(this).attr('data-id');
	
	//alert(did);
	if($('.Grid_'+did).length){
		
	}else{
	
	$currentRow.after('<form name="formrate" id="formrate" method="post"><div class="testdiv" style="display:none"><table width="75%" border="0" cellspacing="0" class="performance-grid Grid_'+did+'" cellpadding="0">'+
					  '<tr>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>No</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Attribute Name</translate></td>'+
					  '<td align="center" valign="middle" class="employee-row-01"><translate>Description</translate></td>'+
					  '</tr>'+
					  '</table></div></form>');
	
	$.getJSON(serviceURLHR+"getperformance_details.php?prd_id="+did,function(data){
		getperform = data.getperformancedts;
		//alert(imdsupervisor);
		var k = 1;
		var perform_unique_id;
		$.each(getperform, function(index, getperform) {
								//	 
				    	$('.Grid_'+did).append('<tr>'+
					   '<td align="center" valign="middle" class="employee-row-01">'+ k + '</td>'+
					   '<td align="center" valign="middle" class="employee-row-01">'+getperform.attribute_name+'</td>'+
					   '<td align="center" valign="middle" class="employee-row-01">'+	
					   '<input type="hidden" name="performid_'+k+'"" value="'+getperform.perform_id+'"/>'+
					   '<input type="text" style="width:100px;" name="descval_'+k+'" id="descval_'+k+'" value="'+getperform.perform_desc+'"/>'+'</td>'+
					   '</tr>');
						
						
				perform_unique_id	=getperform.perform_unique_id;	
						
			k++;				
		});	
		
		$('.Grid_'+did).append('<tr>'+
							   '<td align="center" valign="middle" class="employee-row-01"></td>'+
							   '<td align="center" valign="middle" class="employee-row-01"></td>'+
							   '<td align="center" valign="middle" class="employee-row-01">'+
						'<input type="hidden" value="'+k+'" name="perform_totrow"/>'+
						'<input type="button" name="sub2" id="push1" class="pushbtn1" onclick="fnPerformanceRating()" value="submit" style="width:50px"/>'+'</td>'+
					   '</tr>');
		$('.testdiv').show('blind',300);
	});
	}
	
}



/*langugae selection */

function selectlanguage()
{ 
	$.ajax({
	   url: serviceURLHR+"language.php",
	   success: function(data){
		 $("select[name='lang[]']").html(data);
		 
	   }
   });
}
function languageselected()
{   
	//alert('SEL ID is : '+lang_index);
	//alert('SEL VALUE is : '+language_selected);
	$("#lang"+lang_index).val(language_selected);
	//alert('Val is : '+$("#lang"+lang_index).val());
}

/*************  Add More Language *************/

/*$(function() {
		   
	var addDiv = $('#lang_tr').last('tr');
	
	$('#addNewLang').live('click', function() {
	
			 $('<tr><td width="20%" align="left" valign="top">&nbsp;</td><td align="left" valign="top"><select name="lang[]" id="lang1" ><option value="">--select--</option></select>		</td><td align="left" valign="top"><input type="checkbox" name="radio_eng_rd[]" id="radio_eng_rd[]" value="read" /></td><td align="left" valign="top"><input type="checkbox" name="radio_eng_wt[]" id="radio_eng_wt" value="write" /></td><td align="left" valign="top"><input type="checkbox" name="radio_eng_sk[]" id="radio_eng_sk" value="speak" /></td>		<td><a href="#" id="remLang">Remove</a></td></tr>').insertAfter(addDiv);
		
		selectlanguage();
	});



});	 
*/

	$('.remLang').live('click', function() {
		$(this).parents('tr').remove();
	});
	$('.addNewEdu').live('click', function() { 
										   
		$('#edu').append('<div style="border:1px dotted #ddd; margin:10px 0 10px 0; class="bdr" "></div><table width="100%" border="0" cellspacing="0" cellpadding="0"  ><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Course</label></td><td><input name="course[]" type="text"  /><br /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Specialization</label></td><td><input name="spl[]" type="text"   /></td></tr><tr><td colspan="2" height="8"></td> </tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">University/Institute</label></td><td><input name="unv[]" type="text"   /></td> </tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Year</label></td><td><input name="yr[]" type="text"  /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Percentage</label></td><td><input name="pcntg[]" type="text"  /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td colspan="2"><a href="#" id="remEdu">Remove</a></td></tr></table>');
		
	});
	
	$('#remEdu').live('click', function() {
		$(this).parents('table').prev('div').remove();									
		$(this).parents('table').remove();
		var count = $('#edu').children('table').length;
		if(count==0)
		{
				$('#edu').append('<table width="100%" border="0" cellspacing="0" cellpadding="0"  ><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Course</label></td><td><input name="course[]" type="text"  /><br /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Specialization</label></td><td><input name="spl[]" type="text"   /></td></tr><tr><td colspan="2" height="8"></td> </tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">University/Institute</label></td><td><input name="unv[]" type="text"   /></td> </tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Year</label></td><td><input name="yr[]" type="text"  /></td></tr><tr><td colspan="2" height="8"></td></tr><tr><td width="164" align="right" valign="top" class="form-padd-01"><label for="label">Percentage</label></td><td><input name="pcntg[]" type="text"  /></td></tr><tr><td colspan="2" height="8"></td></tr></table>');
		}
	});




