<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : DeliveryFeeSettleForm.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/delivery/fee/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 id="terms">
						</td>
						<th>유통구분</th>
						<td>
							<select name="distributionGb">
								<option value="">[전체]</option>
								<option th:if="${distributionGbList}" th:each="oneData, status : ${distributionGbList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
						</td>
					</tr>
					<tr>
						<th>공급업체/브랜드</th>
						<td colspan="3">
							<select name="supplyCompCd">
								<option value="">[전체]</option>
								<option th:if="${supplyCompList}" th:each="oneData, status : ${supplyCompList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
							/
							<select name="brandCd">
								<option value="">[전체]</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 supplyCompList = gagajf.convertToArray([[${supplyCompList}]]);
	let distributionGbList = gagajf.convertToArray([[${distributionGbList}]]);

	let columnDefs = [
		{
			headerName: "출고일자", field: "outgoingDt", width: 100, cellClass: 'text-center',
			valueGetter: function (params) {
				return gagaAgGrid.toDateFormat(params.data.outgoingDt);
			}
		},
		{
			headerName: "공급업체", field: "supplyCompCd", width: 100, cellClass: 'text-center',
			valueGetter: function (params) {
				return gagaAgGrid.lookupValue(supplyCompList, params.data.supplyCompCd);
			}
		},
		{
			headerName: "유통구분", field: "distributionGb", width: 100, cellClass: 'text-center',
			valueGetter: function (params) {
				return gagaAgGrid.lookupValue(distributionGbList, params.data.distributionGb);
			}
		},
		{
			headerName: "배송비구분", field: "delvFeeGb", width: 100, cellClass: 'text-center'/* ,
			valueGetter: function (params) {
				return gagaAgGrid.lookupValue(delvFeeGbList, params.data.delvFeeGb);
			} */
		},
		{ headerName: "주문번호", field: "ordNo", width: 100, cellClass: 'text-center' },
		{ headerName: "배송비", field: "delvFee", width: 100, 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>
