<%@ page language="java" pageEncoding="UTF-8"%>
<jsp:directive.page import="java.sql.Timestamp"/>
<jsp:directive.page import="com.stfoa.dao.hibernate.CompanyDAO"/>
<jsp:directive.page import="com.stfoa.common.util.FormatUtil"/>
<jsp:directive.page import="java.util.Date"/>
<%@page import="com.stfhr.dao.hibernate.HRRoleDAO"%>
<%@page import="com.stfhr.domain.HRRole"%>
<%@page import="com.stfoa.common.util.ValidateUtil"%>
<%@page import="com.sysadmin.dao.hibernate.SystemDAO"%>
<%@page import="com.sysadmin.domain.System"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/ajaxform.js"></script>
<script type="text/javascript" src="js/popup.js"></script>
<title>协同办公</title>
<link href="<%=request.getContextPath()%>/css/login.css"rel="stylesheet" type="text/css">
<%
 Integer empId = (Integer)request.getSession().getAttribute("empid");
 String  lastLoginTimeStr = "欢迎首次登录系统！";
 String lastLogoutTimeStr = "";
 String lastLoginIp = (String)session.getAttribute("lastLoginIp");
 if(session.getAttribute("lastLoginTime")!=null){
  lastLoginTimeStr =  FormatUtil.formatDate("yyyy-MM-dd HH:mm:ss",((Date)session.getAttribute("lastLoginTime")));
  }
  if(session.getAttribute("lastLogoutTime")!=null){
   lastLogoutTimeStr =  FormatUtil.formatDate("yyyy-MM-dd HH:mm:ss",((Timestamp)session.getAttribute("lastLogoutTime")));
  }
 if(lastLoginIp==null){
  lastLoginIp= "";
 }
 CompanyDAO comdao = new CompanyDAO();
 String companyName = comdao.findById(new Integer(9)).getCompanyName();
 SystemDAO sysdao = new SystemDAO();
 System sys = sysdao.findById(4);
%>
<script type="text/javascript">
var popmsgwins = new Array();
</script>
<SCRIPT>
  var MSG1; 
  function popupHint(){ 
  if(MSG1==undefined || MSG1.close){ 
   MSG1 = new CLASS_MSN_MESSAGE("aa",240,140,"<b>上次登录信息：</b>","","<b>登录时间:</b> <%=lastLoginTimeStr%> <br><br><b>退出时间:</b> <%=lastLogoutTimeStr%><br><br><b>登录IP:</b> <%=lastLoginIp%> "); 
   MSG1.rect(null,null,null,screen.height-10); 
   MSG1.speed = 10; 
   MSG1.step = 5; 
   MSG1.timeout = 1000; 
   MSG1.show(); 
   } 
  }

