<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : GoodsQnaForm.html
 * @desc    : 상품문의관리 Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.12.28   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="@{'/customer/goods/qna/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
				<table class="frmStyle" aria-describedby="검색조건">
					<colgroup>
						<col style="width:10%;"/>
						<col style="width:12%;"/>
						<col style="width:10%;"/>
						<col style="width:12%;"/>
						<col style="width:10%;"/>
						<col/>
					</colgroup>
					<tr>
						<th>사이트</th>
						<td>
							<select name="siteCd">
								<option th:if="${siteList}" th:each="oneData, status : ${siteList}" th:value="${oneData.cd}" th:text="|[${oneData.cd}] ${oneData.cdNm}|"></option>
							</select>
						</td>
						<th>답변상태</th>
						<td>
							<select name="ansStat">
								<option value="">[전체]</option>
								<option th:if="${ansStatList}" th:each="oneData, status : ${ansStatList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
						</td>
						<th>회원검색</th>
						<td>
							<select name="custGb">
								<option value="">[선택]</option>
								<option value="custId">회원ID</option>
								<option value="custNm">회원명</option>
								<option value="email">이메일</option>
							</select>
							<input type="text" name="condition" class="w200" maxlength="100"/>
						</td>
					</tr>
<!-- 					<tr> -->
<!-- 						<th>답변자</th> -->
<!-- 						<td><input type="text" name="ansId" placeholder="" class="w300" maxlength="20"/></td> -->
<!-- 						<th>의뢰자</th> -->
<!-- 						<td colspan="3"><input type="text" name="ansTransId" class="w300" placeholder="" maxlength="20"/></td> -->
<!-- 					</tr> -->
					<tr>
						<th>기간<i class="required" title="필수"></i></th>
						<td colspan="5">
							<select name="termGb">
								<option value="regDt">문의일</option>
								<option value="ansDt">답변일</option>
							</select>
							<span id="terms"></span>
						</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">
			<div id="gridList" style="width: 100%; height: 570px" class="ag-theme-balham lh60"></div>
		</div>
		<!-- //리스트 영역 -->
	</div>

<script th:inline="javascript">
/*<![CDATA[*/
	let siteList = gagajf.convertToArray([[${siteList}]]); // 사이트
	let ansStatList = gagajf.convertToArray([[${ansStatList}]]); // 답변상태
	
	// specify the columns
	let columnDefs = [
		{
			headerName: "상담일련번호", field: "counselSq", width: 100, cellClass: 'text-center',
			cellRenderer: function(params) { return '<a href="javascript:void(0);">' + params.value + '</a>'; }
		},
		{
			headerName: "사이트", field: "siteCd", width: 100, cellClass: 'text-center',
			valueFormatter: function (params) { return gagaAgGrid.lookupValue(siteList, params.value); }
		},
		{
			headerName: "문의일시", field: "questDt", width: 150, cellClass: 'text-center',
			cellRenderer: function (params) { return gagaAgGrid.toDateTimeFormat(params.value); }
		},
		{
			headerName: "이미지", field: "goodsImg", width: 100, cellClass: 'text-center',
			cellRenderer: function(params) {
				return '<img width="60" src="' + _goodsUrl +  "/" + params.value + '" alt="" onerror="this.src=\'/image/no.png\';"/>';
			}
		},
		{headerName: "상품코드", field: "relGoodsCd", width: 100, cellClass: 'text-center'},
		{headerName: "상품명", field: "goodsNm", width: 300},
		{
			headerName: "비밀글여부", field: "secretYn", width: 100, cellClass: 'text-center',
			cellRenderer: function(params) { return params.value == 'Y' ? 'Yes' : 'No'; }
		},
		{headerName: "고객번호", field: "custNo", width: 100, cellClass: 'text-center', hide: true},
		{headerName: "고객ID", field: "maskingCustId", width: 100, cellClass: 'text-center', hide: true},
		{
			headerName: "고객명", field: "maskingCustNm", width: 150, cellClass: 'text-center',
			cellRenderer: function(params) { return '<a href="javascript:void(0);">' + params.value + '(' + params.data.maskingCustId + ')</a>'; }
		},
		{headerName: "휴대전화번호", field: "maskingCellPhnno", width: 120, cellClass: 'text-center'},
		{
			headerName: "SMS답변요청", field: "smsReqYn", width: 120, cellClass: 'text-center',
			cellRenderer: function(params) { return params.value == 'Y' ? 'Yes' : 'No'; }
		},
		{
			headerName: "SMS답변발송", field: "smsSendYn", width: 120, cellClass: 'text-center',
			cellRenderer: function(params) { return params.value == 'Y' ? 'Yes' : 'No'; }
		},
		{headerName: "이메일", field: "maskingEmail", width: 200},
// 		{
// 			headerName: "이메일답변요청", field: "emailReqYn", width: 120, cellClass: 'text-center',
// 			cellRenderer: function(params) { return params.value == 'Y' ? 'Yes' : 'No'; }
// 		},
// 		{
// 			headerName: "이메일답변발송", field: "emailSendYn", width: 120, cellClass: 'text-center',
// 			cellRenderer: function(params) { return params.value == 'Y' ? 'Yes' : 'No'; }
// 		},
		{
			headerName: "답변상태", field: "ansStat", width: 100, cellClass: 'text-center',
			cellRenderer: function (params) { return gagaAgGrid.lookupValue(ansStatList, params.value); }
		},
		{headerName: "답변자번호", field: "ansNo", width: 100, cellClass: 'text-center', hide: true},
		{headerName: "답변자명", field: "ansNm", width: 100, cellClass: 'text-center'},
		{
			headerName: "답변일시", field: "ansDt", width: 150, cellClass: 'text-center',
			cellRenderer: function (params) { return gagaAgGrid.toDateTimeFormat(params.value); }
		},
		{
			headerName: "답변의뢰일시", field: "ansTransDt", width: 150, cellClass: 'text-center',
			cellRenderer: function (params) { return gagaAgGrid.toDateTimeFormat(params.value); }
		},
		{headerName: "답변의뢰자번호", field: "ansTransNo", width: 100, cellClass: 'text-center', hide: true},
		{headerName: "답변의뢰자명", field: "ansTransNm", width: 100, cellClass: 'text-center'}
	];
	
	// Get GridOptions
	let gridOptions = gagaAgGrid.getGridOptions(columnDefs);
	
	// 이미지가 있을 경우 높이 지정
	gridOptions.rowHeight = 60;
	
	// 셀 클릭 이벤트
	gridOptions.onCellClicked = function(event) {
		if (event.colDef.field == 'counselSq') {
			// 상품문의 상세
			cfnOpenGoodsQnaDetailPopup(event.data.counselSq);
		}
	}
	
	// 조회
	$('#btnSearch').on('click', function() {
		// 입력 값 체크
		if (!gagajf.validation('#searchForm'))
			return false;
		
		// Fetch data
		gagaAgGrid.fetch($('#searchForm').prop('action'), gridOptions, '#searchForm');
	});
	
	$(document).ready(function() {
		// 공통 달력 생성
		cfnCreateCalendar('#terms', 'termStdt', 'termEddt', true);
		$('.btnToday').trigger('click');
		
		// Create a agGrid
		gagaAgGrid.createGrid('gridList', gridOptions);
	});
/*]]>*/
</script>

</html>
