<%@ page contentType="text/html; charset=GBK"  errorPage="../error.jsp" %>
<%@ page import = "zr.zrpower.ejb.sys.UserService"%>
<%@ page import = "zr.zrpower.entity.sys.BPIP_USER"%>
<%@ page import = "zr.zrpower.common.web.ListPage"%>

<%@ page import = "zr.zrpower.ejb.sys.UIService"%>
<%@ page import = "zr.zrpower.ejb.sys.UserService"%>
<%@ page import = "zr.zrpower.entity.sys.SessionUser"%>
<%@page import="zr.zrpower.ejb.sys.SecurityService"%>
<%@ page import = "java.lang.Object" %>
<%@ page import = "java.util.Hashtable" %>

<%
SessionUser user = (SessionUser)session.getAttribute("userinfo");
UIService userUI =new UIService();
UserService UserSer = new UserService();

SecurityService SeService =new SecurityService();
request.setCharacterEncoding("GBK");
String strunitid = "";
if(request.getParameter("nodeId")!=null){
  strunitid = request.getParameter("nodeId");
}

   String USERSTATE = "";
   BPIP_USER[] users = null;
   UserService userMgr =new UserService();

   users = userMgr.GetUserList(strunitid);

   Hashtable Hashtable1 = new Hashtable();
   Hashtable1.put("0","使用中");
   Hashtable1.put("1","已停用");


   String strshow_data = "";

    if (users!=null && users.length>0){
       strshow_data = strshow_data + "[";
       for(int i=0;i<users.length;i++){

         strshow_data = strshow_data + "[";


         strshow_data = strshow_data + "'<input type=checkbox name=select_check value="+users[i].getUSERID()+">',";
         strshow_data = strshow_data + "'"+users[i].getUSERID()+"',";
         strshow_data = strshow_data + "'"+users[i].getLOGINID()+"',";
         strshow_data = strshow_data + "'"+users[i].getNAME()+"',";
         strshow_data = strshow_data + "'"+users[i].getLOGINTIME()+"',";

         USERSTATE = users[i].getUSERSTATE();
         if (USERSTATE==null)
         {USERSTATE="0";}

         if (i < users.length-1 )
         {
            strshow_data = strshow_data + "'"+Hashtable1.get(USERSTATE)+"'],\r\n";
         }else
         {
            strshow_data = strshow_data + "'"+Hashtable1.get(USERSTATE)+"']";
         }

       }
       strshow_data = strshow_data + "]";
    }else
    {
      strshow_data = "null";
    }

%>
<html>
<link rel="stylesheet" type="text/css" media="all" href="../ZrwebGui/sigma_grid/grid/calendar/calendar-blue.css">
<script type="text/javascript" src="../ZrwebGui/sigma_grid/grid/calendar/calendar.js"></script>
<script type="text/javascript" src="../ZrwebGui/sigma_grid/grid/calendar/calendar-setup.js"></script>
<link rel="stylesheet" type="text/css" href="../ZrwebGui/sigma_grid/grid/gt_grid.css">
<link rel="stylesheet" type="text/css" href="../ZrwebGui/sigma_grid/grid/skin/vista/skinstyle.css">
<link rel="stylesheet" type="text/css" href="../ZrwebGui/sigma_grid/grid/skin/pink/skinstyle.css">
<link rel="stylesheet" type="text/css" href="../ZrwebGui/sigma_grid/grid/skin/mac/skinstyle.css">
<script type="text/javascript" src="../ZrwebGui/sigma_grid/grid/gt_msg_en.js"></script>
<script type="text/javascript" src="../ZrwebGui/sigma_grid/grid/gt_const.js"></script>
<script type="text/javascript" src="../ZrwebGui/sigma_grid/grid/gt_grid_all.js"></script>
<%if("6".equals(user.getUserWINDOWTYPE())){ %>
<LINK type="text/css" rel="stylesheet" href="../zrsysmanage/html5/css/style_tables.css">
<SCRIPT LANGUAGE="JavaScript" src="../zrsysmanage/html5/script/jquery-2.0.3.min.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="../zrsysmanage/html5/layer/layer.js"></SCRIPT>
<%}%>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title></title>
<link REL="stylesheet" type="text/css" href="../zrsysmanage/css/<%=user.getUserCSS()%>">
<SCRIPT LANGUAGE="JavaScript" src="../zrsysmanage/script/Public.js"></SCRIPT>

