<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : ExchangeDelvFailListForm.html
 * @desc    : 교환배송 미출곡 목록 대상
 *=============================================================
 * ISTYLE24
 * Copyright(C) 2021 TSIT, All rights reserved.
 *=============================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  ==================================
 * 1.0  2021.06.07   jsh77b        최초 작성
 * 1.1  
 ********************************************************************************
 -->
	<div id="main">
		<!-- 메인타이틀 영역 -->
		<div class="main-title">
		</div>
		<!-- //메인타이틀 영역 -->
		
		<!-- 메뉴 설명 -->
		<div class="infoBox menu-desc">
		</div>
		<!-- //메뉴 설명 -->
		
		<!-- 검색조건 영역 -->
		<div class="panelStyle">
			<!-- TITLE -->
			<div class="panelTitle">
				<h3><i class="fa fa-info-circle"></i>아래 검색조건 중 <font color="red">등록일</font>은 꼭 입력해 주세요.</h3>
				<span class="panelControl">
					<i class="fa fa-chevron-up"></i>
				</span>
			</div>
			<!-- //TITLE -->
			
			<div class="panelContent">	
				<form id="searchForm" name="searchForm" action="#" th:action="@{'/delivery/exchangeDelvFail/list'}" onsubmit="fnSearchList(); return false;">
					<table class="frmStyle">
						<colgroup>
							<col style="width:8%;"/>
							<col style="width:12%;"/>
							<col style="width:8%;"/>
							<col style="width:12%;"/>
							<col style="width:8%;"/>
							<col style="width:12%;"/>
						</colgroup>
						<tr>
							<th class="dashR">주문자명</th>
							<td class="dashR">
								<input type="text" class="w40p" name="ordNm" placeholder="" maxlength="20" />
							</td>
							<th class="dashR">주문번호</th>
							<td class="dashR">
								<input type="text" class="w40p" name="ordNo" placeholder="" maxlength="20" data-valid-type="numeric"/>
							</td>
							<th class="dashR">처리상태</th>
							<td class="dashR" colspan="2">
								<select name="delvCnclYn" id="delvCnclYn">
									<option value="">전체</option>
									<option value="N" selected>대기</option>
									<option value="y">처리완료</option>
								</select>
							</td>
						</tr>
						<tr>
							<th class="dashR">등록일</th>
							<td colspan="6" class="dashR">
								<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(); fnInitCalendar();">초기화</button>
						</li>
					</ul>
				</form>
			</div>
		</div>
		<!-- //검색조건 영역 -->

		<!-- 리스트 영역 -->
		<div class="panelStyle">
			<div class="panelContent" style="overflow: hidden;">
				<div id="gridList" style="width:100%; height: 500px;" class="ag-theme-balham"></div>
			</div>
		</div>
		<!-- //리스트 영역 -->
	</div>

<script th:inline="javascript">
/*<![CDATA[*/ 
var columnDefs = [
	{headerName: "교환배송취소번호",	field: "exchangeDelvFailSq",	width: 50,	cellClass: 'text-center', hide: true},
	{headerName: "변경요청번호",		field: "ordChgSq",				width: 100,	cellClass: 'text-center', hide: true},
	{
		headerName		: "변경요청"
		, field			: "ordChgSq"
		, width			: 100
		, cellClass		: 'text-center'
		, cellRenderer: function (params) {
			var rtnStr = "";
			
			var paramData 	= params.data.ordNo;
			paramData 		+= '@' + params.data.ordDtlNo;
			paramData 		+= '@' + params.data.delvFeeCd;
			paramData 		+= '@' + params.data.delvFeeCdGrp;
										
			rtnStr = '<a href="javascript:void(0);" onclick="fnCancelRequest(\'' + paramData + '\',\'' + params.value + '\');">' + params.value + '</a>';
			return rtnStr;
		}
	},
	{headerName: "주문번호",			field: "ordNo",					width: 100,	cellClass: 'text-center'},
	{headerName: "주문상세번호",		field: "ordDtlNo",				width: 100,	cellClass: 'text-center'},
	{headerName: "교환배송취소여부",	field: "delvCnclYn",			width: 120,	cellClass: 'text-center'},
	{headerName: "출고가능수량",		field: "ordQty",				width: 100,	cellClass: 'text-center'},
	{headerName: "품절취소수량",		field: "cnclRtnQty",			width: 100,	cellClass: 'text-center'},
	{headerName: "품절취소사유",		field: "delvFailReason",		width: 120,	cellClass: 'text-center'},
	{headerName: "상품코드",			field: "goodsCd",				width: 130,	cellClass: 'text-center'},
	{headerName: "상품명",			field: "goodsNm",				width: 180,	cellClass: 'text-center'},
	{headerName: "주문자",			field: "ordNm",					width: 120,	cellClass: 'text-center'},
	{headerName: "핸드폰번호",			field: "ordPhnno",				width: 120,	cellClass: 'text-center'},
	{headerName: "이메일",			field: "ordEmail",				width: 160,	cellClass: 'text-center'}
];

var gridOptions = gagaAgGrid.getGridOptions(columnDefs);
gridOptions.rowSelection = 'multiple';

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

var fnSearchList = function() {
	if ($('#stDate').val() == '') {
		mcxDialog.alert('시작 기간을 입력하세요.');
		return;
	}

	if ($('#edDate').val() == '') {
		mcxDialog.alert('종료 기간을 입력하세요.');
		return;
	}

	// 날짜 유효성 체크
	if (Number($('#stDate').val().replaceAll("-", "")) > Number($('#edDate').val().replaceAll("-", ""))) {
		mcxDialog.alert("시작일은 종료일보다 클 수 없습니다.");
		return;
	}

	gagaAgGrid.fetch($('#searchForm').prop('action'), gridOptions, '#searchForm', function() {
		
	});
}

/*************************************************************************
*  달력 초기화 
**************************************************************************/
var fnInitCalendar = function() {
	cfnChangeCalendar('1d', $('#stDate'), $('#edDate')); //달력 초기화
}

$(document).ready(function() {
	gagaAgGrid.createGrid('gridList', gridOptions);
	
	cfnCreateCalendar('#terms', 'stDate', 'edDate', true, '출고금지상품관리');
	fnInitCalendar();
});

//2021.01.25 추가
//취소요청, 교환요청, 반품요청 일때는 요청 정보 확인 팝업 정보
var fnCancelRequest = function (paramData, ordChgSq) {
	// 취소요청 구분 (orChgSq null 이면 취소요청화면 있으면 취소요청정보화면)
	if (ordChgSq == null) {
		ordChgSq = 0;
	}
	
	var paramArr 	= paramData.split("@");
	var param 		= "";
	param += "&ordNo=" 			+ paramArr[0];
	param += "&ordDtlNo=" 		+ paramArr[1];
	param += "&delvFeeCd="		+ paramArr[2];
	param += "&delvFeeCdGrp="	+ paramArr[3];
	param += "&ordChgSq=" 		+ ordChgSq;
	
	var actionUrl = "/orderChange/cncl/req/form?" + param;
	
	cfnOpenModalPopup(actionUrl, 'popupCancelRequestForm');
	
	return false;
};
/*]]>*/
</script>
</html>
