<%--
  - FileName   : CommMatlCodeTree.jsp
  - Author(s)  : pej
  - Date       : 2007-06-13
  - Copyright  : Copyright (c) 2002-2003 www.hwenc.com, Inc.
  -
  - Description: 자재코드 등록 > 자재코드트리
  --%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="kr.co.hsnc.common.util.*" %>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<%
	ctx.init(request, response);

	HandlerStorage storage = ctx.getHandlerStorage();
	ValueObject user = ctx.getUser();    
	ValueObject params = storage.getParams();
	String event   = storage.getEvent();

    String deptCd    = ctx.getUser().get("site_code");
    String deptName  = ctx.getUser().get("site_name");
    String estGb     = "EST";
	
    
    RowSet rowset = storage.getRowSet("rsSectList");
      
%>
<div style="margin-top: 10px;"></div>
<SCRIPT LANGUAGE="JavaScript">
<!--
root=gFld("공종코드", '/common/CommGongCodeList.screen');
root.iconSrc = ICONPATH + 'root.gif';
root.iconSrcClosed = ICONPATH + 'root.gif';

<%
if(rowset != null && rowset.size()> 0) {
    out.println(getTreeHtml(deptCd, rowset));
}
%>

</SCRIPT>
<style>
a {
		color : dimgray;
		line-height : 120%;
		font-family : 굴림, arial;
		font-size : 12px;
		text-decoration : none;
	};
</style>

<% if(rowset != null && rowset.size()> 0) { %>
<div style="position:absolute;display:none; top:0; left:0;"><table border=0><tr><td><font size=-2><a style="font-size:7pt;text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank>www.treemenu.net</a></font></td></tr></table></div>
<script>initializeDocument();</script>
<noscript>
A tree for site navigation will open here if you enable JavaScript in your browser.
</noscript>
<% } else { %>
    <font style=font-size:9pt>There is no actual budget registered.</font>
<% } %>



<%!
    private String getTreeHtml(String deptCd, RowSet rowset){
    
        StringBuffer html = new StringBuffer();

        String sectCodeL1 = "";
        String sectCodeL2 = "";
        String sectCodeL3 = "";
        
        String sectCodeNameL1 = "";
        String sectCodeNameL2 = "";
        String sectCodeNameL3 = "";
        
        String specCode = "";
        String calTpCode = "";
        int iDepth = 0;

        try {

        	for(int i=0; i<rowset.size(); i++){
        		
        		iDepth = rowset.getRow(i).getInt("DEPTH");
        		
        		if ( iDepth == 1 ){
                  		sectCodeL1 = rowset.getRow(i).get("ITEM_CD");
                  		sectCodeNameL1 = rowset.getRow(i).get("ITEM_NAME");
                  	    html.append("aux0=insFld(root, gFld(\""+rowset.getRow(i).get("ITEM_NAME")+"("+rowset.getRow(i).get("ITEM_CD")+")"+"\", '/common/CommGongCodeList.screen?item_cd="+rowset.getRow(i).get("ITEM_CD")+"&depth="+rowset.getRow(i).get("DEPTH")+"&isNode=true'));").append("\n");
        		}
        		
        		else if ( iDepth == 2 ){
        			sectCodeL2 = rowset.getRow(i).get("ITEM_CD");
        			sectCodeNameL2 = rowset.getRow(i).get("ITEM_NAME");
   	    			html.append("aux1=insFld(aux0, gFld(\""+rowset.getRow(i).get("ITEM_NAME")+"("+rowset.getRow(i).get("ITEM_CD")+")"+"\", '/common/CommGongCodeList.screen?item_cd="+rowset.getRow(i).get("ITEM_CD")+"&depth="+rowset.getRow(i).get("DEPTH")+"&isNode=true'));").append("\n");
        		}
        		
        	}
        	
        } 
        
        catch(Exception e){
            System.out.println(e);
        }
        return html.toString();
    }
%>
