<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<script src="IDC/js/setToken.js"></script>
<script>
//방어존 추가 눌렀을경우
function addDadd(deffence_num, deffence_case){	
	window.location = "addD1add.sev?deffence_num="+deffence_num+"&deffence_case="+ deffence_case;
}

//방어존1 개설
function deffence_zone1(){
	window.location = "deffenceInfo.sev?";
}

//방어존2 개설
function deffence_zone2(){
	window.location = "deffenceInfo.sev?deffence_case=2";
}

//방어존3 개설
function deffence_zone3(){
	window.location = "deffenceInfo.sev?deffence_case=3";
}

//방어존4 개설
function deffence_zone4(){
	window.location = "deffenceInfo.sev?deffence_case=4";
}
//방어존5 개설
function deffence_zone5(){
	window.location = "deffenceInfo.sev?deffence_case=5";
}
//방어존6 개설
function deffence_zone6(){
	window.location = "deffenceInfo.sev?deffence_case=6";
}
//방어존 내 하위 제거
function sub_delBtn(deffence_case, dadd_num){
	window.location = "delD1add.sev?deffence_case=" + deffence_case + "&dadd_num="+dadd_num;
}
//방어존 제거
function deffence_delBtn(client_code, service_code, server_code){
	window.location = "deleteServiceHandle.sev?client_code="+client_code+"&service_code="+service_code+"&server_code="+server_code;
}
</script>
<script type="text/javascript">
$(function()
{
	//방어존 제거시 하위 서비스 있는지 없는지 판단 후 경고
	$(".delID").click(function()
	{
				
		var subC = ".sub"+$(this).attr("value");
		var sub = $(subC);
		if(sub.length>0){
			alert("방어존에 물려있는 방어서비스를 삭제한 후 삭제해 주십시오.");
		}else{			
			
			var result = confirm("정말 삭제하시겠습니까?");
			if(result == true){
				window.location = $(this).attr("uri")+"&token="+$("#token").val();	
			}else{
				return false;
			}
		}
		
	});
	
	//하위 제거시 경고창
	$(".delID2").click(function()
	{
		var result = confirm("정말 삭제하시겠습니까?");
		if(result == true){			
			window.location = $(this).attr("uri")+"&token="+$("#token").val();
		}else{
			return false;
		}
	});
});
</script>
<!-- 여기가 본 페이지이다 -->
<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h4><i class="fa fa-desktop fa-fw"></i>방어라인 정보</h4>
			</div>
			<div class="panel-body">
				<div class="btn-group">
					<!-- 윗줄 ㅇㅇ -->
						<input type="hidden" name="client_code" id="client_code" value="${client_code}"/>	
						<!-- <input class="btn btn-outline btn-default" type="button" value="CS방어" onclick="deffence_zone1()"> -->
						<input class="btn btn-outline btn-default" type="button" value="CS-PRE" onclick="deffence_zone2()">
						<input class="btn btn-outline btn-default" type="button" value="CF/PF 방어" onclick="deffence_zone3()">
						<input class="btn btn-outline btn-default" type="button" value="JCS 상시 방어" onclick="deffence_zone4()">
						<input class="btn btn-outline btn-default" type="button" value="JCS 방어" onclick="deffence_zone5()">
						<input class="btn btn-outline btn-default" type="button" value="MGTK" onclick="deffence_zone6()">						
						<a href="addDeffence1.sev?deffence_case=${deffence_case}" class="btn btn-info">방어존 등록</a>
						<!-- <a class="btn btn-outline btn-default" type="button" href="deffenceInfoExcel.sev?deffence_case=${deffence_case}">엑셀</a> -->
				</div>
				<!-- row -->
				<input type="hidden" id="token">
	   			<div class="table-responsive">
					<table class="table table-bordered table-hover table-striped">
						<thead>
							<tr>
