<%@ 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.flowengine.service.FlowControl"%>

<%@ page import = "zr.zrpower.ejb.sys.UIService"%>
<%@ page import = "java.util.Calendar"%>
<%@ page import = "java.text.SimpleDateFormat"%>

<html>
<head>
<%
  request.setCharacterEncoding("GBK");
  response.setContentType("text/html; charset=GBK");

  SessionUser user = (SessionUser)session.getAttribute("userinfo");
  FlowControl FControl = new FlowControl();
  UIService userUI =new UIService();

  String roles = request.getParameter("roles");//角色编号串
  String sunitid = request.getParameter("sunitid");//左包含的单位编码位数
  if (sunitid==null || sunitid.length()==0)
  {sunitid = "";}



  String isdept = request.getParameter("isdept");//是否本部门的人,1是，0否
  String isSMS = request.getParameter("issms");//是否发送短信,1是，0否
  if (isSMS==null){isSMS="0";}

  Calendar cal = Calendar.getInstance();
  SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
  String mDateTime = formatter.format(cal.getTime());

  String TitleName = "";
  String username = user.getName();

  TitleName = request.getParameter("TitleName");//标题
  if (TitleName==null){TitleName="";}

  TitleName = "["+TitleName+"→分送]["+username+"]["+mDateTime+"]";

  String strUnitid = user.getUnitID();
  if (sunitid.length()>0)
  {sunitid = strUnitid.substring(0,Integer.parseInt(sunitid));}

  String strUserList = FControl.GetShowRolesUserList(roles,"record",user.getUserImage(),"flowuser.gif","2",strUnitid,sunitid,isdept);

  if (isSMS.equals("1"))
  {
      strUserList = "短信提示：<input type='text' name='smsvalue' size='42' value='"+TitleName+"'><br>"+strUserList;
  }

%>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>选择人员--<%=SysPreperty.getProperty().SystemName%></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 selectallPm(unitid){
  var setcheck,length;
  length = document.recordfrm.elements.length ;
  setcheck = true;

  for (var i=0; i<length; i++) {
    if (document.recordfrm.elements[i].title == unitid)
      document.recordfrm.elements[i].checked = setcheck;
  }

}

//作用：取消全选
function selectnotBM(unitid){
  var setcheck,length;
  length = document.recordfrm.elements.length ;
  setcheck = false;
  for (var i=0; i<length; i++) {

    if (document.recordfrm.elements[i].title == unitid)
      document.recordfrm.elements[i].checked = setcheck;
  }

}
//作用：获取记录
function GetUserNo(){
  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].value;
        intValue = strValue.length;
        if (selectedstring == ""){
          selectedstring = strValue;
        }else{
          selectedstring = selectedstring  + "," + strValue;
        }
      }
    }
  }

  if (selectedstring != "") {
      var issms = document.recordfrm.issms.value;
      var smsvalue="";
      if (issms=="1")
      {
         smsvalue = document.recordfrm.smsvalue.value;
      }
      if (smsvalue.length==0)
      {smsvalue="no";}

      window.returnValue = selectedstring+"/"+smsvalue;
      window.close();
      return;
  }else {
      alert("请选择要提交操作的用户!");
  }
  return;
}

function selectOnclick(id)
{
    if (document.getElementById(id).checked==true)
    {document.getElementById(id).checked='';}
    else
    {document.getElementById(id).checked='checked';}
}

</script>
</head>
<BODY class="BodyMain">
<FORM method="post" name="recordfrm" action="">
<input type="hidden" name="setall" value="0">
<input type="hidden" name="issms" value="<%=isSMS%>">

<TABLE border="0" width="95%" cellpadding=0 cellspacing=0>
     <TR>
      <TD height="320">

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

                   <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>
                 <%=userUI.ClickButton1("确 定","GetUserNo();","buttonSure.gif",user.getUserImage())%>
                 <%=userUI.ClickButton1("关 闭","window.close();","buttonClose.gif",user.getUserImage())%>
         </tr></table>
         </center>
    </td></tr></TABLE>
</form>
</body>
</html>
<%
//清空相关对象
user = null;
userUI = null;
%>
