<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzLevelNumber" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ page import="net.sz600.online.*" %>
<%@ include file="/sessionInfo.jsp"%>
<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 sPKEY = SzConvert.toZeroStr(request.getParameter("PKEY"));
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
    String sSearchName = SzConvert.strWriteData(request.getParameter("txtSearchName"));
		String sSearchTitle = SzConvert.strWriteData(request.getParameter("txtSearchTitle"));
		String sSearchBegin = SzConvert.strWriteData(request.getParameter("txtSearchBegin"));
		String sSearchEnd = SzConvert.strWriteData(request.getParameter("txtSearchEnd"));      

    String sTable_type = "";
    //读取数据
    OlMessageControl olMessageControl = new OlMessageControl();
    OlMessageInfo olMessageInfo = null;
    String sCond = "1=1";
    //发送列表
    if (!sPKEY.equals("0")) {
        sCond += "";
    }
    String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField")); 
    int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder"))); 
    if (sSortField.equals("")) { 
      sSortField = "FSID";
      iSortOrder = SzProperties.I_SortOrder_DESC;
    } 
    int iCurrentPage = 1;
    try {
        iCurrentPage =  Integer.parseInt(sPage);
    }catch(Exception e) {
    }
    if (!sSearchBegin.equals("")) {
    	sCond += " AND FSSJ>='" + sSearchBegin + "'";
    }
    if (!sSearchEnd.equals("")) {
    	sCond += " AND FSSJ<='" + sSearchEnd + "'";
    } 
    if (!sSearchName.equals("")) {
    	sCond += " AND FSDLXM ='" + sSearchName + "'";
    }   
    if (!sSearchTitle.equals("")) {
    	sCond += " AND FSBT LIKE '%" + sSearchTitle + "%'";
    } 
    Iterator iter = olMessageControl.getReceiveList(iDLID_SESSION, sCond, sSortField, iSortOrder, iCurrentPage, sSearch).iterator();

    SzPageInfo pageInfo = olMessageControl.getPageInfo();
    int iPageCount = pageInfo.getPageCount();
    int iRecordCount = pageInfo.getRecordCount();
    iCurrentPage = pageInfo.getCurrentPage();
    int i = 0;
    SzData szData = null;  
    
    String sPicture = OlUserSession.getInstance().alertCountInfo(iDLID_SESSION, strLevel_SESSION); 
%>
<!-----上面的工具栏------>
<%@ include file="/online/title.jsp"%>
<table width="100%">
  <form name="formBar" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>"> 
  <tr>
    <td nowrap>    
      <input type="button" name="btnAdd" class="btnClass" value="发送信息" OnClick="javascript:SendMessageWin();">
      <input type="button" name="btnDel" class="btnClass" value="删除" OnClick="javascript:FormSubmitConfirm(formList, 'delete.jsp?OPERATOR=deleteByReceive', '确定要删除？');">
      <span id="divAlert"><%//=sPicture %></span>
     <input type="button" class="btnClass" value="全部接收" OnClick="javascript:ReceiveAll();">
     <input type="button" class="btnClass" value="刷新" OnClick="javascript:document.location.reload();">
     
      发送时间<input type="text" name="txtSearchBegin" class="txtClassSearch" value="<%=sSearchBegin%>" readonly><%=SzPageHelp.calendar2Select2("formBar.txtSearchBegin")%>
      -<input type="text" name="txtSearchEnd" class="txtClassSearch" value="<%=sSearchEnd%>" readonly><%=SzPageHelp.calendar2Select2("formBar.txtSearchEnd")%>
      发送人员<input type="text" name="txtSearchName" class="txtClassSearch" value="<%=sSearchName%>" OnDblClick="javascript:OpenWin32('../../','','formBar.txtSearchName');">
		 标题<input type="text" name="txtSearchTitle" class="txtClassSearch" value="<%=sSearchTitle%>">      
		 <input class="btnClass" type="button" name="btnSearchNameOk" value="确定" OnClick="javascript:FormSubmit(formBar,'index_receive.jsp');">	  
     
    </td>
  </tr>
  </form>
</table>
<script language="javascript">
	//发送信息，send自动刷新父窗口
    function SendMessageWin() {
		var vUrl = "../message/send.jsp?OPERATOR=send";
    	window.open(vUrl,"","status=yes,height=500,width=750,top=100,left=100");    
  	}
	//查看信息
    function ReceiveMessageWin(vJSID) {
    	var vUrl = "../message/receive.jsp?refresh=true&OPERATOR=receive&KEY=" + vJSID;
	  	childWin = window.open(vUrl,"","status=yes,height=500,width=600,top=100,left=100");   
    }  
  
  function ReplyMessageWin(vJSID) {
    	var vUrl = "../message/send.jsp?OPERATOR=reply&KEY=" + vJSID;
	  	childWin = window.open(vUrl,"","status=yes,height=500,width=600,top=100,left=100");	  	
  }
      
	//接收全部信息
	function ReceiveAll() {
		//定位
		formUpdate.target = "_blank";
		formUpdate.OPERATOR.value = "receiveAll";
		formUpdate.action = "control.jsp";
		formUpdate.submit();
	}    
</script>

