<%@ page contentType="text/html; charset=GBK" %>
<%@ page import = "zr.zrpower.common.util.SysPreperty" %>
<%@ page import = "zr.zrpower.entity.sys.SessionUser" %>
<%@ page import = "zr.zrpower.queryengine.service.QueryControl" %>
<%@ page import = "zr.zrpower.ejb.sys.UIService" %>

<%@ page import="zr.zrpower.common.web.SelectBox" %>
<%@ page import = "java.lang.Object"%>
<%@ page import = "java.util.*" %>
<%@ page import = "java.text.*" %>
<HTML>
<%


UIService userUI =new UIService();
SessionUser user = (SessionUser)session.getAttribute("userinfo");
request.setCharacterEncoding("GBK");

QueryControl queryControl= new QueryControl();



String currentPage = request.getParameter("page");
  if(currentPage == null)
    currentPage = "1";



  String DOCNAME = request.getParameter("DOCNAME");
  if(DOCNAME == null)
    DOCNAME = "" ;

  String DOCID = request.getParameter("DOCID");
   if(DOCID == null)
      DOCID = "";


String[][] strArray = queryControl.GetDocNameArray();

SelectBox  selectBox = new SelectBox();
selectBox.setDictStringArrary(strArray);
if(!DOCNAME.equals(""))
{
  selectBox.setSelected(DOCNAME);
}


  String[][] columnsName = null;
  String sqlStr;
  String sqlCount;

 sqlStr = " Select * From FLOW_RUNTIME_PROCESS WHERE FORMTABLE = '"+DOCNAME+"' AND FORMID like '%"+DOCID+"%' ORDER BY CREATEDATE DESC ";

 sqlCount = "Select count(*) as RCount From FLOW_RUNTIME_PROCESS WHERE FORMTABLE = '"+DOCNAME+"' AND FORMID like '%"+DOCID+"%' ";

 columnsName = new String[6][2];

  columnsName[0][0] = "FLOW_RUNTIME_PROCESS.NAME";
  columnsName[0][1] = "220";

  columnsName[1][0] = "FLOW_RUNTIME_PROCESS.CREATEPSN";
  columnsName[1][1] = "60";

  columnsName[2][0] = "FLOW_RUNTIME_PROCESS.CREATEDATE";
  columnsName[2][1] = "120";

  columnsName[3][0] = "FLOW_RUNTIME_PROCESS.FDATE";
  columnsName[3][1] = "120";

  columnsName[4][0] = "FLOW_RUNTIME_PROCESS.UNIT";
  columnsName[4][1] = "280";

  columnsName[5][0] = "FLOW_RUNTIME_PROCESS.FLOWPATH";
  columnsName[5][1] = "1";

%>
<HTML>
<HEAD>
<TITLE><%=SysPreperty.getProperty().SystemName%><%=SysPreperty.getProperty().Versoin%></TITLE>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META http-equiv="Content-Type" content="text/html; charset=GBK">
<base target="_self"/>
<link REL="stylesheet" type="text/css" href="<%=SysPreperty.getProperty().AppUrl%>zrsysmanage/css/<%=user.getUserCSS()%>">
<link REL="stylesheet" type="text/css" href="<%=SysPreperty.getProperty().AppUrl%>ZrwebGui/zrsysmanage/css/<%=user.getUserCSS()%>">
<SCRIPT LANGUAGE="JavaScript" src="<%=SysPreperty.getProperty().AppUrl%>zrsysmanage/script/Public.js" type="text/jscript"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="<%=SysPreperty.getProperty().AppUrl%>ZrwebGui/js/flexgrid.js" type="text/jscript"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="<%=SysPreperty.getProperty().AppUrl%>ZrQueryEngine/Js/QueryEngine.js"  type="text/jscript" ></SCRIPT>
<script language="JavaScript" type="text/JavaScript">
<!--
function Query()
{
  if(recordfrm.DOCID.value.length == 0 )
  {
     alert("请输入文书编号进行查询!");

      SetFocus(recordfrm.DOCID);
      return;
  }

  recordfrm.page.value="1";
  document.recordfrm.submit();
}


//表格双击后执行的JS函数
function ExeOndblclick()
{


  var createUnit = getClickColumnValue("<%=columnsName[4][0]%>");

   var flowPath = getClickColumnValue("<%=columnsName[5][0]%>");
   flowPath=flowPath.substr(1);
   flowPath = " <%=SysPreperty.getProperty().AppUrl%>"+flowPath;
    if (flowPath != "") {
       OpenFlowWindow(flowPath);
       }else {
      alert("未选择审批表记录!");
  }
}

//-->
</script>
</HEAD>
<BODY class="BodyMain">
<FORM name="recordfrm" method="post" action="">
<input type=hidden name="page" value="1"/>
<!--HTML Head表单头显示[显示内容,图标文件,用户肤色的图片文件夹]-->
<%=userUI.ShowHeadHtml("文书查询","IcoTitle.gif",user.getUserImage())%>
<!--HTML Body Start显示表单开始部分-->
<%=userUI.ShowBodyStartHtml()%>
<TABLE height="100%" width="100%" cellSpacing='0' >
<TR height=2><TD></TD></TR>
<TR><TD  valign=TOP>
 <fieldset>
           <legend >查询信息</legend>
           <table border="0" class="inputTable" cellspacing="0" cellpadding="0" align="center" width="100%">
           <tr height=30 >
               <td width="20%" class="inputTdtitle" >文书名称：</td>
               <td width="30%"  class="inputTd"><select id="DOCNAME" name="DOCNAME" style="width:90%;"  class="text"><%=selectBox.show()%></select></td>
               <td width="20%" class="inputTdtitle" >文书编号：</td>
               <td width="30%" class="inputTd" ><input class="text" type="text" name="DOCID" style="width:90%;" maxlength="40" value="<%=DOCID%>"></td>
           </tr>
          </table>
          <br>
         </fieldset>
</TD></TR>

<TR Height=30><TD>
<center>

  <table cellspacing="0" cellpadding="0" border='0' align="center"><tr align="center">
                   <%=userUI.ClickButton1("查   询","JavaScript:Query();","IcoBrowse.gif",user.getUserImage())%>
                   <%=userUI.ClickButton1("文书详情","JavaScript:ExeOndblclick();","buttonSelect.gif",user.getUserImage())%>
               </tr></table>
  </center>

 </TD></TR>

<TR><TD height="100%" valign="top">
<DIV style='position:absolute;width:100%;height:100%;overflow:auto;border:inset 1px ;'>
  <%
        try
        {

          out.print(queryControl.GetQueryResultTableBySql(sqlStr,Integer.parseInt(currentPage),user.getUserPageSize(),columnsName,"","0",true));

        }catch(Exception ex)
        {
          out.print(ex.getMessage());
        }

      %>
</DIV>

</TD></TR>

<TR><TD class='Window_TbE'>
<TABLE border='0' width='100%' cellspacing='0' cellpadding='0'>
  <TR>
 <%
      try
      {
        out.print(queryControl.CreatePageNavigateBySql(sqlCount,Integer.parseInt(currentPage),user.getUserPageSize()));
      }catch(Exception ex)
      {
        out.print(ex.getMessage());
      }

      %>
</TD>
 </TR>
</TABLE>

</TD></TR>

</TABLE>

<%=userUI.ShowBodyEndHtml()%>

<!--HTML Foot显示表单尾-->
<%=userUI.ShowFootHtml()%>

</FORM>
</BODY>
<SCRIPT language="javascript" type="text/javascript">
 window.setTimeout("grid.show()",500);
</SCRIPT>
</HTML>
