<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript" src="IDC/js/setToken.js"></script>
<script>
$(function()
{
	$("#deffence_case").val($("#d_case").val());
	
	//장비번호 클릭시 서버 토글 열기
	$("#server_code").click(function()
	{
		$("#server").show();
	});
	
	//장비번호 불러오기
	$.get("IdcGetUseServerCode.jso","",function(data)
	{
		var t = data.a;
		for(var i=0;i<t.length;i++)
		{
			var li = $("<li>");
			var a = $("<a>");
			
			a.addClass("server_code").html(t[i]).attr("href","#");
			
			li.append(a);
			$("#server").append(li);
		}
	});
	
	//장비번호 여러개 중  클릭시 하는 일.
	$(document).on("click",".server_code",function()
	{
		var code = $(this).html();
		$("#server_code").val(code);
		$("#server").hide();
		var cs = $("#cs_code");
	
		$.get("IdcGetCSList.jso","&server_code="+code,function(data)
		{
			var t = data.a;		//a = cs리스트가 있다.
			var t2 = data.b;		//b = 서비스 정보가 있다.
		
			if(t.length==0)
			{
//				alert("해당 서버에 등록된 cs가 부족합니다.");
			}
			else
			{
				cs.empty();
				for(var i=0;i<t.length;i++)
				{
					cs.append($("<option>").val(t[i]).html(t[i]));
				}
			}
			$("#service_line").val(t2.service_line);
			$("#client_name").val(t2.client_name);
			$("#service_ip").val(t2.service_ip);
			$("#service_code").val(t2.service_code);
			$("#service_admin").val(t2.service_admin);
		});
	});
	
});
</script>
<!-- 여기가 본 페이지이다 -->
<div class="row">
	<div class="col-lg-8">
		<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="row">
				</div>
				<!-- row -->
   				<form action="addDeffenceHandle.sev" method="post">
		   			<input type="hidden" id="token" name="token">
		   			<div class="table-responsive">
   						<input type="hidden" name="service_code" value="${dlist.service_code}">
						<input type="hidden" name="client_code"  value="${dlist.client_code}">
						<input type="hidden" id="d_case" value="${deffence_case}">
						<table class="table table-bordered table-hover table-striped">
							<thead>
							</thead>
							<tbody>
								<tr>
									<td>구분</td>
									<td colspan="3">
										<select name="deffence_case" id="deffence_case">
											<option value="1">CS방어</option>
											<option value="2">CS-PRE</option>
											<option value="3">CF 방어</option>
											<option value="4">BL 방어</option>
											<option value="5">인증방어</option>
											<option value="6">MGTK</option>																						
										</select>
									</td>
								</tr>
								<tr>
									<td>방어존</td>
									<td colspan="3">
										<input type="text" name="deffence_zone" maxlength="50" size="50">
									</td>				
								</tr>
								<tr>
									<td>ACL</td>
									<td colspan="3">
										<input type="text" name="deffence_acl" maxlength="50" size="50">
									</td>
								</tr>
								<tr>
									<td>REAL</td>
									<td colspan="3">
										<input type="text" name="deffence_real" maxlength="50" size="50">
									</td>
								</tr>
								
								<tr>
									<td>포트</td>
									<td colspan="3">
										<input type="text" name="deffence_port" maxlength="50" size="50">
									</td>
								</tr>
								<tr>
									<td>업체명</td>
									<td colspan="3">
										<input type="text" id="client_name" name="client_name" maxlength="50" size="50" value="${dlist.client_name}">
									</td>
								</tr>
								<tr>
									<td>VPC_장비명</td>
									<td colspan="3">
										<input type="text" name="vpc_code" maxlength="50" size="50">
									</td>
								</tr>			
								<tr>
									<td>장비번호</td>
										<td colspan="3">
											<div class="col-lg-4">
												<div class="input-group">
													<span class="input-group-btn">
														<ul class="dropdown-menu" role="menu" id="server">
															
														</ul>
													</span>
													<input type="text" class="btn btn-default" name="server_code" id="server_code" placeholder="클릭하세요" value="" / >
												</div>
											</div>
										</td>
								</tr>
								<tr>
									<td>service_ip</td>
									<td colspan="3">
										<input type="text" name="service_ip" id="service_ip" maxlength="50" size="50" value="${dlist.service_ip}">
									</td>
								</tr>
								
								<tr>
									<td>도메인</td>
									<td colspan="3">
										<input type="text" name="deffence_domain" maxlength="50" size="50">
									</td>
								</tr>
											
								<tr>
									<td>비고</td>
									<td colspan="3">					
										<textarea name="deffence_note" rows="8" cols="100"></textarea>
									</td>
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="4" align="right">
										<button class="btn btn-outline btn-primary" type="submit" value="서비스 등록">서비스 등록</button>
										<a class="btn btn-outline btn-default" href="serviceList.sev?client_code=${dlist.client_code}">취소</a>
									</td>
								</tr>
							</tfoot>
						</table>
					</div>
					<!-- table-responsive -->
				</form>
			</div>
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->
