<%--
  Class Name : EgovAuthorRoleManage.jsp
  Description : EgovAuthorRoleManage 화면
  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 fnCheckAll() {
    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 checkRegYn = document.listForm.regYn;
    var returnValue = "";
    var returnRegYns = "";
    var checkedCount = 0;
    var returnBoolean = false;

    if(checkField) {
        if(checkField.length > 1) {
            for(var i=0; i<checkField.length; i++) {
                if(checkField[i].checked) {
                    checkedCount++;
                    checkField[i].value = checkId[i].value;
                
                    if(returnValue == "") {
                        returnValue = checkField[i].value;
                        returnRegYns = checkRegYn[i].value;
                    }
                    else { 
                        returnValue = returnValue + ";" + checkField[i].value;
                        returnRegYns = returnRegYns + ";" + checkRegYn[i].value;
                    }
                }
            }

            if(checkedCount > 0) 
                returnBoolean = true;
            else {
                alert("선택된  롤이 없습니다.");
                returnBoolean = false;
            }
        } else {
             if(document.listForm.delYn.checked == false) {
                alert("선택된 롤이 없습니다.");
                returnBoolean = false;
            }
            else {
                returnValue = checkId.value;
                returnRegYns = checkRegYn.value;

                returnBoolean = true;
            }
        }
    } else {
        alert("조회된 결과가 없습니다.");
    }

    document.listForm.roleCodes.value = returnValue;
    document.listForm.regYns.value = returnRegYns;

    return returnBoolean;

}

function fncSelectAuthorRoleList() {
	linkPage(1);
}

function fncSelectReAuthorRoleList(){
    document.modiForm.searchKeyword.value = "";
    document.modiForm.pageIndex.value = "1";
    document.modiForm.action = "<c:url value='/sec/ram/EgovAuthorList.do'/>";
    document.modiForm.submit();
}

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

function fncAddAuthorRoleInsert() {
    if(fncManageChecked()) {
        if(confirm("등록하시겠습니까?")) {
            document.listForm.action = "<c:url value='/sec/ram/EgovAuthorRoleInsert.do'/>";
            document.listForm.submit();
        }
    } else return;
}

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


function press() {

    if (event.keyCode==13) {
        fncSelectAuthorRoleList();
    }
}
</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 name="listForm" action="<c:url value='/sec/ram/EgovAuthorRoleList.do'/>" method="post">
	<input type="hidden" name="roleCodes"/>
	<input type="hidden" name="regYns"/>
	<input type="hidden" name="pageIndex" value="<c:out value='${authorRoleManageVO.pageIndex}'/>"/>
	<input type="hidden" name="authorCode" value="<c:out value="${authorRoleManageVO.searchKeyword}"/>"/>
	<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">
					권한(${authorRoleManageVO.searchKeyword}) 롤 명 : 
					<input id="searchKeyword2" name="searchKeyword2" type="text" value="<c:out value='${authorRoleManageVO.searchKeyword2}'/>" size="25" title="검색"  />
					<ul class="board1_div2_ul" style="margin-right: -74px;">
						<li><button class="board1_list_btn" onclick="fncSelectAuthorRoleList(); return false;">검 색</button></li>
						<!-- <li><button class="board1_list_btn" onclick="fncSelectReAuthorRoleList(); return false;">목록 재조회</button></li> -->
						<li><button class="board1_save_btn" onclick="fncAddAuthorRoleInsert(); 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 style="vertical-align: middle">
						<input name="checkAll" type="checkbox" title="Check All" onclick="fnCheckAll();"/>
					</th>
					<th>롤 ID</th>
					<th>롤 명</th>
					<th>롤 타입</th>
					<th>롤 Sort</th>
					<th>롤 설명</th>
					<th>등록일자</th>
					<th>등록여부</th>
				</tr>
				<c:forEach var="authorRole" items="${authorRoleList}" varStatus="status">
				<tr>
					<td><c:out value="${(authorRoleManageVO.pageIndex - 1) * authorRoleManageVO.pageSize + status.count}"/></td>
					<td><input type="checkbox" name="delYn" class="check2" title="선택"><input type="hidden" name="checkId" value="<c:out value="${authorRole.roleCode}"/>" /></td>
					<td><c:out value="${authorRole.roleCode}"/></td>
					<td><c:out value="${authorRole.roleNm}"/></td>
					<td><c:out value="${authorRole.roleTyp}"/></td>
					<td><c:out value="${authorRole.roleSort}"/></td>
					<td><c:out value="${authorRole.roleDc}"/></td>
					<td><c:out value="${authorRole.creatDt}"/></td>
					<td>
						<select name="regYn" title="등록여부">
				            <option value="Y" <c:if test="${authorRole.regYn == 'Y'}">selected</c:if> >등록</option>
				            <option value="N" <c:if test="${authorRole.regYn == 'N'}">selected</c:if> >미등록</option>
				        </select>
					</td>
				</tr>
				</c:forEach>     
			</table>
			<!-- 페이지 네비게이션 시작 -->
			<c:if test="${!empty authorRoleList}">
		 		<div class="board1_btn">
		    		<ul>
		    			<ui:pagination paginationInfo = "${paginationInfo}"  type="image" jsFunction="linkPage" />
		    		</ul>	
		    	</div>  
		  	</c:if>                      
		    <!-- //페이지 네비게이션 끝 --> 
		</div>
	</div>
	</div>
</form:form>
<form name="modiForm" method="get" action="<c:url value='/sec/ram/EgovAuthorRoleList.do'/>" >
	<input type="hidden" name="pageIndex" value="<c:out value='${authorRoleManageVO.pageIndex}'/>"/>
	<input name="searchKeyword" type="hidden" value="<c:out value='${authorRoleManageVO.searchKeyword}'/>" />
	<input name="authorCode" type="hidden" />
	<input name="searchCondition" type="hidden" />
</form>
<form name="searchForm" method="get" action="<c:url value='/sec/ram/EgovAuthorRoleList.do'/>">
	<input name="pageIndex" type="hidden"  />
	<input name="searchCondition" type="hidden" />
	<input name="searchKeyword" type="hidden" value="<c:out value='${authorRoleManageVO.searchKeyword}'/>" />
	<input name="searchKeyword2" type="hidden" />
	<input name="authorCode" type="hidden" />
</form>	
</body>
</html>