<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Collection" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.database.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.tool.SzDateHelp" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.flow.*" %>
<%@ page import="net.sz600.online.*" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ page import="net.sz600.formEngine.*" %>
<%@ page import="net.sz600.weboffice.*" %>
<%@ include file="/sessionInfoWeixin.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="images/soarwell_css.css" rel="stylesheet" type="text/css" />
  <style type="text/css">
	img{vertical-align:middle;} 

    t img { vertical-align:middle;}
    
    
    .btnImg {
      cursor: hand;
    }

    .btnImgOver {
      cursor: hand;
      background:url(<%=strSkin_SESSION%>/top/t_m_over.gif); 
    }
    .btnImgClick {
      cursor: hand;
      background:url(<%=strSkin_SESSION%>/top/t_m_on.gif);
    }    
    
</style> 

<script language="javascript">
  function ChangeImage(obj, img) {
    obj.src = "<%=strSkin_SESSION%>/top2/" + img;
  }
</script>
<script language="javascript">
  function GoUrl(url) {
    if (url != "") {
      document.location.href=url;
    }
  }
	function ClickSecond(number, secondLink) {
		var oImg = document.getElementById("img" +number);
		var oThird = document.getElementsByName("" + number);
		
		if (oImg.src.indexOf("menu_down2.gif") >=0) {
			//未展开
			oImg.src = "../images/skin2_blue2/menu/menu_down1.gif";
			if (oThird != null) {
				HiddenThird(number, oThird, "");		
			} 			
		} else if (oImg.src.indexOf("menu_down1.gif") >=0) {
			//已经展开，要收缩
			oImg.src = "../images/skin2_blue2/menu/menu_down2.gif";
			if (oThird != null) {
				HiddenThird(number, oThird, "none");		
			} 				
		} 
		
		if (oImg.src.indexOf("menu_h02.gif") >=0) {
			oImg.src = "../images/skin2_blue2/menu/menu_h01.gif";
			if (oThird != null) {
				HiddenThird(number, oThird, "");		
			} 		
		} else if (oImg.src.indexOf("menu_h01.gif") >=0) {
			//已经展开，要收缩
			oImg.src = "../images/skin2_blue2/menu/menu_h02.gif";
			if (oThird != null) {
				HiddenThird(number, oThird, "none");		
			} 				
		}
	
	}	
	
	function HiddenThird(number, oThird, vDispaly) {
		var obj = null;
		if (oThird != null) {
			var vCount = oThird.length;
			for (var v = 0; v<vCount; v++) {
				if (vDispaly == "") {
					oThird[v].style.display = "";
				} else {
					oThird[v].style.display = "none";
				}
				
				//是否有下级

			}
		}
		obj = document.getElementsByName("SC" + number);
		var number2 = "";
		if (obj != null) {
		  var vCount = obj.length;

		  for (var v = 0; v<vCount; v++) {
		    number2 = obj[v].value;
		    var oThird2 = document.getElementsByName("" + number2);
		    HiddenThird(number2, oThird2, vDispaly);
		  }
		}  		
	}
	
	function HiddenThird1(number, vDispaly) {
		obj = document.getElementsByName("SC" + number);
		var number2 = "";
		if (obj != null) {
		  var vCount = obj.length;

		  for (var v = 0; v<vCount; v++) {
		    number2 = obj[v].value;
		    var oThird2 = document.getElementsByName("" + number2);
		    HiddenThird(number2, oThird2, vDispaly);
		  }
		}  		
	}	
</script>

</head>
<%
	BdValueControl bdValueControl = new  BdValueControl();
	int iCount = 0;
	StringBuffer sb = new StringBuffer("");
	sb.append("<font size='2' color='#F02C56'><b>[");
	if (!sBMMC_SESSION.equals("")) {
	  sb.append(sBMMC_SESSION);
	  sb.append(",");
	}
	sb.append("");
	sb.append(sDLXM_SESSION);
	sb.append("]</b></font>");	
 
	//获得本人可用的第一级菜单
	 //这里是传递进来的一级模块，下面列出二级模块。
 	String sMKBH_TOP = SzConvert.toZeroStr(request.getParameter("MKBH_TOP"));
   String sType = SzConvert.toZeroStr(request.getParameter("type")); //分公司信息
   String strType = sType;
   if (strType.equals("0")) {
   	strType = "-4";	
   }
   SzModuleApp szModule = new SzModuleApp();
   SzModuleInfo szModuleInfo = new SzModuleInfo();
   //取得传过来的一级
   int iMKID_TOP = szModule.getModuleId(sMKBH_TOP);
   szModuleInfo = (SzModuleInfo)szModule.getModuleInfoByMap(iMKID_TOP);
   if (szModuleInfo == null) {
   	szModuleInfo = new SzModuleInfo(); 
   }
   String sLink = "";
