<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<% pageContext.setAttribute("phpurl",request.getScheme()+"://"+request.getServerName()); %>
<c:set var="member" value="${sessionScope.member}" />
<c:if test="${not empty member}">
  <c:set var="member_code" value="${member.getId()}" />
</c:if>
<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>
<script type="text/javascript">
$(function()
{
	//사용버튼/삭제
	$(".useCup").click(function()
	{
		var result = $(this).attr("val");
		if(result>0)
			window.location = $(this).attr("value")+"&token="+$("#token").val();
		else
			alert("사용할 쿠폰이 없습니다.");
	});
	//삭제, 수정
	$(".delBtn").click(function()
	{
		var temp= $(this).parents("tr").find("input");
		var a="&cupon_request_date="+$(temp[0]).val();
		var b="&cupon_current="+$(temp[1]).val();
		var c="&cupon_use="+$(temp[2]).val();
		var d="&cupon_result="+$(temp[3]).val();
		if($(temp[4]).prop("checked"))
		{
			e="&server_upgrade=o"
		}
		if($(temp[5]).prop("checked"))
		{
			e="&server_upgrade=x"
		}
		var f="&cupon_end_date="+$(temp[6]).val();
		var g="&cupon_note="+$(temp[7]).val();
		window.location = $(this).attr("value")+"&token="+$("#token").val()+a+b+c+d+e+f+g;
	});
});
</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> 도메인 쿠폰 리스트</h4>
			</div>
			<div class="panel-body">
					<c:import url="${phpurl}/dbms/client/coupon/index?&member_code=${member_code}&curPage=${curPage}" />
			</div>
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->
