<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ include file="/jsp/common/include/localemessage.jsp" %>
<%
	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 url      = '<c:url value="/onl/admin/security/cryptoModuleMan.json" />';
var url_view = '<c:url value="/onl/admin/security/cryptoModuleMan.view" />';

$(document).ready(function() {
	$('#grid').jqGrid({
		datatype: "json",
		mtype: 'POST',
		url: url,
		postData: {
			cmd: 'LIST',
			searchName:    $('input[name=searchName]').val(),
			algType:       $('select[name=algType]').val(),
			keySourceType: $('select[name=keySourceType]').val(),
			useYn:         $('select[name=useYn]').val()
		},
		colNames: ['ID', '모듈명', '설명', '알고리즘', '운영모드', '키 소스', '사용'],
		colModel: [
			{ name: 'CRYPTO_ID',       hidden: true },
			{ name: 'CRYPTO_NAME',     align: 'left' },
			{ name: 'CRYPTO_DESC',     align: 'left',   sortable: false },
			{ name: 'ALG_TYPE',        align: 'center', width: 80 },
			{ name: 'CIPHER_MODE',     align: 'center', width: 80 },
			{ name: 'KEY_SOURCE_TYPE', align: 'center', width: 100 },
			{ name: 'USE_YN',          align: 'center', width: 60 }
		],
		jsonReader: { repeatitems: false },
		pager: $('#pager'),
		page: '${param.page}',
		rowNum: '${rmsDefaultRowNum}',
		autoheight: true,
		height: $("#container").height(),
		autowidth: true,
		viewrecords: true,
		rowList: eval('[${rmsDefaultRowList}]'),
		ondblClickRow: function(rowId) {
			var rowData = $(this).getRowData(rowId);
			var cryptoId = rowData['CRYPTO_ID'];
			var url2 = url_view + '?cmd=DETAIL';
			url2 += '&page=' + $(this).getGridParam("page");
			url2 += '&returnUrl=' + getReturnUrl();
			url2 += '&menuId=' + '${param.menuId}';
			url2 += '&searchName=' + $("input[name=searchName]").val();
			url2 += '&cryptoId=' + cryptoId;
			goNav(url2);
		},
		gridComplete: function() {
			var colModel = $(this).getGridParam("colModel");
			for (var i = 0; i < colModel.length; i++) {
				$(this).setColProp(colModel[i].name, { sortable: false });
			}
		},
		loadError: function(jqXHR, textStatus, errorThrown) {
			var location = '<%=request.getContextPath()%>/';
			comloadError(jqXHR, textStatus, errorThrown, location);
		}
	});

	resizeJqGridWidth('grid', 'content_middle', '1000');

	$("#btn_search").click(function() {
		var postData = getSearchForJqgrid("cmd", "LIST");
		postData['algType']       = $('select[name=algType]').val();
		postData['keySourceType'] = $('select[name=keySourceType]').val();
		postData['useYn']         = $('select[name=useYn]').val();
		$("#grid").setGridParam({ url: url, postData: postData, page: 1 }).trigger("reloadGrid");
	});

	$("#btn_new").click(function() {
		var url2 = url_view + '?cmd=DETAIL';
		url2 += '&page=' + $("#grid").getGridParam("page");
		url2 += '&returnUrl=' + getReturnUrl();
		url2 += '&menuId=' + '${param.menuId}';
		goNav(url2);
	});

	$("input[name=searchName]").keydown(function(key) {
		if (key.keyCode == 13) { $("#btn_search").click(); }
	});

	buttonControl();
});
</script>
</head>
<body>
	<div class="right_box">
		<div class="content_top">
			<ul class="path">
				<li><a href="#">${rmsMenuPath}</a></li>
			</ul>
		</div>
		<div class="content_middle" id="content_middle">
			<div class="search_wrap">
				<button type="button" class="cssbtn" id="btn_new" level="W"><i class="material-icons">add</i> 신규</button>
				<button type="button" class="cssbtn" id="btn_search" level="R"><i class="material-icons">search</i> 검색</button>
			</div>
			<div class="title">암호화 모듈 설정</div>
			<form id="ajaxForm" onsubmit="return false;">
				<table class="search_condition" cellspacing="0">
					<tbody>
						<tr>
							<th style="width:100px;">모듈명</th>
							<td><input type="text" name="searchName" value="${param.searchName}"></td>
							<th style="width:100px;">알고리즘</th>
							<td>
								<select name="algType">
									<option value="">전체</option>
									<option value="AES">AES</option>
									<option value="ARIA">ARIA</option>
								</select>
							</td>
							<th style="width:100px;">키 소스</th>
							<td>
								<select name="keySourceType">
									<option value="">전체</option>
									<option value="STATIC">STATIC</option>
									<option value="DYNAMIC">DYNAMIC</option>
								</select>
							</td>
							<th style="width:80px;">사용</th>
							<td>
								<select name="useYn">
									<option value="">전체</option>
									<option value="Y">Y</option>
									<option value="N">N</option>
								</select>
							</td>
						</tr>
					</tbody>
				</table>
			</form>
			<table id="grid"></table>
			<div id="pager"></div>
		</div>
	</div>
</body>
</html>
