<%@ 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 type="text/javascript">
$(function()
{
	//로딩 후 셀렉트 선택
	$("#useSelect").val($("#selData").val());
	
	//각 램 할당
	$("#server_ram1").val($("#ram1").val());
	$("#server_ram2").val($("#ram2").val());
	$("#server_ram3").val($("#ram3").val());
	$("#server_ram4").val($("#ram4").val());
	$("#server_ram5").val($("#ram5").val());
	
	//각 하드 할당
	$("#server_hdd1").val($("#hdd1").val());
	$("#server_hdd2").val($("#hdd2").val());
	$("#server_hdd3").val($("#hdd3").val());
	$("#server_hdd4").val($("#hdd4").val());
	$("#server_hdd5").val($("#hdd5").val());
	
	//브랜드
	$("#server_brand").val($("#brand").val());
	
	//가용 여부 바뀔 시
	$("#useSelect").change(function()
	{
		if($(this).val()=="y")
		{
			$("#server_fomat_date").val(null);
		}
	});
	//서버 포맷일 바뀔경우 체크
	$("#server_fomat_date").change(function()
	{
		if($(this).val()=="")
			$("#useSelect").val("y");  
		else
			$("#useSelect").val("n");
	});
	
	$(".checkServerUse").click(function(){
		var server_check = $("#server_check").val();
		var server_num = $(this).attr("value");

		if(server_check == "y"){
			var result = confirm("정말 삭제하시겠습니까?");
			if(result){
				window.location = "serverDelete.ser?server_num="+server_num+"&token="+$("#token").val();	
			}
			
		}else{
			alert("사용 중인 장비는 삭제 할 수 없습니다.");
		}
	});
	
	$("form[name='form1']").submit(function(){
		var server_ram1 = $("#server_ram1").val();
		var server_ram2 = $("#server_ram2").val();
		var server_ram3 = $("#server_ram3").val();
		var server_ram4 = $("#server_ram4").val();
		var server_ram5 = $("#server_ram5").val();
		
		if(server_ram1 == "" && server_ram2 == "" && server_ram3 == "" && server_ram4 == "" && server_ram5 == "" ){
			alert("램을 입력해 주세요");
			return false;
		}
		
		var server_hdd1 = $("#server_hdd1").val();
		var server_hdd2 = $("#server_hdd2").val();
		var server_hdd3 = $("#server_hdd3").val();
		var server_hdd4 = $("#server_hdd4").val();
		var server_hdd5 = $("#server_hdd5").val();
				
		if(server_hdd1 == "" && server_hdd2 == "" && server_hdd3 == "" && server_hdd4 == "" && server_hdd5 == "" ){
			alert("하드를 입력해 주세요");
			return false;
		}
		return true;
	});
	$("#loSel").val($("#loSel").attr("value"));
	var oldSel = $("#loSel").val();
	
	//장비 변경
	$("#loSel").change(function()
	{
		var server_check = $("#server_check").val();
		var server_num = $(this).attr("value");
		
		if(server_check != "y")
		{
			alert("사용 중인 장비는 삭제 할 수 없습니다.");
			$(this).val(oldSel);
		}
	});
});

