<%--
  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">
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}" />" />
	
	<div class="content_title">
	  <h3>롤관리</h3>
	  <ol class="breadcrumb">
	    <li><a href="#" class="home" title="메인으로 이동"><i></i></a></li>
	    <li><a href="#">권한관리</a></li>
	    <li><strong class="current_location">롤관리</strong></li>
	  </ol>
	</div>
	
	<div class="search_area">
		<div class="search_left">
			<p class="total_number">총 게시물 <b><c:out value="${paginationInfo.totalRecordCount}" /></b>건</p>
		</div>
		<div class="search_right">
			<select class="search_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="input search_input" value="<c:out value='${roleManageVO.searchKeyword}'/>" size="40" title="검색"  />
			<button class="btn btn_search" onclick="fncSelectRoleList(1); return false;">검색</button>
			
			<select class="search_select" name="pageUnit" id="pageUnit" onchange="linkPage(1);" title="줄 선택" style="width: 140px">
				<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>
	

	<!-- list -->
	<div class="table table_type_cols">
		<table>
			<colgroup>
				<col style="width: 40px;">
				<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 scope="col">번호<button class="sort sortBtn" id="sort_SORT_TEMP_NO">▲</button></th>
					<th scope="col">롤설명<button class="sort sortBtn" id="sort_ROLE_DC">▲</button></th>
					<th scope="col">롤패턴<button class="sort sortBtn" id="sort_ROLE_PTTRN">▲</button></th>
					<th scope="col">롤순서<button class="sort sortBtn" id="sort_ROLE_SORT">▲</button></th>
					<th scope="col">롤명<button class="sort sortBtn" id="sort_ROLE_NM">▲</button></th>
					<th scope="col">등록일자<button class="sort sortBtn" id="sort_ROLE_CREAT_DE">▲</button></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>
	<!-- //list -->
	
	<!-- btn_wrap -->
	<div class="btn_wrap">
		<div class="left">
			<button type="button" class="btn line red xlarge"  onclick="fncRoleListDelete(); return false;">삭제</button>
		</div>
		<div class="right">
			<button type="button" class="btn fill primary xlarge"  onclick="fncAddRoleInsert(); return false;">등록</button>
		</div>
	</div>
	<!-- //btn_wrap -->
	
	<!-- page -->
	<c:if test="${!empty roleList}">
	<div class="page">
		<ul class="inline">
			<ui:pagination paginationInfo = "${paginationInfo}"  type="image" jsFunction="linkPage" />
		</ul>
	</div>
	</c:if>
	
</form:form>
</body>
