<%@ 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/getIP.js"></script>
<script type="text/javascript" src="IDC/js/setToken.js"></script>
<script>
//유효성검사
function validateTest(){
	var client_code = document.getElementById("client_code").value;
	if(client_code != null && client_code != "" && client_code != undefined){
		
	}else{
		alert("고객 번호를 입력해주세요");
		return false;
	}
	
	var server_code = document.getElementById("server_code").value;
	if(server_code != null && server_code != "" && server_code != undefined){
		
	}else{
		alert("장비 번호를 입력해주세요");
		return false;
	}
	
	var service_ip = document.getElementById("service_ip").value;
	if(service_ip != null && service_ip != "" && service_ip != undefined){
		
	}else{
		alert("기본 ip를 입력해주세요");
		return false;
	}
	
	var service_payment_date = document.getElementById("service_payment_date").value;	
	if(service_payment_date != null && service_payment_date != "" && service_payment_date != undefined){
		
	}else{
		alert("결제일을 선택해주세요");
		return false;
	}
		
	var service_amount = document.getElementById("service_amount").value;
	if(service_amount != null && service_amount != "" && service_amount != undefined){
		
	}else{
		alert("장비 임대 금액을 입력해주세요");
		return false;
	}				
	
	var check_server_code = document.getElementById("check_server_code").value;
	if(check_server_code=="x")
	{
		alert("장비번호가 중첩됩니다.");
		return false;
	}
	var selCS = $("#selCS").val();
	if(selCS =="")
	{
		alert("CS를 선택하여 주십시오.");
		return false;
	}
	else if(selCS == "vpc")
	{
		if(checkVPC())
		{
			alert("VPC-CS 정보를 입력하여 주십시오.");
			return false;
		}
	}
	else if(selCS == "kt")
	{
		if(checkKT())
		{
			alert("KT-CS 정보를 입력하여 주십시오.");	
			return false;
		}
	}
	return true;
}
//vpc 장비명 체크
var checkVPC = function()
{
	if($("#v_server_code").val()=="")
		return true;
	return false;
}

