
/**  
 * @fileOverview 历史记录主函数
 * @author tan
 * @version 1.0  
 */  
 /**  
 * @author tan  
 * @constructor 历史记录主函数
 * @description 历史记录主函数
 * @date 2011-05-19
 * @since version 1.0 
 */


function historyRecord(historyRecordTable,eno,project){
	this.optLogHtml;
	this.showHistoryRecord=function(){
		$.post('historyRecord!findAllHistoryRecord.action','hisotryRecordDto.eno='+eno+'&hisotryRecordDto.eventType='+project,function(data){
			optLogHtml='';
			if(data!=null && data.length>0){
				$('#'+historyRecordTable+' tbody').html('');
				for(var i=0;i<data.length;i++){
					optLogHtml+="<tr >"+
					"<td style='text-align:center;'>[step]</td>"+
					"<td style='text-align:left'>[action]</td>"+
					"<td style='text-align:left'>[detail]</td>"+
					"<td style='text-align:center'>[operator]</td>"+
					"<td style='text-align:center'>[time]</td>"+
					"</tr>";
					optLogHtml=optLogHtml.replace("[step]",data.length-i)
					.replace("[action]",data[i].logTitle)
					.replace("[detail]",data[i].logDetails==null?'':data[i].logDetails)
					.replace("[operator]",data[i].operator)
					.replace("[time]",timeFormatter(data[i].createdTime));
					
					optLogHtml=formtDetails(optLogHtml);
				}
				$('#'+historyRecordTable+' tbody').append(optLogHtml);
			}
		});
	};
	
}
function formtDetails(optLogHtml){
	var returnStr=optLogHtml;
	var n1=optLogHtml.lastIndexOf('[{')+2　　　
	var n2=optLogHtml.lastIndexOf('}]')
	var changeNo=optLogHtml.substring(n1,n2)
	
	if(n1>0 && n2>0){
		var _href='<a href="javascript:itsm.common.utility.tabUtility.reOpenTab({0},{1})">{2}</a>'
			_href=_href.replace('{0}',"'change!changeInfo.action?queryDTO.eno="+changeNo+"'")
			.replace('{1}',"'"+i18n['title_changeInfo']+"'")
			.replace('{2}',"["+i18n['title_changeInfo']+"]")
		returnStr=optLogHtml.replace("[{"+changeNo+"}]",_href)
	}
	return returnStr;
};