<c:choose>
<c:when test="${deffence_case == 3}"> 
								<td>방어존</td>				
								<td>REAL</td>
								<td>업체명</td>
								<td>VPC_장비번호</td>
								<td>장비번호</td>
								<td>연결IP</td>
								<td>도메인</td>
								<td>비고</td>
								<td>추가</td>
								<td>수정</td>
								<td>삭제</td>
</c:when>
<c:when test="${deffence_case == 4}"> 
								<td>방어존</td>				
								
								<td>REAL</td>
								
								<td>업체명</td>
								
								
								<td>장비번호</td>
								<td>연결IP</td>
								<td>도메인</td>
								
								<td>방화벽&비고</td>
								<td>추가</td>
								<td>수정</td>
								<td>삭제</td>
</c:when>
<c:otherwise>
								<td>방어존</td>				
								<td>ACL</td>
								<td>REAL</td>
								<td>포트</td>
								<td>업체명</td>
								<td>VPC_장비번호</td>
								<td>CS_IP</td>
								<td>장비번호</td>
								<td>연결IP</td>
								<td>도메인</td>
								<td>신청 일자</td>
								<td>신청 시간</td>
								<td>비고</td>
								<td>추가</td>
								<td>수정</td>
								<td>삭제</td>
</c:otherwise>
</c:choose>							
							</tr>
						</thead>
						<tbody>							
<c:choose>
<c:when test="${deffence_case == 3}"> 
							<c:forEach items="${dlist}" var="dto">	
									<tr>
										<td>${dto.deffence_zone}</td>
										<td>${dto.deffence_real}</td>
										<td>${dto.client_name}</td>
										<td>${dto.vpc_code}</td>

										<td>${dto.server_code}</td>
										<td>${dto.service_ip}</td>
										<td>${dto.deffence_domain}</td>
										<td>${dto.deffence_note}</td>
										<td><input type="button" class="btn btn-success" value="추가" onclick="addDadd('${dto.deffence_num}',${deffence_case})"></td>
										<td>
											<form action="deffenceInfoUpdate.sev?" method="post">
												<input type="hidden" name="deffence_case" value="${deffence_case}">												
												<input type="hidden" name="deffence_num" value="${dto.deffence_num}">
												<input type="hidden" name="deffence_case" value="${dto.deffence_case}">
												<input type="hidden" name="deffence_zone" value="${dto.deffence_zone}">
												<input type="hidden" name="deffence_acl" value="${dto.deffence_acl}">
												<input type="hidden" name="deffence_real" value="${dto.deffence_real}">
												<input type="hidden" name="deffence_port" value="${dto.deffence_port}">
												<input type="hidden" name="client_name" value="${dto.client_name}">
												<input type="hidden" name="vpc_code" value="${dto.vpc_code}">
												<input type="hidden" name="vpc_csip" value="${dto.vpc_csip}">
												<input type="hidden" name="server_code" value="${dto.server_code}">
												<input type="hidden" name="service_ip" value="${dto.service_ip}">
												<input type="hidden" name="deffence_domain" value="${dto.deffence_domain}">
												<input type="hidden" name="deffence_request_date" value="${dto.deffence_request_date}">
												<input type="hidden" name="deffence_request_time" value="${dto.deffence_request_time}">
												<input type="hidden" name="deffence_note" value="${dto.deffence_note}">
												<input type="hidden" class="token" name="token">
												<input type="submit" value="수정" class="btn btn-info"/>
											</form>										
										</td>
										<td>
											<a class="btn btn-danger delID mytoken" id="delID" value="${dto.deffence_num }" uri="IdcDeffenceDelete.sev?doWhat=def&num=${dto.deffence_num }">삭제</a>
										</td>				
									</tr>
							</c:forEach>									
</c:when>


