<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : PgDepositSettleForm.html
 * @desc    : PG입금정산 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/pg/deposit/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="ORD_DT">주문일자</option>
								<option value="USAC_DT">정산일자</option>
							</select>
							<span id="terms">
							</span>
						</td>
						<th>PG구분</th>
						<td>
							<select name="pgGb">
								<option value="">[전체]</option>
								<option th:if="${pgGbList}" th:each="oneData, status : ${pgGbList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
						</td>
					</tr>
					<tr>
						<th>결제수단</th>
						<td colspan="3">
							<select name="payMeans">
								<option value="">[전체]</option>
								<option th:if="${payMeansList}" th:each="oneData, status : ${payMeansList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></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 pgGbList = gagajf.convertToArray([[${pgGbList}]]);
	let payMeansList = gagajf.convertToArray([[${payMeansList}]]);

	let columnDefs = [
		{
			headerName: "PG구분", field: "pgGb", width: 100, cellClass: 'text-center',
			valueGetter: function (params) {
				return gagaAgGrid.lookupValue(pgGbList, params.data.pgGb);
			}
		},
		{ headerName: "PG상점ID", field: "pgShopId", width: 100, cellClass: 'text-center' },
		{ headerName: "결제ID", field: "pgTradeNo", width: 150, cellClass: 'text-center' },
		{
			headerName: "결제수단", field: "payMeans", width: 100, cellClass: 'text-center',
			valueGetter: function (params) {
				return gagaAgGrid.lookupValue(payMeansList, params.data.payMeans);
			}
		},
		{ headerName: "주문번호", field: "ordNo", width: 100, cellClass: 'text-center' },
		{ headerName: "주문일자", field: "ordDt", width: 100, cellClass: 'text-center' },
		{ headerName: "주문상태", field: "ordDtlStat", width: 100, cellClass: 'text-center' },
		{ headerName: "총주문금액", field: "totOrdAmt", width: 120, cellClass: 'text-right' },
		{ headerName: "총상품금액", field: "totGoodsAmt", width: 120, cellClass: 'text-right' },
		{ headerName: "배송비", field: "delvFeeAmt", width: 100, cellClass: 'text-right' },
		{ headerName: "쿠폰할인금액", field: "cpnDcAmt", width: 120, cellClass: 'text-right' },
		{ headerName: "포인트할인금액", field: "pntDcAmt", width: 120, cellClass: 'text-right' },
		{ headerName: "상품권", field: "giftCardAmt", width: 120, cellClass: 'text-right' },
		{ headerName: "결제금액", field: "payAmt", width: 120, cellClass: 'text-right' },
		{ headerName: "판매/환입", field: "usacGb", width: 100, cellClass: 'text-center' },
		{ headerName: "결제일", field: "payDt", width: 100, cellClass: 'text-center' },
		{ headerName: "일치여부", field: "sameYn", width: 100, cellClass: 'text-center' },
		{ headerName: "불일치사유", field: "notSameRsn", width: 120, cellClass: 'text-center' },
		{ headerName: "차이금액", field: "diffAmt", width: 120, cellClass: 'text-right' },
		{ headerName: "PG금액", field: "pgUsacAmt", width: 120, cellClass: 'text-right' },
		{ headerName: "PG입금일시", field: "pgDepositDt", width: 100, cellClass: 'text-center' },
		{ headerName: "PG승인상태", field: "pgStat", width: 100, cellClass: 'text-center' },
		{ headerName: "PG승인상태설명", field: "pgStatDesc", width: 150, cellClass: 'text-center' },
		{ headerName: "거래형태", field: "pgTradeType", width: 100, cellClass: 'text-center' },
		{ headerName: "결제수수료", field: "pgFee", width: 100, cellClass: 'text-right' },
		{ headerName: "정산예정일", field: "pgUsacDt", width: 100, cellClass: 'text-center' }
	];

	let gridOptions = gagaAgGrid.getGridOptions(columnDefs);

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

</html>
