<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Map" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.docEngine.*" %>
<%@ include file="/sessionInfo.jsp"%>
<%@ include file="/docEngine/docEngineSession.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>
<%
    boolean canAdd_SESSION = false;
    boolean canPrint_SESSION = false;
    boolean canDelete_SESSION = false;
    boolean canUpdate_SESSION = false;

    //管理资料，只有管理员和有权限的人才能添加。有权限的人员可以查看、修改、删除。
    if (isBarManager_SESSION || docEngineInfo.getModulePopedom().equals("0")) {
        canAdd_SESSION = true;
        canPrint_SESSION = true;
        canDelete_SESSION = true;
        canUpdate_SESSION = true;
    } else {
        canAdd_SESSION = szPopedom_SESSION.isModuleCanAdd(szModuleInfo_SESSION.getMKID(), szLoginInfo_SESSION.getDLID());
        canPrint_SESSION = szPopedom_SESSION.isModuleCanPrint(szModuleInfo_SESSION.getMKID(), szLoginInfo_SESSION.getDLID());
        canDelete_SESSION = false;
        canUpdate_SESSION = false;
    }
    

%>
<%
    //获取提交的参数
    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 XXFL = SzConvert.toZeroStr(request.getParameter("XXFL"));
    
    ///////////////////////这一块判断是否有分类的管理权限
    //取得本人能管理的所有模块ID
    String strFLID_Manager = "0";
    WdyqType wdyqType = new WdyqType(moduleId);
    strFLID_Manager = wdyqType.getManagerFLID(iDLID_SESSION);
    boolean isMangerFLID = wdyqType.isMangerFLID(strFLID_Manager);
    Map mapType = wdyqType.getMainHashMap("1=1");
    if (isMangerFLID) {
        canAdd_SESSION = true;
    }
    //如果选择了分类，又是该分类的管理员，可以做管理操作
    if (!XXFL.equals("0") && wdyqType.isMangerFLID(strFLID_Manager, XXFL)) {
        //判断是否管理员
        canPrint_SESSION = true;
        canDelete_SESSION = true;
        canUpdate_SESSION = true;
    }
    /////////////////////判断分类管理权限

    String sTable_type = "";
    //读取数据
    WdyqDoc wdyqDoc = new WdyqDoc(moduleId);
    WdyqDocInfo wdyqDocInfo = null;
    String sCond = "1=1";
    sCond = wdyqDoc.getCond(iBMID_SESSION, iDLID_SESSION, 
    						isBarManager_SESSION, strFLID_Manager, XXFL, sType);

    String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField"));
    int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder")));
    if (sSortField.equals("")) {
    	sSortField = "XXID";
    	iSortOrder = SzProperties.I_SortOrder_DESC;
    }
    int iCurrentPage = 1;
    try {
        iCurrentPage =  Integer.parseInt(sPage);
    }catch(Exception e) {
    }

    Iterator iter = wdyqDoc.getArrayList(sCond, sSortField, iSortOrder, iCurrentPage, sSearch).iterator();

    SzPageInfo pageInfo = wdyqDoc.getPageInfo();
    int iPageCount = pageInfo.getPageCount();
    int iRecordCount = pageInfo.getRecordCount();
    iCurrentPage = pageInfo.getCurrentPage();
    int i = 0;
    
    if (docEngineInfo.getModulePopedom().equals("0")) {
    	sCond = "FLDLID=" + szDLID_SESSION;
    } else {
    	sCond = "1=1";
    }
    
    //审核信息,如果是type=0,表示上报
    if (docEngineInfo.getModulePopedom().equals("2")) {
    	if (sType.equals("1")) {
            canAdd_SESSION = true;
            canPrint_SESSION = true;
            canDelete_SESSION = true;
            canUpdate_SESSION = true;    		
    	} else if (sType.equals("2") && isBarManager_SESSION ) {
            canAdd_SESSION = false;
            canPrint_SESSION = true;
            canDelete_SESSION = true;
            canUpdate_SESSION = true;    		
    	} else if (sType.equals("2") && !isBarManager_SESSION ) {
            canAdd_SESSION = false;
            canPrint_SESSION = false;
            canDelete_SESSION = false;
            canUpdate_SESSION = false;     		
    	}
    }    
%>
<!-----上面的工具栏------>
<%@ include file="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>
    <% out.println(SzPageHelp.addButtonSubmit(canAdd_SESSION)); %>
    <% out.println(SzPageHelp.deleteButtonUpload(canDelete_SESSION)); %>
    <% if (!docEngineInfo.getTypeName().equals("")) {
         out.println(SzPageHelp.idSelectTreeSubmit(readDocEngineXml.getTypeTable(moduleId) ,"FLID","FLMC","FLBH","XXFL",Integer.parseInt(XXFL), "txtClass200", sCond));
       }
    %>
    </td>
  </tr>
  </form>
</table>

<!-----信息列表----->
<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="XXFL" value="<%=XXFL%>">    
  <tr class="trClassTitle">
    <td width="5"><input type="checkbox" name="chkCheckAll" OnClick="javascript:CheckAll(formList, chkCheckAll, 'chkId');"></td>
    <% if (docEngineInfo.getHasAnnex().equals("1")) {%>
    <td width="5" title="附件标志"><%=SzPageHelp.annexImage(strSkin_SESSION, true)%></td>
    <% } %>
    <% if (!docEngineInfo.getTypeName().equals("")) { %>
    <td width="120"><%=SzPageHelp.sortTitle("分类名称", "XXFL", sSortField, iSortOrder)%></td>
    <% } %>
    <td><%=SzPageHelp.sortTitle("标题", "XXBT", sSortField, iSortOrder)%></td>
    <td width="120"><%=SzPageHelp.sortTitle("发布时间", "XXSJ", sSortField, iSortOrder)%></td>
    <td width="80"><%=SzPageHelp.sortTitle("发布部门", "XXBMMC", sSortField, iSortOrder)%></td>
    <td width="80"><%=SzPageHelp.sortTitle("发布人员", "XXDLXM", sSortField, iSortOrder)%></td>
    <td width="40">操作</td>
  </tr>
