<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.net.URLEncoder" %>

<script type="text/javascript">

//고객 선택시 
function selectedClient(client_code){	
	var selectedClient = document.getElementById("selectedClient");
	selectedClient.value = client_code;				
}

//서비스 정보 페이지로.(고객 전체 서비스 보여줌)
function showServiceDetail(client_code){
	var selectedClient = document.getElementById("selectedClient");
	selectedClient.value = client_code;
	window.location = "serviceDetail.sev?client_code="+client_code;
}


$(function(){	
	//서비스리스트 선택시 서비스리스트만 보여줌
	//고객리스트 선택시 고객리스트만 보여줌
	var view_state = $("#view_state").val();
	//alert($("#view_state").val());
	if($("#view_state").val() == "clientList"){
		$("#sList").css("display", "none");
		$("#cList").css("display", "block");
	}
	
	$(document).ready(function()
	{
		//셀렉트 초기화
		$("#serviceSel").val($("#serviceSel").attr("value"));
	});
});


var tableToExcel = (function(){
	
	var specialElementHandlers = {
            '#bypassme': function (element, renderer) {
                return true;
            }
	};
	
	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>

table.fixed { table-layout:fixed; }
table.fixed td { overflow: hidden; }

td {word-break:break-all; word-wrap:break-word;}
td { font-size: 12px;}

.text {
    overflow: hidden;
    display: inline-block;
    white-space: nowrap;
}

table{
padding:0px;
margin:0px;
}

.ulc {
overflow: auto;
}

.lic {
float: left;
}
</style>


<!-- 여기가 본 페이지이다 -->
<div class="row" onload="init()">
	<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>
			<div class="panel-body">
				<div class="row">
					<div class="col-lg-12 col-md-12 col-sm-12">
						<div class="input-group">
							<span class="input-group-btn">								
								<a class="btn btn-outline btn-default" type="button" href="serviceList.sev">서비스리스트</a>
							</span>
						</div>
					</div>
				</div>
	   			<div class="table-responsive" id="sList" >
					<table class="table table-bordered table-hover table-striped" id="table">
						<tr>
							<td colspan="16">
								<form action="serviceListExcel.sev?view_state=servicetList" method="post">
									<div class="input-group">
										<span class="input-group-btn">
											<select class="btn btn-info" id="serviceSel" name="filter" value="${filter}">
												<option value="client_name">고객명</option>
												<option value="server_code">장비명</option>
												<option value="service_sw">SW</option>
												<option value="service_ip">IP</option>
											</select>
										</span> 
										<input type="text" class="form-control" id="scs" name="searchContextService" value="${searchContextService }">
										<span class="input-group-btn">
											<input class="btn btn-info btn-outline" type="submit" value="검색">											
											<a class="btn btn-outline btn-default" type="button" onclick="tableToExcel('table','name')">엑셀 출력</a>
										</span> 
									</div>
								</form>
							</td>
						</tr>						
						<tr>
							<td>번호</td>							
							<td>상태</td>
							<td>고객코드</td>
							<td>서비스 코드</td>
							<td>고객명</td>
							<td>라인 종류</td>
							<td>장비 번호</td>
							<td>SW</td>
							<td>OS</td>
							<td>IP</td>
							<td>신청일</td>
							<td>결제일</td>
							<td>서비스 금액</td>
							<td>미지급 금액</td>							
							<td>담당자</td>
							<td>메모</td>
						</tr>											
						<c:forEach items="${all}" var="dto">
							<tr>
								<td>${dto.service_num}</td>								
								<td>${dto.service_status}</td>
								<td>${dto.client_code}</td>
								<td>${dto.service_code}</td>
								<td>${dto.client_name}</td>								
								<td>${dto.temp}</td>
								<td>${dto.server_code}</td>
								<td>${dto.service_sw}</td>
								<td>${dto.service_os}</td>
								<td>${dto.service_ip}</td>
								<td>${dto.service_request_date}</td>
								<td>${dto.service_payment_date}</td>
								<td>
									<c:if test="${member.power5 eq 'o'}">${dto.service_amount}</c:if>
								</td>
								<td>
									<c:if test="${member.power5 eq 'o'}">${dto.service_nonpayment}</c:if>
								</td>
								<td>${dto.service_manager}</td>
								<td>
									<textarea style="width:100%;height:100%">${dto.service_note}</textarea>
								</td>								
							</tr>
						</c:forEach>																						
					</table>
				</div>

				<!-- table-responsive -->
			</div>
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->

<input type="hidden" id="view_state" value="${view_state}"/>
<input type="hidden" id="selectedClient" name="selectedClient" />












