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

<html>
<head>
<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 isDetail = false;
$(document).ready(function() {	
	var returnUrl = getReturnUrlForReturn();
	var url ='<c:url value="/bap/admin/common/comErrMessageMan.json" />';
	var msg ="${param.msg}";
	var svrDstcd ="${param.searchSvrDstcd}";
	
   console.log("test");
   
	var svrName = "일괄";
	if(svrDstcd=="BAT"){
		svrName = "배치";
		$(".bapTr").css("display","none");
	}
	$("input[name=svrName]").val(svrName); 
	
	if (msg != "" && msg != "null") {
		isDetail = true;
		$.ajax({  
			type : "POST",
			url:url,
			dataType:"json",
			data:{cmd: 'DETAIL', msg : msg, searchSvrDstcd : svrDstcd},
			success:function(json){
				var data = json;
				$("input[name=msg]").attr('readonly',true);
				$("input,select").each(function(){
					var name = $(this).attr('name').toUpperCase();
               $(this).val($.trim(data[name]));
					if(svrDstcd=="BAT"){
						$("input[name=msg]").val(data['MSGID']);
					}
				});
				$("input[name=svrName]").val(svrName); 
			},
			error:function(e){
				alert(e.responseText);
			}
		});
		
	}
	
	
	$("#btn_modify").click(function(){
		
		if (isDetail) {
			if ( confirm( "수정하시겠습니까?" ) != true ) return;
		} else {
			if ( confirm( "등록하시겠습니까?" ) != true ) return;
		}
		
		var postData = $('#ajaxForm').serializeArray();
		postData.push({ name: "searchSvrDstcd" , value:svrDstcd});
		if (msg != "" && msg !="null"){
			postData.push({ name: "cmd" , value:"UPDATE"});
		}else{
			postData.push({ name: "cmd" , value:"INSERT"});
		}
		$.ajax({
			type : "POST",
			url:url,
			data:postData,
			success:function(args){
				alert("저장 되었습니다.");
				goNav(returnUrl);//LIST로 이동
			},
			error:function(e){
				alert(e.responseText);
			}
		});
	});
	$("#btn_delete").click(function(){
		if ( confirm( "삭제하시겠습니까?" ) != true ) return;
		
		var postData = $('#ajaxForm').serializeArray();
		postData.push({ name: "cmd" , value:"DELETE"});
		postData.push({ name: "searchSvrDstcd" , value:svrDstcd});
		$.ajax({
			type : "POST",
			url:url,
			data:postData,
			success:function(args){
				alert("삭제 되었습니다.");
				goNav(returnUrl);//LIST로 이동

			},
			error:function(e){
				alert(e.responseText);
			}
		});
	});	
	$("#btn_previous").click(function(){
		goNav(returnUrl);//LIST로 이동
	});

	buttonControl(msg);
	titleControl(msg);
});
 
</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">
				<div class="search_wrap">
					<img src="<c:url value="/img/btn_delete.png"/>" alt="" id="btn_delete" level="W" status="DETAIL"/>
					<img src="<c:url value="/img/btn_modify.png"/>" alt="" id="btn_modify" level="W" status="DETAIL,NEW" />				
					<img src="<c:url value="/img/btn_previous.png"/>" alt="" id="btn_previous" level="R" status="DETAIL,NEW"/>
				</div>
				<div class="title">오류메시지<span class="tooltip">표준화된 IF시스템 에러 응답코드를 추가합니다.</span></div>						
				
				<form id="ajaxForm">
					<table class="table_row" cellspacing="0">
						<!-- <tr>
							<th style="width:20%;">서버구분</th>
							<td><input type="text" name="svrName" readonly/></td>
						</tr> -->
						<tr>
							<th style="width:20%;">오류메시지 코드 *</th>
							<td><input type="text" name="msg"/> </td>
						</tr>
						<tr>
							<th>오류메시지 *</th>
							<td><input type="text" name="msgCtnt"/></td>
						</tr>
						<tr class="bapTr">
							<th>SMS발송문구 *</th>
							<td><input type="text" name="treatMatrCtnt"/></td>
						</tr>
						<tr class="bapTr">
							<th>SMS발송여부</th>
                     <!-- <input type="text" name="smsSendYn"> -->
							<td><div class="select-style"><select name="smsSendYn" style="width:100%">
							<option value="1">발송</option>
							<option value="0">미발송</option>
							</select></div></td>
						</tr>
						<tr class="bapTr">
							<th>심각도</th>
							<td><input type="text" name="itsmObstclGrdDstcd"/></td>
						</tr>																		
					</table>
				</form>
				
			</div><!-- end content_middle -->
		</div><!-- end right_box -->	
	</body>
</html>

