<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : OrderDetailCouponHst.html
 * @desc    : 주문상품 상세 쿠폰 이력 화면
 *============================================================================
 * Pastelmall
 * Copyright(C) 2019 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.12.16   jsh77b       최초 작성
 *******************************************************************************
 -->
<div class="modalPopup" data-width="1000">
	<div class="panelStyle">
		<div class="panelTitle">
			<h2>쿠폰 내역</h2>
			<button type="button" class="close" onclick="uifnPopupClose('popupOrderDetailCouponHstForm');"><i class="fa fa-times"></i></button>
		</div>
			
		<div class="panelContent" style="overflow-y:auto;">
			<form id="cancelRequestFrm">
				<div id="gridOrderCouponInfo" style="width:100%; height:260px;" class="ag-theme-balham"></div>
			</form>
		</div>
	</div>
</div>

<!-- data -->
<script th:inline="javascript">
/*<![CDATA[*/
var orderCouponHstList = [[${orderCouponHstList}]];

//specify the columns
var columnDefsOrderCouponInfo = [
	{headerName: "쿠폰구분", 			field: "cpnType", 	width: 100, cellClass: 'text-center'},
	{headerName: "상품코드/공급처코드", 	field: "targetCd1", width: 160, cellClass: 'text-center'},
	{headerName: "주문상세/배송정책", 	field: "targetCd2", width: 160, cellClass: 'text-center'},
	{headerName: "쿠폰ID", 			field: "cpnSq", 	width: 100, cellClass: 'text-center'},
	{headerName: "쿠폰명", 			field: "cpnNm", 	width: 140, cellClass: 'text-center'},
	{
		headerName			: "웹 할인금액/율"
		, field				: "dcPval"
		, width				: 120
		, cellClass			: 'text-center'
		, valueFormatter	: function(params) {
			return (params.data.dcWay == '10') ? params.value.addComma() + '원' : params.value.addComma() + '%';}	
	},
	{
		headerName			: "모바일 할인금액/율"
		, field				: "dcMval"
		, width				: 120
		, cellClass			: 'text-center'
		, valueFormatter	: function(params) {
			return (params.data.dcWay == '10') ? params.value.addComma() + '원' : params.value.addComma() + '%';
		}	
	},
	{
		headerName			: "판매상품가격"
		, field				: "ordAmt"
		, width				: 100
		, cellClass			: 'text-center'
		, valueFormatter	: function(params) {
			return params.value.addComma();
		}	
	},
	{
		headerName			: "실할인금액"
		, field				: "cpnDcAmt"
		, width				: 100
		, cellClass			: 'text-center'
		, valueFormatter	: function(params) {
			return params.value.addComma();
		}	
	}
];

var gridOptionsOrderCouponInfo = orderAgGrid.getGridOptions(columnDefsOrderCouponInfo);

$(document).ready(function() {	
	// Create a agGrid
	gagaAgGrid.createGrid('gridOrderCouponInfo', gridOptionsOrderCouponInfo);
	gridOptionsOrderCouponInfo.api.setRowData(orderCouponHstList);
});
/*]]>*/

</script>

<!-- AgGrid 컬럼 세팅 -->
<script>
// 공통1. 주문상세 그리드 옵션 정보 적용
var orderAgGrid = {
	getGridOptions : function(colDefs) {
		return {
			columnDefs					: colDefs
			, detailCellRendererParams	: {
				detailGridOptions	: {
					columnDefs				: []
					, defaultColDef			: {
						resizable: true
					}
					, suppressLoadingOverlay: false
					, onGridReady			: function (params) {
						params.api.setDomLayout('autoHeight');
					}
					, onFirstDataRendered	: function (params) {
						params.api.sizeColumnsToFit();
					}
				}
				, getDetailRowData: function (params) {
					params.successCallback(params.data.orderDetailList);
				}
			}
			, defaultColDef: {
				resizable: true
			}
			, isRowMaster: function (dataItem) {
				return dataItem ? dataItem.orderDetailList.length > 1 : false;
			}
			, suppressRowTransform: true
			, enableRangeSelection: true
		};
	}
}
</script>
</html>