<script type="text/javascript" >
var css = "<%=user.getUserCSS()%>";
var skincss = "vista";

if (css=="Blue.css")
{skincss = "vista";}
if (css=="Public.css")
{skincss = "default";}
if (css=="Window.css" || css=="nBlue.css")
{skincss = "mac";}
if (css=="Yellow.css")
{skincss = "pink";}


var grid_demo_id = "myGrid1" ;
var show_data= <%=strshow_data%>;

var dsOption= {

	fields :[
                {name : 'SID'  },
		{name : 'USERID'  },
		{name : 'LOGINID'  },
		{name : 'NAME'  },
		{name : 'LOGINTIME' },
                {name : 'USERSTATE'  }
	],

	recordType : 'array',
	data : show_data
}



var colsOption = [

           {id: 'SID' , header: "<center>选择</center>" , width :50 , align : 'center'  },
           {id: 'USERID' , header: "<center>用户编号</center>" , width :150 , align : 'center'  },
           {id: 'LOGINID' , header: "<center>登录名</center>" , width :120,  align : 'center'  },
	   {id: 'NAME' , header: "<center>真实姓名</center>" , width :120 ,align : 'center'  },
	   {id: 'LOGINTIME' , header: "<center>登录次数</center>" , width :100 , align : 'center' },
           {id: 'USERSTATE' , header: "<center>状态</center>" , width :100 , align : 'center' }
];

Sigma.ToolFactroy.register(
	'mybutton',
	{
		cls : 'mybutton-cls',
		toolTip : '全选',
		action : function(event,grid) {selectall(); }
	}
);

var gridOption={
	id : grid_demo_id,
	width: "99%",
	height: "92%",
	container : 'gridbox',
	replaceContainer : true,
	dataset : dsOption ,
	columns : colsOption,
	pageSize : 2000,
	toolbarContent : 'mybutton',
        skin : skincss,

       showIndexColumn : true
};


<%if(!"6".equals(user.getUserWINDOWTYPE())){ %>
var mygrid=new Sigma.Grid( gridOption );
Sigma.Util.onLoad( Sigma.Grid.render(mygrid));
<%}%>
</script>

<style type="text/css">
 .mybutton-cls {
		background : url(../ZrwebGui/sigma_grid/grid/skin/select.gif) no-repeat center center;
}
</style>

</head>
<BODY class="BodyMain">
<form name="recordfrm" action="UserList.jsp">

<TABLE width="100%" height='100%' cellSpacing='0' cellPadding='0' border='0'><tr><td>
<TABLE height='31' cellSpacing='0' cellPadding='0' border='0'>
 <TR>

  <%=userUI.ClickButton("增加","JavaScript:add();","IcoAdd.gif",user.getUserImage())%>
  <%=userUI.ClickButton("详细信息","JavaScript:msg();","IcoEdit.gif",user.getUserImage())%>
  <%=userUI.ClickButton("编辑","JavaScript:edit();","IcoEdit.gif",user.getUserImage())%>
  <%=userUI.ClickButton("密码重置","JavaScript:ReturnPassword();","IcoEdit.gif",user.getUserImage())%>
  <%=userUI.ClickButton("停用","JavaScript:StopUser();","IcoEdit.gif",user.getUserImage())%>
  <%=userUI.ClickButton("启用","JavaScript:StartUser();","IcoEdit.gif",user.getUserImage())%>
  <%=userUI.ClickButton("调动","JavaScript:Transfer1();","IcoEdit.gif",user.getUserImage())%>
  <%=userUI.ClickButton("分配角色","JavaScript:if(SelectRole(document.recordfrm)){document.recordfrm.submit();}","IcoEdit.gif",user.getUserImage())%>


  </tr></table></td></tr><tr><td valign="top">

