<%@ 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(){	
	
	//금액입력시 금액과 일할부분으로 금액이 완납인지 아닌지 판단
	//통합결제인지 나눠서결제인지 판단.
	$(".account").bind("input", function(){
		var account1 = $("#account1").val();		
		var account2 = $("#account2").val();
		
		$("#result").val(account1 - account2);
		
		if($("#result").val() == '0'){
			$("#accountStatus").val("complete");
			$("#accountStatus2").val("완납");
		}else{
			$("#accountStatus").val("incomplete");
			$("#accountStatus2").val("미납");
		}
		
		if(account1 != 0 && account2 == 0){
			$("#united1").val("분할");
			$("#united").val("x");
			$("#payment_div").attr("style", "display:block;");
		}else if(account2 != 0){			
			$("#united1").val("통합");
			$("#united").val("o");
			$("#payment_div").attr("style", "display:none;");
		}
	});
});

function back_btn(sc){
	window.location ="additionalService.sev?service_code="+sc;
	
}

//통합선택시 처리
function clickUnited(selectObj){
	if(selectObj.value == "x"){
		document.getElementById("payment_div").style.display = "block";
	}else{
		document.getElementById("payment_div").style.display = "none";
	}
}

//유효성 검사
function validateTest()
{
	
	return true;
}
</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">
   				<form name="frm" action="IdcETCAdd.sev" method="post" onsubmit="return validateTest();">
		   			<input type="hidden" id="token" name="token">
		   			<div class="table-responsive">
	   					<input type="hidden" name="service_code" id="service_code" value="${service_code}">
						<table class="table table-bordered table-hover table-striped">
							<thead>
							</thead>
							<tbody>
								<tr>
									<td>고객명</td>
									<td>${client_name}<input type="hidden" name="client_name" value=${client_name }></td>
									<td>라인종류</td>
									<td>${service_line}</td>
								</tr>
								<tr>
									<td>장비명</td>
									<td>${server_code}<input type="hidden" name="server_code" value="${server_code}"></td>
									<td>IP</td>			
									<td>${service_ip}<input type="hidden" name="service_ip" value=${service_ip }></td>					
								</tr>
								<tr>
									<td>구분</td>
									<td>부가서비스명</td>
									<td>과금</td>
									<td>일할과금</td>
								</tr>
								<tr>
									<td>부가서비스</td>
									<td>
										<input type="text" id="addDB_code" name="addDB_code" value="" placeholder="부가서비스명"> <br>( 예제: 닷 디펜더 , 도메인 방어 서비스 ) <- 복사 후 사용
										<br> 닷 디펜더 : 25만원 / 도메인 방어 서비스 : 개당 40만원
										<br><b> * 도메인은 이곳이 아닌 1회성 메뉴로 등록하세요!</b>
										<input type="hidden" name="addDB_case" id="addDB_case" value="etc">
									</td>
									<td>
										<input type="text" name="account1" id="account1" class="account" value="250000"/>
									</td>
									<td>
										<input type="text" name="account2" id="account2" class="account" value="0"/>
									</td>						
								</tr>
								<tr>
									<td>기존 결제일</td>
									<td colspan="3"><input type="date" name="service_payment_date" id="service_payment_date" value="${payment_date}"/></td>
								</tr>
								<tr>
									<td>신청일</td>
									<td colspan="3"><input type="date" name="request_date" id="request_date"/ value="${curdate}"></td>			
								</tr>
								<tr>
									<td>해지일</td>
									<td colspan="3"><input type="date" name="cancel_date" id="cancel_date"/>
										<input type="hidden" name="accountStatus"  id="accountStatus" readonly="readonly" value="incomplete"/>
										<input type="hidden" name="accountStatus2"  id="accountStatus2" readonly="readonly" value="미납"/>
										<input type="hidden" name="united"  id="united" value="o"/>
									</td>												
								</tr>
								<tr>
									<td>결제 방식</td>
									<td>
										<input type="text" id="united1" value="통합" readonly="readonly"/>										
									</td>									
									<td colspan="2"><div id="payment_div" style="display:none;">결제일<input type="date" name="payment_date"></div></td>
													
								</tr>	
								<tr>
									<td>비고</td>
									<td colspan="3">
										<textarea name="addDB_note" id="addDB_note" cols="100" rows="4"></textarea>
									</td>
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="4">
										<input class="btn btn-outline btn-primary" type="submit" name="save" value="저장">
										<input class="btn btn-outline btn-default" type="button" name="back" value="취소" onclick="back_btn('${ipAdd.service_code}')">
									</td>
								</tr>	
							</tfoot>
						</table>
					</div>
					<!-- table-responsive -->
				</form>
			</div>
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->
