<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : CancelRequestForm.html
 * @desc    : 취소요청 화면
 *============================================================================
 * STYLE24
 * Copyright(C) 2019 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.12.12   jsh77b       최초 작성
 *******************************************************************************
 -->
<div class="modalPopup" data-width="1400" data-height="350">
	<div class="panelStyle">
		<div class="panelTitle">
			<h2>취소요청정보</h2>
			<button type="button" class="close" onclick="uifnPopupClose('popupCancelRequestForm');"><i class="fa fa-times"></i></button>
		</div>
			
		<div class="panelContent" style="height:90%; overflow-y:auto; padding:0px 20px !important; ">
			<form id="cancelRequestFrm" name="cancelRequestFrm" action="/orderChange/cancel" method="post" target="hdFrameForOrderCancel">
				<input type="hidden" name="ordNo" th:value="${ordNo}"/>
				<input type="hidden" name="ordChgSq" th:value="${ordChgSq}"/>
				<input type="hidden" name="chgReason" value=""/>
				<input type="hidden" name="chgReasonDesc" value=""/>

				<h4>(취소/반품/교환) 요청 정보</h4>
				<div id="gridOrderChangeList" style="width:100%; height: 180px; min-height:99px;" class="ag-theme-balham"></div>
				
				<div style="text-align:right; padding-bottom:5px; padding-top:5px;">
					<button type="button" class="btn btn-success" onclick="fnCnclReq('cancel');">취소철회</button>
					<button type="button" class="btn btn-success" onclick="fnCnclReq('confirm');">취소승인</button>
				</div>
			</form>
		</div>
	</div>
</div>

<!-- data -->
<script th:inline="javascript">
/*<![CDATA[*/
var ordNo 					= [[${ordNo}]];									// 주문번호
var ordChgSq 				= [[${ordChgSq}]];								// 주문변경번호
var orderChangeList 		= [[${orderChangeList}]];						// 취소/반품/교환요청 정보

//
//var orderInfoList 		= [[${orderInfoList}]];							// 주문기본정보
//var payMeans 				= orderInfoList[0].payMeans;					// 결제수단
//var chgReason				= orderChangeList[0].chgReason;					// 변경사유코드
//var chgMemo				= orderChangeList[0].chgMemo;					// 변경사유메모

var temp1 = true;
var temp2 = false;

// 6. 반품/교환 정보
var columnDefsOrderChangeList = [
	{
		headerName		: "요청번호"		
		, field			: "ordChgSq"		
		, width			: 100	
		, cellClass		: 'text-center'
	},
	{headerName: "요청구분"		, field: "chgGbNm"		, width: 100	, cellClass: 'text-center'},
	{headerName: "상품코드"		, field: "goodsCd"		, width: 100	, cellClass: 'text-center'},
	{headerName: "옵션1"			, field: "optCd1"		, width: 100	, cellClass: 'text-center'},
	{headerName: "옵션2"			, field: "optCd2"		, width: 100	, cellClass: 'text-center'},
	{headerName: "수량"			, field: "chgQty"		, width: 100	, cellClass: 'text-center'},
	{headerName: "요청상태"		, field: "chgStatNm"	, width: 100	, cellClass: 'text-center'},
	{
		headerName		: "요청일자"		
		, field			: "regDt"		
		, width			: 150		
		, cellClass		: 'text-center'
		, cellRenderer	: function(params) {
			return !gagajf.isNull(params.value) ? params.value.toDate("YYYYMMDDHHmm").format("YYYY-MM-DD HH:mm") : '';
		}
	},
	{headerName: "변경사유"		, field: "chgReasonNm"	, width: 100	, cellClass: 'text-center'},
	{headerName: "요청메모"		, field: "chgMemo"		, width: 150	, cellClass: 'text-center'},
	{headerName: "변경자명"		, field: "chgerNm"		, width: 100	, cellClass: 'text-center'},
	{headerName: "변경자핸드폰"		, field: "chgerPhnno"	, width: 120	, cellClass: 'text-center'}
];
var gridOptionsOrderChangeList = gagaAgGrid.getGridOptions(columnDefsOrderChangeList);
</script>

<!-- function -->
<script>
// 취소승인
var fnCnclReq = function (cnclGbn) {
	var confirmStr 		= "";
	var cnclLinkStr	 	= "";
	
	if (cnclGbn == "cancel") {
		confirmStr 		= "요청번호 [" + ordChgSq + "] 에 대한 요청철회 처리를 하시겠습니까?";
		cnclLinkStr 	= "/orderChange/cnclReqCancel";
	} else {
		confirmStr 		= "요청번호 [" + ordChgSq + "] 에 대한 취소승인 처리를 하시겠습니까?";
		cnclLinkStr 	= "/orderChange/cnclReqComplete";
	}
	
	mcxDialog.confirm(confirmStr, {
		cancelBtnText	: "취소",
		sureBtnText		: "확인",
		sureBtnClick	: function () {
			var data = new Object();
			data.ordNo 		= ordNo;	//전역변수
			data.ordChgSq 	= ordChgSq;

			var jsonData = JSON.stringify(data);
			
			gagajf.ajaxJsonSubmit(
				cnclLinkStr
				, jsonData
				, function (result) {
					uifnPopupClose('popupOrderDetail');
					fnReOpenOrderDetailPopup();
					uifnPopupClose('popupCancelRequestForm');
				}
			);
		}
	});
};
</script>

<script>
$(document).ready(function() {
	// 1. 그리드생성
	gagaAgGrid.createGrid('gridOrderChangeList'				, gridOptionsOrderChangeList);			// 취소/반품/교환 요청 정보
	
	// 2. 그리드 데이타 싱크작업
	gridOptionsOrderChangeList.api.setRowData(orderChangeList);										// 취소/반품/교환요청 정보
	
	// 2.1 TOTAL ROWS 없애기
	gagaAgGrid.hideStatusBar('gridOrderChangeList');
});
</script>
</html>





