<%--
  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">
$( document).ready(function() {
	$(".sort").click(function (event){
		if($('#sortOrder').val() == 'ASC'){
			$('#sortOrder').val("DESC") ; fncSelectAuthorRoleList();
		}else{
			$('#sortOrder').val("ASC") ; fncSelectAuthorRoleList();
		}
	});	
});

function fnCheckAll() {
    var checkField = document.listForm.del;
    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.del;
    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.del.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;
    searchForm.sortOrder.value =  $('#sortOrder').val() ;
	searchForm.pageUnit.value = $('#pageUnit').val();
    document.searchForm.action = "<c:url value='/sec/ram/EgovAuthorRoleList.do'/>";
    document.searchForm.submit();
}


function press() {

    if (event.keyCode==13) {
        fncSelectAuthorRoleList();
        event.preventDefault();
    }
}
</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="roleNm" value="<c:out value="${authorRoleManageVO.roleNm}"/>"/>
	<input type="hidden" name="searchCondition"/>
	<input type="hidden" name="sortOrder" id="sortOrder" value="${authorRoleManageVO.sortOrder}" />
	
<div class="cont_area">
<div class="cont_main_title">
        <img src="/direct/img/home_icon.png" alt="">
        <span id="cnt_cate_list"></span>
    </div>
    <div class="cont_serch_area">
        <div class="basic_serch_area">
            권한(<span style="color:blue;">${authorRoleManageVO.searchKeyword} : ${authorRoleManageVO.roleNm}</span>) 롤 명(또는 롤 설명)
            <input type="text" id="searchKeyword2" name="searchKeyword2"  value="<c:out value='${authorRoleManageVO.searchKeyword2}'/>" size="25" title="검색" onkeypress="press();" />
            <div class="serch_btns">
                <input type="button" value="검색" class="serch_btn" onclick="fncSelectAuthorRoleList(); return false;">
            </div>
        </div>
    </div>

    <div class="list_info">
        <div class="all_list_number">총 
        	<span class="all_number"><c:out value="${paginationInfo.totalRecordCount}"/></span>건</div>
	        <div class="list_info_right">
	            <div class="list_write"><input type="button" value="등록" onclick="fncAddAuthorRoleInsert(); return false;"></div>
	        <div class="list_count">
	            <select name="pageUnit" id="pageUnit" class="select" title="검색조건선택" onchange="fncSelectAuthorRoleList();">
					   <option value='10' <c:if test="${authorRoleManageVO.pageUnit == '10' or authorRoleManageVO.pageUnit == ''}">selected</c:if>>10줄</option>
					   <option value='20' <c:if test="${authorRoleManageVO.pageUnit == '20'}">selected</c:if>>20줄</option>
					   <option value='30' <c:if test="${authorRoleManageVO.pageUnit == '30'}">selected</c:if>>30줄</option>
				</select>
	        </div>
	        <div class="del_btn">
	            <!-- <input type="button" value="삭제"  onclick="fn_fms_file_delete(); return false;"/> -->
	        </div>
    	</div>
	</div>
    <div class="list_wrap">
        <table>
            <tr>
                <th><input type="checkbox" namve="checkAll" id="checkAll" value="1" onClick="fnCheckAll();"> <label for="checkAll"></label></th>
                <th>번호
                	<div class="sort">
                         <div class="sort_up">
                         	<c:if test="${authorRoleManageVO.sortOrder == 'DESC'}" >
                         	<img src="/direct/img/sort_up_img.png" alt="">
                         	</c:if>
                         </div>
                         <div class="sort_down">
                         	<c:if test="${authorRoleManageVO.sortOrder == 'ASC'}" >
                         	<img src="/direct/img/sort_down_img.png" alt="">
                         	</c:if>
                         </div>
                    </div>
                </th>
                <th>롤 ID</th>
				<th>롤 명</th>
				<th>롤 타입</th>
				<th>롤 Sort</th>
				<th>롤 설명</th>
				<th>등록일자</th>
				<th>등록여부</th>
            </tr>
            <c:forEach var="result" items="${authorRoleList}" varStatus="status">
            <tr>
                <td>
                	<input name="del" id="check${status.index}" type="checkbox" value="<c:out value="${result.roleCode}"/>" />
                	<label for="check${status.index}"></label>
                </td>
                <td>
                	<c:if test="${authorRoleManageVO.sortOrder eq 'DESC' }">
                		<c:out value="${(authorRoleManageVO.pageIndex - 1) * authorRoleManageVO.pageUnit + status.count}"/>
                	</c:if>
                	<c:if test="${authorRoleManageVO.sortOrder eq 'ASC' }">
                		<c:out value="${ ( paginationInfo.totalRecordCount - ((authorRoleManageVO.pageIndex -1)*authorRoleManageVO.pageUnit) ) - status.index }"/>
                	</c:if>
                </td>
                <td>
                	<c:out value="${result.roleCode}"/>
                </td>
                <td>
                	<%-- <a href="#" onclick="fn_view_fms_file('${result.roleCode}' , 'U'); return false;"> --%><c:out value="${result.roleNm}"/></a>
                </td>
                <td>
	               	<c:out value="${result.roleTyp}"/>
                </td>
                <td>
	               <c:out value="${result.roleSort}"/>
                </td>
                <td>
	               <c:out value="${result.roleDc}"/>
                </td>
                <td>
                	<c:out value="${result.creatDt}"/>
                </td>
                <td>
                	<select name="regYn" title="등록여부">
				    	<option value="Y" <c:if test="${result.regYn == 'Y'}">selected</c:if> >등록</option>
				    	<option value="N" <c:if test="${result.regYn == 'N'}">selected</c:if> >미등록</option>
				    </select>
                
                </td>
            </tr>
            <input name="checkId" type="hidden" value="<c:out value="${result.roleCode}"/>" />
           </c:forEach>
           <c:if test="${empty authorRoleList}">
         		<tr><td colspan="8"><spring:message code="common.nodata.msg" /></td></tr>
           </c:if>     
        </table>
    </div>
    <!-- 페이지 네비게이션 시작 -->
	<c:if test="${!empty authorRoleList}">
 	<div class="page">
        <ul>
  			<ui:pagination paginationInfo = "${paginationInfo}"  type="image" jsFunction="linkPage" />
  		</ul>
    </div>
  	</c:if>                      
    <!-- //페이지 네비게이션 끝 --> 
</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="roleNm" type="hidden" value="<c:out value='${authorRoleManageVO.roleNm}'/>" />
	<input name="authorCode" type="hidden" />
	<input name="pageUnit" type="hidden" value="10" />
	<input name="sortOrder" type="hidden"/>
</form>	
</body>
</html>