<%@ page contentType="text/html; charset=GBK"  errorPage="../error.jsp" %>
<%@ page import = "zr.zrpower.entity.sys.SessionUser"%>
<%@ page import = "zr.zrpower.common.util.SysPreperty"%>
<%@ page import = "zr.zrpower.ejb.sys.UserService"%>
<%@ page import = "zr.zrpower.entity.sys.BPIP_USER_ROLE"%>
<%@ page import = "zr.zrpower.ejb.sys.SecurityService"%>

<%@ page import = "zr.zrpower.ejb.sys.UIService"%>
<html>
<head>
<%
  SessionUser user = (SessionUser)session.getAttribute("userinfo");
  UserService userMgr =new UserService();
  SecurityService SeService =new SecurityService();
  UIService userUI =new UIService();
  String strUserListStr=request.getParameter("UserListStr");
  String strUnitId=request.getParameter("UnitId");
  String strUserList = userMgr.GetShowUserRoleList("record",user.getUserImage(),"flowuser.gif");

%>
<%
String roleMenuNoStr="";
String Userid ="";
if(strUserListStr.length()>16){
Userid =strUserListStr.substring(0,16);
}
else{
  Userid =strUserListStr;
}
    BPIP_USER_ROLE[] rolemenu =SeService.GetUserRoleList(Userid);
     //+++++++++++++++
   if (rolemenu!=null && rolemenu.length>0){
      for(int i=0;i<rolemenu.length;i++){
          roleMenuNoStr+=","+rolemenu[i].getROLEID();
      }
    }
%>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title><%=SysPreperty.getProperty().SystemName%><%=SysPreperty.getProperty().Versoin%></title>
<link REL="stylesheet" type="text/css" href="../zrsysmanage/css/<%=user.getUserCSS()%>">
<SCRIPT LANGUAGE="JavaScript" src="../zrsysmanage/script/Public.js"></SCRIPT>
<SCRIPT LANGUAGE="javascript">
//作用：全选
function selectall(){
  var setcheck,length;
  length = document.recordfrm.elements.length ;
  if (document.recordfrm.setall.value == 0){
    document.recordfrm.setall.value = 1;
    setcheck = true;
  }else{
    document.recordfrm.setall.value = 0;
    setcheck = false;
  }
  for (var i=0; i<length; i++) {
    if (document.recordfrm.elements[i].name.indexOf("record") != -1)
      document.recordfrm.elements[i].checked = setcheck;
  }
  return;
}

//作用：获取记录
function GetRoleNo(recordfrm){
  var length = document.recordfrm.elements.length;
  var recordindex="";
  var selectedstring="";
  var strValue="";
  for (var i=0; i<length; i++){
    recordindex  = document.recordfrm.elements[i].name.indexOf("record");
    if (recordindex  != -1) {
      if (document.recordfrm.elements[i].checked){
        strValue = document.recordfrm.elements[i].id;
        intValue = strValue.length;
        if (selectedstring == ""){
          selectedstring = strValue;
        }else{
          selectedstring = selectedstring  + "," + strValue;
        }
      }
    }
  }

  if (selectedstring != "") {
      recordfrm.RoelListStr.value = selectedstring;
  }else {
     if (confirm("未选择相关角色,如确定将删除该用户原有的角色！"))
      { recordfrm.RoelListStr.value = "0";
         return true;}
        else
       {return false;}
  }
  return true;
}


</script>
</head>
<BODY class="BodyMain">
<FORM method="post" name="recordfrm" action="../actionrole.do">
<input type="hidden" name="setall" value="0">
<input type="hidden" name="RoelListStr" value="">
<input type="hidden" name="UserListStr" value="<%=strUserListStr%>">
<input type="hidden" name="UnitId" value="<%=strUnitId%>">
<input type="hidden" name="Act" value="userrolemanage">
<%=userUI.ShowHeadHtml("选择角色","IcoTitle.gif",user.getUserImage())%>
<%=userUI.ShowBodyStartHtml()%>
<TABLE border="0" width="100%" cellpadding=5 cellspacing=0>
     <TR>
      <TD height="240" >

  <DIV id="divMessage" style='padding-left:0;padding-top:0;width:100%;height:100%;overflow:auto'>
  <TABLE border="0" width="100%" cellpadding=0 cellspacing=0 >
    <TR>
       <TD width="100%" height="3"></TD>
    </TR>
    <TR>
      <TD valign="top" >
        <TABLE  border="0" width="100%" cellpadding=0 cellspacing=0>
       <%=strUserList%>
        </TABLE>
      </TD>
    </TR>
  </TABLE>
  </DIV>

  </td></tr>

  <tr><td height="10"></td></tr>
  <tr><td height="30" align="center">
          <center>
          <table cellspacing="0" cellpadding="0" border='0'><tr>
                 <td>
                <br>
                   <img src="<%=SysPreperty.getProperty().AppUrl%>zrsysmanage/images/<%=user.getUserImage()%>/PuTreeRoot.gif" valign="absmiddle" WIDTH="17" HEIGHT="17">
                   <input type="checkbox" name="Dept" onclick="selectall();">全选&nbsp;

                 </td>

                 <%if("html5.css".equals(user.getUserCSS())){ %>
                 <%=userUI.ClickButton("确 定","JavaScript:if(GetRoleNo(document.recordfrm)){document.recordfrm.submit();parent.layer.closeAll();}","buttonSure.gif",user.getUserImage())%>
                 <%=userUI.ClickButton1("关 闭","JavaScript:parent.layer.closeAll();","buttonClose.gif",user.getUserImage())%>
                 <%}else{ %>
                 <%=userUI.ClickButton("确 定","JavaScript:if(GetRoleNo(document.recordfrm)){document.recordfrm.submit();}","buttonSure.gif",user.getUserImage())%>
                 <%=userUI.ClickButton1("关 闭","window.close();","buttonClose.gif",user.getUserImage())%>
                 <%} %>
         </tr></table>
          <br>
         </center>
    </td></tr></TABLE>
    <%=userUI.ShowFootHtml()%>
</form>
<script language="javascript">
function MenuChecked()
{
   var roleMenuNoStr="<%=roleMenuNoStr%>";

   var chkList=document.getElementsByName("record");

   for(i=0;i<chkList.length;i++)
   {
     if(roleMenuNoStr.indexOf(chkList[i].id)>-1)
     {
       chkList[i].checked=true;
     }else
     {
       chkList[i].checked=false;
     }
    }
}
function selectOnclick(id)
{
    if (document.getElementById(id).checked==true)
    {document.getElementById(id).checked='';}
    else
    {document.getElementById(id).checked='checked';}
}
<% if(strUserListStr.length()==16){%>
   MenuChecked();
<%}%>
</script>
</body>
</html>
<%
user = null;
userMgr = null;
SeService = null;
userUI = null;
rolemenu = null;
%>
