<%@ 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="/sessionInfoWeixin.jsp"%>
<% 
  String strLevel = "../../"; 
%> 
<head>
<%@ include file="/share/oa_app_title.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no" />
<link href="<%=strLevel_SESSION%>app/images/soarwell_css.css" rel="stylesheet" type="text/css" />
 <script type="text/javascript" src="<%=strLevel_SESSION%>share/js/commonTool.js"></script>
 <script type="text/javascript" src="<%=strLevel_SESSION%>app/share/appWinOpen.js"></script> 
</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="/app/title.jsp"%>
<table width="100%">
  <tr>
    <td>
    <% if (!bReadonly) { %>
      <%=SzPageHelp.saveButton()%>
    <% } %>
      <%=SzPageHelp.backButton()%>
    </td>
  </tr>
</table>
<!-----信息维护------>
<table width="100%" border="0" cellspacing="3" cellpadding="3" style="border:#D7D7D9 1px solid;">
  <tr>  
    <td><span class="product_content">
        <b>[微信昵称]</b><%=custMessageInfo.getWXNC()%>&nbsp;
        </span>
    </td>
  </tr>  
  <tr>  
    <td><span class="product_content">
        <b>[OA绑定用户]</b><%=user.getBindLoginName(custMessageInfo.getWXOPENID())%>&nbsp;
        </span>

    	<%

    		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="OpenUserSelectWinApp('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">
  function OpenUserSelectWinApp(objId, objName) {
    var type = "all";
    var vUrl = "../../share/organize/user_win_app.jsp";
    vUrl = vUrl + "?objId=" + objId + "&objName=" + objName + "&type=" + type;
      	
    var vElementTop = getElementTop(window.event.srcElement);
    var vWebHeight = document.body.scrollHeight;    
    DivWinOpen(vUrl, vElementTop, vWebHeight);  	
  }
  
  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>
<div id="divWinOpenBg"></div>
<div id="divWinOpen">
 <iframe id="frameWinOpen" frameborder="0"  width="100%" height="100%"></iframe>
</div>
</body>
<%=SzPageHelp.calendarFrame2()%>
