<%--
  Class Name : EgovRoleManage.jsp
  Description : EgovRoleManage 화면
  Modification Information
 
      수정일         수정자                   수정내용
    -------    --------    ---------------------------
     2009.02.01    lee.m.j              최초 생성
     2011.08.31   JJY       경량환경 버전 생성
 
    author   : 공통서비스 개발팀 lee.m.j
    since    : 2009.02.01
--%>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="ko" >
<title>롤 목록</title>
<script type="text/javaScript" language="javascript" defer="defer">
<!--

function fncCheckAll() {
    var checkField = document.listForm.delYn;
    if(document.listForm.checkAll.checked) {
        if(checkField) {
            if(checkField.length > 1) {
                for(var i=0; i < checkField.length; i++) {
                    checkField[i].checked = true;
                }
            } else {
                checkField.checked = true;
            }
        }
    } else {
        if(checkField) {
            if(checkField.length > 1) {
                for(var j=0; j < checkField.length; j++) {
                    checkField[j].checked = false;
                }
            } else {
                checkField.checked = false;
            }
        }
    }
}

function fncManageChecked() {

    var checkField = document.listForm.delYn;
    var checkId = document.listForm.checkId;
    var returnValue = "";
    var returnBoolean = false;
    var checkCount = 0;
    
    if(checkField) {
        if(checkField.length > 1) {
            for(var i=0; i<checkField.length; i++) {
                if(checkField[i].checked) {
                    checkCount++;
                    checkField[i].value = checkId[i].value;
                    if(returnValue == "")
                        returnValue = checkField[i].value;
                    else 
                        returnValue = returnValue + ";" + checkField[i].value;
                }
            }
            if(checkCount > 0) 
                returnBoolean = true;
            else {
                alert("선택된  롤이 없습니다.");
                returnBoolean = false;
            }
        } else {
            if(document.listForm.delYn.checked == false) {
                alert("선택된 롤이 없습니다.");
                returnBoolean = false;
            }
            else {
                returnValue = checkId.value;
                returnBoolean = true;
            }
        }
    } else {
        alert("조회된 결과가 없습니다.");
    }

    document.listForm.roleCodes.value = returnValue;
    return returnBoolean;
}

function fncSelectRoleList(pageNo){
	linkPage(1);
}

function fncSelectRole(roleCode) {
    document.modiForm.roleCode.value = roleCode;
    document.modiForm.action = "<c:url value='/sec/rmt/EgovRole.do'/>";
    document.modiForm.submit();
}

function fncAddRoleInsert() {
    //location.replace("<c:url value='/sec/rmt/EgovRoleInsertView.do'/>");
    document.modiForm.action = "<c:url value='/sec/rmt/EgovRoleInsertView.do'/>";
    document.modiForm.submit();
}

function fncRoleListDelete() {
    if(fncManageChecked()) {
        if(confirm("삭제하시겠습니까?")) {
            document.listForm.action = "<c:url value='/sec/rmt/EgovRoleListDelete.do'/>";
            document.listForm.pageIndex.value = "1";
            document.listForm.submit();
        }
    }
}

function fncAddRoleView() {
    document.listForm.action = "<c:url value='/sec/rmt/EgovRoleUpdate.do'/>";
    document.listForm.submit();     
}

function linkPage(pageNo){
	var searchForm = document.searchForm ;
	searchForm.pageIndex.value = pageNo ;
	searchForm.searchCondition.value = "1";
	searchForm.searchKeyword.value = $('#searchKeyword').val();
	searchForm.action = "<c:url value='/sec/rmt/EgovRoleList.do'/>";
	searchForm.submit();
}

function press() {

    if (event.keyCode==13) {
        fncSelectRoleList('1');
    }
}
//-->
</script>
<style>
	select { -webkit-appearance: none; -moz-appearance: none; appearance: none; background: url('/') no-repeat 95% 50%; /* 화살표 모양의 이미지 */ }
	select::-ms-expand { display: none;}
