<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.organize.*" %>
<%@ include file="/sessionInfo.jsp"%>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
</head>
<%
    //获取提交的参数
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
%>
<%
    String sOPERATOR = request.getParameter("OPERATOR");
    String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));
    //读取数据
    SzLoginInfo loginInfo = null;
    if (!sKEY.equals("0")) {
        SzLogin login = new SzLogin();
        loginInfo = (SzLoginInfo)login.getInfoByKey(Integer.parseInt(sKEY));
    }
    if (loginInfo == null) {
        loginInfo = new SzLoginInfo();
    }
    //读取数据
    SzUserInfo szUserInfo = null;
    if (!sKEY.equals("0")) {
        SzUser szUser = new SzUser();
        szUserInfo = (SzUserInfo)szUser.getInfoByCond("YGDL=" + sKEY);
    }

    if (szUserInfo == null) {
        szUserInfo = new SzUserInfo();
        szUserInfo.setYGBH(SzKey.getInstance().genNextKey("YG", "YG", 4));
    }

    String sMM = SzConvert.decryptStr(loginInfo.getDLMM());
%>

<!-----上面的工具栏------>
<form name="formUpdate" method="post">
  <%@ include file="/share/title.jsp" %>
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
  <input type="hidden" name="KEY" value="<%=sKEY%>">
  <input type="hidden" name="DLID" value="<%=loginInfo.getDLID()%>">
  <input type="hidden" name="YGID" value="<%=szUserInfo.getYGID()%>">
  <input type="hidden" name="DLMM" value="<%=sMM%>">
<table width="100%">
  <tr>
    <td>
      <input type="button" name="btnSave" class="btnClass" value="保存" OnClick="javascript:FormSave(formUpdate, 'control.jsp');">
      <input type="button" name="btnBack" class="btnClass" value="返回" OnClick="javascript:FormSubmit(formHidden, 'index.jsp');">
    </td>
  </tr>
</table>

<!-----信息维护------>
<table width="600" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">
  <tr>
    <td width="100" align="right">登陆帐号</td>
    <td><input type="text" name="DLZH" value="<%=loginInfo.getDLZH()%>" class="txtClass1">
    <font color="red">*</font>
    </td>

    <td width="100" align="right">用户姓名</td>
    <td><input type="text" name="DLXM" value="<%=loginInfo.getDLXM()%>" class="txtClass1">
    <font color="red">*</font>
    </td>
  </tr>
  <tr>
    <td width="100" align="right">登陆密码</td>
    <td><input type="password" name="DLMM_INPUT" value="" class="txtClass1"></td>

    <td width="100" align="right">使用状态</td>
    <td>
      <input type="radio" name="DLBZ" value="0" <% if(loginInfo.getDLBZ() == 0 ) { %> checked <% } %> >可用&nbsp;
      <input type="radio" name="DLBZ" value="1" <% if(loginInfo.getDLBZ() == 1 ) { %> checked <% } %> >禁用&nbsp;
    </td>
  </tr>   
  <tr>
    <td width="100" align="right">所属部门</td>
    <td>
      <%=SzPageHelp.idSelectTree2("SZXT_BM","BMID","BMMC","BMBH", "BMGSID=" + szCOMPANY_SESSION, "DLBM",loginInfo.getDLBM(), "txtClass1")%>
    </td>

    <td width="100" align="right">所任职务</td>
    <td>
      <%=SzPageHelp.idSelectTree3("SZXT_ZW","ZWID","ZWMC","ZWDJ", "ZWGSID=" + szCOMPANY_SESSION, "DLZW",loginInfo.getDLZW(), "txtClass1")%>
    </td>
  </tr>
  <% if (ReadOaConfig.getAlert_button().indexOf("weixin") >=0) { %>
  <tr>
    <td width="100" align="right">绑定微信ID</td>
    <td colspan="3"><input type="text" class="txtClass2R"  name="DLOPENID" value="<%=loginInfo.getDLOPENID()%>">   
    </td>
  </tr>   
  <% } %>   
  <tr>
    <td width="100" align="right">外网登陆</td>
    <td colspan="3">
    <%
    	String str_id[] = {"0","1"};
    	String str_name[] = {"禁用","可用"};
    	out.println(SzPageHelp.radio("DLWW", str_id, str_name, "" + loginInfo.getDLWW()));
    %>
      (当“系统安全设置”设置为“指定人员可以在外网访问，未指定人员只能内网访问”时，本限制才会有作用)
    </td>
  </tr>   
 
  <tr>
    <td width="100" align="right">权限级别</td>
    <td colspan="3">
    <%
    	String str_id2[] = {"0","1"};
    	String str_name2[] = {"普通","<font color='blue'>超级管理员</font>"};
    	out.println(SzPageHelp.radio("DLQX", str_id2, str_name2, "" + loginInfo.getDLQX()));
    %>
      (设置为超级管理员时，不需要另外再分配权限，拥有系统所有模块的管理权限；普通用户可通过“系统设置--权限分配”分配权限)
    </td>
  </tr>    
