<%@ 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="/sessionInfoWeixin.jsp"%>
<%@ include file="/docEngine/docEngineSession.jsp"%>
<head>
<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" />
<%@ include file="/share/oa_app_title.jsp"%>
 <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>
</head>
<%
	//获取文件夹显示方式信息
	boolean isTree = false;
	if(docEngineInfo.getTypeShowTree().equals("1")){
		isTree = true;
	}

	//获取信息 以权限设置
	int DLID = Integer.parseInt(szDLID_SESSION);
	String DLXM = szLoginInfo_SESSION.getDLXM();
    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;
    }

%>
<%
		//2012-01-05增加
    String sSearchCond = SzConvert.strWriteDataHTML(request.getParameter("searchCond"));	
    //获取提交的参数
    String sType = SzConvert.toZeroStr(request.getParameter("type"));
    String sPKEY = SzConvert.toZeroStr(request.getParameter("PKEY"));
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteDataHTML(request.getParameter("txtSearch"));
    String sSearch2 = SzConvert.strWriteData(request.getParameter("txtSearch"));
    String sSearchName = SzConvert.strWriteData(request.getParameter("txtSearchName"));
    String XXFL = SzConvert.toZeroStr(request.getParameter("XXFL"));
    
    String toFLID = SzConvert.toZeroStr(request.getParameter("toFLID"));

    ///////////////////////这一块判断是否有分类的管理权限
    //取得本人能管理的所有模块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")) {
    	if(wdyqType.isMangerFLID(strFLID_Manager, XXFL)){
    		//判断是否管理员
            canPrint_SESSION = true;
            canDelete_SESSION = true;
            canUpdate_SESSION = true;
    	}else{
    		WdyqTypeInfo typeInfo = (WdyqTypeInfo)wdyqType.getInfoByKey(Integer.valueOf(XXFL));
    		if(typeInfo!=null&&(","+typeInfo.getFLKTJDL()+",").indexOf(","+DLID+",")>0){
    			canAdd_SESSION = true;
    		}
    	}
    }
    /////////////////////判断分类管理权限

    String sTable_type = "";
    //读取数据
    WdyqDoc wdyqDoc = new WdyqDoc(moduleId);
    WdyqDocInfo wdyqDocInfo = null;
    String sCond = "XXGSID=" + szCOMPANY_SESSION;
    if (!sSearchCond.equals("")) {
    	//sSearchCond = sSearchCond.replaceAll("‘", "'");
    	//sSearchCond = SzConvert.toHTMLString(sSearchCond);
    	//
    	sCond += " AND " + sSearchCond;
    }
    sCond += " AND " + wdyqDoc.getCond(iBMID_SESSION, iDLID_SESSION, 
    						isBarManager_SESSION, strFLID_Manager, XXFL);
    //out.println(sCond);
    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) {
    }
    //if(XXFL.equals("0")){
	//	sCond += " or ','+ XXFJCKDLID+',' like '%,"+DLID+",%'";
    //}
    //out.println(sCond);
    int iPageSize = SzProperties.I_PageSize_APP;
    Iterator iter = wdyqDoc.getArrayList(sCond, sSortField, iSortOrder, iCurrentPage, iPageSize, sSearch2).iterator();

    SzPageInfo pageInfo = wdyqDoc.getPageInfo();
    int iPageCount = pageInfo.getPageCount();
    int iRecordCount = pageInfo.getRecordCount();

    iCurrentPage = pageInfo.getCurrentPage();
    int i = 0;
    
    sCond = "FLGSID=" + szCOMPANY_SESSION;
    if (docEngineInfo.getModulePopedom().equals("0")) {
    	sCond += " AND FLDLID=" + szDLID_SESSION;
    } else {
    	sCond += " AND 1=1";
    }
    

%>
<!-----上面的工具栏------>
<%@ include file="/app/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>
    <% if (!isTree&&!docEngineInfo.getTypeName().equals("")) {
         out.println(SzPageHelp.idSelectTreeSubmit(readDocEngineXml.getTypeTable(moduleId) ,"FLID","FLMC","FLBH","XXFL",Integer.parseInt(XXFL), "txtClass200", sCond));
       } else {
    	   out.println("<input type=\"hidden\" name=\"XXFL\" value=\"" + XXFL + "\">");
       }

	  %>  
	  <%=SzPageHelp.button("综合查询","javascript:FormSubmit(formBar, 'search.jsp');") %>
    </td>
  </tr>
  </form>
</table>

<!-----信息列表----->
<table width="100%" border="0" cellspacing="3" cellpadding="3" style="border:#D7D7D9 1px solid;">

  <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%>">  
 
