<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : SitePolicyForm.html
 * @desc    : 사이트정책관리 Page
 *============================================================================
 * SISUN
 * Copyright(C) 2019 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.01.13   jaewonHo   최초 작성
 *******************************************************************************
 -->
<head>
	<style>
		input[type="text"]{
			width:70%;
		}
		select{
			width:80.7%;
		}
		.frmStyle th {
		    padding: 2px 15px;
		    height: 36px;
		    line-height: 24px;
		    white-space: nowrap;
		    text-align: center;
		    background: #e9ecfb;
		    line-height: normal;
		}
	</style>
</head>
	<div id="main">
		<!-- 메인타이틀 영역 -->
		<div class="main-title">
		</div>
		<!-- //메인타이틀 영역 -->
		<!-- 검색조건 영역 -->
		<div class="panelStyle2">
			<!-- Search -->
			<form id="searchForm" name="searchForm" action="#" th:action="@{'/system/site/policy/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
				<table class="frmStyle">
					<colgroup>
						<col style="width:10%;"/>
					</colgroup>
					<tbody>
						<tr>
							<th>사이트</th>
							<td>
								<select name="siteCd" class="w150">
									<option th:if="${siteList}" th:each="oneData, status : ${siteList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
								</select>
							</td>
						</tr>
					</tbody>
				</table>
				<div class="panelBtnB">
					<button type="button" class="btn btn-base btn-lg" id="btnSearch" onclick="fnSearch('#searchForm');">조회</button>
				</div>
			</form>
		</div>
		<!-- //검색조건 영역 -->
		<!-- 테이블 영역 -->
		<div class="panelStyle2">
			<form id="detailForm" name="detailForm" action="#" th:action="@{'/system/site/policy/save'}"  onsubmit="$('#btnSearch').trigger('click'); return false;">
				<table class="frmStyle">
					<colgroup>
						<col style="width:9.5%;"/>
						<col style="width:16.5%;"/>
						<col style="width:9.5%;"/>
						<col style="width:14.5%;"/>
						<col style="width:9.5%;"/>
						<col style="width:15.5%;"/>
						<col style="width:9.5%;"/>
						<col style="width:15.5%;"/>
					</colgroup>
					<tbody>
						<tr>
							<th>정책일련번호</th>
							<td colspan = "3">
								<input name="policySq" type="text" class="w100 aR" style="width:28% !important;" readonly/>
								<em><font color="red"><i class="fa fa-info-circle"></i>현재 적용되고 있는 사이트 정책입니다.</font></em>
							</td>
							<th>사이트<i class="star"></i></th>
							<td colspan = "3">
								<select name="siteCd" required="required" data-valid-name="사이트" class="w150">
									<option th:if="${siteList}" th:each="oneData, status : ${siteList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
								</select>
							</td>
						</tr>
						<tr>
							<th rowspan="2">혜택구분<i class="star"></i></th>
							<td rowspan="2">
								<select name="benefitGb" onchange="fnBenefitGb(this.value)" data-valid-name="혜택구분" required>
									<option value='C'>[C] 쿠폰</option>
									<option value='P'>[P] 포인트</option>
									<option value='B'>[B] 쿠폰/포인트</option>
								</select>
							</td>

							<th>가입축하쿠폰</th>
							<td colspan="3">
								<input name="joinCpnNm" type="text" class="cpn" onkeyup="fnJoinCpnOnKeyUp(this);" style="width:150px;"/>
								<button type="button" class="btn icn cpn" id="joinCpnIdBtn" onclick="fnCouponSerch('J')"><i class="fa fa-search cpn" aria-hidden="true"></i></button>
								<input name="joinCpnId" type="text" style="width:80px;" readonly/>
								<button type="button" class="btn icn" onclick="$('input[name=joinCpnId],input[name=joinCpnNm]').val('')"><i class="fa fa-eraser"></i></button>
							</td>
							<th>가입축하포인트</th>
							<td>
								<input name="joinPnt" type="text" class="aR point"  maxlength="5" />
							</td>
						</tr>
						<tr>
							<th>생일축하쿠폰</th>
							<td colspan="3">
								<input name="birthCpnNm" type="text" class="cpn" onkeyup="fnBirthCpnOnKeyUp(this);" style="width:150px;"/>
								<button type="button" class="btn icn cpn" id="birthCpnIdBtn" onclick="fnCouponSerch('B')"><i class="fa fa-search" aria-hidden="true"></i></button>
								<input name="birthCpnId" type="text" style="width:80px;" readonly/>
								<button type="button" class="btn icn" onclick="$('input[name=birthCpnId],input[name=birthCpnNm]').val('')"><i class="fa fa-eraser"></i></button>
							</td>
							<th>생일축하포인트</th>
							<td>
								<input name="birthPnt" type="text" class="aR point"  maxlength="5" />
							</td>
						</tr>
						<tr>
							<th>가용포인트전환대기일수<i class="star"></i></th>
							<td>
								<input name="usablePntPendingDays" type="text" class="aR"  maxlength="5" required="required" data-valid-name="가용포인트전환대기일수"/>일
							</td>
							<th>텍스트상품평포인트<i class="star"></i></th>
							<td>
								<input name="textReviewPnt" type="text" class="aR"  maxlength="5" required="required" data-valid-name="텍스트상품평포인트"/>
							</td>
							<th>포토상품평포인트<i class="star"></i></th>
							<td>
								<input name="photoReviewPnt" type="text" class="aR"  maxlength="5" required="required" data-valid-name="일반상품평포인트"/>
							</td>
							<th>앱최초설치포인트<i class="star"></i></th>
							<td>
								<input name="appFsetupPnt" type="text" class="aR" required="required" data-valid-name="앱최초설치포인트"/>
							</td>
						</tr>
						<tr>
							<th>자사상품포인트적립율(PC정상)<i class="star"></i></th>
							<td>
								<input name="sgoodsPntPrate10" type="text" class="aR"  maxlength="5" required="required" data-valid-name="자사상품포인트적립율(PC정상)"/>%
							</td>
							<th>자사상품포인트적립율(모바일정상)<i class="star"></i></th>
							<td>
								<input name=sgoodsPntMrate10 type="text" class="aR"  maxlength="5" required="required" data-valid-name="자사상품포인트적립율(모바일정상)"/>%
							</td>
							<th>자사상품포인트적립율(PC이월)<i class="star"></i></th>
							<td>
								<input name="sgoodsPntPrate20" type="text" class="aR"  maxlength="5" required="required" data-valid-name="자사상품포인트적립율(PC이월)"/>%
							</td>
							<th>자사상품포인트적립율(모바일이월)<i class="star"></i></th>
							<td>
								<input name="sgoodsPntMrate20" type="text" class="aR"  maxlength="5" required="required" data-valid-name="자사상품포인트적립율(모바일이월)"/>%
							</td>
						</tr>
						<tr>
							<th>입점상품포인트적립율(PC정상)<i class="star"></i></th>
							<td>
								<input name="egoodsPntPrate10" type="text" class="aR"  maxlength="5" required="required" data-valid-name="입점상품포인트적립율(PC정상)"/>%
							</td>
							<th>입점상품포인트적립율(모바일정상)<i class="star"></i></th>
							<td>
								<input name="egoodsPntMrate10" type="text" class="aR"  maxlength="5" required="required" data-valid-name="입점상품포인트적립율(모바일정상)"/>%
							</td>
							<th>입점상품포인트적립율(PC이월)<i class="star"></i></th>
							<td>
								<input name="egoodsPntPrate20" type="text" class="aR"  maxlength="5" required="required" data-valid-name="입점상품포인트적립율(PC이월)"/>%
							</td>
							<th>입점상품포인트적립율(모바일이월)<i class="star"></i></th>
							<td>
								<input name="egoodsPntMrate20" type="text" class="aR"  maxlength="5" required="required" data-valid-name="입점상품포인트적립율(모바일이월"/>%
							</td>
						</tr>
						<tr>
							<th>배송지연보상기준일수<i class="star"></i></th>
							<td>
								<input name="shipDelayBaseDays" type="text" class="aR"  maxlength="5" required="required" data-valid-name="배송지연보상기준일수"/>일
							</td>
							<th>배송지연보상포인트<i class="star"></i></th>
							<td>
								<input name="shipDelayPnt" type="text" class="aR"  maxlength="5" required="required" data-valid-name="배송지연보상포인트"/>
							</td>
							<th>품절보상기준일수<i class="star"></i></th>
							<td>
								<input name="soldoutBaseDays" type="text" class="aR"  maxlength="5" required="required" data-valid-name="품절보상기준일수"/>일
							</td>
							<th>품절보상포인트<i class="star"></i></th>
							<td>
								<input name="soldoutPnt" type="text" class="aR"  maxlength="5" required="required" data-valid-name="품정보상포인트"/>
							</td>
						</tr>
						<tr>
							<th>사용가능포인트구분<i class="star"></i></th>
							<td>
								<label class="rdoBox"><input type="radio" name="usePossibPntGb" value="A" checked="checked" onclick="fnUsePntGb('A');">정액<span></span></label>
								<label class="rdoBox"><input type="radio" name="usePossibPntGb" value="R" onclick="fnUsePntGb('R');">정율<span></span></label>
							</td>
							<th>사용가능최대포인트<i class="star"></i></th>
							<td>
								<input name="usePossibMaxPnt" type="text" class="aR"  maxlength="5" required="required" data-valid-name="사용가능최대포인트"/>
								<span id="pntR">%</span>
							</td>
							<th>사용포인트단위<i class="star"></i></th>
							<td>
								<select name="usePntUnit" required="required" data-valid-name="사용포인트단위">
									<option value=''>선택</option>
									<option value='10'>원단위절사</option>
									<option value='100'>십원단위절사</option>
									<option value='1000'>백원단위절사</option>
								</select>
							</td>
							<th>무료배송비최소주문금액<i class="star"></i></th>
							<td>
								<input name="minOrdAmt" type="text" class="aR"  maxlength="5" required="required" data-valid-name="사용가능최대포인트"/>
							</td>
						</tr>
					</tbody>
				</table>
				<div class="panelBtnB">
					<button type="button" class="btn btn-success btn-lg" id="btnSave" onclick="fnSave('#detailForm');">저장</button>
				</div>
			</form>
		</div>
		<!-- 리스트 영역 -->
		<div class="panelStyle2">
			<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 siteList = gagajf.convertToArray([[${siteList}]]);
	var benefitGbList = {"C":"쿠폰", "P":"포인트", "B":"쿠폰/포인트"};
	var usePntUnitList = {"10" :"10:원단위절사", "100" :"100:원단위절사", "1000" :"1000:원단위절사"};
	var usePossibPntGbList = {"A" : "정액", "R" : "정율"};

	// specify the columns
	var columnDefs = [
		{headerName: "정책일련번호"					, field: "policySq"			, width: 100 , cellClass: 'text-center', pinned: 'left' },
		{headerName: "사이트"						, field: "siteCd"			, width: 120 , cellClass: 'text-center', pinned: 'left' ,
			valueFormatter: function (params) {
				return gagaAgGrid.lookupValue(siteList, params.value);
			}
		},
		{headerName: "혜택구분"					, field: "benefitGb"			, width: 90 , cellClass: 'text-center', pinned: 'left',
			valueFormatter: function (params) {
				return gagaAgGrid.lookupValue(benefitGbList, params.value);
			}
		},
		{headerName: "가입축하쿠폰ID"				, field: "joinCpnId"			, width: 140 , cellClass: 'text-center', pinned: 'left' },
		{headerName: "가입축하포인트"				, field: "joinPnt"				, width: 120 , cellClass: 'text-center', pinned: 'left' },
		{headerName: "생일축하쿠폰ID"				, field: "birthCpnId"			, width: 140 , cellClass: 'text-center', pinned: 'left' },
		{headerName: "생일축하포인트"				, field: "birthPnt"				, width: 120 , cellClass: 'text-center', pinned: 'left' },
		{headerName: "가용포인트전환대기일수"			, field: "usablePntPendingDays"	, width: 150 , cellClass: 'text-center' },
		{headerName: "자사상품포인트적립율(PC정상)"	, field: "sgoodsPntMrate10"		, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "자사상품포인트적립율(모바일정상)"	, field: "sgoodsPntMrate10"		, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "자사상품포인트적립율(PC이월)"	, field: "sgoodsPntPrate20"		, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "자사상품포인트적립율(모바일이월)"	, field: "sgoodsPntMrate20"		, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "입점상품포인트적립율(PC정상)"	, field: "egoodsPntPrate10"		, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "입점상품포인트적립율(모바일정상)"	, field: "egoodsPntMrate10"		, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "입점상품포인트적립율(PC이월)"	, field: "egoodsPntPrate20"		, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "입점상품포인트적립율(모바일이월)"	, field: "egoodsPntMrate20"		, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "텍스트상품평포인트"				, field: "textReviewPnt"		, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "포토상품평포인트"				, field: "photoReviewPnt"		, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "최소주문금액"					, field: "minOrdAmt"			, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "배송지연보상기준일수"			, field: "shipDelayBaseDays"	, width: 150 , cellClass: 'text-center' },
		{headerName: "배송지연보상포인트"				, field: "shipDelayPnt"			, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "품절보상기준일수"				, field: "soldoutBaseDays"		, width: 150 , cellClass: 'text-center' },
		{headerName: "품절보상포인트"				, field: "soldoutPnt"			, width: 150 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "사용가능포인트구분"				, field: "usePossibPntGb"		, width: 140 , cellClass: 'text-center',
			valueFormatter: function (params) {
				return gagaAgGrid.lookupValue(usePossibPntGbList, params.value);
			}
		},
		{headerName: "사용가능최대포인트"				, field: "usePossibMaxPnt"		, width: 110 , cellClass: 'text-center'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "사용포인트단위"				, field: "usePntUnit"			, width: 140 , cellClass: 'text-center',
			valueFormatter: function (params) {
				return gagaAgGrid.lookupValue(usePntUnitList, params.value);
			}
		},
		{headerName: "등록아이디"					, field: "regId"				, width: 110 , cellClass: 'text-center' },
		{headerName: "등록일"						, field: "regDt"				, width: 110 , cellClass: 'text-center',
			cellRenderer: function(params) {
				return !gagajf.isNull(params.value) ? params.value.toDate("YYYYMMDD").format("YYYY-MM-DD") : '';
			}
		}
	];

	var gridOptionsPolicy = gagaAgGrid.getGridOptions(columnDefs);

	//조회
	var fnSearch = function() {
		$('#detailForm')[0].reset();

		var siteCd = $('#searchForm select[name=siteCd]').val();
		var actionUrl = $('#searchForm').prop('action') +'/'+siteCd;
		gagaAgGrid.fetch(actionUrl, gridOptionsPolicy, '#searchForm', fnSearchCallBack);
	}
	var fnSearchCallBack = function(){
		fnBindDetail(gridOptionsPolicy.api.getRowNode(0).data);

		//혜택구분 쿠폰/포인트 초기화
		fnBenefitGb(gridOptionsPolicy.api.getRowNode(0).data.benefitGb);
	}

	// 셀클릭시 바인딩
	gridOptionsPolicy.onCellClicked = function(event) {
		fnBindDetail(event.data);
		fnBenefitGb(event.data.fnBenefitGb);
	}

	//로우클릭시 셋팅
	fnBindDetail = function(rowData){
		formId = '#detailForm';
		$(formId + ' input[name=policySq]').val(rowData.policySq);
		$(formId + ' select[name=siteCd]').val(rowData.siteCd).prop("selected", true);
		$(formId + ' select[name=benefitGb]').val(rowData.benefitGb).prop("selected", true);

		$(formId + ' input[name=joinCpnId]').val(rowData.joinCpnId);
		$(formId + ' input[name=joinCpnNm]').val(rowData.joinCpnNm);
		$(formId + ' input[name=joinPnt]').val(rowData.joinPnt);

		$(formId + ' input[name=birthCpnId]').val(rowData.birthCpnId);
		$(formId + ' input[name=birthCpnNm]').val(rowData.birthCpnNm);
		$(formId + ' input[name=birthPnt]').val(rowData.birthPnt);

		$(formId + ' input[name=sgoodsPntPrate10]').val(rowData.sgoodsPntPrate10.addComma());
		$(formId + ' input[name=sgoodsPntMrate10]').val(rowData.sgoodsPntMrate10.addComma());
		$(formId + ' input[name=sgoodsPntPrate20]').val(rowData.sgoodsPntPrate20.addComma());
		$(formId + ' input[name=sgoodsPntMrate20]').val(rowData.sgoodsPntMrate20.addComma());
		$(formId + ' input[name=egoodsPntPrate10]').val(rowData.egoodsPntPrate10.addComma());
		$(formId + ' input[name=egoodsPntMrate10]').val(rowData.egoodsPntMrate10.addComma());
		$(formId + ' input[name=egoodsPntPrate20]').val(rowData.egoodsPntPrate20.addComma());
		$(formId + ' input[name=egoodsPntMrate20]').val(rowData.egoodsPntMrate20.addComma());
		$(formId + ' input[name=appFsetupPnt]').val(rowData.appFsetupPnt.addComma());
		$(formId + ' input[name=usablePntPendingDays]').val(rowData.usablePntPendingDays);
		$(formId + ' input[name=textReviewPnt]').val(rowData.textReviewPnt.addComma());
		$(formId + ' input[name=photoReviewPnt]').val(rowData.photoReviewPnt.addComma());
		$(formId + ' input[name=usePossibMaxPnt]').val(rowData.usePossibMaxPnt.addComma());
		$(formId + ' input[name=minOrdAmt]').val(rowData.minOrdAmt.addComma());
		$(formId + ' input[name=shipDelayBaseDays]').val(rowData.shipDelayBaseDays);
		$(formId + ' input[name=shipDelayPnt]').val(rowData.shipDelayPnt.addComma());
		$(formId + ' input[name=soldoutBaseDays]').val(rowData.soldoutBaseDays);
		$(formId + ' input[name=soldoutPnt]').val(rowData.soldoutPnt.addComma());
		$(formId + ' select[name=usePntUnit]').val(rowData.usePntUnit).prop("selected", true);
		$(formId + " input:radio[name=usePossibPntGb]:input[value="+rowData.usePossibPntGb+"]").click();
	}

	// 사용가능포인트 구분시 사용가능최대포인트 %
	var fnUsePntGb = function(pntGb) {
		if(pntGb == "A") {
			$("#pntR").html("원");
		}else if(pntGb == "R") {
			$("#pntR").html("%");
		}

	}

	// 혜택구분(C:쿠폰, P:포인트, B:둘다) 선택시 이벤트
	var fnBenefitGb = function(pVal) {
		// 가입축하쿠폰ID(혜택구분이 "C:쿠폰" 또는 "B:둘다"일 때 사용)
		if(pVal == "C") {
			$(".cpn").each(function(){
				$(this).attr("disabled", false);
			});
			$(".point").each(function(){
				$(this).attr("disabled", true);
			});
		}else if(pVal == "P"){
			$(".cpn").each(function(){
				$(this).attr("disabled", true);
			});
			$(".point").each(function(){
				$(this).attr("disabled", false);
			});
		}else if(pVal == "B"){
			$(".cpn").each(function(){
				$(this).attr("disabled", false);
			});
			$(".point").each(function(){
				$(this).attr("disabled", false);
			});
		}
	}

	// 쿠폰가지고 오기
	var fnCouponSerch = function(type) {
		var actionUrl = "/marketing/policy/coupon/popup/form?callBackFun=fnResult&type="+type;
		cfnOpenModalPopup(actionUrl,'popupCoupon');
	}

	// 가지고온 쿠폰값 셋팅
	var fnResult = function(result) {
		if(result[0].type == 'J'){
			$('#detailForm input[name=joinCpnId]').val(result[0].cpnId);
		}else if(result[0].type == 'B'){
			$('#detailForm input[name=birthCpnId]').val(result[0].cpnId);
		}
	}

	//저장
	fnSave = function(){

		var formId = '#detailForm';
		// 입력 값 체크
		if (!gagajf.validation(formId))
			return false;

		var siteCd = 					$(formId + " select[name=siteCd]").val();                      //사이트
		var joinCpnId = 				$(formId + " input[name=joinCpnId]").val();                    //가입쿠폰ID
		var birthCpnId = 				$(formId + " input[name=birthCpnId]").val();                   //생일쿠폰ID
		var joinPnt = 					$(formId + " input[name=joinPnt]").val().removeComma();              //가입포인트
		var birthPnt = 					$(formId + " input[name=birthPnt]").val().removeComma();             //생일포인트
		var benefitGb = 				$(formId + " select[name=benefitGb]").val();                   //해택구분
		var appFsetupPnt =				$(formId + " input[name=appFsetupPnt]").val().removeComma();         //앱최초설치포인트
		var sgoodsPntMrate10 = 			$(formId + " input[name=sgoodsPntMrate10]").val().removeComma();     //자사상품포인트적립율(PC정상)
		var sgoodsPntMrate20 = 			$(formId + " input[name=sgoodsPntMrate20]").val().removeComma();     //자사상품포인트적립율(모바일정상)
		var sgoodsPntPrate10 = 			$(formId + " input[name=sgoodsPntPrate10]").val().removeComma();     //자사상품포인트적립율(PC이월)
		var sgoodsPntPrate20 = 			$(formId + " input[name=sgoodsPntPrate20]").val().removeComma();     //자사상품포인트적립율(모바일이월)
		var egoodsPntMrate10 = 			$(formId + " input[name=egoodsPntMrate10]").val().removeComma();     //입점상품포인트적립율(PC정상)
		var egoodsPntMrate20 = 			$(formId + " input[name=egoodsPntMrate20]").val().removeComma();     //입점상품포인트적립율(모바일정상)
		var egoodsPntPrate10 = 			$(formId + " input[name=egoodsPntPrate10]").val().removeComma();     //입점상품포인트적립율(PC이월)
		var egoodsPntPrate20 = 			$(formId + " input[name=egoodsPntPrate20]").val().removeComma();     //입점상품포인트적립율(모바일이월)
		var usablePntPendingDays = 		$(formId + " input[name=usablePntPendingDays]").val().removeComma(); //가용포인트전환대기일수
		var textReviewPnt = 			$(formId + " input[name=textReviewPnt]").val().removeComma();        //텍스트상품평포인트
		var photoReviewPnt = 			$(formId + " input[name=photoReviewPnt]").val().removeComma();       //포토상품평포인트
		var usePossibMaxPnt = 			$(formId + " input[name=usePossibMaxPnt]").val().removeComma();      //사용가능최대포인트
		var minOrdAmt = 				$(formId + " input[name=minOrdAmt]").val().removeComma();            //무료배송비최소주문금액
		var shipDelayBaseDays = 		$(formId + " input[name=shipDelayBaseDays]").val();            //배송지연보상기준일수
		var shipDelayPnt = 				$(formId + " input[name=shipDelayPnt]").val().removeComma();         //배송지연보상포인트
		var soldoutBaseDays = 			$(formId + " input[name=soldoutBaseDays]").val();              //품절보상기준일수
		var soldoutPnt = 				$(formId + " input[name=soldoutPnt]").val().removeComma();           //품절보상포인트
		var usePntUnit =				$(formId + " select[name=usePntUnit]").val();                  //사용포인트단위
		var usePossibPntGb = 			$(formId + " input:radio[name=usePossibPntGb]:checked").val(); //사용가능포인트구분

		mcxDialog.confirm("저장하시겠습니까?", {
			cancelBtnText: "취소",
			sureBtnText: "확인",
			sureBtnClick: function() {
				var data = {
						formId : formId
						,siteCd  				: siteCd
						,joinCpnId  			: joinCpnId
						,birthCpnId  			: birthCpnId
						,joinPnt  				: joinPnt
						,birthPnt  				: birthPnt
						,benefitGb  			: benefitGb
						,appFsetupPnt 			: appFsetupPnt
						,sgoodsPntMrate10 		: sgoodsPntMrate10
						,sgoodsPntMrate20 		: sgoodsPntMrate20
						,sgoodsPntPrate10 		: sgoodsPntPrate10
						,sgoodsPntPrate20 		: sgoodsPntPrate20
						,egoodsPntMrate10 		: egoodsPntMrate10
						,egoodsPntMrate20 		: egoodsPntMrate20
						,egoodsPntPrate10 		: egoodsPntPrate10
						,egoodsPntPrate20 		: egoodsPntPrate20
						,usablePntPendingDays 	: usablePntPendingDays
						,textReviewPnt  		: textReviewPnt
						,photoReviewPnt  		: photoReviewPnt
						,usePossibMaxPnt  		: usePossibMaxPnt
						,minOrdAmt  			: minOrdAmt
						,shipDelayBaseDays		: shipDelayBaseDays
						,shipDelayPnt  			: shipDelayPnt
						,soldoutBaseDays  		: soldoutBaseDays
						,soldoutPnt  			: soldoutPnt
						,usePntUnit 			: usePntUnit
						,usePossibPntGb  		: usePossibPntGb
				};
				var jsonData = JSON.stringify(data);
				gagajf.ajaxJsonSubmit($(formId).prop('action'), jsonData, fnSaveCallback);
			}
		});
	}

	var fnSaveCallback = function () {
		fnSearch();
		$("#detailForm")[0].reset();
	}

	$(document).ready(function() {
		gagaAgGrid.createGrid('gridList', gridOptionsPolicy);

		//혜택구분 쿠폰/포인트 초기화
		fnBenefitGb('B');

		$(":input[name=benefitGb]").change();

		fnSearch();
	});


	/*가입축하쿠폰 온키업 이벤트*/
	var fnJoinCpnOnKeyUp = function(pThis){
		if(window.event.keyCode == 13){
			var actionUrl = "/marketing/policy/coupon/popup/form?callBackFunc=fnJoinCallBack&cpnNm="+$(pThis).val();
			cfnOpenModalPopup(actionUrl,'popupCoupon');
		}
	}
	var fnJoinCallBack = function(params){
		$("input[name=joinCpnId]").val(params[0].cpnId);
		$("input[name=joinCpnNm]").val(params[0].cpnNm);
	}

	//생일축하쿠폰 온키업 이벤트
	var fnBirthCpnOnKeyUp = function(pThis){
		if(window.event.keyCode == 13){
			var actionUrl = "/marketing/policy/coupon/popup/form?callBackFunc=fnBirthCallBack&cpnNm="+$(pThis).val();
			cfnOpenModalPopup(actionUrl,'popupCoupon');
		}
	}
	var fnBirthCallBack = function(params){
		$("input[name=birthCpnId]").val(params[0].cpnId);
		$("input[name=birthCpnNm]").val(params[0].cpnNm);
	}


/*]]>*/
</script>
</html>