<%if("6".equals(user.getUserWINDOWTYPE())){ %>
  <div id="mianRole" style="height: 300px;overflow: auto;">
  <table class="bordered" id="html5_table" >

<thead>
<tr>
<th style="width:5%;">编号</th>
<th style="width:8%;">选择</th>
<th style="width:15%;">用户编号</th>
<th style="width:15%;">登录名</th>
<th style="width:15%;">真实姓名</th>
<th style="width:15%;">登录次数</th>
<th style="width:15%;">状态</th>
</tr>
</thead>
<%
if (users!=null && users.length>0){
  for(int i=0;i<users.length;i++){
     %>
     <tr  onclick="click_color(this,'<%=users[i].getUSERID() %>');">
        <td style="text-align:center;"><%=i+1 %></td>
        <td style="text-align:center;"><input type=checkbox  name=select_check value=<%=users[i].getUSERID() %>></td>
        <td style="text-align:center;"><%=users[i].getUSERID() %></td>
        <td style="text-align:center;"><%=users[i].getLOGINID() %></td>
        <td style="text-align:center;"><%=users[i].getNAME() %></td>
        <td style="text-align:center;"><%=users[i].getLOGINTIME() %></td>
        <td style="text-align:center;"><%=Hashtable1.get(users[i].getUSERSTATE()) %></td>
     </tr>

     <%
  }
}

 %>
</table></div>
  <%}else{ %>
  <div id="gridbox" style="border:0px solid #cccccc;background-color:#f3f3f3;padding:5px;height:200px;width:700px;" ></div>
  <% }%>

</td></tr></TABLE>
</form>
</BODY>
<script language="JavaScript" type="text/JavaScript">
<!--
<%if("6".equals(user.getUserWINDOWTYPE())){ %>
 var h=$(document.body).height();//浏览器当前窗口文档body的高度
 h=h*1-100;
 $('div').css('height',h);

 var allvalue="";
function clickValue(value){
    allvalue=value;
}
<%}%>