<%
    int iBY = 0;
    while (iter != null && iter.hasNext()) {
        wdyqDocInfo = (WdyqDocInfo)iter.next();
        i++;
        iBY = 0;
        if (wdyqDocInfo.getXXBY1().equals("") || wdyqDocInfo.getXXBY1().equals("0")) {
        	iBY = 1;
        }
%>
  <tr>
    <td width="5" title="<%=i%>">
    <input type="checkbox" name="chkId" id="chkId" value="<%=wdyqDocInfo.getXXID()%>">
    </td>
    
    <% if (docEngineInfo.getHasAnnex().equals("1")) {%>
    <td width="5"><%=SzPageHelp.annexImage(strSkin_SESSION, wdyqDoc.hasAnnex(wdyqDocInfo.getXXID()))%></td>
    <% } %>
    <% if (!docEngineInfo.getTypeName().equals("")) { %>
    <td><%=mapType.get(new Integer(wdyqDocInfo.getXXFL()))%>&nbsp;</td>
    <% } %>
    <td><a href="#" OnClick="javascript:FormSubmit(formPage,'detail.jsp?OPERATOR=detail&type=0&KEY=<%=wdyqDocInfo.getXXID()%>');">
        <%=wdyqDocInfo.getXXBT()%>&nbsp;
        </a>
        <%
        if (docEngineInfo.getModulePopedom().equals("1") && docEngineInfo.getHasReadRecord().equals("1")) {
          out.println(SzPageHelp.newImage(strSkin_SESSION, wdyqDoc.hasRead(wdyqDocInfo.getXXID(), iDLID_SESSION)));
        }
        %>
        <%=SzPageHelp.titleHelp(strSkin_SESSION, iBY, "等待审批") %>        
        <%=SzPageHelp.titleHelp(strSkin_SESSION, wdyqDocInfo.getXXZD(), "推荐") %>
        <%=SzPageHelp.titleHelp(strSkin_SESSION, wdyqDocInfo.getXXJH(), "精华") %>
    </td>
    <td><%=wdyqDocInfo.getXXSJ()%>&nbsp;</td>
    <td><%=wdyqDocInfo.getXXBMMC()%>&nbsp;</td>
    <td><%=wdyqDocInfo.getXXDLXM()%>&nbsp;</td>
    <td>
      <%
        if (docEngineInfo.getModulePopedom().equals("1") && docEngineInfo.getHasReadRecord().equals("1")) {
          out.println( SzPageHelp.operatorButton(sType, wdyqDocInfo.getXXID(), "feedback.jsp", "feedback", "反馈") );
        }
      %>
      <% out.println( SzPageHelp.viewButton(sType, wdyqDocInfo.getXXID()) );%>
      <% 
        //发布后，只有管理员能修改
        if (sType.equals("1")) {
        	out.println( SzPageHelp.operatorButton(sType, wdyqDocInfo.getXXID(), "update.jsp", "update", "修改") );        	
        } else if (sType.equals("2")) {
        	out.println( SzPageHelp.operatorButton(sType, wdyqDocInfo.getXXID(), "update.jsp", "update", "审核") );        	
        }                
      %>
    </td>
  </tr>
<%
    }
    int iLen = 6;
    if (docEngineInfo.getHasAnnex().equals("1")) {
    	iLen ++;
    }
    if (!docEngineInfo.getTypeName().equals("")) {
    	iLen ++;
    }
    out.println(SzPageHelp.outIndexTableTr(i, SzProperties.I_PageSize, iLen));
%>

  </form>
</table>

<!-----下面的工具栏------>
<table width="100%">
  <form name="formPage" method="post">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>">
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">
  <input type="hidden" name="XXFL" value="<%=XXFL%>">  
  <tr>
    <td align="right">
      <!----翻页---->
      <% if (iCurrentPage==1) { %>
      首页
      上页
      <% } else {%>
      <a href="#" OnClick="javascript:FormSubmit(formPage,'index_m.jsp?page=1');">首页</a>
      <a href="#" OnClick="javascript:FormSubmit(formPage,'index_m.jsp?page=<%=iCurrentPage-1%>');">上页</a>
      <% } %>
      <% if (iCurrentPage<iPageCount) { %>
      <a href="#" OnClick="javascript:FormSubmit(formPage,'index_m.jsp?page=<%=iCurrentPage+1%>');">下页</a>
      <a href="#" OnClick="javascript:FormSubmit(formPage,'index_m.jsp?page=<%=iPageCount%>');">尾页</a>
      <% } else { %>
      下页
      尾页
      <% } %>
      第<input type="text" name="page" class="txtClassPage" value="<%=iCurrentPage%>" size="2">页

      共&nbsp;<%=iPageCount%>&nbsp;页/共&nbsp;<%=iRecordCount%>&nbsp;记录&nbsp;
      <!----快速查找---->快速查找
      <input type="text" name="txtSearch" class="txtClassSearch" value="<%=sSearch%>" size="10">
      <input type="button" name="btnGoPage" class="btnClass" value="确定" OnClick="javascript:FormSubmit(formPage,'index_m.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="XXFL" value="<%=XXFL%>">    
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<%
  mapType = null;
%>
