<%@ 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">
$(function()
{
	//li에서 나온 리스트 선택시 히든에 같이 넣어주기.
	$("#searchDiv > ul > li > a").click(function()
	{
		$("#searchBtn").html($(this).html());
		$("#serverHidden").val($(this).attr("value"));
	});
	
	$("#format_filter").val($("#temp").val());
	//검색필터 교체
	$("#format_filter").change(function(){
		var format_filter = $(this).val();			
		var url="serverListExcel.ser";			
		window.location=url+"?format_filter="+format_filter;
	});
		//날짜변경
	$("#select_date").change(function(){
		var temp = $(this).val();
		if(temp != null && temp != ""){
			window.location="serverListExcel.ser?select_date="+temp;
		}
	});
});

		
var tableToExcel = (function(){
	var uri = 'data:application/vnd.ms-excel;base64,'
	    , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table>{table}</table></body></html>'
	    , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
	    , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
	  return function(table, name) {
	    if (!table.nodeType) table = document.getElementById(table)
	    var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
	    window.location.href = uri + base64(format(template, ctx))
	  }
})();

</script>

<style>
@media screen and (max-width:800px) {	
	}
}

.tdcenter{
	 text-align: center;
	 vertical-align: text-bottom;
}
</style>

<!-- 여기가 본 페이지이다 -->
<div class="row">
	<div class="col-lg-12" style="min-width:600px">
		<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 class="col-lg-12">											
						 <form class="form-inline" role="form" action="serverListExcel.ser" method="post">
						 	<div class="input-group">
						 		<div class="input-group-btn">
									<a class="btn btn-outline btn-default" href="serverList.ser">장비리스트</a>
									<a class="btn btn-outline btn-default"  onclick="tableToExcel('table','name')">엑셀 출력</a>
								</div>
								<div class="input-group-btn" id="searchDiv">
									<input type="hidden" id="serverHidden" value="${searchOption }" name="searchOption">
									<button type="button" class="btn btn-info" data-toggle="dropdown" id="searchBtn">${searchOptionName }</button>
									<ul class="dropdown-menu" role="menu" id="search_li">
										<li><a class="btn btn-default" value="server_use_status">가용</a></li>
										<li><a class="btn btn-default" value="server_code">장비명</a></li>
										<li><a class="btn btn-default" value="server_process">cpu</a></li>										
									</ul>
						 		</div>						 		
						        	<input type="text" class="form-control" placeholder="검색어입력" name="searchContent" value="${searchContent }">						        						        						        							        						        
						      	<div class="input-group-btn">
							    	<button type="submit" class="btn btn-outline btn-info">검색</button>
					  			</div>					  				
						 	</div>
						</form>
					</div>
				</div>
				<!-- row -->
	   			<div class="table-responsive"  id="table"> 	   				
					<table class="table table-bordered table-hover table-striped">
						<thead>
							<tr>
								<td class="tdcenter">NO</td>
								<td class="tdcenter">
									<input type="hidden" id="temp" value="${format_filter}"/>									
									<select name="format_filter" id="format_filter">
										<option value="">구분</option>
										<option value="all">전체</option>
										<option value="normal">사용가능</option>
										<option value="format">포맷보류</option>								
									</select>
								</td>
								<td class="tdcenter">장비번호</td>
								<td class="tdcenter">구분</td>
								<td class="tdcenter">스펙</td>
								<td class="tdcenter">cpu모델명</td>
								<td class="tdcenter">장비 사양</td>
								<td class="tdcenter">브랜드</td>
								<td class="tdcenter">위치정보</td>
								<td class="tdcenter">포맷 보류
									<input type="date" name="date" id="select_date" value="${select_date}" />
								</td>
								<td class="tdcenter">입고일</td>
								<td class="tdcenter">출고일</td>
								<td class="tdcenter">비고</td>
								<td class="tdcenter">폐기일</td>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${idcServerList}" var="dto">
								<tr>
									<td>${dto.number}</td>
									<td>${dto.server_use_status}</td>
									<td>${dto.server_code}</td>
									<td>${dto.server_process}</td>
									<td>${dto.server_spec}</td>
									<td>${dto.server_cpuname}</td>
									<td>${dto.server_spec}/${dto.server_ram}/${dto.server_hdd}</td>
									<td>${dto.server_brand}</td>
									<td>${dto.server_location}</td>
									<td>${dto.server_fomat_date}</td>
									<td>${dto.server_recieve_date}</td>
									<td>${dto.server_release_date}</td>
									<td>${dto.server_note}</td>
									<td>${dto.server_disuse_date}</td>
								</tr>
							</c:forEach>
						</tbody>
						<tfoot>
						
						</tfoot>
					</table>
				</div>
				<!--	 table-responsive-->
				
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>

<!-- row -->
</div>
<!-- /#page-wrapper -->