//장비번호 체크
var checkKT = function()
{
	if($("#k_server_code").val()=="")
		return true;
	return false;
}
///vpn등록으로 이동
$(function()
{		
	//vpn선택시 vpn등록으로 이동
	$("#service_line").change(function(){
		var service_line = $(this).val();
		var client_code =$(this).attr("client_code");
		
		if(service_line != 'vpn'){
			window.location = "serviceWriteForm.sev?client_code="+client_code;	
		}
	});
	$("#server_code").bind("input",function()
	{
		var sCode = $(this).val();
		data ="server_code="+ sCode;
		$.get("IdcGetServerCodeJSON.jso",data, function(json)
		{
			var a = json[0].code;
			for(var i=0;i<a.length;i++)
			{
 				if(sCode.toUpperCase()==a[i].toUpperCase())
				{
					$("#check_server_code").val("x");
					break;
				}
				else
					$("#check_server_code").val("o");
			}
		});
	});
	
	//vpn클릭시 vpn등록
	$("#btnVPC").click(function()
	{
		$(this).removeClass("btn-default").addClass("btn-success");
		$("#btnKT").removeClass("btn-success").addClass("btn-default");
		$("#selCS").val("vpc");
	});
	
	//ktc클릭시 ktccs등록
	$("#btnKT").click(function()
	{
		$(this).removeClass("btn-default").addClass("btn-success");
		$("#btnVPC").removeClass("btn-success").addClass("btn-default");
		$("#selCS").val("kt");
	});
	
	
});
</script>
<style>
.modalDiv
{
	border-bottom:thin solid #dddddd;
	padding:5px;
}
</style>
<!-- 여기가 본 페이지이다 -->
<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="row">
					<!-- 윗줄 ㅇㅇ -->
				</div>
				<!-- row -->											
				<form name="frm" action="vpnWriteHandle.sev" method="post" onsubmit="return validateTest();">			
		   			<input type="hidden" id="token" name="token">
		   			<div class="table-responsive">
						<table class="table table-bordered table-hover table-striped">
							<thead>
							</thead>
							<tbody>
								<tr>
									<td style="min-width: 120px">서비스 상태</td>
									<td colspan="5">
										<select name="service_status">
											<option value="o">o</option>
											<option value="x">x</option>						
										</select>
									</td>
								</tr>								
								<tr>
									<td>고객 코드</td>
									<td colspan="5">
										<input type="text" name="client_code" id="client_code" maxlength="50" size="50" value="${client_code}">
									</td>
								</tr>																
								<tr>
									<td>라인 종류</td>
									<td colspan="5">					
										<select name="service_line" id="service_line" client_code="${client_code}">
											<option value="normal">일반</option>
											<option value="defence">방어</option>
											<option value="solo">전용</option>
											<option value="test">테스트</option>
											<option value="soloLine">전용라인</option>
											<option value="substitution">대체서버</option>
											<option value="vpn" selected="selected">VPN</option>																						
										</select>
									</td>
								</tr>
								
								<tr>
									<td>장비번호</td>
									<td colspan="5">																
										<input type="text" id="server_code" name="server_code" id="server_code" maxlength="50" size="50" placeholder="장비번호">			
										사용가능 여부 : <input type="text" id="check_server_code" readonly="readonly" value="o">
									</td>
								</tr>																
								<tr>
									<td>기본IP</td>
									<td colspan="5">
										<div class="row">
											<div class="col-lg-4">
										  		<div class="input-group">
													<input type="text" class="form-control" name="service_ip" id="service_ip" maxlength="50" size="50" placeholder="기본IP">
												</div>
											</div>
										</div>
									</td>
								</tr>
								<tr>
									<td>CS선택</td>
									<td>
										<input type="button" class="btn btn-default" id="btnVPC" data-toggle="modal" data-target="#vpcModal" value="VPC-CS">
										<input type="button" class="btn btn-default" id="btnKT" data-toggle="modal" data-target="#ktModal" value="KT-CS">
										<input type="hidden" id="selCS" name="selCS" value="">
									</td>
								</tr>																																																								
								<tr>
									<td>신청일</td>
									<td colspan="5">
										<input type="date" name="service_request_date" id="service_request_date" value="${curdate}">
									</td>
								</tr>								
								<tr>
									<td>익월 결제일</td>
									<td colspan="5">
										<input type="date" name="service_payment_date" id="service_payment_date" value="${curdate}">					
									</td>
								</tr>															
								<tr>
									<td>장비 임대 금액</td>
									<td colspan="5">										
										<input type="text" name="service_amount" id="service_amount" placeholder="장비 임대 금액"/>
									</td>
								</tr>								
								<tr>
									<td>메모</td>
									<td colspan="5">					
										<textarea name="service_note" rows="8" cols="100"></textarea>
									</td>
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="6" align="right">
										<input class="btn btn-outline btn-primary" type="submit" value="서비스 등록">
									</td>
								</tr>
							</tfoot>
						</table>
					</div>
					<!-- table-responsive -->
					<!-- VPC 모달창 -->
					<div class="modal fade" id="vpcModal" tabindex="-1" role="dialog" aria-labelledby="vpcTitle" aria-hidden="true"><!-- 뒤 배경 검정 ㄱㄱ -->
						<div class="modal-dialog"> <!-- 앞으로 보여줄 모달 창 -->
							<div class="modal-content"> <!-- 모달에 보여질 내용들 -->
								<div class="modal-header"> <!-- 모달 대가리 -->
									<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
									<h4 class="modal-title" id="vpcTitle">VPC-CS 등록</h4>
								</div>
								<div class="modal-body"><!-- 모달 몸통 -->
									<div class="row">
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>장비번호</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="text" id="v_server_code" name="v_server_code" value=""></div>
										</div>
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>VPC-CS-IP</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="text" id="v_ip" name="v_ip" value=""></div>
										</div>
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>연결 도매인</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="text" id="v_linkDomain" name="v_linkDomain" value=""></div>
										</div>
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>방화벽 설정</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="text" id="v_fireWall" name="v_fireWall" value=""></div>
										</div>
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>최종 공격일</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="date" id="v_attackDay" name="v_attackDay"></div>
										</div>
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>비고</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="text" id="v_note" name="v_note" value=""></div>
										</div>
									</div>
								</div>
								<div class="modal-footer"><!-- 모달 아래 -->
									<button type="button" class="btn btn-default" data-dismiss="modal">닫기</button>
								</div>
							</div>
						</div>
					</div>
					
					<!--KT 모달창 -->
					<div class="modal fade" id="ktModal" tabindex="-1" role="dialog" aria-labelledby="ktTitle" aria-hidden="true"><!-- 뒤 배경 검정 ㄱㄱ -->
						<div class="modal-dialog"> <!-- 앞으로 보여줄 모달 창 -->
							<div class="modal-content"> <!-- 모달에 보여질 내용들 -->
								<div class="modal-header"> <!-- 모달 대가리 -->
									<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
									<h4 class="modal-title" id="ktTitle">KT-CS  등록</h4>
								</div>
								<div class="modal-body"><!-- 모달 몸통 -->
									<div class="row">
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>서버 계정</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="text" id="k_id" name="k_id" value=""></div>
										</div>
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>장비번호</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="text" id="k_server_code" name="k_server_code" value=""></div>
										</div>
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>KT-CS-IP</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="text" id="k_ip" name="k_ip" value=""></div>
										</div>
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>연결 도매인</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="text" id="k_linkDomain" name="k_linkDomain" value=""></div>
										</div>
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>접속 도매인</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="text" id="k_inDomain" name="k_inDoamin" value=""></div>
										</div>
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>최종 공격일</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="date" id="k_attackDay" name="k_attackDay"></div>
										</div>
										<div class="modalDiv col-lg-12 col-md-12 col-sm-12">
											<div class="col-lg-3 col-md-4 col-sm-5"><label>비고</label></div>
											<div class="col-lg-9 col-md-8 col-sm-7"><input type="text" id="k_note" name="k_note" value=""></div>
										</div>
									</div>
								</div>
								<div class="modal-footer"><!-- 모달 아래 -->
									<button type="button" class="btn btn-default" data-dismiss="modal">닫기</button>
								</div>
							</div>
						</div>
					</div>
					<!-- 모달 끝 -->
				</form>
			</div>
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->
