<%@ page contentType="text/html; charset=GBK"  errorPage="../error.jsp" %>
<%@ page import = "zr.zrpower.ejb.sys.UserService"%>
<%@ page import = "zr.zrpower.ejb.sys.UnitService" %>
<%@ page import = "zr.zrpower.entity.sys.BPIP_USER"%>
<%@ page import = "zr.zrpower.ejb.sys.UIService"%>
<%@ page import = "zr.zrpower.entity.sys.SessionUser"%>
<%@ page import = "java.util.Hashtable" %>

<html>
<head>
<%
SessionUser user = (SessionUser)session.getAttribute("userinfo");
UIService userUI =new UIService();
UnitService unitMgr =new UnitService();
request.setCharacterEncoding("GBK");

BPIP_USER[] users = null;
UserService userMgr =new UserService();
users = userMgr.GetRecoveryUserList();

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

String strshow_data="";
String USERSTATE ="";
     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";
    }

%>
<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>

<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>
<%}%>
<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: "85%",
	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="RegForm" action="UserDel.jsp">

<%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:10%;">用户编号</th>
<th style="width:20%;">登录名</th>
<th style="width:20%;">真实姓名</th>
<th style="width:10%;">登录次数</th>
<th style="width:10%;">状态</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:600px;width:800px;" ></div>
  <% }%>
             <center>
             <table cellspacing="0" cellpadding="0" border='0'><tr>
                 <%if("6".equals(user.getUserWINDOWTYPE())){ %>
                   <%=userUI.ClickButton("全选","JavaScript:selectall();","buttonReturn.gif",user.getUserImage())%>
                <%}%>
                 <%=userUI.ClickButton("清空","JavaScript:Check()","buttonDelete.gif",user.getUserImage())%>
                 <%=userUI.ClickButton("还原","JavaScript:Check1()","buttonReturn.gif",user.getUserImage())%>
               </tr></table>
              </center>



</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 Check(){
 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==""){
    <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请先选择要清空的记录!', {icon: 7});
    <%}else{%>
        alert("请先选择要清空的记录！");
    <%}%>
 }
 else{
      if (confirm("将删除所有关联信息,确定要删除吗？"))
      {
        location.href="UserDel.jsp?ID="+chestr+"&TYPE=Del";
      }
  }
}
function Check1(){
 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==""){
      <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请先选择要还原的记录!', {icon: 7});
    <%}else{%>
        alert("请先选择要还原的记录！");
    <%}%>
 }else
 {
    location.href="UserDel.jsp?ID="+chestr+"&TYPE=Restore";
 }
}

</script>
<script language="JavaScript" type="text/JavaScript">

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;
unitMgr = null;
users = null;
userMgr = null;
%>