%>
<table width="100%" border="0" cellspacing="3" cellpadding="3" style="border:#D7D7D9 1px solid;">
  <tr>
    <td valign="top">
      <span class="product_name"><%=sb.toString()%></span>

      <a href="#" OnClick="javascript:top.location.href='index.jsp';"  onfocus="javascript:blur();">
      <img src="<%=strSkin_SESSION%>/top2/t_desktop.png" width="60" height="26" id="t_relogin" border="0" 
           OnMouseOver="javascript:ChangeImage(this, 't_desktop2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_desktop.png');">           
      </a>
      
      <a href="#" OnClick="javascript:top.location.href='../reloginApp.jsp?DLID=<%=iDLID_SESSION%>';"  onfocus="javascript:blur();">
      <img src="<%=strSkin_SESSION%>/top2/t_relogin.png" width="60" height="26" id="t_relogin" border="0" 
           OnMouseOver="javascript:ChangeImage(this, 't_relogin2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_relogin.png');">
	    </a>

    </td>
  </tr>

  <tr>
    <td height="8" align="left" background="images/line.gif"></td>
  </tr>

  <tr onMouseOver="javascript:this.className='trMouseOver'" onMouseOut="javascript:this.className='trMouseOut'">
    <td style="background-color:#DFF2FA">
    <%
    sLink = SzModuleApp.getMenuLink(szModuleInfo.getMKLJDZ(), szModuleInfo.getMKID());
    if (!sLink.equals("")) {
  		out.println("<a href=\"" + sLink + "\" onfocus=\"javascript:blur();\">");
  	}
		out.println("<span class=\"product_name\">");
		out.println(szModuleInfo.getMKMC());
		out.println("</span>");
  	if (!sLink.equals("")) {
    	out.println("</a>");
    }
    %>
    </td>
  </tr>

  <tr>
    <td height="8" align="left" background="images/line.gif"></td>
  </tr>
