
/*
 * Depends on table_data_base.js
 */

function TableDataGroupHistory(groupId, pNameSpace, numPages, locale, loginUserId, loginUsername, loginUserRole) {
	
	this.groupId = groupId;
	this.pNameSpace = pNameSpace;
	this.page = 1;
	this.numPages = numPages;
	this.locale = locale;
	this.loginUserId = loginUserId;
	this.loginUsername = loginUsername;
	this.loginUserRole = loginUserRole;
	
	this.numberOfColumns = 3;
	
	this.getRemoteListDataBean = function getRemoteListDataBean(page) {
	    
		this.addLoading(this.pNameSpace + "Trans");	    
		var parent = this;
		var callbackProxy = function(dataFromServer) {
			callbackGetRemoteListDataBean(dataFromServer, page, parent);				
		};
		var exceptionHandlerProxy = function(exceptionMessage, exception) {
			callbackExceptionGetRemoteListDataBean(exceptionMessage, exception, parent, numberOfColumns);				
		};
		
	    var callMetaData = {
	    	callback: callbackProxy,		  		  
		  	exceptionHandler: exceptionHandlerProxy
		};
	    
		CompaniesRemoteService.getGroupHistory(this.groupId, page, this.locale, this.loginUserId, this.loginUsername, this.loginUserRole, callMetaData);
	 
	}
	
	this.fillTable = function fillTable(resp) {
		var val;
		
		var cellFuncs = [
			function(data) {return data.date;},
		  	function(data) {return data.oldValue;},
		  	function(data) {return data.currentValue;},
		  	function(data) {return data.username;},		  	
		];	
		
		
		DWRUtil.removeAllRows(this.pNameSpace + "Trans");
		DWRUtil.addRows(this.pNameSpace + "Trans", resp.data, cellFuncs, 
		{ 
			rowCreator:function(options) {
			    var row = document.createElement("tr");			    
			    row.className = "tableListNormalTr";
			    return row;
		  	},
			cellCreator:function(options) {
			    var td = document.createElement("td");			   
			    td.className = "tableListNormal";
			    return td;
			},
			escapeHtml:false 
		});		
	}
	
	this.getErrorHtml = getErrorHtml;
	this.addLoading = addLoading;
	this.backPaginatedPage = backPaginatedPage;
	this.nextPaginatedPage = nextPaginatedPage;
	this.changePaginatedPage = changePaginatedPage;
	this.updatePaginationTable = updatePaginationTable;			
}