<%@ 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 delIp(ip_able,ip_address, line_code){
	if(ip_able == '1'){
		window.location = "IdcIPDeleteHandle.lin?ip_address="+ip_address+"&line_code="+line_code+"&token="+$("#token").val();		
	}else{
		alert("사용 중인 IP는 삭제할 수 없습니다.");
	}
}
</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">
								<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"  href="IdcIPListFormExcel.lin">엑셀</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>
								<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><input type="button" value="삭제" onclick="delIp('${temp.ip_able}','${temp.ip_address}','${temp.line_code }')"/></td>
									<td>${temp.ip_note }</td>
								</tr>
							</c:forEach>
						</tbody>
						<tfoot>
						</tfoot>
					</table>
					<!-- table -->
				</div>
				<!-- table-responsive -->
				<c:if test="${curPage!=null }">
					<div class="row">
						<div class="col-lg-12">
							<ul class="pagination" style="margin:0px;">
								<li>
									<a class="btn btn-outline btn-default" href="IdcIPListForm.lin?searchContent=${sc}">
										<i class="fa fa-angle-double-left "></i>
									</a>
								</li>
								<li>
									<c:if test="${curPage!=1 }">
										<a class="btn btn-outline_btn-default" href="IdcIPListForm.lin?curPage=${curPage-1 }&searchContent=${sc}">
											<i class="fa fa-angle-left"></i>
										</a>
									</c:if>
									<c:if test="${curPage==1 }">
										<a class="btn btn-outline_btn-default" href="IdcIPListForm.lin?curPage=1&searchContent=${sc}">
											<i class="fa fa-angle-left"></i>
										</a>
									</c:if>
								</li>
								<c:forEach var="i" begin="${firstPage }" end="${endPage }">
								<li>
									<a class="btn btn-outline btn-defualt" href="IdcIPListForm.lin?curPage=${i }&searchContent=${sc}">${i}</a>	
								</li>
								</c:forEach>
								<li>
									<c:if test="${curPage!=pageCnt }">
										<a class="btn btn-outline_btn-default" href="IdcIPListForm.lin?curPage=${curPage+1 }&searchContent=${sc}">
											<i class="fa fa-angle-right"></i>
										</a>
									</c:if>
									<c:if test="${curPage==pageCnt }">
										<a class="btn btn-outline_btn-default" href="IdcIPListForm.lin?curPage=${pageCnt }&searchContent=${sc}">
											<i class="fa fa-angle-right"></i>
										</a>
									</c:if>
								</li>
								<li>
									<a class="btn btn-outline btn-default" href="IdcIPListForm.lin?curPage=${pageCnt }&searchContent=${sc}">
										<i class="fa fa-angle-double-right "></i>
									</a>
								</li>
							</ul>
							<!-- ul -->
						</div>			
					</div>
					<!-- row -->
				</c:if>
			</div>
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->
