
function call_leave_type(id){

	var datastr1="emp_id="+id;
	$("#lv_id").load("module/hr_admin/get_leave_type.php",datastr1);
}

$("#btn_go").click(function(){

	var emp_id = $("#emp_id").val();
	var leave_type =$("select[name=lv_idr]").val();
	
	
	var datastr_sc="emp_idd="+emp_id+"&leave_type="+leave_type;
	//alert(datastr_sc);

	if(emp_id==""){
		alert("Enter Employee ID");
		$('#emloyee_id').focus();
		return false;
	}
	 if(leave_type==""){
		alert("Select Leave Type");
		$('#lv_id').focus();
		return false;
	}
	
	else{

		$("#data").load("module/hr_admin/leave_application.php",datastr_sc);
		//$('#first_part').remove();
		$('#second_part').css("display","block");


	}


});

$("#btn_apply").click(function(){

	var reason = $("#lv_reason").val();
	var leave_dates =$("#lv_date").val();
	var emp_id = $("#idd").val();
	var leave_id =$("select[name=lv_idr]").val();
	var leave_name =$("#lv_name").val();
	var u_id = $("#emp_u_id").val();
	var pay_type = $('input:radio[name=form-field-radio]').filter(":checked").val();	
	
	var opr="entry";
	
	
	var datastr_lv="reason="+reason+"&leave_dates="+leave_dates+"&opr="+opr+"&emp_id="+emp_id+"&leave_id="+leave_id+"&leave_name="+leave_name+"&pay_type="+pay_type;
	var datastr_lvAJAX="id="+emp_id+"&leave_id="+leave_id;
	var datastr_tbl="leave_id="+leave_id+"&emp_id="+u_id;
	//alert(datastr_tbl);

	if(reason==""){
		alert("Enter Reason");
		$('#lv_reason').focus();
		return false;
	}
   else if(leave_dates==""){
		alert("Select Leave Dates");
		$('#lv_date').focus();
		return false;
	}

	else{
		$(".leave_info").load("module/hr_admin/get_leave_emplv_info.php",datastr_lvAJAX);

	$.ajax({
			type:"post" ,
		  	url:"module/hr_admin/leave_entry_ajax.php" ,
		  	data:datastr_lv ,
		  	success:function(st){
			alert(st);
			$(".leave_info").load("module/hr_admin/get_leave_emplv_info.php",datastr_lvAJAX);
			$(".table_leave").load("module/hr_admin/get_leave_table.php",datastr_tbl);
            $("#lv_reason").val('');
            $("#lv_date").val('');
		  	}
		  });
		}


});

$("#btn_find").click(function(){

	var month_id = $("#month_id").val();
	var year_id = $("#year_id").val();
	
	
	var datastr_sc="month="+month_id+"&year="+year_id;
	//alert(datastr_sc);

	if(month_id==""){
		alert("Select Month Name");
		$('#month_id').focus();
		return false;
	}
	else if(year_id==""){
		alert("Select Year");
		$('#year_id').focus();
		return false;
	}
	

	else{

		$("#data").load("module/hr_admin/leave_archive_result.php",datastr_sc);

		//$('#first_part').remove();
		$('#second_part').css("display","block");

	}


});

function count(){
	var leave_dates =$("#lv_date").val();
	var count=(leave_dates.split("/").length -1);
	//alert(count/2);
	$("#count").text(count/2);
}


function show_leave_dates(id){
	
	var operation='edit';
	var datastr="id="+id +"&operation="+operation;
    //alert(datastr);
	$("#value").load("module/hr_admin/leave_dates_inmodal.php",datastr);

}
function leave_delete(id){
	var emp_id =$("#emp_id").val();
	var e_id =$("#idd").val();
	var leave_id =$("#leave_id").val();
	var operation='delete';
	var datastr_d="id="+id +"&operation="+operation+"&emp_id="+emp_id+"&leave_id="+leave_id;
	var datastr_de="emp_id="+emp_id+"&leave_id="+leave_id;
	var datastr_RLV="id="+e_id+"&leave_id="+leave_id;
    alert(datastr_d);
    $.ajax({
			type:"post" ,
		  	url:"module/hr_admin/leave_entry_ajax.php" ,
		  	data:datastr_d ,
		  	success:function(st){
			alert(st);
			$("#table_leave").load("module/hr_admin/get_leave_table.php",datastr_de);
			$(".leave_info").load("module/hr_admin/get_leave_emplv_info.php",datastr_RLV);
		  	}
		  });
	

}

function leave_delete_date(id){
	var emp_id =$("#idd").val();
	var emp_u_id =$("#emp_u_id").val();
	var leave_id =$("#leave_id").val();
	var opr='delete_date';
	var p_id =$("#pid").val();
	var datastr_de="id="+id+"&opr="+opr+"&pid="+p_id;
	var datastr_deT="id="+p_id;
	var datastr_RLV="id="+emp_id+"&leave_id="+leave_id;
	var datastr_ajax="emp_id="+emp_u_id+"&leave_id="+leave_id;
    //alert(datastr_ajax);
    $.ajax({
			type:"post" ,
		  	url:"module/hr_admin/leave_entry_ajax.php" ,
		  	data:datastr_de,
		  	success:function(st){
			alert(st);
		  	}
		  });
	$("#value").load("module/hr_admin/leave_dates_inmodal.php",datastr_deT);
	$(".leave_info").load("module/hr_admin/get_leave_emplv_info.php",datastr_RLV);
	$(".table_leave").load("module/hr_admin/get_leave_table.php",datastr_ajax);

}






