var serviceURLHR =localStorage['serviceURLHR'];
var hosturl    =localStorage['basicURL'];
//----------------------------------------------------------------------------------------------------//Listing

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 employeetimesheet(pagenum){ 
var month=$("#month").val();
var year=$("#year").val();
var employees=$("employees").val();
//var employees=65;
	$.ajax({
   url: serviceURLHR+"timesheet-employees.php?page="+pagenum+"&month="+month+"&year="+year+"&employees="+employees,
   success: function(data){
	   $("#employeetimesheet" ).html(data);
   }
 });	
pagination(pagenum);
selmon();
}
function  pagination(pagenum)
{
var month=$("#month").val();
var year=$("#year").val();
var employees=$("employees").val();

$.ajax({
   url: serviceURLHR+"timesheet-employeespagination.php?page="+pagenum+"&month="+month+"&year="+year+"&employees="+employees,
   success: function(data){
          $("#pagediv" ).html(data);
	 
   }
 });	
}

function  download(pagenum)
{
	window.location = serviceURLHR+"download1.php?pagenum="+pagenum;
/*	alert(pagenum);
	$.ajax({
			type: "POST",
			url:serviceURLHR+"download.php",
			data: 'pagenum='+pagenum,
			success:function(msg){ 
			//$("#subject_div").html(msg);alert()
			//alert(msg);
				window.open('data:application/vnd.ms-excel,' + $('#dvData').html(msg));		
					}
			});*/
}

function gonextpage(page)
{ 
	CutlaryList(page);
}

function dropdownval(num,ing)
{
	$.ajax({
   url: serviceURLHR+"dropdownvalue.php?table=employee&field1=e_fname&field2=e_id&ingvalue="+ing,
   success: function(data){
     $("#employees").append(data);
   }
 });	
}
function selmon(){
var month1='';
var month=$("#month").val();
var year=$("#year").val();	
if(month==null)month=new Date().getMonth() + 1;if(year==null)year=new Date().getFullYear();
if(month=='01')month1='January';if(month=='02')month1='February';;if(month=='03')month1='March';if(month=='04')month1='April';if(month=='05')month1='May';
if(month=='06')month1='Jun';if(month=='07')month1='July';;if(month=='08')month1='August';if(month=='09')month1='September';if(month=='10')month1='October';
if(month=='11')month1='November';if(month=='12')month1='December';
var data=month1 +' '+ year;
 $("#selmonth").html(data);
}
function selectmonthfn()
{ 

var obj=document.getElementById("month");  
 opt = document.createElement("option");
                opt.appendChild(document.createTextNode(value));
                opt.selected = selected;
                opt.value = '01';
                opt.text='January';
                obj.appendChild(opt);
}
