<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/jsp/common/include/localemessage.jsp" %>
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setHeader("Expires", "0");

%>
<html>
<head>
<%
String defaultIp = "";
String defaultPort = "";

if(session.getAttribute("defaultIp") != null){
	defaultIp = (String)session.getAttribute("defaultIp");
}

if(session.getAttribute("defaultPort") != null){
	defaultPort = (String)session.getAttribute("defaultPort");
}

%>
	
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<jsp:include page="/jsp/common/include/css.jsp"/>
<jsp:include page="/jsp/common/include/script.jsp"/>
<script language="javascript" >
var url      = '<c:url value="/onl/admin/service/firstAccountMan.json" />';
var url_view = '<c:url value="/onl/admin/service/firstAccountMan.view" />';


$(document).ready(function() {	
	
	var defaultIp = '<%=defaultIp%>';
	var defaultPort = '<%=defaultPort%>';
	
	$("input[name=sendip]").val(defaultIp);
	$("input[name=sendport]").val(defaultPort);
	
	//구분값 
	$("input[name=sendType]").change(function(){
		var sendType = $(this).val();
		
		 if(sendType == "I") {
			 $("input[name=sendmsg]").val("0000");
		  }else {
			  $("input[name=sendmsg]").val("");
		  }
		
	});
	
	
	//계좌 상태조회
	$("#btn_search").click(function(){
		
		var postData = [];
		postData.push({ name: "cmd" , value:"DETAIL_ACCOUNT"});
			
		$.ajax({
			type : "POST",
			url : url,
			data : postData,
			success : function(json) {
				var account = json.message
				console.log("message : "+account);
				if( account == "" || account == null){
					account = "account txtFile read error. ";
				}
				$("input[name=accountCtnt]").val(account);
			},
			error : function(e) {
				console.log("error");
			}
		});
		
		
	});
	
	
	//등록버튼
	$("#btn_regist").click(function(){
		
		if($("input[name=sendip]").val() == ""){
			alert("필수항목입니다. ip를 입력해주세요");
			$("input[name=sendip]").focus();
			return false;
		}
		
		if($("input[name=sendport]").val() == ""){
			alert("필수항목입니다. port를 입력해주세요");
			$("input[name=sendport]").focus();
			return false;
		}
		
		
		if($("input[name=sendmsg]").val() == ""){
			alert("전송내용 항목은 필수 입니다. 초기화 를 원하시면 0000을 입력해 주세요");
			return false;
		}
		
		if (confirm("여러계좌 등록시 세미콜론(;) 으로 구분 합니다. 확인하셨습니까? ") == false){
			return;
		}
		
		//공통부만 form으로 구성
		var postData = $('#ajaxForm').serializeArray();
		
		postData.push({
			name : "cmd",
			value : "INSERT"
		});
		
		 $.ajax({
				type : "POST",
				url : url,
				data : postData,
				success : function(json) {
					alert("정상 처리 되었습니다");
						
				},
				error : function(e) {
					alert("전송 중 오류가 발생하였습니다"+e.responseText);
				}
			});  
		
		
	});
	
	buttonControl();
	
});
 
</script>
</head>
	<body>		
		<div class="right_box">
			<div class="content_top">
				<ul class="path">
					<li><a href="#">${rmsMenuPath}</a></li>					
				</ul>					
			</div><!-- end content_top -->
			<div class="content_middle" id="content_middle">
				<div class="search_wrap">
					<button type="button" class="cssbtn" id="btn_search" level="R"><i class="material-icons">search</i> <%= localeMessage.getString("button.search") %></button>
<%-- 					<img src="<c:url value="/img/btn_search.png"/>" alt="" id="btn_search" level="R" /> --%>
				</div>
				<div class="title"><%=localeMessage.getString("firAccMan.title")%></div>
				
				<form id="ajaxForm" style="margin-top:10px;">
					<table class="search_condition" cellspacing=0;>
						<tbody>
							<tr>
								<th style="width:130px;"><%=localeMessage.getString("firAccMan.statChk")%></th>
								<td>
									<input type="text" name="accountCtnt"  readonly/>
								</td>
							</tr>
						</tbody>
					</table>
				
				<div style="text-align:right; font-size:12px;">
					<button type="button" class="cssbtn" id="btn_regist" level="W"><i class="material-icons">save</i> <%= localeMessage.getString("button.register") %></button>
<%-- 					<img id="btn_regist" src="<c:url value="/img/btn_regist.png" />" level="W" class="btn_img" /> --%>
				</div><br>
				
					<table class="table_row" cellspacing=0;>
						<tbody>
							<tr>
								<th style="width:130px;"><%=localeMessage.getString("firAccMan.cla")%></th>
								<td>
									<input type="radio" name="sendType" value="A"  checked/><label for="logType_1"><%=localeMessage.getString("firAccMan.conAcc")%></label>
									<input type="radio" name="sendType" value="I"  /><label for="logType_2"><%=localeMessage.getString("firAccMan.init")%></label>
								</td>
							</tr>
							<tr>
								<th style="width:130px;">IP</th>
								<td>
									<input type="text" name="sendip" />
								</td>
							</tr>
							<tr>
								<th style="width:130px;">PORT</th>
								<td>
									<input type="text" name="sendport" />
								</td>
							</tr>
							<tr>
								<th style="width:130px;"><%=localeMessage.getString("firAccMan.conAcc")%></th>
								<td>
									<input type="text" name="sendmsg" />
								</td>
							</tr>
						</tbody>
					</table>
				</form>
				</div>	
			</div><!-- end content_middle -->
		</div><!-- end right_box -->				
	</body>	
</html>