<c:when test="${deffence_case == 4}"> 
							<c:forEach items="${dlist}" var="dto">	
									<tr>
										<td>${dto.deffence_zone}</td>
										
										<td>${dto.deffence_real}</td>
										
										<td>${dto.client_name}</td>
										
										
										<td>${dto.server_code}</td>
										<td>${dto.service_ip}</td>
										<td>${dto.deffence_domain}</td>
										
										<td>${dto.deffence_note}</td>
										<td><input type="button" class="btn btn-success" value="추가" onclick="addDadd('${dto.deffence_num}',${deffence_case})"></td>
										<td>
											<form action="deffenceInfoUpdate.sev?" method="post">
												<input type="hidden" name="deffence_case" value="${deffence_case}">												
												<input type="hidden" name="deffence_num" value="${dto.deffence_num}">
												<input type="hidden" name="deffence_case" value="${dto.deffence_case}">
												<input type="hidden" name="deffence_zone" value="${dto.deffence_zone}">
												<input type="hidden" name="deffence_acl" value="${dto.deffence_acl}">
												<input type="hidden" name="deffence_real" value="${dto.deffence_real}">
												<input type="hidden" name="deffence_port" value="${dto.deffence_port}">
												<input type="hidden" name="client_name" value="${dto.client_name}">
												<input type="hidden" name="vpc_code" value="${dto.vpc_code}">
												<input type="hidden" name="vpc_csip" value="${dto.vpc_csip}">
												<input type="hidden" name="server_code" value="${dto.server_code}">
												<input type="hidden" name="service_ip" value="${dto.service_ip}">
												<input type="hidden" name="deffence_domain" value="${dto.deffence_domain}">
												<input type="hidden" name="deffence_request_date" value="${dto.deffence_request_date}">
												<input type="hidden" name="deffence_request_time" value="${dto.deffence_request_time}">
												<input type="hidden" name="deffence_note" value="${dto.deffence_note}">
												<input type="hidden" class="token" name="token">
												<input type="submit" value="수정" class="btn btn-info"/>
											</form>										
										</td>
										<td>
											<a class="btn btn-danger delID mytoken" id="delID" value="${dto.deffence_num }" uri="IdcDeffenceDelete.sev?doWhat=def&num=${dto.deffence_num }">삭제</a>
										</td>				
									</tr>
							</c:forEach>									
</c:when>








