$(document).ready(function(){
	load();
});

function call_btn_only(br_type){
	//alert(br_type);
	$('.btn_all').css("display","none");
	$('.btn_only').css("display","block");
}

function call_btn_all(br_type){
	//alert(br_type);
	$('.btn_only').css("display","none");
	$('.btn_all').css("display","block");
}


function call_save(type){

	var branch_id = $("#branchid").val();
	var roaster_name = $("#roaster_name").val();
	var roaster_descrption = $("#roaster_descrption").val();
	var start = $("#start_time").val();
	var end = $("#end_time").val();
	var operation = 'save';
	
	var datastr_only="operation="+operation+"&branch_id="+branch_id+"&roaster_name="+roaster_name+"&roaster_descrption="+roaster_descrption+'&start_time='+start+'&end_time='+end;

	if(roaster_name==""){
		alert("Enter Roaster Name");
		$('#roaster_name').focus();
		return false;
	}
	
	else if(start==""){
		alert("Enter Start Time");
		$('#start_time').focus();
		return false;
	}
	else if(end==""){
		alert("Enter End Time");
		$('#end_time').focus();
		return false;
	}
	else{
		$.ajax({
			type:"post",
			url:"module/hr_admin/get_roaster.php",data:datastr_only ,success:function(st){
				 //alert(st);
				load();
			}
		});
	}

}
	
// ============================================


function e_call_save(type){

	if(type=='e_only'){
		console.log($("#e_roaster_name").val());
		var roaster_name = $("#e_roaster_name").val();
		
		var start_time = $("#e_start_time").val();
		var end_time = $("#e_end_time").val();
		var status = $("#e_status").val();
		var roaster_id = $("#e_id").val();

		var operation = "e_only";

		var e_datastr_only="operation="+operation+"&roaster_name="+roaster_name+"&start_time="+start_time+"&end_time="+end_time+"&status="+status+"&id="+roaster_id;

		if(roaster_name==""){
			alert("Enter roaster name");
			$('#roaster_name').focus();
			return false;
		}
		else if(start_time==""){
			alert("Enter Start time");
			$('#start_time').focus();
			return false;
		}
		else if(end_time==""){
			alert("Enter End time");
			$('#end_time').focus();
			return false;
		}
		else{
			$.ajax({
				type:"post",
				url:"module/hr_admin/get_roaster.php",data:e_datastr_only ,success:function(st){
					//alert(st);
					load();
				}
			});
		}

	}

}



// =============================================



function show_edit_view(id){
//alert(id);
	var datastr = "id="+id;
	$("#model_table_value").load("module/hr_admin/edit_roaster.php",datastr);
}

function load(){
	$(".data_grade_system").load("module/hr_admin/get_roaster.php");	
}