</SCRIPT>
<script type="text/JavaScript">
<!--
var refreshcount = 0;
//var activestatus = true;
var popwindows = popmsgwins;
var intervalId = setInterval('refreshdesk()',15000);
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function refreshdesk(){
   ajaxQueryWithExcption("<%=request.getContextPath()%>/refreshDesktop.do");
}
function ajaxQueryException(status){
 //if(activestatus){
  //alert('与服务器连接已断开，请检查网络重新连接！');
  //activestatus = false;
 //}
}
function ajaxQueryHandle(responseXML){
 if(responseXML.getElementsByTagName("RefreshInfo")[0]){
  var infonode = responseXML.getElementsByTagName("RefreshInfo")[0];
  var count = infonode.getAttribute('OnlineCount');
  var lastcount = parent.button.onlinecount.innerText;
 //判断在线人数是否改变
  if(lastcount != count){
    parent.button.onlinecount.innerHTML = count;
  }
   var hasmessagetip = infonode.getAttribute('HasMessageTip');
   if(hasmessagetip != '0'){
    if(!parent.button.flag_flashmsg){
     window.focus();
     parent.button.flashmsg();
     document.all.bgs.src="<%=request.getContextPath()%>/sound/message.wav"; 
    }
    if(hasmessagetip!=parent.button.msgnum.innerText){   
     if(parent.button.locationtext.innerText=='首页'){
       parent.main.todoframe.location.reload();
       parent.main.taskframe.location.reload();
       parent.main.tagframe.location.reload();
       parent.main.doingframe.location.reload();      
      }
      parent.button.msgnum.innerText = hasmessagetip;
    }
   }else{
    parent.button.stopflashmsg();
    parent.button.msgnum.innerText ='0';
   }
  }else {
   //clearInterval(intervalId);
   //window.onunload="dovoid();";
   //parent.location.href="<%=request.getContextPath()%>/timeout.jsp";
 }
}
function dovoid(){

}
function openfocus(){
 <%
  Integer roleid = (Integer)session.getAttribute("roleid");
  HRRoleDAO roledao = new HRRoleDAO();
  HRRole role =  roledao.findById(roleid);
  if(!"".equals(role.getFocusActions())){
 %>
 var focuswin = window.open('<%=request.getContextPath()%>/jsp/focus/index.jsp','今日关注<%=empId%>','width=900,height=600,top=60, left=100,status=no');
 focuswin.focus();
 <%}%>
}
function showMessageTip(){
 window.open("<%=request.getContextPath()%>/messageTip.do","","width=450,height=260,left=100,top=100,scrollbars=yes");
 parent.button.stopflashmsg();
}
//-->
</script>
<script language="javascript">
     window.onunload = function closeout(){
     var i = 0;
     for(;i<popwindows.length;i++){
      if(popwindows[i] && !popwindows[i].closed){
        popwindows[i].close();
	   }
     }
    ajaxQueryWithFunction('<%=request.getContextPath()%>/logout.jsp',logoutHandler);
}
function logoutHandler(responseText){
  
} 
</script>
	</head>
	<%
		String username = (String) session.getAttribute("empname");
		String deptname = (String) session.getAttribute("deptname");
	%>
	<body onload="refreshdesk();popupHint();openfocus();"onkeydown=return(!(event.keyCode==78&&event.ctrlKey)) oncontextmenu="return false" onselectstart="self.event.returnValue=false"  ondrag="return false">
	<bgsound loop="1" id="bgs"/>
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td width="55%" valign="middle">
					<%if(ValidateUtil.isNull(sys.getImageURL())){ %>
                     <img src="images/hr.gif">
                    <%}else{ %>
                     <img  width="360px" height="54px" src="images/customer/showImage.jsp">
                    <%}%>
				</td>
				<td width="45%" align="right">
					<table width="100%" border="0"  align="right" cellpadding="0">
						<tr>
							<td  align=left style="background: url('images/top1_kbg.gif') repeat-y;" colspan=3>
								<a title="退出登录" href="logout.jsp" target="_top" class="black">退出登录</a>
								<a title="密码修改" href="<%=request.getContextPath()%>/tools/updatePassword.jsp" target="main" class="black">密码修改</a>
								
								<a title="使用说明" href="#" class="black"
									onClick="MM_openBrWindow('<%=request.getContextPath()%>/help/manual/index.htm','HR使用说明','width=800,height=600,scrollbars=yes')">使用说明</a>
							</td>
						</tr>
						<tr>
							<td class="black1" colspan=3 align=left>
								单位名称：
								<%=companyName %>
							</td>
						</tr>
						<tr>
							<td align="left" class="black1">
								登录人员：
								<label title=<%=username %>><%=FormatUtil.formatString(username,6)%></label>
							</td>
							<td class="black1" align="left">
							部门：
							<label title=<%=deptname %>><%=FormatUtil.formatString(deptname,8) %></label>
							</td>
							<td class="black1" align="left">
								<span id="timespan"><%=FormatUtil.formatDate("yyyy年MM月dd日 E",new Date())%></span>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		
	</body>
</html>