<c:otherwise>
							<c:forEach items="${dlist}" var="dto">
								<!-- 
								<c:if test="${dto.deffence_case eq deffence_case}">
								 -->									
									<tr>
										<td>${dto.deffence_zone}</td>
										<td>${dto.deffence_acl}</td>
										<td>${dto.deffence_real}</td>
										<td>${dto.deffence_port}</td>
										<td>${dto.client_name}</td>
										<td>${dto.vpc_code}</td>
										<td>${dto.vpc_csip}</td>
										<td>${dto.server_code}</td>
										<td>${dto.service_ip}</td>
										<td>${dto.deffence_domain}</td>
										<td>${dto.deffence_request_date}</td>
										<td>${dto.deffence_request_time}</td>
										<td>${dto.deffence_note}</td>
										<td><input type="button" class="btn btn-success" value="추가" onclick="addDadd('${dto.deffence_num}',${deffence_case})"></td>
										<td>
											<form action="deffenceInfoUpdate.sev?" method="post">
												<input type="hidden" name="deffence_case" value="${deffence_case}">												
												<input type="hidden" name="deffence_num" value="${dto.deffence_num}">
												<input type="hidden" name="deffence_case" value="${dto.deffence_case}">
												<input type="hidden" name="deffence_zone" value="${dto.deffence_zone}">
												<input type="hidden" name="deffence_acl" value="${dto.deffence_acl}">
												<input type="hidden" name="deffence_real" value="${dto.deffence_real}">
												<input type="hidden" name="deffence_port" value="${dto.deffence_port}">
												<input type="hidden" name="client_name" value="${dto.client_name}">
												<input type="hidden" name="vpc_code" value="${dto.vpc_code}">
												<input type="hidden" name="vpc_csip" value="${dto.vpc_csip}">
												<input type="hidden" name="server_code" value="${dto.server_code}">
												<input type="hidden" name="service_ip" value="${dto.service_ip}">
												<input type="hidden" name="deffence_domain" value="${dto.deffence_domain}">
												<input type="hidden" name="deffence_request_date" value="${dto.deffence_request_date}">
												<input type="hidden" name="deffence_request_time" value="${dto.deffence_request_time}">
												<input type="hidden" name="deffence_note" value="${dto.deffence_note}">
												<input type="hidden" class="token" name="token">
												<input type="submit" value="수정" class="btn btn-info"/>
											</form>										
										</td>
										<td>
											<a class="btn btn-danger delID mytoken" id="delID" value="${dto.deffence_num }" uri="IdcDeffenceDelete.sev?doWhat=def&num=${dto.deffence_num }">삭제</a>
										</td>				
									</tr>
									<c:forEach items="${subList}" var="sub">
										<c:if test="${dto.deffence_num == sub.deffence_num}">
										<tr>	
											<td colspan="3"></td>											
											<td>${sub.deffence_port}</td>
											<td>${sub.client_name}</td>
											<td>${sub.vpc_code}</td>
											<td>${sub.vpc_csip}</td>
											<td>${sub.server_code}</td>
											<td>${sub.service_ip}</td>
											<td>${sub.deffence_domain}</td>
											<td>${sub.deffence_request_date}</td>
											<td>${sub.deffence_request_time}</td>
											<td>${sub.deffence_note}</td>
											<td></td>
											<td>
												<form action="addD1InfoUpdate.sev?" method="post">
													<input type="hidden" name="deffence_case" value="${deffence_case}">	
													<input type="hidden" name="dadd_num" value="${sub.dadd_num}">
													<input type="hidden" name="service_code" value="${dto.service_code}">
													<input type="hidden" name="deffence_port" value="${sub.deffence_port}">
													<input type="hidden" name="client_name" value="${sub.client_name}">
													<input type="hidden" name="vpc_code" value="${sub.vpc_code}">
													<input type="hidden" name="vpc_csip" value="${sub.vpc_csip}">
													<input type="hidden" name="server_code" value="${sub.server_code}">
													<input type="hidden" name="service_ip" value="${sub.service_ip}">
													<input type="hidden" name="deffence_domain" value="${sub.deffence_domain}">
													<input type="hidden" name="deffence_request_date" value="${sub.deffence_request_date}">
													<input type="hidden" name="deffence_request_time" value="${sub.deffence_request_time}">													
													<input type="hidden" name="deffence_note" value="${sub.deffence_note}">												
													<input type="hidden" class="token" name="token">
													<input type="submit" value="수정" class="btn btn-info"/>
												</form>
											</td>
											<td>
												<a class="btn btn-danger sub${dto.deffence_num} delID2" uri="IdcDeffenceDelete.sev?doWhat=sub&num=${sub.dadd_num }">삭제</a>
											</td>
										</tr>
										</c:if>
									</c:forEach>
								
								<!-- 	
								</c:if>
								 -->									
							</c:forEach>
</c:otherwise>
</c:choose>
						</tbody>
						<tfoot>
						</tfoot>
					</table>
				</div>
				<!-- table-responsive -->
				<div>
					<ul class="pagination" style="margin:0px;">
						<li>
							<a class="btn btn-outline btn-default" href="deffenceInfo.sev?client_code=${client_code}&deffence_case=${deffence_case}">
								<i class="fa fa-angle-double-left "></i>
							</a>
						</li>
						<c:forEach var="i" begin="1" end="${pageCnt }">
						<li>
							<a class="btn btn-outline btn-defualt" href="deffenceInfo.sev?client_code=${client_code}&curPage=${i}&deffence_case=${deffence_case}">${i}</a>	
						</li>
						</c:forEach>
						<li>
							<a class="btn btn-outline btn-default" href="deffenceInfo.sev?client_code=${client_code}&curPage=${pageCnt}&deffence_case=${deffence_case}">
								<i class="fa fa-angle-double-right "></i>
							</a>
						</li>
					</ul>
					<!-- ul -->
				</div>
				<!-- UL DIV -->
			</div>
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->