</table>
<br>
<table width="600" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">
  <tr>
    <td width="100" align="right">员工编号</td>
    <td><input type="text" name="YGBH" value="<%=szUserInfo.getYGBH()%>" class="txtClass1"></td>

    <td width="100" align="right">性别</td>
    <td>
        <input type="radio" name="YGXB" value="男" <% if(szUserInfo.getYGXB().equals("男") ) { %> checked <% } %> >男&nbsp;
        <input type="radio" name="YGXB" value="女" <% if(szUserInfo.getYGXB().equals("女") ) { %> checked <% } %> >女&nbsp;
        <input type="radio" name="YGXB" value="" <% if(szUserInfo.getYGXB().equals("") ) { %> checked <% } %> >不详&nbsp;
    </td>
  <tr>
    <td width="100" align="right">证件类型</td>
    <td><input type="text" name="YGZJLX" value="<%=szUserInfo.getYGZJLX()%>" class="txtClass1"></td>

    <td width="100" align="right">出生日期</td>
    <td><input type="text" name="YGSR" value="<%=szUserInfo.getYGSR()%>" class="txtClass120"><%=SzPageHelp.calendar2Select2("formUpdate.YGSR")%></td>
  </tr>

  <tr>
    <td width="100" align="right">证件号码</td>
    <td colspan="3"><input type="text" name="YGSFZ" value="<%=szUserInfo.getYGSFZ()%>"  class="txtClass2"></td>
  </tr>

  <tr>
    <td width="100" align="right">手机号码</td>
    <td><input type="text" name="YGSJ" value="<%=szUserInfo.getYGSJ()%>" class="txtClass1"></td>

    <td width="100" align="right">联系电话</td>
    <td><input type="text" name="YGDH" value="<%=szUserInfo.getYGDH()%>" class="txtClass1"></td>
  </tr>
  <tr>
    <td width="100" align="right">传真号码</td>
    <td><input type="text" name="YGCZ" value="<%=szUserInfo.getYGCZ()%>" class="txtClass1"></td>

    <td width="100" align="right">电子邮箱</td>
    <td><input type="text" name="YGYX" value="<%=szUserInfo.getYGYX()%>" class="txtClass1"></td>
  </tr>
  <tr>
    <td width="100" align="right">入职日期</td>
    <td><input type="text" name="YGMSN" value="<%=szUserInfo.getYGMSN()%>" readonly class="txtClass120R"><%=SzPageHelp.calendar2Select2("formUpdate.YGMSN")%></td>

    <td width="100" align="right">QQ帐号</td>
    <td><input type="text" name="YGQQ" value="<%=szUserInfo.getYGQQ()%>" class="txtClass1"></td>
  </tr>
  <tr>
    <td width="100" align="right">联系地址</td>
    <td colspan="3"><input type="text" name="YGDZ" value="<%=szUserInfo.getYGDZ()%>" class="txtClass2"></td>
  </tr>
  <tr>
    <td width="100" align="right">工作职责</td>
    <td colspan="3"><textarea name="YGZW" rows="5" class="areaClass2"><%=szUserInfo.getYGZW()%></textarea></td>
  </tr>
  <tr>
    <td width="100" align="right">个人简介</td>
    <td colspan="3"><textarea name="YGJJ" rows="5" class="areaClass2"><%=szUserInfo.getYGJJ()%></textarea></td>
  </tr>
</table>
<br>
<%
    //获取本员工的部门任职
    //获取员工，部门，职务的hashMap
    SzDepart szDepart = new SzDepart();
    HashMap mapDepart = szDepart.getMainHashMap("1=1");
    SzPost szPost = new SzPost();
    HashMap mapPost = szPost.getMainHashMap("1=1");

    SzUserPost szUserPost = new SzUserPost();
    SzUserPostInfo szUserPostInfo = null;
    String sCond = "RZDL=" + sKEY;
    Iterator iter = szUserPost.getArrayList(sCond).iterator();
    StringBuffer sb = new StringBuffer("");

    while (iter.hasNext()) {
        szUserPostInfo = (SzUserPostInfo)iter.next();
        sb.append(SzConvert.strReadData((String)mapDepart.get(new Integer(szUserPostInfo.getRZBM()))));
        sb.append("[");
        sb.append(SzConvert.strReadData((String)mapPost.get(new Integer(szUserPostInfo.getRZZW()))));
        sb.append("]  ");
    }
    String sTemp = sb.toString();
    mapDepart = null;
    mapPost = null;
%>
<table  width="600" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <tr class="trClassTitle">
    <td width="100" align="right">部门任职</td>
    <td width="10">&nbsp;</td>
    <td><%=sTemp%></td>
  </tr>
</table>
</form>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
</form>
<script language="javascript">
  //第一个表示对象，form，第二个表示字符串
  function FormSubmit(oFormName, vUrl) {
    oFormName.action = vUrl;
    oFormName.submit();
  }
</script>
<script language="javascript">
  function FormSave(formName, url) {
    //检查是否可以保存
    if (formName.DLZH.value == "") {
      formName.DLZH.focus();
      alert("登陆帐号不能为空");
      return false;
    }
    if (formName.DLXM.value == "") {
      formName.DLXM.focus();
      alert("用户姓名不能为空");
      return false;
    }
    if (formName.YGBH.value == "") {
      formName.YGBH.focus();
      alert("员工编号不能为空");
      return false;
    }

    //密码判断
    if (formName.OPERATOR.value == "update") {
      if (formName.DLMM_INPUT.value != "" && formName.DLMM_INPUT.value != formName.DLMM.value) {
        if (confirm("密码已经改变，是否修改")) {
          formName.DLMM.value = formName.DLMM_INPUT.value;	
        } else {
	  return false;
	}
      }
    } else {
      formName.DLMM.value = formName.DLMM_INPUT.value;	
    }

    //提交
    formName.action = url;
    formName.submit();
  }
</script>
<%
    out.println(SzPageHelp.calendar2Frame2());
%>
