<%@ 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 calc(){
	var f = document.frm;
	
	var a = 0;
	var b = 0;
	
	a = (parseInt(f.onetime_amount.value)||0);
	b = (parseInt(f.onetime_payment.value)||0);		
	
	var result = a - b;
			
	f.onetime_nonpayment.value = result;	
}

//뒤로가기 버튼
function back_btn(sc){
	location.href="additionalService.sev?service_code="+sc;
}

//기타 추가시 일회성 종류와 sub를 초기화
function addEtc(){
	var etc = document.getElementById("onetime_etc");
	if(etc.value != "" && etc.value != null){
		document.getElementById("onetime_case").value = "x";
		document.getElementById("onetime_sub").value = "";
	}
}

//유효성 체크
function validateTest(){
	var onetime_case = document.getElementById("onetime_case").value;
	if(onetime_case == "x"){
		alert("추가 항목을 선택해주세요");
		return false;
	}
	
	var onetime_request_date = document.getElementById("onetime_request_date").value;
	if(onetime_payment_date == "" || onetime_payment_date == null || onetime_request_date == undefined){
		alert("결제일을 선택해주세요");
		return false;
	}
	
	var onetime_amount = document.getElementById("onetime_amount").value;
	if(onetime_amount == "" || onetime_amount == null || onetime_amount == undefined){
		alert("서비스 금액을 입력해주세요");
		return false;
	}
	
	var onetime_payment = document.getElementById("onetime_payment").value;
	if(onetime_payment == "" || onetime_payment == null || onetime_payment == undefined){
		alert("입금액을 입력해주세요");
		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>1회성 등록</h4>
			</div>
			<div class="panel-body">
   				<form name="frm" action="etcHandle.sev?service_code=${ise.service_code}&client_code=${ise.client_code}" 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>고객코드</td>
									<td colspan="5"><input type="text" readonly="readonly" value="${ise.client_code}"></td>			
								</tr>
								<tr>
									<td>서비스코드</td>
									<td colspan="5"><input type="text" readonly="readonly" value="${ise.service_code}"></td>									
								</tr>
								<tr>
									<td>고객명</td>									
									<td colspan="5"><input type="text" name="client_name" readonly="readonly" value="${ise.client_name}"></td>			
								</tr>
								<tr>
									<td>장비번호</td>
									<td colspan="5"><input type="text" name="server_code" readonly="readonly" value="${ise.server_code}"></td>		
								</tr>
								<tr>
									<td>
										<select name="onetime_case" id="onetime_case">
												<option value="x">없음</option>
												<option value="domain">도메인 구매</option>
												<option value="hdd">HDD 추가</option>
												<option value="ram">RAM 추가</option>
												<option value="ip">IP 변경</option>
												<option value="etc">기타 서비스 추가</option>																													
											</select>
									</td>
									<td colspan="5">
										<input type="text" name="onetime_sub" id="onetime_sub"/> 
										<br>1. 도메인 : 구매 시 반드시 숫자로만 갯수를 입력하세요 (* 3개 구매시 작성 예제 : <font color=red><b>3</b></font>)
										<br>2. 메모리 과금 : 2G당 5만원 (빠른 계산법:기존4G일때 16기가로 요청 = 12G 추가 12/2*5=30만원)
										<br>3. IP 변경 후 차단등의 상황이 발생했을때 10만원 과금 할 것
										<br> <a href=/IdcETCAddForm.sev?service_code=${ise.service_code}&mkworker=${member.name }><font color=red><b>닷 디펜더 / CF 방어등 월과금 서비스는 이곳 을 클릭</b></font></a> 
									</td>
								</tr>																
								<tr>
									<td>서비스 금액</td>
									<td colspan="3">
										<input type="text" name="onetime_amount" id="onetime_amount" onkeyup="calc()"/>
										<input type="hidden" name="onetime_payment" id="onetime_payment" value="0"/>
										<input type="hidden" name="onetime_nonpayment" id="onetime_nonpayment"/> ( 도메인 : 게임윙의 경우 개당 20000 그 외 개당 30000 으로 계산할것)
									</td>
									<!-- 
									<td>입금액</td>
									<td>
										<input type="text" name="onetime_payment" id="onetime_payment" value="0" onkeyup="calc()"/>
									</td>
									<td>미납금액</td>
									<td>
										<input type="text" name="onetime_nonpayment" id="onetime_nonpayment"/>
									</td>
									 -->						
								</tr>		
								<tr>
									<td>신청일</td>
									<td>
										<input type="date" name="onetime_request_date" id="onetime_request_date" value="${ise.onetime_curdate}"/>
									</td>				
									<td>결제 예정일</td>
									<td colspan="3">
										<input type="date" name="onetime_payment_date" id="onetime_payment_date" value="${ise.onetime_curdate}"/>
									</td>
								</tr>
								<tr>
									<td>비고</td>
									<td colspan="5"><textarea cols="100" rows="4" type="text" name="onetime_note" id="onetime_note" ></textarea></td>
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="6">
										<input type="hidden" name="vpnFlag" value="${vpnFlag}">
										<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('${ise.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 -->
