<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : GiftcardSettleForm.html
 * @desc    : 상품권정산 Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.10.26   gagamel     최초 작성
 *******************************************************************************
 -->
	<div id="main">
		<!-- 메인타이틀 영역 -->
		<div class="main-title">
		</div>
		<!-- //메인타이틀 영역 -->
		
		<!-- 메뉴 설명 -->
		<div class="infoBox menu-desc">
		</div>
		<!-- //메뉴 설명 -->
		
		<!-- 검색조건 영역 -->
		<div class="panelStyle">
			<form id="searchForm" name="searchForm" action="#" th:action="@{'/settle/giftcard/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
				<table class="frmStyle" aria-describedby="검색조건">
					<colgroup>
						<col style="width:10%;"/>
						<col style="width:60%;"/>
						<col style="width:10%;"/>
						<col/>
					</colgroup>
					<tr>
						<th>기간<i class="required" title="필수" aria-hidden="true"></i></th>
						<td>
							<select name="termGb">
								<option value="REG_DT">등록일</option>
								<option value="EXPIRE_DT">사용만료일</option>
								<option value="USE_DT">사용일</option>
							</select>
							<span id="terms">
							</span>
						</td>
						<th>유효상품권</th>
						<td>
							<select name="availYn">
								<option value="">[전체]</option>
								<option value="Y">Yes</option>
								<option value="N">No</option>
							</select>
						</td>
					</tr>
				</table>
				
				<ul class="panelBar">
					<li class="center">
						<button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
						<button type="button" class="btn btn-gray btn-lg" onclick="$('#searchForm')[0].reset();">초기화</button>
					</li>
				</ul>
			</form>
		</div>
		<!-- 검색조건 영역 -->

		<!-- 리스트 영역 -->
		<div class="panelStyle">
			<!-- 버튼 배치 영역 -->
			<ul class="panelBar">
				<li class="right">
					<button type="button" class="btn btn-default btn-lg" id="btnExcel">엑셀다운로드</button>
				</li>
			</ul>
			<!-- //버튼 배치 영역 -->
			
			<div id="gridList" style="width: 100%; height: 470px" class="ag-theme-balham"></div>
		</div>
		<!-- //리스트 영역 -->
	</div>

<script th:inline="javascript">
/*<![CDATA[*/
	let columnDefs = [
		{ headerName: "상품권번호", field: "giftcardNo", width: 100, cellClass: 'text-center' },
		{ headerName: "등록일", field: "regDt", width: 120, cellClass: 'text-center' },
		{ headerName: "사용만료일", field: "expireDt", width: 120, cellClass: 'text-center' },
		{ headerName: "유효여부", field: "availYn", width: 100, cellClass: 'text-center' },
		{ headerName: "회원ID", field: "custId", width: 100, cellClass: 'text-center' },
		{ headerName: "상품권금액", field: "giftcardAmt", width: 120, cellClass: 'text-right' },
		{ headerName: "최초등록금액", field: "firstRegAmt", width: 120, cellClass: 'text-right' },
		{ headerName: "누적사용금액", field: "totUseAmt", width: 100, cellClass: 'text-right' },
		{ headerName: "잔액", field: "remainAmt", width: 120, cellClass: 'text-right' }
	];

	let gridOptions = gagaAgGrid.getGridOptions(columnDefs);

	// 검색
	$('#btnSearch').on('click', function() {
		gagaAgGrid.fetch($('#searchForm').prop('action'), gridOptions, '#searchForm');
	});
	
	// 엑셀다운로드
	$('#btnExcel').on('click', function() {
		gagaAgGrid.exportToExcel('상품권정산 목록', gridOptions);
	});
	
	$(document).ready(function() {
		cfnCreateCalendar('#terms', 'startDt', 'endDt', true);
		$('.btnToday').trigger('click');
		
		// Create a agGrid
		gagaAgGrid.createGrid('gridList', gridOptions);
	});
/*]]>*/
</script>

</html>
