<%@ 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" %>
<% pageContext.setAttribute("phpurl",request.getScheme()+"://"+request.getServerName()); %>

<script type="text/javascript">
//초기화
function init(){	
	var view_state = document.getElementById("view_state").value;
	if(view_state == "serviceList"){
		document.getElementById("sList").style.display = "block";
		document.getElementById("cList").style.display = "none";
	}else if(view_state == "clientList"){
		document.getElementById("sList").style.display = "none";
		document.getElementById("cList").style.display = "block";
	}
}

//서비스리스트와 고객리스트 보여주기
function showView(seletedObj){
	if(seletedObj == "sList"){
		document.getElementById("sList").style.display = "block";
		document.getElementById("cList").style.display = "none";
		document.getElementById("selectedClient").value = "";
	}else if(seletedObj == "cList"){
		document.getElementById("sList").style.display = "none";
		document.getElementById("cList").style.display = "block";
	}
}

//고객 선택시 
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();
	if($("#view_state").val() == "clientList"){
		$("#sList").css("display", "none");
		$("#cList").css("display", "block");
	}
	
	$(document).ready(function()
	{
		//셀렉트 초기화
		$("#serviceSel").val($("#serviceSel").attr("value"));
	});
});

</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">
								<input type="button" class="btn btn-default" value="서비스 리스트" onclick="showView('sList')"/>
								<input type="button" class="btn btn-default" value="고객 리스트" onclick="showView('cList')"/>
							</span>
						</div>
					</div>
				</div>
				<!-- 	
				<div class="row">
					<div class="col-lg-6 col-md-6 col-sm-6">
						<textarea class="form-control">업무일지</textarea>
					</div>
					<div class="col-lg-6 col-md-6 col-sm-6">
						<textarea class="form-control">메모 및 전달</textarea>
					</div>
				</div>
				 -->
				<!-- row -->
	   			<div class="table-responsive" id="sList" >
					<table class="table table-bordered table-hover table-striped" >
						<tr>
							<td colspan="16">								
								<form action="serviceList.sev?view_state=servicetList" method="get">
									<div class="input-group">
										<span class="input-group-btn">
											<select class="btn btn-info" id="serviceSel" name="filter" value="${filter}">
											<option value="mk_all">전체검색</option>
												<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" href="serviceListExcel.sev">엑셀</a>
										</span> 										
									</div>
								</form>
							</td>
						</tr>						
						<tr>
							<!-- <td align="center"  width="10">NO</td> -->							
							<th style="text-align:center;width:10px;">CS</th>
							<!-- <td align="center" width="30">고객코드</td> -->
							<th style="text-align:center;width:45px;">서비스 코드</th>
							<th style="text-align:center;width:30px;">고객명</th>
							<th style="text-align:center;width:20px;">라인</th>
							<th style="text-align:center;width:20px;">장비 번호</th>
							<th style="text-align:center;width:45px;">스위치정보</th>
							<th style="text-align:center;width:32px;">IP 정보</th>
							<th style="text-align:center;width:30px;">OS 정보</th>							
							<th style="text-align:center;width:20px;">쿠폰</th>
							<th style="text-align:center;width:32px;">신청일</th>
							<th style="text-align:center;width:32px;">결제일</th>
							<th style="text-align:center;width:20px;">요금</th>
							<!-- <th style="text-align:center;width:20px;">미지급가</th>	-->						
							<th style="text-align:center;width:20px;">메모</th>
							<!-- <td align="center" width="20">담당자</td> -->
						</tr>											
						<c:forEach items="${all}" var="dto">
							<tr>
								<!-- <td align="center">${dto.service_num}</td>-->								
								<td align="center"><c:import url="${phpurl}/dbms/dashboard/cscount/service_code/${dto.service_code}/client_code/${dto.client_code}" /> </td>
								<!-- <td align="center"><input type="hidden" id="client_code" value="${dto.client_code }"><a href="/serviceDetail.sev?client_code=${dto.client_code }">${dto.client_code }</a>
								[<a href="/IdcDepositNonPaymentList.dep?searchContent=${dto.client_name }">청구</a>]								
								</td> -->
								<td align="center"><a href="serviceDetailSolo.sev?client_code=${dto.client_code}&service_code=${dto.service_code}">${dto.service_code}</a></td>
								<td align="center">
									<a href="serviceDetail.sev?client_code=${dto.client_code}">${dto.client_name}</a>									 									
								</td>								
								<td align="center">${dto.temp}</td>
								<td align="center">${dto.server_code}</td>
								<td  align="center">${dto.service_sw}</td>
								<td align="center">${dto.service_ip}</td>
								<td><nobr style=" display:block; width:90px;  ">${dto.service_os}</nobr></td>								
								<td align="center"><c:import url="${phpurl}/dbms/dashboard/coupon/service_code/${dto.service_code}/client_code/${dto.client_code}" /> </td>
								<td align="center">${dto.service_request_date}</td>
								<td align="center">${dto.service_payment_date}</td>
								<td style="text-align:center;">
									<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>
								<!--  <nobr style=" display:block; text-overflow:ellipsis; width:150px;  overflow:hidden;">${dto.service_note}</nobr>-->
								<nobr style=" display:block; width:180px;  ">${dto.service_note}</nobr>
									<!-- <textarea style="width:100%;height:100%">${dto.service_note}</textarea> -->
								</td>	
								<!-- <td>${dto.service_manager}</td> -->							
							</tr>
						</c:forEach>
						<tr>
							<td colspan="16">
								<ul class="pagination ulc" style="margin:0px;">
									<li class="lic">																			
										<form action="serviceList.sev?view_state=serviceList" method="post">
											<input type="hidden" name="filter" value="${filter}"/>
											<input type="hidden" name="searchContextService" value="${searchContextService}"/>
											<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-double-left" value="<<">											
										</form>
									</li>
									<li class="lic">
										<c:if test="${s_curPage!=1 }">											
											<form action="serviceList.sev?view_state=serviceList" method="post">
												<input type="hidden" name="s_curPage" value="${s_curPage-1}">
												<input type="hidden" name="filter" value="${filter}"/>
												<input type="hidden" name="searchContextService" value="${searchContextService}"/>
												<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-left" value="<">											
											</form>
										</c:if>
										<c:if test="${s_curPage==1 }">
											<form action="serviceList.sev?view_state=serviceList" method="post">
												<input type="hidden" name="s_curPage" value="1">
												<input type="hidden" name="filter" value="${filter}"/>
												<input type="hidden" name="searchContextService" value="${searchContextService}"/>
												<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-left" value="<">											
											</form>
										</c:if>
									</li>
									<c:forEach var="i" begin="${s_firstPage }" end="${s_endPage}">
										<li class="lic">
											<form action="serviceList.sev?view_state=serviceList" method="post">
												<input type="hidden" name="s_curPage" value="${i}">
												<input type="hidden" name="filter" value="${filter}"/>
												<input type="hidden" name="searchContextService" value="${searchContextService}"/>
												<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-left" value="${i}">											
											</form>
										</li>	
									</c:forEach>
									<li class="lic">
										<c:if test="${s_curPage!=s_pageCnt }">
											<form action="serviceList.sev?view_state=serviceList" method="post">																							
												<input type="hidden" name="s_curPage" value="${s_curPage+1}">
												<input type="hidden" name="filter" value="${filter}"/>
												<input type="hidden" name="searchContextService" value="${searchContextService}"/>
												<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-right" value=">">											
											</form>
										</c:if>
										<c:if test="${s_curPage==s_pageCnt }">																																	
												<form action="serviceList.sev?view_state=serviceList" method="post">											
													<input type="hidden" name="s_curPage" value="${s_pageCnt}">
													<input type="hidden" name="filter" value="${filter}"/>
													<input type="hidden" name="searchContextService" value="${searchContextService}"/>
													<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-right" value=">">											
												</form>
										</c:if>
									</li>
									<li class="lic">
										<form action="serviceList.sev?view_state=serviceList" method="post">												
											<input type="hidden" name="s_curPage" value="${s_pageCnt}">
											<input type="hidden" name="filter" value="${filter}"/>
											<input type="hidden" name="searchContextService" value="${searchContextService}"/>
											<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-right" value=">>">											
										</form>
									</li>
								</ul>
							</td>
						</tr>																							
					</table>
				</div>

				
				<div class="table-responsive" id="cList" style="display:none;">
					<table class="table table-bordered table-hover table-striped" >
						<tr>
							<td colspan="16">
								<form action="serviceList.sev?view_state=clientList" method="post">
									<div class="input-group">
										<input type="text" class="form-control" id="scc" name="searchContextClient" value="${searchContextClient }">
										<span class="input-group-btn">
											<input class="btn btn-info btn-outline" type="submit" value="검색">
										</span> 
									</div>
								</form>
							</td>
						</tr>
						<tr>
							<!-- <th style="text-align:center;width:20px;">번호</th> -->
							<th style="text-align:center;width:40px;">고객코드</th>
							<th style="text-align:center;width:40px;">고객명</th>
							<th style="text-align:center;width:40px;">리셀러</th>
							<th style="text-align:center;width:40px;">연락처1</th>
							<th style="text-align:center;width:40px;">연락처2</th>
							<th style="text-align:center;width:40px;">E-mail</th>
							<th style="text-align:center;width:40px;">E-mail</th>
							<th style="text-align:center;width:40px;">등록일</th>
							<!-- <th style="text-align:center;width:40px;">갱신일</th> -->	
							<th style="text-align:center;width:300px;">비고</th>
							<!-- <td>선택</td> -->
							<!-- <td>보기</td> -->
						</tr>
						<c:forEach items="${clientList}" var="dto">
							<tr>
								<!-- <td>${dto.client_num }</td> -->
								<td style="text-align:center;"><a href="#" onclick="showServiceDetail('${dto.client_code}')">${dto.client_code }</a></td>
								<td style="text-align:center;"><a href="#" onclick="showServiceDetail('${dto.client_code}')">${dto.client_name }</a></td>
								<td style="text-align:center;">${dto.client_reseller }</td>
								<td style="text-align:center;">${dto.client_phone1 }</td>
								<td style="text-align:center;">${dto.client_phone2 }</td>
								<td style="text-align:center;">${dto.client_email1 }</td>
								<td style="text-align:center;">${dto.client_email2 }</td>
								<td style="text-align:center;">${dto.client_receive_date }</td>
								<!-- <td>${dto.client_renew_date }</td>-->			
								<td>
								<nobr style=" display:block; width:180px;  ">${dto.client_note }</nobr>
									<!-- <textarea style="width:100%;height:100%"></textarea> -->
								</td>
								<!-- <td>
									
									<input type="button" name="client_code" value="V" size="1" onclick="showServiceDetail('${dto.client_code}')" >
										<button name="client_code"  class="btn btn-default"><i class="fa fa-level-down"></i></button>		
								</td> -->
							</tr>		
						</c:forEach>		
						<tr>
							<td colspan="16">
								<ul class="pagination ulc" style="margin:0px;">
									<li class="lic">																			
										<form action="serviceList.sev?view_state=clientList" method="post">
											<input type="hidden" name="searchContextClient" value="${searchContextClient}"/>
											<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-double-left" value="<<">											
										</form>
									</li>
									<li class="lic">
										<c:if test="${c_curPage!=1 }">											
											<form action="serviceList.sev?view_state=clientList" method="post">
												<input type="hidden" name="c_curPage" value="${c_curPage-1}">
												<input type="hidden" name="searchContextClient" value="${searchContextClient}"/>
												<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-left" value="<">											
											</form>
										</c:if>
										<c:if test="${c_curPage==1 }">
											<form action="serviceList.sev?view_state=clientList" method="post">
												<input type="hidden" name="c_curPage" value="1">
												<input type="hidden" name="searchContextClient" value="${searchContextClient}"/>
												<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-left" value="<">											
											</form>
										</c:if>
									</li>
									<c:forEach var="i" begin="${c_firstPage }" end="${c_endPage}">
										<li class="lic">
											<form action="serviceList.sev?view_state=clientList" method="post">
												<input type="hidden" name="c_curPage" value="${i}">
												<input type="hidden" name="searchContextClient" value="${searchContextClient}"/>
												<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-left" value="${i}">											
											</form>
										</li>	
									</c:forEach>
									<li class="lic">
										<c:if test="${c_curPage!=c_pageCnt }">
											<form action="serviceList.sev?view_state=clientList" method="post">
												<input type="hidden" name="c_curPage" value="${c_curPage+1}">
												<input type="hidden" name="searchContextClient" value="${searchContextClient}"/>
												<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-right" value=">">											
											</form>
										</c:if>
										<c:if test="${c_curPage==c_pageCnt }">																							
												<form action="serviceList.sev?view_state=clientList" method="post">												
													<input type="hidden" name="c_curPage" value="${c_pageCnt}">
													<input type="hidden" name="searchContextClient" value="${searchContextClient}"/>
													<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-right" value=">">											
												</form>
										</c:if>
									</li>
									<li class="lic">
										<form action="serviceList.sev?view_state=clientList" method="post">												
											<input type="hidden" name="c_curPage" value="${c_pageCnt}">
											<input type="hidden" name="searchContextClient" value="${searchContextClient}"/>
											<input type="submit" class="btn btn-info btn-outline btn-default fa fa-angle-right" value=">>">											
										</form>
									</li>
								</ul>
							</td>
						</tr>		
					</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" />