function add(){
    location.href="UserAdd.jsp?unitid=<%=strunitid%>";
}
function msg(){
  var str=document.getElementsByName("select_check");

    var objarray=str.length;
    var chestr="";
    for (i=0;i<objarray;i++)
    {
      if(str[i].checked == true)
      {
        if (chestr=="")
        {
          chestr = str[i].value;
        }else
        {chestr = chestr + "," + str[i].value;}
      }
    }

  if(chestr.length>16)
    { <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请选择一条记录进行操作!', {icon: 7});
      <%}else{%>
       alert("请选择一条记录进行操作!");
       <%}%>
       }
  else if(chestr.length<16)
    { <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请先选择要查看的信息!', {icon: 7});
      <%}else{%>
       alert("请先选择要查看的信息!");
       <%}%>
    }else
    {location.href="UserInfo.jsp?SelectedItems="+chestr+"&unitid=<%=strunitid%>";}
}
function edit(){
  var str=document.getElementsByName("select_check");
    var objarray=str.length;
    var chestr="";
    for (i=0;i<objarray;i++)
    {
      if(str[i].checked == true)
      {
        if (chestr=="")
        {
          chestr = str[i].value;
        }else
        {chestr = chestr + "," + str[i].value;}
      }
    }

    if(chestr.length>16)
    { <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请选择一条记录进行操作!', {icon: 7});
      <%}else{%>
       alert("请选择一条记录进行操作！");
       <%}%>
       }
  else if(chestr.length<16)
    { <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请先选择编辑的记录!', {icon: 7});
      <%}else{%>
       alert("请先选择编辑的记录!");
       <%}%>
   }
    else
    {location.href="UserEdit.jsp?SelectedItems="+chestr+"&unitid=<%=strunitid%>";}
}
function ReturnPassword(){
  var str=document.getElementsByName("select_check");
    var objarray=str.length;
    var chestr="";
    for (i=0;i<objarray;i++)
    {
      if(str[i].checked == true)
      {
        if (chestr=="")
        {
          chestr = str[i].value;
        }else
        {chestr = chestr + "," + str[i].value;}
      }
    }

  if(chestr.length<16)
  { <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请先选择要重置的记录!', {icon: 7});
      <%}else{%>
       alert("请先选择要重置的记录！");
       <%}%>
   }else
{ var loginid = "1";
  var userid = chestr;
  location.href="../actionuser.do?SelectedItems="+chestr+"&Act=repw&loginid="+loginid+"&userid="+userid+"&unitid=<%=strunitid%>";
}
}
function StopUser(){
   var str=document.getElementsByName("select_check");
    var objarray=str.length;
    var chestr="";
    for (i=0;i<objarray;i++)
    {
      if(str[i].checked == true)
      {
        if (chestr=="")
        {
          chestr = str[i].value;
        }else
        {chestr = chestr + "," + str[i].value;}
      }
    }

   if(chestr.length<16)
    { <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请先选择停用的记录!', {icon: 7});
      <%}else{%>
       alert("请先选择停用的记录！");
       <%}%>
    }else
    {
      var userid = chestr;
      location.href="../actionuser.do?SelectedItems="+chestr+"&Act=stop&userid="+userid+"&unitid=<%=strunitid%>";
    }
}
function StartUser(){
   var str=document.getElementsByName("select_check");
    var objarray=str.length;
    var chestr="";
    for (i=0;i<objarray;i++)
    {
      if(str[i].checked == true)
      {
        if (chestr=="")
        {
          chestr = str[i].value;
        }else
        {chestr = chestr + "," + str[i].value;}
      }
    }

   if(chestr.length<16)
    { <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请先选择启用的记录!', {icon: 7});
      <%}else{%>
       alert("请先选择启用的记录！");
       <%}%>
    }else
    {
     var userid = chestr;
     location.href="../actionuser.do?SelectedItems="+chestr+"&Act=unstop&userid="+userid+"&unitid=<%=strunitid%>";
    }
}
function Transfer1(){
    var str=document.getElementsByName("select_check");
    var objarray=str.length;
    var chestr="";
    for (i=0;i<objarray;i++)
    {
      if(str[i].checked == true)
      {
        if (chestr=="")
        {
          chestr = str[i].value;
        }else
        {chestr = chestr + "," + str[i].value;}
      }
    }

  if(chestr.length>16)
    { <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请输入单位名称!', {icon: 7});
      <%}else{%>
       alert("请输入单位名称！");
       <%}%>
       }
  else if(chestr.length<16)
    { <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请先选择要调动的记录!', {icon: 7});
      <%}else{%>
       alert("请先选择要调动的记录！");
       <%}%>
    }else
    {location.href="UserRemoveAdd.jsp?SelectedItems="+chestr+"&unitid=<%=strunitid%>";}
}

function SelectRole(theForm){

    var str=document.getElementsByName("select_check");
    var objarray=str.length;
    var chestr="";
    for (i=0;i<objarray;i++)
    {
      if(str[i].checked == true)
      {
        if (chestr=="")
        {
          chestr = str[i].value;
        }else
        {chestr = chestr + "," + str[i].value;}
      }
    }

    if (chestr==null||chestr=="")
    { <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请先选择要分配角色的用户!', {icon: 7});
      <%}else{%>
       alert("请先选择要分配角色的用户！");
       <%}%>
    }else
    {
     var url="SelectUserRoleList.jsp?UnitId=<%=strunitid%>&UserListStr="+chestr+"";
     var name="PopWindow";
     var ShowPopWindow = null;
     var status="toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width=520,height=320";
     <%if("6".equals(user.getUserWINDOWTYPE())){ %>
       openLaoadUrl(url,'520','320');
      <%}else{%>
       ShowPopWindow = window.open(url,name,status);
     ShowPopWindow.moveTo(280,180);
     ShowPopWindow.focus();
       <%}%>

   }
 }


  function selectall(){
  var chkList=document.getElementsByName("select_check");
  var setcheck;

  if (chkList.length>0)
  {
    if (chkList[0].checked){
       setcheck = false;
    }else{
       setcheck = true;
    }
  }

  for(i=0;i<chkList.length;i++)
  {

    chkList[i].checked=setcheck;
  }
}
//-->
</script>
</HTML>
<%
user = null;
userUI = null;
users = null;
userMgr = null;
%>
