<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.tool.SzDateHelp" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="com.soarwell.weixin.append.*" %>
<%@ page import="com.soarwell.weixin.oa.User" %>
<%@ include file="/sessionInfo.jsp"%>
<% 
  String strLevel = "../../"; 
%> 
<head>
<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 sType = SzConvert.toZeroStr(request.getParameter("type"));
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
%>
<%
    SzData szData = null;
    SzDataInfo szDataInfo = null;

    String sOPERATOR = SzConvert.toSpaceStr(request.getParameter("OPERATOR"));
    String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));
    String sReadonly = "";
    boolean bReadonly = false;
    if (sOPERATOR.equals("detail")) {
        sReadonly = "readonly";
        bReadonly = true;
    }
    //读取数据
    CustMessageInfo custMessageInfo = null;
    CustMessage custMessage = new CustMessage();
    if (!sKEY.equals("0")) {
    	custMessageInfo = (CustMessageInfo)custMessage.getInfoByKey(Integer.parseInt(sKEY));
    }
    if (custMessageInfo == null) {
    	custMessageInfo = new CustMessageInfo();
    } else {
    	if (custMessageInfo.getWXHFNR().equals("")) {
        	custMessageInfo.setWXHFRY(sDLXM_SESSION);
        	custMessageInfo.setWXHFSJ(SzDateHelp.getTimeStr());
    		
    	}    	
    }
    
	User user = new User(); 
	String name = user.getBindLoginName(custMessageInfo.getWXOPENID());  
%>

<body>
<!-----上面的工具栏------>
<form name="formUpdate" method="post">
  <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="type" value="<%=sType%>">
  <input type="hidden" name="WXOPENID" value="<%=custMessageInfo.getWXOPENID() %>" >
  <input type="hidden" name="name" value="<%=name%>" > 
<%@ include file="/share/title.jsp"%>
<table width="100%">
  <tr>
    <td>
    <% if (!bReadonly) { %>
      <%=SzPageHelp.saveButton()%>
    <% } %>
      <%=SzPageHelp.backButton()%>
    </td>
  </tr>
</table>
<!-----信息维护------>
<table width="750" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">
  <tr>
    <td class="tdClassTitle">昵称</td>
    <td colspan="3"><%= custMessageInfo.getWXNC()%></td>
  </tr>
  
  <tr>
    <td class="tdClassTitle">OA绑定用户</td>
    <td>
    	<%

    		if (!name.equals("")) {
    			out.println("已选择用户:" + name + "<br>");
    			out.println("不选择系统用户保存时，解除绑定<br>");
    		}
    	%>    
    	<input type="hidden" name="loginid" class="txtClass1">
    	<input type="text" name="username" class="txtClass1">
    	<input type="button" class="btnClass100" value="选择系统用户" onClick="OpenWin32('../../', 'formUpdate.loginid', 'formUpdate.username');">

    </td>
  </tr>

</table>  
</form>
<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="type" value="<%=sType%>">
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">

  function FormSave(formName, url) {
  	var username = formName.username.value;
  	var name = formName.name.value;
    //检查是否可以保存
    var v = "";
    var flag = false;
    if (name != "" && username == "") {
      v = "绑定用户已从[" + name + "]设置为空，将解除绑定?";
      flag = true;
    } else if (name == "" && username == "") {
    	v = "请选择绑定用户";
    	flag = false;
    } else if (name == "" && username != "") {
    	v = "已选择用户[" + username + "]，将绑定"
    	flag = true;
		} else if (name != "" && username != "" && name == username) {   
			v = "绑定用户没有变化";
			flag = false;
		} else if (name != "" && username != "" && name != username) {			 
			v = "绑定用户已从[" + name + "]变更为[" + username + "]";
			flag = true;	
    }	
		if (!flag) {
			alert(v);
			return false;
		} else {
			if (confirm(v)) {
    		formName.action = url;
    		formName.submit();
			} else {
				return false;
			}
		}
  }
 
</script>
</body>
<%=SzPageHelp.calendarFrame2()%>
