<%@ page import="java.io.*, java.util.*"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="com.eactive.eai.common.errorcode.ErrorCodeManager"%>
<%@ page import="com.eactive.eai.common.errorcode.ErrorCodeVO"%>

<%
    ErrorCodeManager manager = ErrorCodeManager.getInstance();    
    String[]         alls   = manager.getAllCodes();
    String           action  = request.getParameter("actionType");
    
    String selectedKey = request.getParameter("selectedKey");
    if(selectedKey == null && alls.length>1) {
    	selectedKey = alls[0];
    }
    if ("reload".equals(action)){
    	manager.reload(selectedKey);
    }else if ("reloadAll".equals(action)){
    	manager.reload();
    }else {
    	;
    }
    ErrorCodeVO vo    = null;
    
    if(selectedKey != null){
        vo    = manager.getMessageVO(selectedKey);
    }
    
    
%>
<html>
    <head>
        <title>
           Error Code Message 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='180' bgcolor="#ccccff"><label value=" "/>오류메시지 코드 :&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"   name="searchTxt" onkeydown="enterEvent()" value="<%=selectedKey%>" style="width:98%"  /></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' colspan=2 bgcolor="#003366">&nbsp; <font color="yellow"><b>내용</b> &nbsp;</font></td>
        </tr>
<% if(vo!=null) { %>        
        <tr bgcolor='white'>            
            <td align='right' width='180' bgcolor="#ccccff">오류메시지 코드 :&nbsp;&nbsp;</td>
            <td align='left' style="height: 40;">&nbsp;<input type="text" name="text" size="80" value="<%=vo.getMsgKey()%>"></td>            
        </tr>
        <tr bgcolor='white'>            
            <td align='right' width='180' bgcolor="#ccccff">오류메시지 :&nbsp;&nbsp;</td>
            <td align='left' style="height: 40;">&nbsp;<input type="text" name="text" size="80" value="<%=vo.getMsgTxt()%>"></td>            
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='180' bgcolor="#ccccff">조치사항 :&nbsp;&nbsp;</td>            
            <td align='left' style="height: 40;">&nbsp;<input type="text" name="text" size="80" value="<%=vo.getMsgEtc()%>"></td>
        </tr>
<% } else { %>
        
<% } %>
        </table>
        </form>
    </body>
</html>