<%@ 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>
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>

<!-- 여기가 본 페이지이다 -->
<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> IP 리스트</h4>
			</div>
			<div class="panel-body" id="table">
				<input type="hidden" id="token">
				<c:if test="${curPage!=null }">
					<div class="row">
						<div class="col-lg-8">
							<form action="IdcIPListFormExcel.lin" method="POST">
								<a class="btn btn-outline btn-default"  href="IdcIPListForm.lin">IP 리스트</a>
								<div class="input-group">																		
									<input type="text" class="form-control" id="searchContent" name="searchContent" placeholder="고객명 OR IP" value=${sc }>
									<span class="input-group-btn">
										<input type="submit" class="btn btn-default" value="검색">
										<a class="btn btn-outline btn-default"  onclick="tableToExcel('table','name')">엑셀 출력</a>
									</span>
								</div>
							</form>
						</div>
					</div>
				</c:if>
				<c:if test="${curPage==null }">
		   			<div class="table-responsive">
						<table class="table table-bordered table-hover table-striped">
							<thead>
								<tr>
									<td colspan="6">현사용자</td>
									<td colspan="8">전사용자</td>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>메인ip</td>
									<td>${IdcLineDB.line_mainip }</td>
									<td rowspan="4">사용자</td>
									<td rowspan="4">${IdcLineDB.line_client_name }</td>
									<td rowspan="4">할당일</td>
									<td rowspan="4">${IdcLineDB.line_user_allocatingday }</td>
									<td>메인ip</td>
									<td>${IdcLineDB.line_before_mainip }</td>
									<td rowspan="4">사용자</td>
									<td rowspan="4">${IdcLineDB.line_before_user }</td>
									<td rowspan="4">할당일</td>
									<td rowspan="4">${IdcLineDB.line_before_allocatingday }</td>
									<td rowspan="4">종료일</td>
									<td rowspan="4">${IdcLineDB.line_before_endday }</td>
								</tr>
								<tr>
									<td>보조ip1</td>
									<td>${IdcLineDB.line_subip1 }</td>
									<td>보조ip1</td>
									<td>${IdcLineDB.line_before_subip1 }</td>
								</tr>
								<tr>
									<td>보조ip2</td>
									<td>${IdcLineDB.line_subip2 }</td>
									<td>보조ip2</td>
									<td>${IdcLineDB.line_before_subip2 }</td>
								</tr>
								<tr>
									<td>보조ip3</td>
									<td>${IdcLineDB.line_subip3 }</td>
									<td>보조ip3</td>
									<td>${IdcLineDB.line_before_subip3 }</td>
								</tr>
							</tbody>
							<tfoot>
							</tfoot>
						</table>
						<!-- table -->
					</div>
					<!-- table-responsive -->
				</c:if>
				<div class="table-responsive">
					<table class="table table-bordered table-hover table-striped">
						<thead>
							<tr>
								<td>회선명</td>
								<td>구분</td>
								<td>사용자</td>
								<td>IP</td>
								<td>가용여부</td>
								<td>이전 사용자</td>
								<td>해지사유</td>
								<td>차단</td>
								<td>차단해제일</td>
								<td>메모</td>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${IPList }" var="temp" varStatus="i">
								<tr>
									<td>${temp.line_code }</td>
									<td>${temp.ip_case2 }</td>
									<td>${temp.ip_user }</td>
									<td><a href="IdcIPModifyForm.lin?ip_address=${temp.ip_address }">${temp.ip_address }</a></td>
									<td>
										<c:if test="${temp.ip_able==1 }">사용 가능</c:if>
										<c:if test="${temp.ip_able==0 }">사용 불능</c:if>	
									</td>
									<td>${temp.ip_before_user }</td>
									<td>${temp.cancel_reason }</td>
									<td>${temp.block }</td>
									<td>${temp.block_endday }</td>									
									<td>${temp.ip_note }</td>
								</tr>
							</c:forEach>
						</tbody>
						<tfoot>
						</tfoot>
					</table>
					<!-- table -->
				</div>
				<!-- table-responsive -->
				
			</div>
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->