<%
    
    while (iter != null && iter.hasNext()) {
        wdyqDocInfo = (WdyqDocInfo)iter.next();
        i++;
        
        //如果是个人的
        if (docEngineInfo.getModulePopedom().equals("0")) {
        	if (wdyqDocInfo.getXXDLID() == iDLID_SESSION) {
        		canUpdate_SESSION = true;
        	} else {
        		canUpdate_SESSION = false;
        	}
        } else if (docEngineInfo.getModulePopedom().equals("1")) {
        	canUpdate_SESSION = false;
        	if (isBarManager_SESSION) {
        		canUpdate_SESSION = true;
        	} else {
        		XXFL = "" + wdyqDocInfo.getXXFL();
        		//管理类型的
    			if (!XXFL.equals("0") 
    				&& wdyqType.isMangerFLID(strFLID_Manager, XXFL) 
    				&& (wdyqDocInfo.getXXDLID() == iDLID_SESSION)) {
        			canUpdate_SESSION = true;
    			}else if(!XXFL.equals("0")&&docEngineInfo.getManagerCanSee().equals("1")){
    				//这个条件可管理人员可以管理可管理文件夹及下级文件夹的文档
    				if(wdyqType.isMangerFLID(wdyqType.getManagerFLID(iDLID_SESSION),XXFL)){
    				
    				//可管理人员可以有对可管理文件夹下的文档进行管理
    				//if(wdyqType.isMangerFLID(((WdyqTypeInfo)wdyqType.getInfoByKey(wdyqDocInfo.getXXFL())).getFLGLDL(),DLID+"")){
    					canUpdate_SESSION = true;
    				}
    			}
        	}
        }
%>
<%
	if (i>1) {
%>
  <tr>
    <td height="8" align="left" background="../images/line.gif"></td>
  </tr> 
<% } %> 
  <tr>
    <td><span class="product_name"><%=i%></span>
    <% if (docEngineInfo.getHasAnnex().equals("1")) {%>
    <%=SzPageHelp.annexImage(strSkin_SESSION, wdyqDoc.hasAnnex(wdyqDocInfo.getXXID()))%>
    <% } %>
        <%
        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, wdyqDocInfo.getXXZD(), "推荐") %>
        <%=SzPageHelp.titleHelp(strSkin_SESSION, wdyqDocInfo.getXXJH(), "精华") %>         
    <% out.println( SzPageHelp.viewButton(sType, wdyqDocInfo.getXXID()) );%>
    </td>
  </tr>  
  <tr>  
    <td><span class="product_content"><a href="#" OnClick="javascript:FormSubmit(formPage,'detail.jsp?OPERATOR=detail&type=0&KEY=<%=wdyqDocInfo.getXXID()%>');">
        <b>[标题]</b><%=wdyqDocInfo.getXXBT()%>&nbsp;
        </a></span>
    </td>
  </tr>
  <% if (!docEngineInfo.getTypeName().equals("")) { %>
  <tr>
    <td><span class="product_content"><b>[分类]</b><%=mapType.get(new Integer(wdyqDocInfo.getXXFL()))%>&nbsp;</span></td>
  </tr>
  <% } %>  
  <tr>
  	<td><span class="product_content"><b>[发布时间]</b><%=wdyqDocInfo.getXXSJ()%></span>
  	</td>
  </tr>
  <tr>
  	<td><span class="product_content"><b>[发布部门]</b><%=wdyqDocInfo.getXXBMMC()%></span>
  	</td>
  </tr>
  <tr>
  	<td><span class="product_content"><b>[发布人员]</b><%=wdyqDocInfo.getXXDLXM()%></span>
  	</td>
  </tr>  
<%
    }
    int iLen = 7;
    if (docEngineInfo.getHasAnnex().equals("1")) {
    	iLen ++;
    }
    if (!docEngineInfo.getTypeName().equals("")) {
    	iLen ++;
    }
    out.println(SzPageHelp.printTableBlankApp(i, iPageSize));
%>

  </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%>">  
  <%@ include file="/app/share/page_include.jsp" %>
  </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>
<%
  mapType = null;
%>
<script language="javascript">
  //第一个表示对象，form，第二个表示字符串
  function FormSubmit2(obj,oFormName, vUrl) {
  	if(obj.value=="0"){
  		alert("请选择文件夹！");
  		return false;
  	}
  	if(confirm("确定要转移选中的文件？")){
	    oFormName.action = vUrl+"&toFLID="+document.getElementById("toXXFL").value;
	    oFormName.submit();
    }
  }
</script>
