<%@ page contentType="text/html; charset=gbk" language="java" %>
<%@ page import="mediastore.web.global.*"%>
<%@ page import="mediastore.web.form.*"%>
<%@ page import="java.util.*"%>

<script language="JavaScript">
function Trim(str){
 if(str.charAt(0) == " "){
  str = str.slice(1);
  str = Trim(str); 
 }
 return str;
}

function addUserRec(){
	if (Trim(document.form1.username.value) == "" | document.form1.username.value == null) 
	{ 
		alert("请输入用户名！"); 
		document.form1.username.value="";
		document.form1.username.focus(); 
	}
	else 
	{
		document.form1.action="userManageInsert.do";
		document.form1.submit();
	}
}

</script>


<table width="768" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="5" rowspan="4" class="trtable"></td>
    <td width="6" bgcolor="#214984" height="1"></td>
    <td rowspan="4" bgcolor="#214984" width="1" height="1"></td>
    <td bgcolor="#214984" class="10p" colspan="2" height="1"></td>
    <td rowspan="4" width="1" bgcolor="#214984" height="1"></td>
    <td bgcolor="#214984" width="5" height="1"></td>
    <td width="5" rowspan="4" class="trtable"></td>
  </tr>
  <tr> 
    <td width="6"></td>
    <td width="379" height="20" class="mainhead">用户管理</td>
    <td class="mainhead" width="379" height="20">&nbsp;</td>
    <td width="5"></td>
  </tr>
<tr> 
    <td width="6"></td>
    <td valign="top" colspan="2"> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        
        <tr> 
          <td height="300" align="center" valign="top">   
          
<%
	UserManageFB umfb = (UserManageFB)request.getAttribute(Globals.REQUEST_USERMANAGE);
	List userList = umfb.getUserList();
	String orderStr = umfb.getOrderStr();
%>

    	<form name="form1" method="post" action="" >
    	<font color=#215385><b>添加用户</b></font>
    	<IMG src="images/line1.gif" border=0>
    	<br>
    	<input type="hidden" name="orderStr"  value="<%=orderStr%>">
    	<TABLE width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#FFFFFF" class="mailtable"> 
		<!--测试<input name=submit type=submit onClick="addUserRec();">-->
	  <tr>
            <td  align="right" width=20%> 
                <b>用户名:</b>
            </td>
            <td width=20%>
            	<INPUT class=none  name="username" type="text" size="30" >
            </td>
            <td width=30%>&nbsp;</td>
          </tr>
          
          <tr>
            <td  align="right"> 
                <b>密&nbsp;&nbsp;码:</b>
            </td>
            <td>
            	<INPUT class=none  name="userpassword" type="password" size="30">
            </td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input name=addrec type=button value="添加" onClick="addUserRec()">
            </td>
          </tr>

          <tr> 
            <td  align="right"> 
                <b>类&nbsp;&nbsp;型:</b>
            </td>
            <td>
            	&nbsp;
            	<input type="radio" name="userrole" value="0" >系统管理员
            	&nbsp;
            	<input type="radio" name="userrole" value="1" checked>一般用户
            </td>
            <td>&nbsp;</td>
          </tr>
	</TABLE>
	</form>
	
	<br>
    	<br>
	
	<font color=#215385><b>用户列表</b></font>
	<IMG src="images/line1.gif" border=0>
	<TABLE width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#FFFFFF" class="mailtable">  
		<tr bgcolor="#C2CEDC">
		<th>用户标识<a href="userManage.do">（升序）</a></th>
		<th>用户名</th>
		<th>身份</th>
		<th>状态</th>
		<th>创建时间</th>
		<th>最近一次登录时间<a href="userManageLastLoginTimeDesc.do">（降序）</a></th>
		<th>删除</th>
		</tr>
		
		<%
		int index = 0;
	      	UserInfo tmpUserInfo = null;
	      	
	      	for (index=0; index<userList.size(); index++)
		{
	      		tmpUserInfo = (UserInfo)userList.get(index);
	      	%>
	        <tr <%if((index%2)==1){%>bgcolor="#CAE4F4"<%}%> >
	        <td align=center><%= tmpUserInfo.getUserId() %></td>
	        <td align=center><%= tmpUserInfo.getUserName() %></td>
	        <td align=center><%
	        if (tmpUserInfo.getRole().equals("0"))
	        { %>
	        系统管理员
	        <%}else{%>
	        一般用户
	        <%}%>
	        </td>
	        <td align=center><%
	        if (tmpUserInfo.getUserStatus().equals("1"))
	        { %>
	        在线
	        <%}else{%>
	        离线
	        <%}%>
	        </td>
	        <td align=center>
	        <%
	        	String tmpTime = tmpUserInfo.getCreateTime();
	        	if(tmpTime==null)tmpTime="";
	        	if(tmpTime.length()>=19)
	        	{
	        %>
	        		<%= tmpTime.substring(0,19) %>
	        <%
	        	}
	        %>
	        </td>
	        <td align=center>
	        <%
	        	tmpTime = tmpUserInfo.getLastLoginTime();
	        	if(tmpTime==null)tmpTime="";
	        	if(tmpTime.length()>=19)
	        	{
	        %>
	        		<%= tmpTime.substring(0,19) %>
	        <%
	        	}
	        %>
	        </td>
	        <td align=center>
	        <%
	        	if(!tmpUserInfo.getUserId().equals("0"))
	        	{
	        %>
	        <a href="userManageDelete.do?orderStr=<%=orderStr%>&userId=<%=tmpUserInfo.getUserId()%>"><IMG src="images/delto.gif" border=0></a></td>
		<%
			}
		%>
	        </tr>
	        <%
	
	      	}
	        %>
	</TABLE>
	
	<p><center>
	用户总数：<font color="red"><%=umfb.getTotalUserNum()%></font>&nbsp;&nbsp;&nbsp;
        在线：<font color="red"><%=umfb.getOnlineUserNum()%></font>&nbsp;&nbsp;&nbsp;
        离线：<font color="red"><%=umfb.getOfflineUserNum()%></font>&nbsp;&nbsp;&nbsp;
    	</center><p>
    	



	</td>
        </tr>
        <tr> 
          <td valign="middle" align="center">&nbsp;</td>
        </tr>

      </table>
      
    </td>
    <td width="5"></td>
  </tr>
  <tr> 
    <td width="6"></td>
    <td colspan="2" class="mainhead">&nbsp;</td>
    <td width="5"></td>
  </tr>
  <tr> 
    <td colspan="8" bgcolor="#214984" height="2"></td>
  </tr>
</table>