<!-----信息列表----->
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <form name="formList" method="post">
  <input type="hidden" name="page" value="<%=iCurrentPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">
	<input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
	<input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>">  
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">
  <input type="hidden" name="txtSearchTitle" value="<%=sSearchTitle%>">     
  <tr class="trClassTitle">
    <td width="5"><input type="checkbox" name="chkCheckAll" OnClick="javascript:CheckAll(formList, chkCheckAll, 'chkId');"></td>
    <td width="5">&nbsp;</td>
    <td width="120"><%=SzPageHelp.sortTitle("发送人员", "FSDLXM", sSortField, iSortOrder)%></td>   
    <td ><%=SzPageHelp.sortTitle("标题", "FSBT", sSortField, iSortOrder)%></td>
    <td width="120"><%=SzPageHelp.sortTitle("时间", "FSSJ", sSortField, iSortOrder)%></td>
    <% if (ReadOaConfig.getAlert_button().indexOf("weixin") >=0) { %>
    <td width="45"><%=SzPageHelp.sortTitle("微信", "JSWJJ", sSortField, iSortOrder)%></td>
    <% } %>    
    <td width="30">操作</td>
  </tr>
<%
    while (iter != null && iter.hasNext()) {
        olMessageInfo = (OlMessageInfo)iter.next();
        
        i++;
%>
  <tr  onMouseOver="javascript:this.className='trMouseOver'" onMouseOut="javascript:this.className='trMouseOut'">
    <td width="5" title="<%=i%>"><input type="checkbox" name="chkId" id="chkId" value="<%=olMessageInfo.getJSID()%>"></td>
    <td width="5" ><%=olMessageControl.receiveTag(olMessageInfo.getJSID()) %></td>
    <td><%=olMessageInfo.getFSDLXM()%>&nbsp;</td>    
    <td><%=olMessageControl.faceTag(olMessageInfo.getFSBQ())%>
        <a href="#" OnClick="javascript:ReceiveMessageWin('<%=olMessageInfo.getJSID()%>');"><%=olMessageInfo.getFSBT()%>&nbsp;</a>
        <%=olMessageControl.newTag(olMessageInfo.getJSYD())%></td>
    <td><%=olMessageInfo.getFSSJ()%>&nbsp;</td>
    <% if (ReadOaConfig.getAlert_button().indexOf("weixin") >=0) { %>
    <td width="50" align="center"><%=olMessageControl.getWeixinStateName(olMessageInfo.getJSWJJ(), olMessageInfo.getJSDLID()) %>&nbsp;</td>
    <% } %>    
    <td width="60" align="center">
      <a href="#" OnClick="javascript:ReceiveMessageWin('<%=olMessageInfo.getJSID()%>');">查看</a> 
      <% if (olMessageInfo.getFSDLID() > 0) { %>
      <a href="#" OnClick="javascript:ReplyMessageWin('<%=olMessageInfo.getJSID()%>');">回复</a>
      <% } %>      
    </td>
  </tr>
<%
    }
		if (ReadOaConfig.getAlert_button().indexOf("weixin") >=0) {
    	out.println(SzPageHelp.outIndexTableTr(i, SzProperties.I_PageSize, 7));
		} else {
			out.println(SzPageHelp.outIndexTableTr(i, SzProperties.I_PageSize, 6));
		}
%>

  </form>
</table>

<!-----下面的工具栏------>
<table width="100%">
  <form name="formPage" method="post">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">
	<input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
	<input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>">  
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">
  <input type="hidden" name="txtSearchTitle" value="<%=sSearchTitle%>">     
  <tr>
    <td align="right">
      <%@ include file="/share/page/page_include.jsp"%>
    </td>
  </tr>
  </form>
</table>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="page" value="<%=iCurrentPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>"> 
	<input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
	<input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>">  
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">
  <input type="hidden" name="txtSearchTitle" value="<%=sSearchTitle%>">    
</form>
<form name="formUpdate" method="post" ENCTYPE="multipart/form-data">
  <input type="hidden" name="OPERATOR" value="">
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
/*
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	var checkresult=null; 

	function CheckMessage() { 
		xmlhttp.open("POST", "refresh_action.jsp", false); 
		//xmlhttp.onreadystatechange = updatePage; 
		xmlhttp.send(null); 

		var response = xmlhttp.responseText;
		var vCount = "0";
		var vFirst = "0";
		var vIndex = response.indexOf("SzMessageYes");		
		if (vIndex >=0) {
			var vIndex1 = response.indexOf("SzFirstJSID");
			var vIndex2 = response.indexOf("SzEnd");
		    vCount = response.substring(vIndex + 12, vIndex1);
		    vFirst = response.substring(vIndex1 + 11, vIndex2);
		    divAlert.innerHTML 
		    	   =  ""
    	           + "<a href='#' OnClick='javascript:ReceiveMessageWin(" + vFirst + ")'>"
    	           + "<img border='0' src='../../images/share/online_m.gif'>"
    	           + "</a>"		    	   
				   + "未收信息[<b>" + vCount + "</b>]";
		} else {
		    divAlert.innerHTML = "<img border='0' src='../../images/share/online_i.gif'>未收信息[0]";
		}
		xmlhttp.abort();
	} 
	
	window.setInterval('CheckMessage()',5000);
*/
</script>
<%
    ////如果要使用日历控件，必须输出这个calendarFrame
    out.println(SzPageHelp.calendar2Frame2());
%>

