<%@ 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 type="text/javascript">
$(function()
{

	//검색하기 셀렉트
	$("#search > li > a").click(function()
	{
		$("#searchBtn").html($(this).html());
		$("#searchOption").attr("value",$(this).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>

input {display:block; width:100%;padding:0;border-width:2px;}

</style>
<!-- 여기가 본 페이지이다 -->
<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> 고객 리스트</h4>
			</div>
			<div class="panel-body">
				<div class="row">
					<div class="col-lg-7">
						<input type="hidden" id="token">
						<input id="isClientDB" type="hidden" value="${isClientDB }">
						<form id="cliForm" action="" method="POST">
							<div class="input-group">							
								<div class=" input-group-btn" >
									<a class="btn btn-outline btn-default" type="button" href="IdcClientDBList.cli">고객리스트</a>																
									<a class="btn btn-outline btn-default" type="button" onclick="tableToExcel('table','name')">엑셀 출력</a>
								<!-- <div class="input-group-btn" > -->
								</div>
								<div class="input-group-btn">
									<button type="button" class="btn btn-info" data-toggle="dropdown" id="searchBtn">${searchOptionName }<span class="caret"></span></button>
									<input type="hidden" value="${searchOption }" id="searchOption" name="searchOption">
									<ul class="dropdown-menu" role="menu" id="search">
						
										<li><a class="btn btn-default" value="client_code">고객코드</a></li>
										<li><a class="btn btn-default" value="client_name">고객명</a></li>
										<li><a class="btn btn-default" value="client_reseller">리셀러</a></li>
										<li><a class="btn btn-default" value="client_phone">연락처</a></li>
										<li><a class="btn btn-default" value="client_mail">E-Mail</a></li>
										<li><a class="btn btn-default" value="client_note">비고</a></li>




									</ul>
								</div>

								<input class="form-control"  type="text" name ="searchContent" value="${searchContent }">
								<div class="input-group-btn">
									<input class="btn btn-outline btn-default btn-disabled" type="submit" value="검색">
								</div>
							</div>
						</form>
					</div>
				</div>
				<!-- btn-group -->
	   			<div class="table-responsive" id="table">	   				
					<table class="table table-bordered table-hover table-striped">
						<thead>
						<tr>

							<td>No</td>						
							<td>고객코드</td>
							<td>고객명</td>
							<td>리셀러</td>
							<td>연락처1</td>
							<td>연락처2</td>
							<td>E-mail</td>
							<td>E-mail</td>
							<td>등록일</td>
							<td>갱신일</td>							
							<td>비고</td>

							
					</tr>
					</thead>
						<tbody>
							<c:forEach items="${IdcClientDBList }" var="dto">
							<tr>
																					
										<td>${dto.client_num }</td>
										<td>${dto.client_code }</td>
										<td>${dto.client_name }</td>
										<td>${dto.client_reseller }</td>
										<td>${dto.client_phone1 }</td>
										<td>${dto.client_phone2 }</td>
										<td>${dto.client_email1 }</td>
										<td>${dto.client_email2 }</td>
										<td>${dto.client_receive_date}</td>
										<td>${dto.client_renew_date}</td>
										<td>${dto.client_note }</td>
										
													
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
				<!-- table-responsive -->				
			</div>
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->