</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>
	   			<form name="form1" action="serverUpdate.ser" method="post">
		   			<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="width:85px">NO</td>
									<td colspan="4"><input type="text" name="server_num" value="${idcServerRead.server_num}" readonly="readonly"></td>			
								</tr>
								<tr>
									<td>가용여부</td>
									<td colspan="4">
										<select id="useSelect" name="server_use_status">
											<option value="y">사용가능</option>
											<option value="n">사용불능</option>
										</select>
										<input type="hidden" id="selData" value="${idcServerRead.server_use_status}" >
										<input type="hidden" id="server_check" value="${idcServerRead.server_check}">
									</td>			
								</tr>	
								<tr>
									<td>서버코드</td>
									<td colspan="4"><input type="text" name="server_code"  value="${idcServerRead.server_code}"  readonly="readonly"></td>			
								</tr>
								<tr>
									<td>구분</td>
									<td colspan="4"><input type="text" name="server_process"  size="50" value="${idcServerRead.server_process}"></td>			
								</tr>
								<tr>
									<td>서버 스펙</td>
									<td colspan="4"><input type="text" name="server_spec" size="50" value="${idcServerRead.server_spec}"></td>			
								</tr>
								<tr>
									<td>서버cpu모델명</td>
									<td><input type="text" name="server_cpuname"  size="50" value="${idcServerRead.server_cpuname}"></td>			
								</tr>															
								<tr>
									<td>서버ram
										<input type="hidden" id="ram1" value="${idcServerRead.server_rams[0]}" />
										<input type="hidden" id="ram2" value="${idcServerRead.server_rams[1]}" />
										<input type="hidden" id="ram3" value="${idcServerRead.server_rams[2]}" />
										<input type="hidden" id="ram4" value="${idcServerRead.server_rams[3]}" />
										<input type="hidden" id="ram5" value="${idcServerRead.server_rams[4]}"/>
									</td>
									<td>										
										<select name="server_ram1" id="server_ram1">
											<option value="">없음</option>
											<option value="1g">1g</option>
											<option value="2g">2g</option>
											<option value="4g">4g</option>
											<option value="8g">8g</option>
											<option value="16g">16g</option>
											<option value="24g">24g</option>
											<option value="32g">32g</option>
											<option value="64g">64g</option>
											<option value="128g">128g</option>
											<option value="256g">256g</option>																												
										</select>
										<select name="server_ram2" id="server_ram2">
											<option value="">없음</option>
											<option value="1g">1g</option>
											<option value="2g">2g</option>
											<option value="4g">4g</option>
											<option value="8g">8g</option>
											<option value="16g">16g</option>
											<option value="24g">24g</option>
											<option value="32g">32g</option>
											<option value="64g">64g</option>
											<option value="128g">128g</option>
											<option value="256g">256g</option>																												
										</select>
										<select name="server_ram3" id="server_ram3">
											<option value="">없음</option>
											<option value="1g">1g</option>
											<option value="2g">2g</option>
											<option value="4g">4g</option>
											<option value="8g">8g</option>
											<option value="16g">16g</option>
											<option value="24g">24g</option>
											<option value="32g">32g</option>
											<option value="64g">64g</option>
											<option value="128g">128g</option>
											<option value="256g">256g</option>																												
										</select>
										<select name="server_ram4" id="server_ram4">
											<option value="">없음</option>
											<option value="1g">1g</option>
											<option value="2g">2g</option>
											<option value="4g">4g</option>
											<option value="8g">8g</option>
											<option value="16g">16g</option>
											<option value="24g">24g</option>
											<option value="32g">32g</option>
											<option value="64g">64g</option>
											<option value="128g">128g</option>
											<option value="256g">256g</option>																												
										</select>										
									</td>
									<td>직접입력: <Input type="text" name="server_ram5" id="server_ram5"/></td>									
								</tr>																																								
								<tr>
									<td>서버hdd
										<input type="hidden" id="hdd1" value="${idcServerRead.server_hdds[0]}" />
										<input type="hidden" id="hdd2" value="${idcServerRead.server_hdds[1]}" />
										<input type="hidden" id="hdd3" value="${idcServerRead.server_hdds[2]}" />
										<input type="hidden" id="hdd4" value="${idcServerRead.server_hdds[3]}" />
										<input type="hidden" id="hdd5" value="${idcServerRead.server_hdds[4]}"/>
									</td>
									<td>
										<select name="server_hdd1" id="server_hdd1">
											<option value="">없음</option>
											<option value="SAS 73G">SAS 73G</option>																																														
											<option value="SAS 146G">SAS 146G</option>
											<option value="SATA 300G">SATA 300G</option>
											<option value="SATA 500G">SATA 500G</option>
											<option value="SSD 128G">SSD 128G</option>
											<option value="SSD 256G">SSD 256G</option>
											<option value="SCSI 73G">SCSI 73G</option>
											<option value="SCSI 146G">SCSI 146G</option>
										</select>
										<select name="server_hdd2" id="server_hdd2">
											<option value="">없음</option>
											<option value="SAS 73G">SAS 73G</option>																																														
											<option value="SAS 146G">SAS 146G</option>
											<option value="SATA 300G">SATA 300G</option>
											<option value="SATA 500G">SATA 500G</option>
											<option value="SSD 128G">SSD 128G</option>
											<option value="SSD 256G">SSD 256G</option>
											<option value="SCSI 73G">SCSI 73G</option>
											<option value="SCSI 146G">SCSI 146G</option>
										</select>
										<select name="server_hdd3" id="server_hdd3">
											<option value="">없음</option>
											<option value="SAS 73G">SAS 73G</option>																																														
											<option value="SAS 146G">SAS 146G</option>
											<option value="SATA 300G">SATA 300G</option>
											<option value="SATA 500G">SATA 500G</option>
											<option value="SSD 128G">SSD 128G</option>
											<option value="SSD 256G">SSD 256G</option>
											<option value="SCSI 73G">SCSI 73G</option>
											<option value="SCSI 146G">SCSI 146G</option>
										</select>
										<select name="server_hdd4" id="server_hdd4">
											<option value="">없음</option>
											<option value="SAS 73G">SAS 73G</option>																																														
											<option value="SAS 146G">SAS 146G</option>
											<option value="SATA 300G">SATA 300G</option>
											<option value="SATA 500G">SATA 500G</option>
											<option value="SSD 128G">SSD 128G</option>
											<option value="SSD 256G">SSD 256G</option>
											<option value="SCSI 73G">SCSI 73G</option>
											<option value="SCSI 146G">SCSI 146G</option>
										</select>
									</td>
									<td>직접입력: <Input type="text" name="server_hdd5" id="server_hdd5"/></td>
								</tr>
								
								<tr>
									<td>서버brand
										<input type="hidden" id="brand" value="${idcServerRead.server_brand}">										
									</td>
									<td colspan="4">
										<select name="server_brand" id="server_brand">
											<option value="intel">intel</option>
											<option value="amd">amd</option>
											<option value="HP">HP</option>
											<option value="IBM">IBM</option>
											<option value="Dell">Dell</option>
											<option value="Fujitsu">Fujitsu</option>
											<option value="Cisco">Cisco</option>
											<option value="3Y">3Y</option>
											<option value="Eslim">Eslim</option>
											<option value="SuperMicro">SuperMicro</option>																													
										</select>
									</td>			
								</tr>
								<tr>
									<td>서버 위치</td>
									<td colspan="4">
										<!--
										<input type="text" name="server_location" value="${idcServerRead.server_location}" readonly="readonly">
										  -->
										<select id="loSel" name="server_location" value="${idcServerRead.server_location}">
											<option value="chiba">치바</option>
											<option value="tokyo">도쿄</option>
										</select>
									</td>			
								</tr>
								<tr>
									<td>포맷 보류</td>
									<td colspan="4"><input type="date" name="server_fomat_date" id="server_fomat_date"  value="${idcServerRead.server_fomat_date}"></td>			
								</tr>
								<tr>
									<td>입고일</td>
									<td colspan="4"><input type="date" name="server_recieve_date" value="${idcServerRead.server_recieve_date}"></td>			
								</tr>
								<tr>
									<td>출고일</td>
									<td colspan="4"><input type="date" name="server_release_date" value="${idcServerRead.server_release_date}"></td>			
								</tr>								
								<tr>
									<td>폐기일</td>
									<td colspan="4"><input type="date" name="server_disuse_date" value="${idcServerRead.server_disuse_date}" ></td>			
								</tr>
								<tr>
									<td>전 사용자</td>
									<td colspan="4"><input type="text" name="server_before_user" value="${idcServerRead.server_before_user}"></td>			
								</tr>
								<tr>
									<td>현 사용자</td>
									<td colspan="4"><input type="text" name="server_now_user" value="${idcServerRead.server_now_user}"></td>			
								</tr>
								<tr>								
									<td>비고</td>
									<td colspan="4"><textarea name="server_note" rows="5" cols="100">${idcServerRead.server_note}</textarea></td>			
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<td align="right">
										<div class="input-group-btn">
											<input class="btn btn-outline btn-primary" type="submit" value="수정">
											<a class="btn btn-outline btn-danger checkServerUse" value="${idcServerRead.server_num}">삭제</a>				
											<a class="btn btn-outline btn-default" href="javascript:history.go(-1)">뒤로가기</a> 
										</div>
									</td>
								</tr>		
							</tfoot>
						</table>
					</div>
					<!-- table-responsive -->
				</form>
			</div>
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->
