<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : OneToOneQnaForm.html
 * @desc    : 1:1문의관리 Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.12.24   gagamel     최초 작성
 *******************************************************************************
 -->
	<div id="main">
	<form id="searchForm" name="searchForm" action="#" th:action="@{'/customer/onetoone/qna/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
		<!-- 메인타이틀 영역 -->
		<div class="main-title">
		</div>
		<!-- //메인타이틀 영역 -->
		
		<!-- 메뉴 설명 -->
		<div class="infoBox menu-desc">
		</div>
		<!-- //메뉴 설명 -->
		
		<!-- 검색조건 영역 -->
		<div class="panelStyle">
			
				<table class="frmStyle" aria-describedby="검색조건">
					<colgroup>
						<col style="width:10%;"/>
						<col style="width:12%;"/>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
						<col style="width:10%;"/>
						<col style="width:10%;"/>
						<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="counselClsf">
								<option value="">[선택]</option>
								<option th:if="${counselClsfList}" th:each="oneData, status : ${counselClsfList}" 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="7" id="terms"></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>
			
		</div>
		<!-- //검색조건 영역 -->
		
		<!-- 리스트 영역 -->
		<div class="panelStyle">
			<ul class="panelBar">
				<li class="right">
					검색결과 : <strong>
					<span id="gridRowTotalCount">0</span> 건</strong>&nbsp; 쪽번호 <span id="pgNo">0</span>/
					<strong id="endPgNo">0</strong>&nbsp;&nbsp; <select id="pageSize"
					name="pageSize">
						<option value="50" selected="selected">50개씩 보기</option>
						<option value="100">100개씩 보기</option>
						<option value="500">500개씩 보기</option>
						<option value="1000">1000개씩 보기</option>
				</select> <input type="hidden" name="pageNo" id="pageNo" value="1" />
				</li>
			</ul>
		
			<div id="gridList" style="width: 100%; height: 570px" class="ag-theme-balham"></div>
			<ul class="panelBar">
				<li class="center">
					<div class="tablePaging" id="onePagination"></div>
				</li>
			</ul>
		</div>
		<!-- //리스트 영역 -->
		</form>
	</div>

<script type="text/javascript" src="/ux/plugins/gaga/gaga.paging.js"></script>
<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: "counselClsfNm", width: 150, cellClass: 'text-center'
// 			valueFormatter: function (params) { return params.value + (gagajf.isNull(params.data.counselDclsfNm) ? "" : "-" + params.data.counselDclsfNm); }
		},
		{
			headerName: "문의일시", field: "questDt", width: 150, cellClass: 'text-center',
			cellRenderer: function (params) { return gagaAgGrid.toDateTimeFormat(params.value); }
		},
		{headerName: "문의 제목", field: "questTitle", width: 300},
		{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); }
		}
	];
	
	// Get GridOptions
	let gridOptions = gagaAgGrid.getGridOptions(columnDefs);
	
	// 셀 클릭 이벤트
	gridOptions.onCellClicked = function(event) {
		if (event.colDef.field == 'counselSq') {
			// 1:1문의 상세
			cfnOpenOneToOneQnaDetailPopup(event.data.counselSq);
		} else if (event.colDef.field == 'maskingCustNm') {
			// 고객 상세
			cfnOpenCustDetailPopup(event.data.custNo);
		}
	}

	$('#pageSize').on('click', function () {
		$('#btnSearch').trigger('click');
	});

	// 조회
	$('#btnSearch').on('click', function() {
		// 입력 값 체크
		if (!gagajf.validation('#searchForm'))
			return false;
		
		gagaPaging.init('searchForm', fnSearchCallBack, 'onePagination', $('#pageSize').val());
		gagaPaging.load($("#searchForm input[name=pageNo]").val());
	});
	
	var fnSearchCallBack = function(result){
		$('#searchForm').find('#gridRowTotalCount').html(result.pageing.pageable.totalCount.addComma());
		$('#searchForm').find('#pageNo').val(result.pageing.pageable.pageNo.addComma());
		$('#searchForm').find('#pgNo').html(result.pageing.pageable.pageNo.addComma());
		$('#searchForm').find('#endPgNo').html(result.pageing.pageable.totalPage.addComma());
		gridOptions.api.setRowData(result.counselList);
		
		gagaPaging.createPagination(result.pageing.pageable);
	}
	
	$(document).ready(function() {
		// 공통 달력 생성
		cfnCreateCalendar('#terms', 'termStdt', 'termEddt', true);
		$('.btnToday').trigger('click');
		
		// Create a agGrid
		gagaAgGrid.createGrid('gridList', gridOptions);
	});
/*]]>*/
</script>

</html>