</style>
</head>

<body>
<form:form id="listForm" name="listForm" action="<c:url value='/sec/rmt/EgovRoleList.do'/>" method="post">
	<input type="hidden" name="roleCode"/>
	<input type="hidden" name="roleCodes"/>
	<input type="hidden" name="pageIndex" value="<c:out value='${roleManageVO.pageIndex}'/>"/>
	<input type="hidden" name="searchCondition"/>
	
	<div class="ad_content">
	<div class="ad_con_head">
		<div class="ad_head_text">
			<p class="today_txt">롤 관리</p>
			<div class="ad_head_ment">
				<p class="today_last_txt"><span id="cnt_cate_list"></span></p>
			</div>
		</div>
	</div>
	<div class="ad_subcon">
		<div class="ad_con_body">
			<div class="ad_bo_h3">
				<div class="board1_div1">
					롤 명 : 
					<input id="searchKeyword" name="searchKeyword" type="text" value="<c:out value='${roleManageVO.searchKeyword}'/>" size="25" title="검색" onkeypress="press();" />
					<ul class="board1_div2_ul">
						<li><button class="board1_list_btn" onclick="fncSelectRoleList('1'); return false;">검 색</button></li>
						<li><button class="board1_del_btn" onclick="fncRoleListDelete(); return false;">삭 제</button></li>
						<li><button class="board1_save_btn" onclick="fncAddRoleInsert(); return false;">등 록</button></li>
					</ul>
				</div>
			</div>
		</div>
		<p class="mem_count">조회건수 : <c:out value="${paginationInfo.totalRecordCount}"/></p>
		<div class="ad_mem_list">
			<table>
				<tr>
					<th>번호</th>
					<th>
						<input type="checkbox" name="checkAll" class="check2" onclick="javascript:fncCheckAll()" title="전체선택">
					</th>
					<th>롤 ID</th>
					<th>롤 명</th>
					<th>롤 타입</th>
					<th>롤 순서</th>
					<th>롤 설명</th>
					<th>등록일자</th>
				</tr>
				<c:forEach var="role" items="${roleList}" varStatus="status">
				<tr>
					<td><c:out value="${(roleManageVO.pageIndex - 1) * roleManageVO.pageSize + status.count}"/></td>
					<td>
						<input type="checkbox" name="delYn" class="check2" title="선택">
						<input type="hidden" name="checkId" value="<c:out value="${role.roleCode}"/>" />
					</td>
					<td>
						<a href="#LINK" onclick="javascript:fncSelectRole('<c:out value="${role.roleCode}"/>')"><c:out value="${role.roleCode}"/></a>
					</td>
					<td><c:out value="${role.roleNm}"/></td>
					<td><c:out value="${role.roleTyp}"/></td>
					<td><c:out value="${role.roleSort}"/></td>
					<td><c:out value="${role.roleDc}"/></td>
					<td><c:out value="${role.roleCreatDe}"/></td>
				</tr>
				</c:forEach>
				 <c:if test="${empty roleList}">
         			<tr><td colspan="8"><spring:message code="common.nodata.msg" /></td></tr>
         		</c:if>
			</table>
			<!-- 페이지 네비게이션 시작 -->
			<c:if test="${!empty roleList}">
		 		<div class="board1_btn">
		    		<ul>
		    			<ui:pagination paginationInfo = "${paginationInfo}"  type="image" jsFunction="linkPage" />
		    		</ul>	
		    	</div>  
		  	</c:if>                      
		    <!-- //페이지 네비게이션 끝 --> 
		</div>
	</div>
	</div>
</form:form>
<form name="searchForm" method="get">
	<input name="searchCondition" type="hidden" />
	<input name="searchKeyword" type="hidden" />
	<input name="pageIndex" type="hidden" />
</form>
<form name="modiForm" method="get">
	<input name="roleCode" type="hidden" />
</form>
 </body>
</html>