<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.HashMap" %>
<%@ 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.SzPageHelp" %>
<%@ page import="net.sz600.organize.*" %>
<%@ 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 sTable_type = "";
    //读取数据
    SzPopedomApp szPopedomApp = new SzPopedomApp();
    SzPopedomInfo szPopedomInfo = null;
    String sCond = "QXGSID=" + szCOMPANY_SESSION;
    if (!sPKEY.equals("0")) {
        sCond += "";
    }
    String sSortField = "QXMK,QXLX";
    int iSortOrder = SzProperties.I_SortOrder_DESC;
    int iCurrentPage = 1;
    try {
        iCurrentPage =  Integer.parseInt(sPage);
    }catch(Exception e) {
    }

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

    SzPageInfo pageInfo = szPopedomApp.getPageInfo();
    int iPageCount = pageInfo.getPageCount();
    int iRecordCount = pageInfo.getRecordCount();
    iCurrentPage = pageInfo.getCurrentPage();
    int i = 0;

    //模块
    SzModuleApp szModuleApp = new SzModuleApp();
    SzModuleInfo szModuleInfo = null;
    //HashMap mapModule = szModule.getMainHashMap("1=1");
%>
<!-----上面的工具栏------>
<%@ include file="/share/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%>">
  <tr>
    
    <td>
    <% if (isSystemManager_SESSION) { %>
      <%=SzPageHelp.addButtonSubmit()%>
      <%=SzPageHelp.deleteButton()%>
      <input type="button" name="btnDel" class="btnClass" value="全部删除" OnClick="javascript:FormSubmitConfirm(formList, 'control.jsp?OPERATOR=deleteAll', '确定要全部删除？');">
    <% } %>      
    </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%>">
  <tr class="trClassTitle">
    <td width="5"><input type="checkbox" name="chkCheckAll" OnClick="javascript:CheckAll(formList, chkCheckAll, 'chkId');"></td>
    <td>模块名称</td>
    <td>模块属性</td>
    <td width="80">权限名称</td>
    <td>已授权的人员</td>
  </tr>
<%
    String sName = "";
    String sDesc = "";
    String s = "";
    while (iter != null && iter.hasNext()) {
        szPopedomInfo = (SzPopedomInfo)iter.next();
        i++;
        sName = "";
        if (szPopedomInfo.getQXMK() == 0) {
          sName = "[整个系统]";
        } else {
          szModuleInfo = (SzModuleInfo)szModuleApp.getModuleInfoByMap(szPopedomInfo.getQXMK());
          if (szModuleInfo != null) {
              sName = szModuleInfo.getMKMC();
              sDesc = szModuleApp.getPropertyName(szModuleInfo.getMKQX());
          }
        }
        if (szPopedomInfo.getQXRYLB() == 0) {
          s = "[人员]" + SzUserHelp.getLoginName(szPopedomInfo.getQXRY());
        } else if (szPopedomInfo.getQXRYLB() == 1) {
          s = "[部门]" + SzUserHelp.getDepartName(szPopedomInfo.getQXRY());
        } else if (szPopedomInfo.getQXRYLB() == 2) {
          s = "[职务]" + SzUserHelp.getPostName(szPopedomInfo.getQXRY());
        }
        if (sName.equals("")) {
        	//调用清理权限的功能
        	szPopedomApp.deleteNotModule();
        	continue;
        }
%>
  <tr  onMouseOver="javascript:this.className='trMouseOver'" onMouseOut="javascript:this.className='trMouseOut'">
  	<% if (szPopedomInfo.getQXID() != 1) { %>
    <td width="5" title="<%=i%>"><input type="checkbox" name="chkId" id="chkId" value="<%=szPopedomInfo.getQXID()%>"></td>
    <% } else { %>
    <td width="5" title="<%=i%>"><input type="checkbox" name="chkId2" id="chkId2" disabled></td>
    <% } %>
    <td><%=sName%>&nbsp;</td>
    <td><%=sDesc%>&nbsp;</td>
    <td><%=SzProperties.getPopedomName(szPopedomInfo.getQXLX())%>&nbsp;</td>
    <td><%=s%>&nbsp;</td>
  </tr>
<%
    }
    out.println(SzPageHelp.outIndexTableTr(i, SzProperties.I_PageSize,5));
%>
  </form>
</table>

<!-----下面的工具栏------>
<table width="100%">
  <form name="formPage" method="post">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">
  <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%>">
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>

