<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : OrderListForm.html
 * @desc    : 주문목록 Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2021.01.04   jsh77b       최초 작성
 *******************************************************************************
 -->
<div class="modalPopup" data-width="1000">
	<div class="panelStyle">
		<div class="panelTitle">
			<h2>환불계좌정보</h2>
			<button type="button" class="close" onclick="uifnPopupClose('popupCreateRefundAccount');"><i class="fa fa-times"></i></button>
		</div>

		<div class="panelContent" style="height:90%; overflow-y:auto; padding:0px 20px !important; ">
			<form id="orderRefundAccontForm">
				<table class="frmStyle">
					<colgroup>
						<col style="width:160px;" />
						<col />
						<col />
						<col />
						<col />
						<col />
						<col />
					</colgroup>
					<tbody>
					<tr>
						<th>은행</th>
						<td>
							<select name="bankCd">
								<option value="">[선택하세요]</option>
								<option th:if="${bankList}" th:each="oneData, status : ${bankList}" th:value="${oneData.cd}" th:bankNm="${oneData.cdNm}" th:text="|[${oneData.cd}] ${oneData.cdNm}|"></option>
							</select>
						</td>
						<th>계좌번호</th>
						<td><input type="text" name="accountNo" data-valid-type="numeric"></td>
						<th>예금주</th>
						<td><input type="text" name="accountNm"></td>
						</th:block>
						<td>
							<button type="button" class="btn btn-success" id="saveAccountBtn" onclick="fnSaveAccount();">저장</button>
						</td>
					</tr>
					</tbody>
				</table>
			</form>
		</div>
	</div>
</div>

<script th:inline="javascript">
/*<![CDATA[*/
/* 이벤트 바인딩 관련 */
var orderInfoList 			= [[${orderInfoList}]];							// 주문기본정보
var ordNo 					= orderInfoList[0].ordNo;
var custNo 					= orderInfoList[0].custNo;

/* 환불계좌번호 저장 */
var fnSaveAccount = function(){
	var bankCd 		= $("#orderRefundAccontForm select[name=bankCd]").val();
	var bankNm 		= $("#orderRefundAccontForm select[name=bankCd] option:selected").attr("banknm");
	var accountNo 	= $("#orderRefundAccontForm input[name=accountNo]").val();
	var accountNm 	= $("#orderRefundAccontForm input[name=accountNm]").val();

	if (gagajf.isNull(bankCd)) {
		mcxDialog.alert('은행을 선택하세요.');
		return;
	}

	if (gagajf.isNull(accountNo)) {
		mcxDialog.alert('계좌번호를 입력하세요.');
		return;
	}

	if (gagajf.isNull(accountNm)) {
		mcxDialog.alert('예금주를 입력하세요.');
		return;
	}

	if (gagajf.isNull(ordNo) || gagajf.isNull(custNo)) {
		mcxDialog.alert('주문정보를 다시 확인하시기 바랍니다..');
		return;
	}

	mcxDialog.confirm("환불계좌를 저장하시겠습니까?", {
		cancelBtnText	: "취소",
		sureBtnText		: "확인",
		sureBtnClick	: function(){
			var data = {};
			data.ordNo 			= ordNo;
			data.custNo 		= custNo;
			data.bankCd 		= bankCd;
			data.accountNo 		= accountNo;
			data.accountNm 		= accountNm;

			var jsonData = JSON.stringify(data);

			gagajf.ajaxJsonSubmit('/orderChange/account/save', jsonData, function(result){
				uifnPopupClose('popupCreateRefundAccount');
				
				if (custNo > 0) {
					fnBindOrderRfAccountInfo();
				} else {
					$("#refundAccount .accountNo").eq(0).text(accountNo);
					$("#refundAccount .accountNm").eq(0).text(accountNm);
					$("#refundAccount .bankCd").eq(0).text(bankCd);
					$("#refundAccount .bankNm").eq(0).text(bankNm);
					$("#refundAccount .defaultYn").eq(0).text("N");
				}
				
			});
		}
	});
};

$(document).ready(function() {

});

/*]]>*/
</script>

</html>