<%

    //权限
    SzPopedomApp szPopedom = new SzPopedomApp();
    //读取数据，2008-01-18改成到treeMap里读取。

    Collection collTop = SzModuleApp.getChildModuleList(sMKBH_TOP, szCOMPANY_SESSION, isSuperManager_SESSION);
	//Collection collTop = SzModule.getTopLevelModuleList(szCOMPANY_SESSION, isSuperManager_SESSION, szDLID_SESSION, strType);
	//
    //Collection collTop = szModule.getArrayList();
    Iterator iter = null;
    int iSize = collTop.size();
    iSize = 600 - iSize * 21;
    if (collTop != null) {
    	iter = collTop.iterator();
    }

    String sBH = "";
    String sBH_ROOT = "";
    String sBH_SJ = "";

    String sBH_DEFAULT = "";
		//String sImage_DEFAULT = "t_default.gif";
		String sImage_DEFAULT = "blank.gif";
		String sImage = "";

    String sTemp_BH = ""; //这里保存不可使用的上级模块。如果上级模块都不能使用，直接跳过。
    String sManage_BH = ""; //这里保存有栏目管理权限的模块编号。下级可以继承
    boolean isBarManager = false;
    String sCanSee_BH = "";
    boolean isCanSee = false;
    int i = 0;
    boolean hasChild = false;
    boolean hasUrl = false;
    String sTarget = "";
    
    int j1 = 0;
    int j2 = 0;
    int iFormID =0;
    
    String sHidden = "";
    String sImg = "";
    while (iter != null && iter.hasNext()) {
  		szModuleInfo = (SzModuleInfo)iter.next();
  		sBH = szModuleInfo.getMKBH();
	  
  	  
  	    isCanSee = false;
  	    if (isSuperManager_SESSION) {
  	  	  isCanSee = true;
  	    } else {
            //如果上级模块都不能使用，直接跳过。
            if (!sTemp_BH.equals("") && sBH.indexOf(sTemp_BH) == 0) {
                continue;
            }

            //根据编号判断是否是管理员，上级模块是管理员，则可管理所有下级模块
            if (!sManage_BH.equals("") && sBH.indexOf(sManage_BH) == 0) {
                isBarManager = true;
            } else {
                isBarManager = szPopedom.isModuleManager(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());
                if (isBarManager) {
                    sManage_BH = sBH;
                } else {
                    sManage_BH = "";
                }
            }

            //如果上级模块分派了可见权限，则下级可以继承，不需要再判断权限
            if (!sCanSee_BH.equals("") && sBH.indexOf(sCanSee_BH) == 0) {
                isCanSee = true;
            } else {
                if (szModuleInfo.getMKQX() == 3) {
                  //系统管理员可见，判断是否系统管理员，该模块有没有设置成可见的权限。
                  isCanSee = isSystemManager_SESSION ||
                             szPopedom.isModuleCanSee(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());
                  if (isCanSee) {
                      sCanSee_BH = sBH;
                  }

                } else if (szModuleInfo.getMKQX() == 2) {
                  //模块管理员可见，判断是否模块管理员，该模块有没有设置成可见的权限。
                  isCanSee = isBarManager ||
                             szPopedom.isModuleCanSee(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());
                  if (isCanSee) {
                      sCanSee_BH = sBH;
                  }
                } else if (szModuleInfo.getMKQX() == 1) {
                    isCanSee = isBarManager ||
                    					szPopedom.isModuleCanSee(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());
         						if (isCanSee) {
             					sCanSee_BH = sBH;
         						}                	
                } else {
                  //普通模块，判断是否设置可见的权限
                  isCanSee = szPopedom.isModuleCanSee(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());
                  //这个的目的是保存已经授权的上级模块编号，不是作为本级显示的依据
                  if (isCanSee) {
                      sCanSee_BH = sBH;
                  }
                  isCanSee = true; //这个应该永远是tree
                }
             } //if (!sCanSee_BH.equals("") && sBH.indexOf(sCanSee_BH) == 0) { } else {
  	    } //if (isSuperManager_SESSION) {} else {

        if (!isCanSee) {
               //该模块不能使用，该模块直接跳过。
               sTemp_BH = sBH;  //记录不能使用的上级模块
               sCanSee_BH = "";
               continue;
        }
        sTemp_BH = "";    	  
    	  
    	sBH = szModuleInfo.getMKBH();
    	sBH_SJ = SzConvert.toZeroStr( SzLevelNumber.getParentNumber(sBH) );
    	sLink = SzModuleApp.getMenuLink(szModuleInfo.getMKLJDZ(), szModuleInfo.getMKID());
  	  
      	if (!sLink.equals("")) {
      		hasUrl = true;
      	} else {
      		hasUrl = false;
     	}    	 
  		if (sBH_DEFAULT.equals("")) {
  		  	sBH_DEFAULT = sBH;
  	  	}    	
    	  
    	//是否有下级,
    	hasChild = SzModuleApp.hasChildModule(sBH, szModuleInfo.getMKTZID());
    	sTarget = szModuleInfo.getMKLJCK();
    	if (!sTarget.equals("_blank")) {
    		   sTarget = "szMainFrame";
    	} 
    	  
    	if (!hasChild && !hasUrl) {
    		//没有连接,没有下级的跳过
    		//continue;
    	}
    	  
        i ++;
        
        //获取formID
        j1 = sLink.indexOf("index_transact.jsp?FormID=");
        iFormID = szModule.getTransaxtFormID(sLink);
        if (iFormID > 0) {
        	iCount = bdValueControl.getTransactCount(iFormID, iDLID_SESSION);
        } else {
        	iFormID = szModule.getReceiveFormID(sLink);
        	if (iFormID > 0) {
        		iCount = bdValueControl.getReceiveCount(iFormID, iDLID_SESSION);
        	}
        }
        
			if (sBH.length() > 	SzLevelNumber.I_NUMBER_LEN * 2 ) {
 				sHidden = "display:none;";
 				sImg = "menu_down1.gif";
 			} else {
 				sHidden = "display:;";
 				sImg = "menu_down2.gif";
 			}
			
     	if (hasChild) {

    		  //有下级
          if (i>1) {
        	  out.println("<tr id=\"" +SzLevelNumber.getParentNumber(sBH) + "\" name=\"" + SzLevelNumber.getParentNumber(sBH) + "\" style='" + sHidden + "'>");
          	out.println("<td height=\"8\" align=\"left\" background=\"images/line.gif\"></td>");
          	out.println(" </tr>");          	
          }   
          out.println("<input type='hidden' id=\"SC" +SzLevelNumber.getParentNumber(sBH) + "\" name=\"SC" + SzLevelNumber.getParentNumber(sBH) + "\" value=" + sBH + ">");
          out.println("<tr onMouseOver=\"javascript:this.className='trMouseOver'\" onMouseOut=\"javascript:this.className='trMouseOut'\" id=\"" +SzLevelNumber.getParentNumber(sBH) + "\" name=\"" + SzLevelNumber.getParentNumber(sBH) + "\" style='" + sHidden + "'>");
		  		
		  		//有下级
		  		out.println("<td OnClick=\"javascript:ClickSecond('" + sBH + "','" + sLink + "');\"");
		  		out.println(" style='cursor:hand;'>");
		  		out.println(SzLevelNumber.getLevelSpace(sBH));
		  		out.println("<img src=\"" + strSkin_SESSION + "/menu/" + sImg + "\" id=\"img" + sBH + "\"  width=16 style=\"cursor:hand;\" border=\"0\" >&nbsp;");
	      	if (!sLink.equals("")) {
  		    	out.println("<a href=\"" + sLink + "\" onfocus=\"javascript:blur();\">");
  	      } else {
  	    		//out.println("<a href=\"#\" OnClick=\"javascript:ClickSecond('" + sBH + "','" + sLink + "');\">");
  	      }
	      	out.println("<span class=\"product_name\">");
	      	out.println(szModuleInfo.getMKMC());
	     		out.println("</span>");
	      	if (iFormID > 0) {
		      	out.println("<span class=\"product_price\">(");
		      	out.println(iCount);
		      	out.println(")</span>");
	      	}
	      	if (!sLink.equals("")) {
	      	  out.println("</a>");
	      	}
  	  		out.println(" </td></tr>");  	      
 	      
     	} else { //if (hasChild) {
     		
          if (i>1) {
        	  out.println("<tr id=\"" +SzLevelNumber.getParentNumber(sBH) + "\" name=\"" + SzLevelNumber.getParentNumber(sBH) + "\" style='" + sHidden + "'>");
        	  out.println("<td height=\"8\" align=\"left\" background=\"images/line.gif\"></td>");
        	  out.println(" </tr>");          	
          }  
          out.println("<input type='hidden' id=\"SC" +SzLevelNumber.getParentNumber(sBH) + "\" name=\"SC" + SzLevelNumber.getParentNumber(sBH) + "\" value=" + sBH + ">");
          out.println("<tr onMouseOver=\"javascript:this.className='trMouseOver'\" onMouseOut=\"javascript:this.className='trMouseOut'\"  id=\"" +SzLevelNumber.getParentNumber(sBH) + "\" name=\"" + SzLevelNumber.getParentNumber(sBH) + "\" style='" + sHidden + "'>");
  		  	out.println("<td ");
    	    if (!sLink.equals("")) {
  					out.println("OnClick=\"GoUrl('" + sLink + "')\"");
  	  		} 	 		  	
  		  	out.println(">");
  		  	out.println(SzLevelNumber.getLevelSpace(sBH));
  		  	out.println("<img src=\"" + strSkin_SESSION + "/menu/menu_b01.gif\" width=16 style=\"cursor:hand;\" border=\"0\" OnClick=\"GoUrl('" + sLink + "')\">&nbsp;");
  	      if (!sLink.equals("")) {
    				out.println("<a href=\"" + sLink + "\" onfocus=\"javascript:blur();\">");
    	  	}
  	      out.println("<span class=\"product_name\">");
  	      out.println(szModuleInfo.getMKMC());
  	      out.println("</span>");
  	      if (iFormID > 0) {
  		      out.println("<span class=\"product_price\">(");
  		      out.println(iCount);
  		      out.println(")</span>");
  	      } 	      
    	  	if (!sLink.equals("")) {
      		  out.println("</a>");
      	  }    
    	  	out.println(" </td></tr>");  
     		
     	}//end if (hasChild) {
 

   }//while ends  
%>      
</table>
<script language="javascript">

  
</script>
