<%--
  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="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ 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">
function fnCheckAll() {
	$("input[name=delYn]").prop("checked",$("input[name=checkAll]").prop("checked")); 
}

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){
	<c:if test="${!empty loginId}">
	if(""!= document.listForm.searchKeyword.value){
		updateRecentSearch();//최근검색어 등록	
	}
	</c:if>
	linkPage(1);
}

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

function fncAddRoleInsert() {
	var listForm = document.listForm ;
	listForm.pageIndex.value = '1';
	listForm.action = "<c:url value='/sec/rmt/EgovRoleInsertView.do'/>";
    listForm.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 listForm = document.listForm ;
	listForm.pageIndex.value = pageNo ;
	listForm.action = "<c:url value='/sec/rmt/EgovRoleList.do'/>";
	listForm.submit();
}

function press() {
    if (event.keyCode==13) {
    	fncSelectRoleList('1');
    }
}

//엑셀 다운로드
function roleListExcelDownload(){
    document.listForm.method = "post"; 
    //document.listForm.action = "<c:url value='/uss/umt/user/userExcelDownload.do'/>";
    document.listForm.action = "<c:url value='/sec/rmt/roleListExcelDownload.do'/>";
    document.listForm.submit(); 
}
</script>
</head>
<body>
<form:form id="listForm" name="listForm" action="<c:url value='/sec/ram/EgovAuthorList.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="searchSortCnd" value="<c:out value="${roleManageVO.searchSortCnd}" />" />
	<input type="hidden" name="searchSortOrd" value="<c:out value="${roleManageVO.searchSortOrd}" />" />
	
	<!-- cont -->
	<div class="contWrap">
		<div class="pageTitle">
			<div class="pageIcon"><img src="/pb/img/pageTitIcon4.png" alt=""></div>
			<h2 class="titType1 c_222222 fwBold">롤관리</h2>
			<p class="tType6 c_999999">현재 사용중인 롤의 현황을 파악할 수 있으며, 롤을 등록할수 있습니다.</p>
		</div>
		<div class="pageCont">
			<div class="listSerch">
				<select id="searchCondition" name="searchCondition" title="조회조건">
				 	<option value="" <c:if test="${roleManageVO.searchCondition == ''}">selected</c:if> >전체</option>
	                <option value="1" <c:if test="${roleManageVO.searchCondition == '1'}">selected</c:if> >롤명</option>
	                <option value="2" <c:if test="${roleManageVO.searchCondition == '2'}">selected</c:if> >롤설명</option>
	                <option value="3" <c:if test="${roleManageVO.searchCondition == '3'}">selected</c:if> >롤패턴</option>
	            </select>
				<input type="text" id=searchKeyword name="searchKeyword" class="recentSearch" value="<c:out value='${roleManageVO.searchKeyword}'/>" size="40" title="검색"  onkeydown="press();"/>
				<input type="button" class="btnType1" onclick="fncSelectRoleList(1); return false;" value="검색">
			</div>
			<div class="listTop">
				<p class="tType5">총 <span class="tType4 c_456ded fwBold"><fmt:formatNumber value="${paginationInfo.totalRecordCount}" pattern="#,###" /></span>건</p>
				<div class="rightWrap">
					<input type="button" class="excelBtn" onclick="javascript:roleListExcelDownload();">
					<!-- <input type="button" class="printBtn" > -->
					<select name="pageUnit" id="pageUnit" class="select" title="검색조건선택" onchange="linkPage(1);">
					   <option value='10' <c:if test="${roleManageVO.pageUnit == '10' or roleManageVO.pageUnit == ''}">selected</c:if>>10줄</option>
					   <option value='20' <c:if test="${roleManageVO.pageUnit == '20'}">selected</c:if>>20줄</option>
					   <option value='30' <c:if test="${roleManageVO.pageUnit == '30'}">selected</c:if>>30줄</option>
					</select>
				</div>
			</div>
			<div class="tableWrap">
				<table class="tbType1">
					<colgroup>
						<col style="width: 5%">
						<col style="width: 8%">
						<col style="width: 19%">
						<col style="width: 34%">
						<col style="width: 10%">
						<col style="width: 25%">
						<col style="width: 10%">
					</colgroup>
					<thead>
						<tr>
							<th><input type="checkbox" name="checkAll" id="checkAll" onclick="fnCheckAll();" /><label for="checkAll"></label></th>
							<th>번호<input type="button" class="sort sortBtn" id="sort_SORT_TEMP_NO"></th>
							<th>롤설명<input type="button" class="sort sortBtn" id="sort_ROLE_DC"></th>
							<th>롤패턴<input type="button" class="sort sortBtn" id="sort_ROLE_PTTRN"></th>
							<th>롤순서<input type="button" class="sort sortBtn" id="sort_ROLE_SORT"></th>
							<th>롤명<input type="button" class="sort sortBtn" id="sort_ROLE_NM"></th>
							<th>등록일자<input type="button" class="sort sortBtn" id="sort_ROLE_CREAT_DE"></th>
						</tr>
					</thead>
					<tbody>
						<c:forEach var="role" items="${roleList}" varStatus="status">
						<tr>
							<td>
								<input type="checkbox" name="delYn" id="<c:out value="${role.roleCode}"/>"><label for="<c:out value="${role.roleCode}"/>"></label>
								<input type="hidden" name="checkId" value="<c:out value="${role.roleCode}"/>" />
							</td>
							<td>
								<c:if test="${roleManageVO.searchSortOrd eq 'desc' }">
		                			<c:out value="${ ( paginationInfo.totalRecordCount - ((roleManageVO.pageIndex -1)*roleManageVO.pageUnit) ) - status.index }"/>
			                	</c:if>
			                	<c:if test="${roleManageVO.searchSortOrd eq 'asc' }">
									<c:out value="${(roleManageVO.pageIndex - 1) * roleManageVO.pageUnit + status.count}"/>                		
			                	</c:if>
							</td>
							<td>
								<a href="#LINK" onclick="javascript:fncSelectRole('<c:out value="${role.roleCode}"/>')"><c:out value="${role.roleDc}"/></a>
							</td>
							<td><c:out value="${role.rolePtn}"/></td>
							<td><c:out value="${role.roleSort}"/></td>
							<td><c:out value="${role.roleNm}"/></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>
					</tbody>
				</table>
			</div>
			<div class="btnWrap">
				<input type="button" class="btnType2"  onclick="fncRoleListDelete(); return false;" value="삭제">
				<input type="button" class="btnType1"  onclick="fncAddRoleInsert(); return false;" value="등록">
			</div>
			<!-- 페이지 네비게이션 시작 -->
			<c:if test="${!empty roleList}">
			<div class="page">
				<ul class="inline">
					<ui:pagination paginationInfo = "${paginationInfo}"  type="image" jsFunction="linkPage" />
				</ul>
			</div>
			</c:if> 
			<!-- //페이지 네비게이션 끝 -->
		</div>
	</div>
	<!-- //cont -->
</form:form>
</body>