<%@ page import="java.io.*, java.util.*"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="com.eactive.eai.common.EAITable"%>
<%@ page import="com.eactive.eai.common.bizkey.BizKeyFldVO"%>
<%@ page import="com.eactive.eai.common.bizkey.BizKeyManager"%>
<%@ page import="com.eactive.eai.common.bizkey.BizKeyVO"%>

<%
    BizKeyManager manager = BizKeyManager.getInstance();
    String[]      alls    = manager.getAllKeyNames();
    String        action  = request.getParameter("actionType");
    
        
    String selectedKey = request.getParameter("selectedKey");
    
    if(selectedKey == null && alls.length > 1) {
    	selectedKey = alls[0];
    }
    if ("reload".equals(action)){
    	//마지막 TR 을 빼고 처리 해야됨
    	manager.reload(selectedKey.substring(0, selectedKey.length()-2), selectedKey.substring(selectedKey.length()-2));
    }else if ("reloadAll".equals(action)){
    	manager.reload();
    }else {
    	;
    }
       
    BizKeyVO vo = null;
    if(selectedKey != null) {
        vo = manager.getBizKey(selectedKey);        
    }
%>
<html>
    <head>
        <title>
            BizKey Manager
        </title>
        <script>
        function doAction() {
            document.frm.submit();
        }
        function managerReload(){ 
        	document.frm.actionType.value="reload";
        	document.frm.submit();
        	
        }
        function managerReloadAll(){
        	document.frm.actionType.value="reloadAll";
        	document.frm.submit();
        }        
        function doSearch(){
        	var searchValue = document.frm.searchTxt.value;
        	document.frm.selectedKey.value = searchValue;
        	document.frm.submit();
        }
        function enterEvent(){
        	if(window.event.keyCode==13){
        		doSearch();
        	}
        }
        </script>
    </head>
    <body>
        <p style="font-size:12pt;">
        <b>로그조회키 관리</b> <br><br>
        </p>
        <form name="frm" action="">
        <input type="hidden" name="actionType" value="">
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
	        <tr bgcolor='white'>
	            <td rowspan=2 align='right' width='350' bgcolor="#ccccff">로그조회키 :&nbsp;&nbsp;</td>
	            <td align='left'>&nbsp;<select name="selectedKey" onchange="doAction();"style="width:98%">
	            <%
	                for(int i=0;i<alls.length;i++) {
	            %>
	                <option value="<%=alls[i]%>" <%= (alls[i].equals(selectedKey)) ? "selected" : "" %>><%=alls[i]%>
	            <%           
	                 }
	            %></select>
	            </td>
	            <td width='50'><input type="button" name="reload" value="reload" onClick="managerReload()" /></td>
	            <td width='70'><input type="button" name="reloadAll" value="reloadAll" onClick="managerReloadAll()" /></td>
	            
	        </tr>
	        <tr bgcolor='white'>
	            <td align='left' >&nbsp;<input type="edit" style="width:98%;" name="searchTxt" onkeydown="enterEvent()" value="<%=selectedKey%>"  /></td> 
	            <td colspan=2 align="center"><input type="button" name="search" value="search" onClick="doSearch()" /></td>
	        </tr>
        </table>
        <br>
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td align='right'bgcolor="#003366">&nbsp; <font color="yellow"><b>Property Key</b> &nbsp;</font></td>
            <td align='left' bgcolor="#003366">&nbsp;<font color="yellow">&nbsp; <b>Property Value</b></font></td>
        </tr>
<%
    if(vo != null) {
%>        
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; EAI서비스코드 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="EaiSvcCd" style="width:98%" value="<%=vo.getEaiSvcCd()%>" readonly></td>
        </tr>
        
         <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 추출구분 : &nbsp;</td>
            <td align='left' style="height:40px;">
            <%
                int exrClassLength = EAITable.EXR_CLASS_TYPES.length;
                String exrClassTypeName = "";
                for(int i=0; i<exrClassLength; i++) {
                    if(EAITable.EXR_CLASS_TYPES[i].equals(vo.getExrClsNm())) exrClassTypeName = EAITable.EXR_CLASS_TYPES[i];
                }
            %>&nbsp;<input type="text" name="ExrClsNm" style="width:98%" value="<%=exrClassTypeName%>" readonly>
            </td>
        </tr>
        <%
            int fldSize  = vo.getBizKeyFldLength();
            for(int i=0; i<fldSize; i++) {
                
        %>
        <tr bgcolor='white'>
            <td align='right' width="350" height="5" bgcolor="#003366" colspan="2">&nbsp;<font color="yellow"><b>FldPrcssNo[<%= vo.getBizKeyFld(i).getColPssSeq() %>]</b> &nbsp;</font></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 메시지유형 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<select name="MsgTp" style="width:98%">
            <%
                int msgTypeLength = EAITable.MSG_TYPES.length;
                
                for(int j=0; j<msgTypeLength; j++) {
            %>
            <option value="<%=EAITable.MSG_TYPES[j]%>" <%= (EAITable.MSG_TYPES[j].equals(vo.getBizKeyFld(i).getMsgTp())) ? "selected" : "" %>><%=EAITable.MSG_TYPES[j]%>
            <%
                }
            %>
            </select>
            </td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 업무필드명 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="BwkColNm" style="width:98%" value="<%=vo.getBizKeyFld(i).getBwkColNm()%>"></td>
        </tr>
        
<% 
        }
    } 
%>
        </table>
        </form>
    </body>
</html>