<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : GoodsDetailForm.html
 * @desc    : 상품 상세 팝업
 *============================================================================
 * SISUN
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.10.23   eskim       최초 작성
 *******************************************************************************
 -->
	<div class="modalPopup" data-width="1500"> <!-- data-width="1500" data-height="870" -->
		<div class="panelStyle">
			<div class="panelTitle">
				<h2>상품상세</h2>
				<button type="button" class="close" onclick="fnGoodsDetailClose()"><i class="fa fa-times"></i></button>
			</div>
			<div class="panelContent">
			<form id="goodsDetailForm" name="goodsDetailForm" action="#" th:method="post">
				<input type="hidden" id="mode" name="mode" th:value="${params.mode}"/>
				<input type="hidden" id="goodsCd" name="goodsCd" th:value="${params.goodsCd}"/>
				<input type="hidden" id="niClsfCd" name="niClsfCd"/>
				<input type="hidden" id="selfGoodsYn" name="selfGoodsYn"/>
				<input type="hidden" id="notiList" name="notiList" />
				<input type="hidden" id="chDataYn" name="chDataYn" />
				<input type="hidden" id="chStockDataYn" name="chStockDataYn" />
				<input type="hidden" id="goodsImageYn" name="goodsImageYn" />
				<input type="hidden" id="niClsfNm" name="niClsfNm" />
				<input type="hidden" id="uploadGoodsUrl" name="uploadGoodsUrl" th:value="${@environment.getProperty('upload.goods.view')}"/>
				<input type="hidden" id="goodsType" name="goodsType" />
				<input type="hidden" id="codiGoodsList" name="codiGoodsList" />
				<input type="hidden" id="GoodsComposeList" name="GoodsComposeList" />
				<table class="frmStyle">
					<colgroup>
						<col width="11%"/>
						<col/>
						<col width="11%"/>
						<col width="14%"/>
						<col width="11%"/>
						<col width="14%"/>
						<col width="11%"/>
						<col width="14%"/>
					</colgroup>
					<tr>
						<th>브랜드명<em class="required" title="필수"></em></th>
						<td colspan="3">
							<select name="selSupplyCompCd" id="selSupplyCompCd" disabled="disabled" class="w40p">
								<option value="">[선택]</option>
								<option th:if="${supplyCompList}" th:each="oneData, status : ${supplyCompList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
							<select name="selBrandCd" id="selBrandCd" disabled="disabled"  class="w40p">
								<option value="">[선택]</option>
							</select>
	
							<input type="hidden" name="supplyCompCd" id="supplyCompCd" />
							<input type="hidden" name="brandGrpNm" id="brandGrpNm" />
							<input type="hidden" name="brandCd" id="brandCd" />
						</td>
						<th>상품코드<em class="required" title="필수"></em></th>
						<td><div id="goodsCdTxt"></div></td>
						<th>원코드</th>
						<td><span id="supplyGoodsCdTxt"></span></td>
					</tr>
				</table>
				<!-- TABS SPACE -->
				<div class="tabs">
					<!-- TABS NAVI -->
					<div class="tabsNav">
						<ul>
							<li class="on"><a href="#goodstab1">기본정보</a></li>
							<li><a href="#goodstab2">옵션/재고정보</a></li>
							<li><a href="#goodstab3">상품상세정보</a></li>
							<li id="goodsNotiTab"><a href="#goodstab4">고시정보</a></li>
							<li id="goodsCodiTab"><a href="#goodstab5">코디상품</a></li>
							<li id="GoodsComposeTab" style="display:none;"><a href="#goodstab6">구성상품</a></li>
							<li><a href="#goodstab7">변경이력</a></li>
						</ul>
					</div>
					<!-- //TABS NAVI -->
					<!-- TABS CONTENTS -->
					<ul class="tabsCont" th:with="uxImgUrl=${@environment.getProperty('domain.uximage')}">
						<!-- TAB1 : 기본정보 -->
						<li class="tab on" id="goodstab1">
							<!-- TAB1 CONTENTS AREA -->
							<div class="panelStyle">
								<table class="frmStyle">
									<colgroup>
										<col width="10%"/>
										<col width="15%"/>
										<col width="15%"/>
										<col width="15%"/>
										<col width="15%"/>
										<col width="15%"/>
										<col/>
									</colgroup>
									<tbody>
									<tr>
										<td rowspan="4" style="text-align:center" th:with="uploadGoodsUrl=${@environment.getProperty('upload.goods.view')}">
										<img id="goodsImgUrl" src="" width="100px"/>
										<input type="hidden" name="imgPath1" id="imgPath1" />
										</td>
										<th>상품타이틀</th>
										<td colspan="5">
											<input type="text" class="w80p" id="goodsTnm" name="goodsTnm" maxlength=""></input>
											<span class="byteChk"><em class="cBlue" id="goodsTnmLen">0</em>/200 bytes</span>
											<input type="hidden" id="goodsTnmOrg" name="goodsTnmOrg"/>
										</td>
									</tr>
									<tr>
										<th>상품명<em class="required" title="필수"></em></th>
										<td colspan="5">
											<input type="text" class="w80p" id="goodsNm" name="goodsNm"></input>
											<span class="byteChk"><em class="cBlue" id="goodsNmLen">0</em>/200 bytes</span>
											<input type="hidden" id="goodsNmOrg" name="goodsNmOrg"/>
										</td>
									</tr>
									<tr>
										<th>사용자검색어</th>
										<td colspan="5">
											<input type="text" class="w60p" id="goodsSnm1" name="goodsSnm1"></input>
											<span class="byteChk"><em class="cBlue" id="goodsSnm1Len">0</em>/200 bytes</span><font class="cBlue padL10"><b>* 여러개설정할경우 ; 구분자 사용 / 공백은 자동삭제처리</b></font>
											<input type="hidden" id="goodsSnm1Org" name="goodsSnm1Org"/>
										</td>
									</tr>
									<tr>
										<th>검색어</th>
										<td colspan="5">
											<textarea class="textareaR2 w100p" id="goodsSnmTxt" name="goodsSnmTxt" disabled="disabled"></textarea>
											<!-- <input type="text" class="w100p" id="goodsSnmTxt" name="goodsSnmTxt" disabled="disabled"></input> -->
											<input type="hidden" id="goodsSnm" name="goodsSnm"></input>
										</td>
									</tr>
									<tr>
										<td class="aC cRed" style="font-weight:bold;"><span id="goodsTypeNm"></span></td> <!-- 상품타입노출 -->
										<th>정상/이월 구분<em class="required" title="필수"></em></th>
										<td>
											<label class="rdoBtn" th:if="${formalGbList}" th:each="oneData, status : ${formalGbList}" ><input type="radio" id="formalGb" name="formalGb" th:value="${oneData.cd}" th:text="${oneData.cdNm}" /></label>
											<input type="hidden" id="formalGbOrg" name="formalGbOrg"/>
										</td>
										<th>상품상태<em class="required" title="필수"></em></th>
										<td>
											<select  name="goodsStat" id="goodsStat">
											<option value="">[선택]</option>
											<option th:if="${goodsStatList}" th:each="oneData, status : ${goodsStatList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
											</select>
											<input type="hidden" id="goodsStatOrg" name="goodsStatOrg"/>
										</td>
										<th>색상</th>
										<td>
											<select class="w90p"  name="colorCd" id="colorCd" disabled="disabled">
											<option th:if="${colorList}" th:each="oneData, status : ${colorList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
											</select>
										</td>
									</tr>
									<tr>
										<td rowspan="10">&nbsp;</td>
										<th>시즌<em class="required" title="필수"></em></th>
										<td >
											<select  name="seasonCd" id="seasonCd">
												<option value="">[선택]</option>
												<option th:if="${seasonList}" th:each="oneData, status : ${seasonList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
											</select>
											<input type="hidden" id="seasonCdOrg" name="seasonCdOrg"/>
										</td>
										<th>성별<em class="required" title="필수"></em></th>
										<td>
											<select  name="sexGb" id="sexGb">
												<option value="">[선택]</option>
												<option th:if="${sexGbList}" th:each="oneData, status : ${sexGbList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
											</select>
											<input type="hidden" id="sexGbOrg" name="sexGbOrg"/>
										</td>
										<th>스타일년도</th>
										<td><span id="styleYearTxt"></span></td>
									</tr>
									<tr id="erplinkarea">
										<th>원산지</th>
										<td><span id="makeNmTxt"></span></td>
										
										<th>상품구분<em class="required" title="필수"></em></th>
										<td>
											<select  name="goodsGb" id="goodsGb">
												<option value="">[선택]</option>
												<option th:if="${goodsGbList}" th:each="oneData, status : ${goodsGbList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
											</select>
											<input type="hidden" id="goodsGbOrg" name="goodsGbOrg"/>
										</td>
										<th>가격변경일</th>
										<td colspan="3"><span id="priceUpdDtTxt"></span></td>
									</tr>
									<tr>
										<th>정상가</th>
										<td class="aR"><span id="listPriceTxt"></span> 원
											<input type="hidden" id="listPrice" name="listPrice"/>
										</td>
										<th>판매가<em class="required" title="필수"></em></th>
										<td><input type="text" class="w80p aR" id="currPrice" name="currPrice" maxlength="10" data-valid-type="integer"/> 원
											<input type="hidden" id="currPriceOrg" name="currPriceOrg"/>
										</td>
										<th>할인율</th>
										<td class="aR" ><span id="dcRateTxt"></span> ％  <input type="hidden" id="dcRate" name="dcRate"/></td>
									</tr>
									<tr id="selfGoodsNSellFeeRate">
										<th>최초승인일</th>
										<td><span id="frstCfrmDtTxt"></span></td>
										<th>판매수수료율<em class="required" title="필수"></em></th>
										<td><span id="sellFeeRateTxt"></span> ％</td>
										<th>자사몰 노출여부<em class="required" title="필수"></em></th>
										<td>
											<label class="rdoBtn"><input type="radio" name="selfMallYn" id="selfMallYnY" value="Y"  checked/>Y</label>
											<label class="rdoBtn"><input type="radio" name="selfMallYn" id="selfMallYnn" value="N"/>N</label>
											<input type="hidden" id="selfMallYnOrg" name="selfMallYnOrg"/>
										</td>
									</tr>
									<tr>
										<th>품목코드<em class="required" title="필수"></em></th>
										<td colspan="3">
											<select  name="itemkindCd" id="itemkindCd" th:disabled="${sessionInfo.roleCd != 'G001_0000' AND sessionInfo.roleCd != 'G001_A000' AND sessionInfo.roleCd != 'G001_A101' AND sessionInfo.roleCd != 'G001_A100' AND sessionInfo.roleCd != 'G001_A001'}">
												<option th:if="${itemkindList}" th:each="oneData, status : ${itemkindList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
											</select>
											<input type="hidden" id="orgItemkindCd" name="orgItemkindCd"/>
											<th:block th:if="${sessionInfo.roleCd == 'G001_0000' OR sessionInfo.roleCd == 'G001_A000' OR sessionInfo.roleCd == 'G001_A101' OR sessionInfo.roleCd == 'G001_A100' OR sessionInfo.roleCd == 'G001_A001' }">
											<button type="button" class="btn btn-success btn-lg" id="btnGoodsItemkindChange">품목변경</button>
											</th:block>
										</td>
										<th>기본배송비</th>
										<td>
											<input type="text" class="w100 aR" id="delvFee" name="delvFee"  disabled="disabled"/> 원
										</td>
									</tr>
									<tr>
										<th>PC포인트<em class="required" title="필수"></em></th>
										<td>
											<input type="text" class="w50 aR" id="pntPrate" name="pntPrate" data-valid-type="integer" maxlength="3"/> ％ /&nbsp;
											<input type="hidden" id="pntPrateOrg" name="pntPrateOrg"/>
											<label class="rdoBtn"><input type="radio" name="prePpntUsableYn" id="prePpntUsableYnY" value="Y"/>Y</label>
											<label class="rdoBtn"><input type="radio" name="prePpntUsableYn" id="prePpntUsableYnN" value="N"/>N</label>
											<input type="hidden" id="prePpntUsableYnOrg" name="prePpntUsableYnOrg"/>
										</td>
										<th>모바일포인트<em class="required" title="필수"></em></th>
										<td>
											<input type="text" class="w50 aR" id="pntMrate" name="pntMrate" data-valid-type="integer" maxlength="3"/> ％ /&nbsp;
											<input type="hidden" id="pntMrateOrg" name="pntMrateOrg"/>
											<label class="rdoBtn"><input type="radio" name="preMpntUsableYn" id="preMpntUsableYnY" value="Y"/>Y</label>
											<label class="rdoBtn"><input type="radio" name="preMpntUsableYn" id="preMpntUsableYnN" value="N"/>N</label>
											<input type="hidden" id="preMpntUsableYnOrg" name="preMpntUsableYnOrg"/>
										</td>
										<th>무료배송비기준<em class="required" title="필수"></em></th>
										<td>
											<input type="text" class="w100 aR" id="minOrdAmt" name="minOrdAmt" data-valid-type="real" maxlength="10"/> 원
											<input type="hidden" id="minOrdAmtOrg" name="minOrdAmtOrg"/>
										</td>
									</tr>
									<tr>
										<th>최소주문수량<em class="required" title="필수"></em></th>
										<td>
											<input type="text" class="w100 aR" id="minOrdQty" name="minOrdQty" data-valid-type="integer" maxlength="5"/>
											<input type="hidden" id="minOrdQtyOrg" name="minOrdQtyOrg"/>
										</td>
										<th>최대주문수량<em class="required" title="필수"></em></th>
										<td>
											<input type="text" class="w100 aR" id="maxOrdQty" name="maxOrdQty" data-valid-type="integer" maxlength="5"/>
											<input type="hidden" id="maxOrdQtyOrg" name="maxOrdQtyOrg"/>
										</td>
										<th>ID당1일최대구매수량<em class="required" title="필수"></em></th>
										<td>
											<input type="text" class="w100 aR" id="dayMaxOrdQty" name="dayMaxOrdQty" data-valid-type="integer" maxlength="5"/>
											<input type="hidden" id="dayMaxOrdQtyOrg" name="dayMaxOrdQtyOrg"/>
										</td>
									</tr>
									</tbody>
								</table>
							</div>
							<!-- //TAB1  CONTENTS AREA -->
						</li>
						<!-- //TAB1 -->
						<!-- TAB2 : 옵셥/재고 -->
						<li class="tab" id="goodstab2">
							<!-- TAB2 CONTENTS AREA -->
							<div class="panelStyle">
								<!-- <ul class="notice cBlue">
									<li><strong>상품 이미지 사이즈</strong> : <em><strong>600 × 600</strong> px</em></li>
								</ul> -->
								<div id="sizeStockArea"></div>
							</div>
							<!-- //TAB2 CONTENTS AREA -->
						</li>
						<!-- //TAB2 : 이미지/옵셥/재고 -->
						<!-- TAB3 : 상품상세 -->
						<li class="tab" id="goodstab3">
							<!-- TAB3 CONTENTS AREA -->
							<div class="panelStyle">
								<!-- TABS SPACE -->
								<div class="tabsJr">
									<!-- TABS CONTENT -->
									<ul class="tabsJrCont">
										<!-- TAB -->
										<li class="tabJr on" id="goodstab11">
											<!-- TAB11 CONTENTS AREA -->
											<table class="frmStyle">
											<colgroup>
												<col width="12%"/>
												<col/>
											</colgroup>
											<tr>
												<th>상세설명</th>
												<td><label class="chkBox"><input type="checkbox" name="chkDescKeep" checked="checked" value="Y">정보유지<span></span></label>
												</td>
											</tr>
											<tr>
												<th>상위(PC)</th>
												<td><div class="tabJrContArea">
													<textarea name="goodsPcTopDesc" id="goodsPcTopDesc" rows="5" cols="50" style="width:1050px; height: 150px;"></textarea>
													</div>
												</td>
											</tr>
											<tr>
												<th>상위(MOBILE)</th>
												<td><div class="tabJrContArea">
													<textarea name="goodsMobileTopDesc" id="goodsMobileTopDesc" rows="5" cols="50" style="width:1050px; height: 150px;"></textarea>
													</div>
												</td>
											</tr>
											<tr>
												<th>하위(PC)</th>
												<td><div class="tabJrContArea">
													<textarea name="goodsPcDownDesc" id="goodsPcDownDesc" rows="5" cols="50" class="w100p" style="width:1050px; height: 150px;"></textarea>
													</div>
												</td>
											</tr>
											<tr>
												<th>하위(MOBILE)</th>
												<td><div class="tabJrContArea">
													<textarea name="goodsMobileDownDesc" id="goodsMobileDownDesc" rows="5" cols="50" style="width:1050px; height: 150px;"></textarea>
													</div>
												</td>
											</tr>
											</table>
										</li>
										<!-- //TAB -->
									</ul>
									<!-- //TAB CONTENT -->
								</div>
								<!-- //TABS SPACE -->
							</div>
							<!-- //TAB3 CONTENTS AREA -->
						</li>
						<!-- //TAB3 : 상품상세 -->
						<!-- TAB4 : 고시정보 -->
						<li class="tab" id="goodstab4">
							<!-- TAB5 CONTENTS AREA -->
							<div class="panelStyle">
								<!-- TABS SPACE -->
								<table class="frmStyle">
									<colgroup>
										<col style="width:10%"/>
										<col/>
									</colgroup>
									<tr>
										<th>Details (상품상세정보 고시)<em class="required" title="필수"></em></th>
										<td>
											<select id="selNiClsfCd" name="selNiClsfCd"  class="w40p">
												<option value="">[선택]</option>
												<option th:if="${niClsfCdList}" th:each="oneData, status : ${niClsfCdList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}"></option>
											</select>
											<button type="button" class="btn btn-dark btn-lg" id="btnNotinfo">선택</button>
											<span class="padL10" id='itemkindNoti'></span>
										</td>
									</tr>
								</table>
								<hr/>
								<div id="notiArea"></div>
								<!-- //TABS SPACE -->
							</div>
							<!-- //TAB4 CONTENTS AREA -->
						</li>
						<!-- //TAB4 : 고시정보 -->
						<!-- TAB5 : 코디정보 -->
						<li class="tab" id="goodstab5">
							<!-- TAB6 CONTENTS AREA -->
							<div class="panelStyle">
								<!-- 내용 삽입 -->
								<ul class="panelBar">
									<li class="left">
										<button type="button" class="btn btn-danger btn-lg" id="btnCodiGoodsDelete">삭제</button>
									</li>
									<li class="right">
										<button type="button" class="btn btn-default btn-lg" onclick="cfnDownloadSampleFile('SF003');">양식다운로드</button>
										<button type="button" class="btn btn-success btn-lg" id="btnCodiGoodsExcel">엑셀조회</button>
										<button type="button" class="btn btn-base btn-lg" onclick="fnOpenCodiGoodsPopup()">상품조회</button>
									</li>
								</ul>
								<div id="gridGoodsCodiList" style="height: 480px;" class="ag-theme-balham lh60"></div>
								<!-- 내용 삽입 -->
							</div>
							<!-- //TAB6 CONTENTS AREA -->
						</li>
						<!-- //TAB5 : 코디정보 -->
						<!-- TAB6 : 구성상품 -->
						<li class="tab" id="goodstab6">
							<!-- TAB6 CONTENTS AREA -->
							<div class="panelStyle">
								<!-- 내용 삽입 -->
								<ul class="panelBar"  id="GoodsComposeBtnArea">
									<li class="right">
										<button type="button" class="btn btn-default btn-lg" onclick="cfnDownloadSampleFile('SF003');">양식다운로드</button>
										<button type="button" class="btn btn-success btn-lg" id="btnGoodsDealSearchExcel">엑셀조회</button>
										<button type="button" class="btn btn-base btn-lg" onclick="fnOpenGoodsDetailPopup()">상품조회</button>
									</li>
								</ul>
								<div id="gridGoodsComposeList" style="height: 550px;" class="ag-theme-balham lh60"></div>
								<!-- 내용 삽입 -->
							</div>
							<!-- //TAB6 CONTENTS AREA -->
						</li>
						<!-- //TAB7 : 추가정보 -->
						<!-- TAB5 : 이력정보 -->
						<li class="tab" id="goodstab5">
							<!-- TAB8 CONTENTS AREA -->
							<div class="panelStyle">
								<!-- 내용 삽입 -->
								<div id="gridGoodsHstoryList" style="height: 500px;" class="ag-theme-balham"></div>
								<!-- 내용 삽입 -->
							</div>
							<!-- //TAB5 CONTENTS AREA -->
						</li>
						<!-- //TAB5 : 추가정보 -->
					</ul>
					<!-- //TABS CONTENTS -->
					<!-- TABS BUTTON AREA -->
					<ul class="panelBar marT10">
						<li class="left">
							<button type="button" class="btn btnLeft btn-base btn-lg" id="btnGoodsDetailPreview">미리보기</button>
							<button type="button" class="btn btnLeft btn-base btn-lg" id="btnGoodsDetailImg">이미지보기</button>
						</li>
						<li class="right">
							<th:block th:if="${sessionInfo.roleCd == 'G001_0000' OR sessionInfo.roleCd == 'G001_A000' OR sessionInfo.roleCd == 'G001_A101' OR sessionInfo.roleCd == 'G001_A100' OR sessionInfo.roleCd == 'G001_A001'}">
							<button type="button" class="btn btnRight btn-success btn-lg" id="btnGoodsDetailSave">저장</button>
							</th:block>
						</li>	
					</ul>
					<!-- //TABS BUTTON AREA -->
				</div>
				<!-- //TABS SPACE -->
			</form>
			</div>	<!--  class=panelContent -->
		</div>	<!--  class=panelStyle -->
	</div> <!--  class=modalPopup -->
<script type="text/javascript" src="/smartEditor/js/HuskyEZCreator.js?v=2019122801" charset="utf-8"></script>
<script type="text/javascript" src="/ux/plugins/gaga/gaga.smarteditor.js?v=2019122801"></script>
<script th:inline="javascript">
/*<![CDATA[*/

	var sessRoleCd = [[${sessionInfo.roleCd}]];
	var formalGbList = gagajf.convertToArray([[${formalGbList}]]);
	var goodsStatList = gagajf.convertToArray([[${goodsStatList}]]);
	var itemkindList = gagajf.convertToArray([[${itemkindList}]]);
	var authBrandList = [[${authBrandList}]];
	var useYnList = gagajf.convertToArray([[${useYnList}]]);
	var goodsTypeList = gagajf.convertToArray([[${goodsTypeList}]]);
	var uploadGoodsUrl = [[${@environment.getProperty('upload.goods.view')}]];
	// Get a SmartEditor options
	var seOptions = gagaSe.getEditorOptions();
	
	// specify the columns - 상품변경이력
	var columnGoodsHstoryDefs = [
		{headerName: 'No', width: 60, cellClass: 'text-center', valueGetter: function(params) { return params.node.rowIndex + 1 }},
		{headerName: "변경일자", field: "regDt", width: 130, cellClass: 'text-center' ,
			cellRenderer: function(params) {
				return !gagajf.isNull(params.value) ? params.value.toDate("YYYYMMDDHHmm").format("YYYY-MM-DD HH:mm") : '';
			}
		},
		{headerName: "변경자", field: "regNm", width: 100, cellClass: 'text-center'},
		{headerName: "판매가", field: "currPrice" , width: 100, cellClass: 'text-right'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "변경전판매가", field: "currBprice" , width: 100, cellClass: 'text-right'
			,valueFormatter: function(params) { return Number(params.value).addComma(); }
		},
		{headerName: "상품상태", field: "goodsStat" , width: 100, cellClass: 'text-center',
			cellEditorParams: { values: gagaAgGrid.extractValues(goodsStatList) },
			valueFormatter: function (params) { return gagaAgGrid.lookupValue(goodsStatList, params.value); },
			valueParser: function (params) { return gagaAgGrid.lookupKey(goodsStatList, params.newValue); }
		},
		{headerName: "상품명", field: "goodsNm" , width: 180, cellClass: 'text-left'},
		{headerName: "상품타이틀", field: "goodsTnm" , width: 180, cellClass: 'text-left'},
		/* {headerName: "상품검색어", field: "goodsSnm" , width: 180, cellClass: 'text-left'}, */
		{headerName: "정상이월구분", field: "formalGb" , width: 100, cellClass: 'text-center',
			cellEditorParams: { values: gagaAgGrid.extractValues(formalGbList) },
			valueFormatter: function (params) { return gagaAgGrid.lookupValue(formalGbList, params.value); },
			valueParser: function (params) { return gagaAgGrid.lookupKey(formalGbList, params.newValue); }
		},
		{headerName: "품목", field: "itemkindCd" , width: 180, cellClass: 'text-left',
			cellEditorParams: { values: gagaAgGrid.extractValues(itemkindList) },
			valueFormatter: function (params) { return gagaAgGrid.lookupValue(itemkindList, params.value); },
			valueParser: function (params) { return gagaAgGrid.lookupKey(itemkindList, params.newValue); }
		},
		{headerName: "최초승인일자", field: "frstCfrmDt", width: 150, cellClass: 'text-center' ,
			cellRenderer: function(params) {
				return !gagajf.isNull(params.value) ? params.value.toDate("YYYYMMDDHHmmss").format("YYYY-MM-DD HH:mm:ss") : '';
			}
		},
		{headerName: "재고연동여부", field: "erpStockLinkYn" , width: 100, cellClass: 'text-center'},
		{headerName: "자사몰노출여부", field: "selfMallYn" , width: 120, cellClass: 'text-center'},
		{headerName: "사용자검색어", field: "goodsSnm1" , width: 150, cellClass: 'text-left'},
		{headerName: "검색어", field: "goodsSnm" , width: 450, cellClass: 'text-left', tooltipField: "goodsSnm"}
	];
	
	// specify the columns - 구성상품
	var columnGoodsComposeDefs = [
		{headerName: "정렬", field: "dispOrd", width: 70 ,hide: false, cellClass: 'text-center',  rowDrag: true },
		{headerName: "CRUD", field: "crud", width: 75, minWidth: 75, hide: true},
		//{headerName: 'No', width: 60, cellClass: 'text-center', valueGetter: function(params) { return params.node.rowIndex + 1 }},
		{headerName: "이미지", field: "imgPath1", width: 100, height: 60, cellClass: 'text-center'
			,cellRenderer: function(params) {
				if (params.data.imgType == "A"){
					if(!gagajf.isNull(params.data.imgPath6)){
						return '<img width="60" src="'+ uploadGoodsUrl+params.data.imgPath6 + '" alt=""  onerror="this.src=\'/image/no.gif\';"/>';
					}else{
						return '<img width="60" src="'+ uploadGoodsUrl+params.value + '" alt=""  onerror="this.src=\'/image/no.gif\';"/>';
					}	
				}else{
					if(!gagajf.isNull(params.data.imgPath6)){
						return '<img width="60" src="'+ params.data.imgPath1 + '" alt="" onerror="this.src=\'/image/no.gif\';"/>';
					}else{
						return '<img width="60" src="'+ params.value + '" alt="" onerror="this.src=\'/image/no.gif\';"/>';
					}
					
				}
			}
		},
		{headerName: "상품타입", field: "goodsType" , width: 100, cellClass: 'text-center',
			cellEditorParams: { values: gagaAgGrid.extractValues(goodsTypeList) },
			valueFormatter: function (params) { return gagaAgGrid.lookupValue(goodsTypeList, params.value); },
			valueParser: function (params) { return gagaAgGrid.lookupKey(goodsTypeList, params.newValue); }
		},
		{headerName: "구성상품코드", field: "extendGoodsCd" , width: 130, cellClass: 'text-center'},
		{headerName: "구성상품코드명", field: "extendGoodsCdNm" , width: 200, cellClass: 'text-left'},
		//{headerName: "순서", field: "dispOrd" , width: 80, cellClass: 'text-right',editable: true, required: true},
		{headerName: "수량", field: "qty" , width: 100, cellClass: 'text-right'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "판매가", field: "currPrice" , width: 100, cellClass: 'text-right'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "상품판매가", field: "compsCurrPrice" , width: 150, cellClass: 'text-right'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "기준여부(품목-카테고리)", field: "baseYn", width: 180, cellClass: 'text-center'},
		{headerName: "전시여부", field: "useYn", width: 100, cellClass: 'text-center',editable: true,
			cellEditor: 'agRichSelectCellEditor',
			cellEditorParams: { values: gagaAgGrid.extractValues(useYnList), required: true },
			valueFormatter: function (params) { return gagaAgGrid.lookupValue(useYnList, params.value); },
			valueParser: function (params) { return gagaAgGrid.lookupKey(useYnList, params.newValue); }
		},
		{headerName: "옵션명(딜상품용)", field: "extendGoodsOptNm" , width: 200, cellClass: 'text-left',editable: true, required: true},
		{headerName: "상품상태", field: "goodsStat" , width: 100, cellClass: 'text-center',
			cellEditorParams: { values: gagaAgGrid.extractValues(goodsStatList) },
			valueFormatter: function (params) { return gagaAgGrid.lookupValue(goodsStatList, params.value); },
			valueParser: function (params) { return gagaAgGrid.lookupKey(goodsStatList, params.newValue); }
		},
		{headerName: "등록일시", field: "regDt", width: 150, cellClass: 'text-center' ,
			cellRenderer: function(params) {
				return !gagajf.isNull(params.value) ? params.value.toDate("YYYYMMDDHHmmss").format("YYYY-MM-DD HH:mm:ss") : '';
			}
		},
		{headerName: "등록자", field: "regNm", width: 100, cellClass: 'text-center'},
		{headerName: "수정일시", field: "updDt", width: 150, cellClass: 'text-center' ,
			cellRenderer: function(params) {
				return !gagajf.isNull(params.value) ? params.value.toDate("YYYYMMDDHHmmss").format("YYYY-MM-DD HH:mm:ss") : '';
			}
		},
		{headerName: "수정자", field: "updNm", width: 100, cellClass: 'text-center'}
	];
	
	// specify the columns - 코디상품
	var columnCodiGoodsDefs = [
		{width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
		{headerName: "정렬", field: "dispOrd", width: 70 ,hide: false, cellClass: 'text-center',  rowDrag: true },
		{headerName: "CRUD", field: "crud", width: 75, minWidth: 75, hide: true},
		//{headerName: 'No', width: 60, cellClass: 'text-center', valueGetter: function(params) { return params.node.rowIndex + 1 }},
		{headerName: "이미지", field: "imgPath1", width: 100, height: 60, cellClass: 'text-center'
			,cellRenderer: function(params) {
				if (params.data.imgType == "A"){
					if(!gagajf.isNull(params.data.imgPath6)){
						return '<img width="60" src="'+ uploadGoodsUrl+params.data.imgPath6 + '" alt=""  onerror="this.src=\'/image/no.gif\';"/>';
					}else{
						return '<img width="60" src="'+ uploadGoodsUrl+params.value + '" alt=""  onerror="this.src=\'/image/no.gif\';"/>';
					}	
				}else{
					if(!gagajf.isNull(params.data.imgPath6)){
						return '<img width="60" src="'+ params.data.imgPath1 + '" alt="" onerror="this.src=\'/image/no.gif\';"/>';
					}else{
						return '<img width="60" src="'+ params.value + '" alt="" onerror="this.src=\'/image/no.gif\';"/>';
					}
					
				}
			}
		},
		{headerName: "상품코드", field: "codiGoodsCd" , width: 130, cellClass: 'text-center'},
		{headerName: "상품명", field: "goodsNm" , width: 300, cellClass: 'text-left'},
		{headerName: "판매가", field: "currPrice" , width: 100, cellClass: 'text-right'
			,valueFormatter: function(params) { return Number(params.value).addComma();}
		},
		{headerName: "상품상태", field: "goodsStat" , width: 100, cellClass: 'text-center',
			cellEditorParams: { values: gagaAgGrid.extractValues(goodsStatList) },
			valueFormatter: function (params) { return gagaAgGrid.lookupValue(goodsStatList, params.value); },
			valueParser: function (params) { return gagaAgGrid.lookupKey(goodsStatList, params.newValue); }
		},
		{headerName: "정상이월구분", field: "formalGb" , width: 100, cellClass: 'text-center',
			cellEditorParams: { values: gagaAgGrid.extractValues(formalGbList) },
			valueFormatter: function (params) { return gagaAgGrid.lookupValue(formalGbList, params.value); },
			valueParser: function (params) { return gagaAgGrid.lookupKey(formalGbList, params.newValue); }
		},
		{headerName: "Master상품코드", field: "goodsCd", width: 150, cellClass: 'text-center', hide: true}
		
	];

	// Get GridOptions
	var gridGoodsHstoryOptions = gagaAgGrid.getGridOptions(columnGoodsHstoryDefs);
	gridGoodsHstoryOptions.enableBrowserTooltips = true;
	var gridCodiGoodsOptions = gagaAgGrid.getGridOptions(columnCodiGoodsDefs);
	gridCodiGoodsOptions.enableBrowserTooltips = true;
	var gridGoodsComposeOptions = gagaAgGrid.getGridOptions(columnGoodsComposeDefs);
	gridGoodsComposeOptions.enableBrowserTooltips = true;
	// 드래그
	gridGoodsComposeOptions.suppressRowClickSelection = true;
	gridGoodsComposeOptions.rowDragManaged = true;
	//gridGoodsComposeOptions.rowDeselection = true;
	//gridGoodsComposeOptions.enableMultiRowDragging = true;
	//gridGoodsComposeOptions.rowSelection = 'multiple';
	gridCodiGoodsOptions.suppressRowClickSelection = true;
	gridCodiGoodsOptions.rowDragManaged = true;
	
	gridGoodsComposeOptions.rowHeight = 60; //이미지가 있을경우 높이 지정해야함.
	gridCodiGoodsOptions.rowHeight = 60; //이미지가 있을경우 높이 지정해야함.
	
	//기준여부 표시
	gridGoodsComposeOptions.getRowStyle = function(params) {
		if ("Y" == params.data.baseYn) {
			return { background: '#1ab394' };
		}
	}

	// 상품상세 조회
	var fnGoodsDeailSearch = function() {

		$('#goodsDetailForm').find('.tabs .tabsNav li a').attr("style", "color:#888;");

		var params = new Object();
		params.mode = $('#goodsDetailForm input[name=mode]').val();
		params.goodsCd = $('#goodsDetailForm input[name=goodsCd]').val();

		cfnAjaxSubmit("/goods/detail", "json", fnGoodDetailSearchCallback, params);
	}

	var fnGoodDetailSearchCallback = function(result) {

		$('#goodsDetailForm').find(".tabsNav > li").removeClass('on');
		$('#goodsDetailForm').find(".tabsNav > li").eq(0).addClass('on');
		$('#goodsDetailForm').find(".tabsCont > li").removeClass('on');
		$('#goodsDetailForm').find(".tabsCont > li").eq(0).addClass('on');

		if (result != null){
			//기본정보
			$('#goodsDetailForm select[name=selSupplyCompCd]').val(result.supplyCompCd);
			$('#goodsDetailForm input[name=supplyCompCd]').val(result.supplyCompCd);
			$('#goodsDetailForm input[name=brandCd]').val(result.brandCd);
			fnBrand(result.supplyCompCd, result.brandCd);

			$('#goodsDetailForm').find('#goodsCdTxt').html(result.goodsCd);
			$('#goodsDetailForm').find('#supplyGoodsCdTxt').html(result.supplyGoodsCd);

			$("#goodsDetailForm input[name=goodsImageYn]").val(result.goodsImageYn);
			$("#goodsDetailForm input[name=niClsfCd]").val(result.niClsfCd);
			$("#goodsDetailForm select[name=selNiClsfCd]").val(result.niClsfCd);
			$("#goodsDetailForm input[name=selfGoodsYn]").val(result.selfGoodsYn);
			$('#goodsDetailForm').find('#goodsNumTxt').html(result.goodsNum);
			$('#goodsDetailForm input[name=goodsNum]').val(result.goodsNum);
			$('#goodsDetailForm select[name=goodsStat]').val(result.goodsStat);
			$("#goodsDetailForm input[name=goodsStatOrg]").val(result.goodsStat);
			$('#goodsDetailForm').find('#brandGrpNmTxt').html(result.brandGrpNm);

			$('#goodsDetailForm select[name=colorCd]').val(result.colorCd);
			//cfnCreateCombo("/renderer/avail/color/list", $('#goodsDetailForm select[name=colorCd]'), "[선택]", result.colorCd);

			$('#goodsDetailForm select[name=itemkindCd]').val(result.itemkindCd);
			$('#goodsDetailForm input[name=orgItemkindCd]').val(result.itemkindCd);
			$('#goodsDetailForm select[name=seasonCd]').val(result.seasonCd);
			$('#goodsDetailForm input[name=seasonCdOrg]').val(result.seasonCd);
			$('#goodsDetailForm select[name=sexGb]').val(result.sexGb);
			$('#goodsDetailForm input[name=sexGbOrg]').val(result.sexGb);
			$('#goodsDetailForm').find('#makeNmTxt').html(result.makeNm);
			$('#goodsDetailForm').find('#styleYearTxt').html(result.styleYear);
			$('#goodsDetailForm select[name=goodsGb]').val(result.goodsGb);
			$('#goodsDetailForm input[name=goodsGbOrg]').val(result.goodsGb);

			$("#goodsDetailForm input[name=goodsNm]").val(result.goodsNm);
			$('#goodsDetailForm input[name=goodsNmOrg]').val(result.goodsNm);
			fnDataLengthCheck('goodsNm');
			$("#goodsDetailForm input[name=goodsTnm]").val(result.goodsTnm);
			$('#goodsDetailForm input[name=goodsTnmOrg]').val(result.goodsTnm);
			fnDataLengthCheck('goodsTnm');
			$("#goodsDetailForm input[name=goodsSnm1]").val(result.goodsSnm1);
			$("#goodsDetailForm input[name=goodsSnm1Org]").val(result.goodsSnm1);
			fnDataLengthCheck('goodsSnm1');
			$("#goodsDetailForm textarea[name=goodsSnmTxt]").val(result.goodsSnm);
			$("#goodsDetailForm input[name=goodsSnm]").val(result.goodsSnm);
			$('#goodsDetailForm').find('#listPriceTxt').html(result.listPrice.addComma());
			$('#goodsDetailForm input[name=listPrice]').val(result.listPrice);
			$('#goodsDetailForm input[name=currPrice]').val(result.currPrice.addComma());
			$('#goodsDetailForm input[name=currPriceOrg]').val(result.currPrice);
			$('#goodsDetailForm').find('#dcRateTxt').html(result.dcRate);
			$('#goodsDetailForm input[name=dcRate]').val(result.dcRate);
			$('#goodsDetailForm').find('#priceUpdDtTxt').html(!gagajf.isNull(result.priceUpdDt) ? result.priceUpdDt.toDate("YYYYMMDDHHmmss").format("YYYY-MM-DD") : '');
			$('#goodsDetailForm').find('#frstCfrmDtTxt').html(!gagajf.isNull(result.frstCfrmDt) ? result.frstCfrmDt.toDate("YYYYMMDDHHmmss").format("YYYY-MM-DD") : '');

			$("#goodsDetailForm input[type=radio]").parent().removeClass("checked");
			$("#goodsDetailForm input[type=radio]").removeAttr('checked');
			
			if (result.formalGb == "G009_20"){
				$("#goodsDetailForm input:radio[name=formalGb]:input[value='G009_20']").trigger('click');
			}else{
				$("#goodsDetailForm input:radio[name=formalGb]:input[value='G009_10']").trigger('click');
			}
			if (result.erpPriceLinkYn == "Y"){
				$("#goodsDetailForm input:radio[name=erpPriceLinkYn]:input[value='Y']").trigger('click');
			}else{
				$("#goodsDetailForm input:radio[name=erpPriceLinkYn]:input[value='N']").trigger('click');
			}
			if (result.selfMallYn == "Y"){
				$("#goodsDetailForm input:radio[name=selfMallYn]:input[value='Y']").trigger('click');
			}else{
				$("#goodsDetailForm input:radio[name=selfMallYn]:input[value='N']").trigger('click');
			}
			$('#goodsDetailForm').find('#sellFeeRateTxt').html(result.sellFeeRate);
			
			if (result.prePpntUsableYn == "Y"){
				$("#goodsDetailForm input:radio[name=prePpntUsableYn]:input[value='Y']").trigger('click');
			}else{
				$("#goodsDetailForm input:radio[name=prePpntUsableYn]:input[value='N']").trigger('click');
			}
			if (result.preMpntUsableYn == "Y"){
				$("#goodsDetailForm input:radio[name=preMpntUsableYn]:input[value='Y']").trigger('click');
			}else{
				$("#goodsDetailForm input:radio[name=preMpntUsableYn]:input[value='N']").trigger('click');
			}
			if (result.changeableYn == "Y"){
				$("#goodsDetailForm input:radio[name=changeableYn]:input[value='Y']").trigger('click');
			}else{
				$("#goodsDetailForm input:radio[name=changeableYn]:input[value='N']").trigger('click');
			}

			$("#goodsDetailForm input[name=formalGbOrg]").val(result.formalGb);
			$("#goodsDetailForm input[name=erpPriceLinkYnOrg]").val(result.erpPriceLinkYn);
			$("#goodsDetailForm input[name=selfMallYnOrg]").val(result.selfMallYn);
			$("#goodsDetailForm input[name=prePpntUsableYnOrg]").val(result.prePpntUsableYn);
			$("#goodsDetailForm input[name=preMpntUsableYnOrg]").val(result.preMpntUsableYn);
			$("#goodsDetailForm input[name=changeableYnOrg]").val(result.changeableYn);

			$("#goodsDetailForm input[type=radio][checked]").addClass("checked");
			//$("#goodsDetailForm input[type=radio][checked]").parent("label").addClass("checked");

			//입점상품일 경우
			if (result.selfGoodsYn == "N"){
				$('#goodsDetailForm').find('#erplinkarea').hide();
				$("#goodsDetailForm").find("#selfGoodsDpTitle").html('원코드');
				$("#goodsDetailForm").find("#selfGoodsDpTxt").html('<div id="supplyGoodsCdTxt"></div>');
				$('#goodsDetailForm').find('#supplyGoodsCdTxt').html(result.supplyGoodsCd);
			}
			$('#goodsDetailForm input[name=delvFee]').val(result.delvFee.addComma());
			$('#goodsDetailForm input[name=pntPrate]').val(result.pntPrate);
			$('#goodsDetailForm input[name=pntPrateOrg]').val(result.pntPrate);
			$('#goodsDetailForm input[name=pntMrate]').val(result.pntMrate);
			$('#goodsDetailForm input[name=pntMrateOrg]').val(result.pntMrate);
			$('#goodsDetailForm input[name=minOrdAmt]').val(result.minOrdAmt.addComma());
			$('#goodsDetailForm input[name=minOrdAmtOrg]').val(result.minOrdAmt);
			$('#goodsDetailForm input[name=minOrdQty]').val(result.minOrdQty);
			$('#goodsDetailForm input[name=minOrdQtyOrg]').val(result.minOrdQty);
			$('#goodsDetailForm input[name=maxOrdQty]').val(result.maxOrdQty);
			$('#goodsDetailForm input[name=maxOrdQtyOrg]').val(result.maxOrdQty);
			$('#goodsDetailForm input[name=dayMaxOrdQty]').val(result.dayMaxOrdQty);
			$('#goodsDetailForm input[name=dayMaxOrdQtyOrg]').val(result.dayMaxOrdQty);
			
			$('#goodsDetailForm input[name=goodsType]').val(result.goodsType);
			$("#goodsDetailForm").find("#goodsTypeNm").html(result.goodsTypeNm);
			
			//상품상세
			gagaSe.setContents('goodsPcTopDesc', result.goodsPcTopDesc);
			gagaSe.setContents('goodsMobileTopDesc', result.goodsMobileTopDesc);
			gagaSe.setContents('goodsPcDownDesc', result.goodsPcDownDesc);
			gagaSe.setContents('goodsMobileDownDesc', result.goodsMobileDownDesc);

			if (!gagajf.isNull(result.niClsfNm)){
				$('#goodsDetailForm').find('#itemkindNoti').html('품목기준 고시분류 : ' + result.niClsfNm);
				$('#goodsDetailForm input[name=niClsfNm]').val(result.niClsfNm);
				var objNotiInfo = $("#goodsDetailForm select[name=selNiClsfCd] option");
				for(var i=0;i<objNotiInfo.length; i++ ){
					if (objNotiInfo.eq(i).text() == result.niClsfNm){
						objNotiInfo.eq(i).prop("selected","true");
					}
				}
			}

			var goodsImg = "";
			var goodsImgPath1 = "";
			if (result.imgType == "G030_A"){
				if (!gagajf.isNull(result.imgPath6)){
					goodsImg = result.imgPath6;
					goodsImgPath1 = result.imgPath6;
				}else{
					goodsImg = result.imgPath1;
					goodsImgPath1 = result.imgPath1;
				}
				
			}else{
				if (!gagajf.isNull(result.imgPath6)){
					goodsImg = uploadGoodsUrl+result.imgPath6;
					goodsImgPath1 = result.imgPath6;
				}else{
					goodsImg = uploadGoodsUrl+result.imgPath1;
					goodsImgPath1 = result.imgPath1;
				}
			}
			$('#goodsDetailForm').find('#goodsImgUrl').attr('src',goodsImg);
			$('#goodsDetailForm input[name=imgPath1]').val(goodsImgPath1);
			$("#goodsDetailForm input[type=checkbox][checked]").parent("label").addClass("checked");

			//품목변경 권한 관련 처리
			//md권한
			if(sessRoleCd == "G001_A101" || sessRoleCd == "G001_B000"){
				var roleFlag = "N";
				$.each(authBrandList, function(idx, item) {
					if (result.brandCd == item.cd ){
						roleFlag = "Y";
						return false;
					}
				});
				if (roleFlag == "N"){
					$('#goodsDetailForm select[name=itemkindCd]').attr('disabled',true);
					$('#goodsDetailForm #btnGoodsItemkindChange').addClass('off');
				}
			}

			//상품 구분에 따른 컬럼 사용여부처리 start
			//세트
			if ("G056_S" == result.goodsType){
				$('#goodsDetailForm #erplinkarea').addClass('off');
				if (result.selfGoodsYn == "Y") $('#goodsDetailForm #GoodsComposeTab').css('display','block');
				$('#goodsDetailForm #goodsNotiTab').css('display','none');
			}else if ("G056_D" == result.goodsType){
				$('#goodsDetailForm #erplinkarea').addClass('off');
				$('#goodsDetailForm #erplinkarea').addClass('off');
				if (result.selfGoodsYn == "Y") $('#goodsDetailForm #GoodsComposeTab').css('display','block');
				$('#goodsDetailForm #goodsNotiTab').css('display','none');
			}
			
			//상품 구분에 따른 컬럼 사용여부처리 end
			
			var params = new Object();
			params.mode = $('#goodsDetailForm input[name=mode]').val();
			params.goodsCd = result.goodsCd;
			params.brandCd = result.brandCd;
			params.supplyCompCd = result.supplyCompCd;
			params.niClsfCd = result.niClsfCd;
			params.goodsType = result.goodsType;
			params.erpPriceLinkYn = result.erpPriceLinkYn;

			//옵셥 재고(ajax html)
			fnGoodsDetailSizeStockSearch(params);
			//정보고시
			fnGoodsDetailNotiInfoSearch(params);
			//코디상품
			fnGoodsDetailCodiSearch();
			
			//구성상품
			if ("G056_S" == result.goodsType || "G056_D" == result.goodsType){
				fnGoodsComposeListSearch(params);
			}
			//이력
			fnGoodsDetailHstSearch();

		}
	}

	//옵셥 재고
	var fnGoodsDetailSizeStockSearch = function(params) {
		cfnAjaxSubmit("/goods/detail/sizeStock/form", "html", "sizeStockArea", params);
	}

	//정보고시
	var fnGoodsDetailNotiInfoSearch = function(params) {
		cfnAjaxSubmit("/goods/detail/notiInfo/list", "json", fnGoodsDetailNotiInfoSearchCallback, params);
	}
	
	//구성상품
	var fnGoodsComposeListSearch = function(params) {
		if ("G056_S" == params.goodsType){	//세트
			gagaAgGrid.showOrHideColumn(gridGoodsComposeOptions, 'currPrice', false);
			gagaAgGrid.showOrHideColumn(gridGoodsComposeOptions, 'useYn', false);
			gagaAgGrid.showOrHideColumn(gridGoodsComposeOptions, 'extendGoodsOptNm', false);
			
			$('#GoodsComposeBtnArea').addClass("off");
		}else{	//딜
			gagaAgGrid.showOrHideColumn(gridGoodsComposeOptions, 'qty', false);
			gagaAgGrid.showOrHideColumn(gridGoodsComposeOptions, 'extendcompsCurrPrice', false);
		}
		gagaAgGrid.fetch("/goods/detail/compose/list?goodsCd=" + params.goodsCd , gridGoodsComposeOptions);
	}	
	
	//이력
	var fnGoodsDetailHstSearch = function() {
		gagaAgGrid.fetch("/goods/detail/hst/list?goodsCd=" + $('#goodsDetailForm input[name=goodsCd]').val() , gridGoodsHstoryOptions);
	}
	
	//코디상품
	var fnGoodsDetailCodiSearch = function() {
		gagaAgGrid.fetch("/goods/detail/codi/list?goodsCd=" + $('#goodsDetailForm input[name=goodsCd]').val() , gridCodiGoodsOptions);
	}
	
	//정보고시 콜백
	var fnGoodsDetailNotiInfoSearchCallback = function(result) {
		if (result == null) return;

		var notiHtml = "";
		var idx = 0;
		$('#goodsDetailForm').find('#notiArea').html('');
		notiHtml += '<table class="frmStyle">';
		notiHtml += '<colgroup><col style="width:20%"/><col/><col style="width:5%"/><col style="width:5%"/></colgroup>';
		notiHtml += '<tbody id="infoContents">\n';
		notiHtml += '<tr><th>고시항목</th><th>고시내용</th><th>필수여부</th><th>전시여부</th></tr>';
		result.forEach(function(info){
			notiHtml += '<tr><th>'+ gagajf.convNull(info.niItemNm, '') +'<input type="hidden" name="niItemCd" value="'+ gagajf.convNull(info.niItemCd, '') +'" />\n<input type="hidden" name="dispOrd" value="'+ gagajf.convNull(info.dispOrd, '') +'" /></th>';
			notiHtml += '<td><input type="text" name="niContent" value="'+ gagajf.convNull(info.niContent, '') +'"/></td>\n';
			notiHtml += '<td class="aC">'+gagajf.convNull(info.reqYn, '')+'<input type="hidden" name="reqYn" value="'+ gagajf.convNull(info.reqYn, '') +'"/></td>\n';
			notiHtml += '<td class="aC">'+gagajf.convNull(info.dispYn, '')+'<input type="hidden" name="dispYn" value="'+ gagajf.convNull(info.dispYn, '') +'"/></td>\n';
			notiHtml += '</tr>\n';
		});
		notiHtml += '</tbody></table>';

		$('#goodsDetailForm').find('#notiArea').append(notiHtml);

		//고시정보탭 변경여부
		$('#goodsDetailForm').find('#goodstab4').find("input, select, textarea").on('change', function() {
			$('#goodsDetailForm').find('.tabs .tabsNav li:eq(3) a').attr("style", "color:red;");
		});
	}

	//상품명 길이표시
	$("#goodsDetailForm input[name=goodsNm]").bind('focus focusout input keyup keydown paste change', function () {
		fnDataLengthCheck('goodsNm');
	});

	//상품타이틀 길이표시
	$("#goodsDetailForm input[name=goodsTnm]").bind('focus focusout input keyup keydown paste change', function () {
		fnDataLengthCheck('goodsTnm');
	});
	
	//사용자검색어 길이표시
	$("#goodsDetailForm input[name=goodsSnm1]").bind('focus focusout input keyup keydown paste change', function () {
		fnDataLengthCheck('goodsSnm1');
	});

	//판매가 변경시 할인율 계산
	$("#goodsDetailForm input[name=currPrice]").bind('focusout paste', function () {
		fnCurrPriceCheck();
	});

	//판매가의 할인율 확인
	var fnCurrPriceCheck = function(){
		var dcRate = 0;

		var listPrice = $("#goodsDetailForm input[name=listPrice]").val().removeComma();
		var currPrice = $("#goodsDetailForm input[name=currPrice]").val().removeComma();
		//dcRate = Math.round(100 - Math.floor((Number(currPrice) / Number(listPrice) * 100)*100)/100);
		dcRate = 100 - (Number((Number(currPrice) / Number(listPrice)).toFixed(2)) *100)

		$("#goodsDetailForm").find("#dcRateTxt").html(dcRate);
		$("#goodsDetailForm input[name=dcRate]").val(dcRate);

	}

	//판매가의 할인율 확인
	/* var fnCurrPriceCheck_org = function(){
		var dcRate = 0;

		var listPrice = $("#goodsDetailForm input[name=listPrice]").val().removeComma();
		var currPrice = $("#goodsDetailForm input[name=currPrice]").val().removeComma();
		//dcRate = Math.round(100 - Math.floor((Number(currPrice) / Number(listPrice) * 100)*100)/100);
		dcRate = 100 - (Number((Number(currPrice) / Number(listPrice)).toFixed(2)) *100)

		if (dcRate < 0){
			mcxDialog.alert('할인율이 0보다 작습니다.\n판매가를 확인해주세요.', function(){
				$("#goodsDetailForm input[name=currPrice]").focus();
			});
			return false;
		}else if (dcRate >= 90){
			gagaAlert.confirm("할인율이 90%이상입니다. 계속하시겠습니까?", function(){
				$("#goodsDetailForm").find("#dcRateTxt").html(dcRate);
				$("#goodsDetailForm input[name=dcRate]").val(dcRate);
				return true;
			},
			function(){
				$('#goodsDetailForm input[name=currPrice]').val($('#goodsDetailForm input[name=currPriceOrg]').val().addComma());
				return false;
			});

		}else{
			$("#goodsDetailForm").find("#dcRateTxt").html(dcRate);
			$("#goodsDetailForm input[name=dcRate]").val(dcRate);
			return true;
		}
	} */

	// 브랜드 조회
	var fnBrand = function(supplyCompCd, brandCd) {
		var actionUrl = '/renderer/supplyCompany/brand/list/' + supplyCompCd;

		if(sessRoleCd == "G001_B000"){
			actionUrl = '/renderer/brand/AuthBrandlist';
		}
		$("#goodsDetailForm select[name=selBrandCd] option:gt(0)").remove();

		cfnCreateCombo(actionUrl, $('#goodsDetailForm select[name=selBrandCd]'), "[선택]", brandCd);

	}

	//데이터 길이 확인
	var fnDataLengthCheck = function(id){
		var maximumByte = 200;
		var strLenEng = $('#goodsDetailForm').find('#'+id).val().length;
		var cbyteStr = 0;
		var liLenStr = 0;
		for (i = 0; i < strLenEng; i++) {
			var lsOneChar = $('#goodsDetailForm').find('#'+id).val().charAt(i);
			if (lsOneChar == "\n" || lsOneChar == "\'") {
				cbyteStr += 5; //엔터면 5를 더한다
			} else if (lsOneChar == "\"") {
				cbyteStr += 6; //쌍따옴표면 6를 더한다
			} else if (escape(lsOneChar).length > 4) {
				cbyteStr += 3; //한글이면 3를 더한다
			} else {
				cbyteStr++; //한글아니면 1을 다한다
			}
			if (cbyteStr <= maximumByte) {
				liLenStr = i + 1;
			}
		}

		// 사용자가 입력한 값이 제한 값을 초과하는지를 검사한다.
		if (parseInt(cbyteStr) > parseInt(maximumByte)) {
			mcxDialog.alertC('허용된 글자수가 초과되었습니다.\n초과된 부분은 자동으로 삭제됩니다.', {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$('#goodsDetailForm').find('#'+id).focus();
				}
			});
			var str = $('#goodsDetailForm').find('#'+id).val().substr(0, liLenStr);
			$('#goodsDetailForm').find('#'+id).val(str);
			var cbyteStr = 0;
			for (i = 0; i < $('#goodsDetailForm').find('#'+id).val().length; i++) {
				var lsOneChar = $('#goodsDetailForm').find('#'+id).val().charAt(i);
				if (lsOneChar == "\n" || lsOneChar == "\'") {
					cbyteStr += 5; //엔터면 5를 더한다
				} else if (lsOneChar == "\"") {
					cbyteStr += 6; //쌍따옴표면 6를 더한다
				} else if (escape(lsOneChar).length > 4) {
					cbyteStr += 3; //한글이면 3를 더한다
				} else {
					cbyteStr++; //한글아니면 1을 다한다
				}
			}
		}

		$('#goodsDetailForm').find('#'+id+'Len').text(cbyteStr);
	}

	//상품저장 버튼 클릭 시
	$('#btnGoodsDetailSave').click(function() {

		var optCheck = false;
		var idx = 0;

		//상품상태가 승인대기나 승인 완료일 경우
		if($("#goodsDetailForm select[name=goodsStat]").val() == "G008_40" || $("#goodsDetailForm select[name=goodsStat]").val() == "G008_90"){

			// SUPER관리자, 어드민관리자, 계정관리자. 총괄관리자, MD 를 제외하고 승인처리 할수 없음
			if ("G001_0000" != sessRoleCd && "G001_A000" != sessRoleCd && "G001_A001" != sessRoleCd && "G001_A100" != sessRoleCd && "G001_A101" != sessRoleCd ){
				if ($("#goodsDetailForm select[name=goodsStat]").val() == "G008_90" &&  $("#goodsDetailForm select[name=goodsStatOrg]").val() != "G008_90"){
					mcxDialog.alert(" '승인완료' 상태로 변경할 권한이 없습니다.");
					return false;
				}
				
			}
			//list가 등록되지 않은 상품은 상태변경 불가
			if(Number($("#goodsDetailForm input[name=listPrice]").val()) == 0){
				mcxDialog.alertC("TAG가 등록되지 않은 상품은 '승인대기'나 '승인완료' 상태로 변경할 수 없습니다.", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$("#goodsDetailForm select[name=goodsStat]").focus();
					}
				});
				return false;
			}

			//판매가가 0인  상품은 상태변경 불가
			if((gagajf.isNull($("#goodsDetailForm input[name=currPrice]").val()) || $("#goodsDetailForm input[name=currPrice]").val() == 0)){
				mcxDialog.alertC("판매가가 등록되지 않은 상품은 '승인대기'나 '승인완료' 상태로 변경할 수 없습니다.", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$("#goodsDetailForm select[name=goodsStat]").focus();
					}
				});
				return;
			}

			//사이즈정보가 등록되지 않은 상품은 상태변경 불가
			if($("#goodsDetailForm #sizeStockArea").find("#optionList tr").length == 0){
				mcxDialog.alertC("사이즈정보가 등록되지 않은 상품은 '승인대기'나 '승인완료' 상태로 변경할 수 없습니다.", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$("#goodsDetailForm select[name=goodsStat]").focus();
					}
				});
				return;
			}

			//이미지가 등록되지 않은 상품은 상태변경 불가
			if($("#goodsDetailForm input[name=goodsImageYn]").val() == "N"){
				mcxDialog.alertC("이미지가 등록되지 않은 상품은 '승인대기'나 '승인완료' 상태로 변경할 수 없습니다.", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$("#goodsDetailForm select[name=goodsStat]").focus();
					}
				});
				return;
			}

			//고시정보가 등록되지 않은 상품은 상태변경 불가 - 일반상품만 체크
			if ("G056_N" == $("#goodsDetailForm input[name=goodsType]").val()){
				if($("#goodsDetailForm #notiArea").find("#infoContents tr").length == 0){
					mcxDialog.alertC("고시정보가 등록되지 않은 상품은 '승인대기'나 '승인완료' 상태로 변경할 수 없습니다.", {
						sureBtnText: "확인",
						sureBtnClick: function() {
							$("#goodsDetailForm select[name=goodsStat]").focus();
						}
					});
					return;
				}

				idx = 0;

				$("#goodsDetailForm #notiArea").find("#infoContents tr").each(function() {
					if ("Y" == $(this).find("input[name=reqYn]").val() ||  "Y" == $(this).find("input[name=dispYn]").val()){
						if (gagajf.isNull($(this).find("input[name=niContent]").val())){
							optCheck = true;
							mcxDialog.alertC("고시정보를 입력해주세요.");
							return false;
						}
					}
					idx++;
				});
	
			}
		}

		if(optCheck) {
			return false;
		}

		//상품명
		if(gagajf.isNull($("#goodsDetailForm input[name=goodsNm]").val())){
			mcxDialog.alertC("상품명을 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=goodsNm]").focus();
				}
			});
			return;
		}

		//상품상태
		if(gagajf.isNull($("#goodsDetailForm select[name=goodsStat]").val())){
			mcxDialog.alertC("상품상태를 선택해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm select[name=goodsStat]").focus();
				}
			});
			return;
		}

		//성별
		if(gagajf.isNull($("#goodsDetailForm select[name=sexGb]").val())){
			mcxDialog.alertC("성별을 선택해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm select[name=sexGb]").focus();
				}
			});
			return;
		}

		//시즌
		if(gagajf.isNull($("#goodsDetailForm select[name=seasonCd]").val())){
			mcxDialog.alertC("시즌을 선택해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm select[name=seasonCd]").focus();
				}
			});
			return;
		}

		//판매가
		if(gagajf.isNull($("#goodsDetailForm input[name=currPrice]").val())) {
			mcxDialog.alertC("판매가를 올바르게 입력해주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=currPrice]").focus();
				}
			});
			return false;
		}
		
		/* if(Number($("#goodsDetailForm input[name=currPrice]").val().removeComma()) < 1000) {
			mcxDialog.alertC("판매가는 1000원 이상을 입력하셔야 합니다.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=currPrice]").focus();
				}
			});
		} */

		//정상가와 판매가 비교
		if(Number($("#goodsDetailForm input[name=listPrice]").val().removeComma()) < Number($("#goodsDetailForm input[name=currPrice]").val().removeComma())) {
			mcxDialog.alertC("판매가를 올바르게 입력해주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=currPrice]").focus();
				}
			});
			return false;
		}
		
		// 포인트
		if ( gagajf.isNull($("#goodsDetailForm input[name=pntPrate]").val())) {
			mcxDialog.alertC("PC 포인트를 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=pntPrate]").focus();
				}
			});
			return false;
		}
		if ( gagajf.isNull($("#goodsDetailForm input[name=pntMrate]").val())) {
			mcxDialog.alertC("MOBILE 포인트를 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=pntMrate]").focus();
				}
			});
			return false;
		}

		// 주문수량
		if ( gagajf.isNull($("#goodsDetailForm input[name=minOrdQty]").val())) {
			mcxDialog.alertC("최소주문 수량을 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=minOrdQty]").focus();
				}
			});
			return false;
		}
		if (Number($("#goodsDetailForm input[name=minOrdQty]").val()) <= 0) {
			mcxDialog.alertC("최소주문 수량을 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=minOrdQty]").focus();
				}
			});
			return false;
		}
		if ( gagajf.isNull($("#goodsDetailForm input[name=maxOrdQty]").val())) {
			mcxDialog.alertC("최대주문 수량을 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=maxOrdQty]").focus();
				}
			});
			return false;
		}
		if (Number($("#goodsDetailForm input[name=maxOrdQty]").val()) <= 0) {
			mcxDialog.alertC("최대주문 수량을 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=maxOrdQty]").focus();
				}
			});
			return false;
		}
		if ( gagajf.isNull($("#goodsDetailForm input[name=dayMaxOrdQty]").val())) {
			mcxDialog.alertC("ID당1일최대구매 수량을 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=dayMaxOrdQty]").focus();
				}
			});
			return false;
		}
		if (Number($("#goodsDetailForm input[name=dayMaxOrdQty]").val()) <= 0) {
			mcxDialog.alertC("ID당1일최대구매 수량을 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=dayMaxOrdQty]").focus();
				}
			});
			return false;
		}

		if(Number($("#goodsDetailForm input[name=minOrdQty]").val()) > Number($("#goodsDetailForm input[name=maxOrdQty]").val())){
			mcxDialog.alertC("최소주문수량은 최대주문수량보다 클 수 없습니다.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=minOrdQty]").focus();
				}
			});
			return false;
		}
		
		if(Number($("#goodsDetailForm input[name=maxOrdQty]").val()) > Number($("#goodsDetailForm input[name=dayMaxOrdQty]").val())){
			mcxDialog.alertC("최대주문수량이 ID당1일최대구매수량보다 클 수 없습니다.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=maxOrdQty]").focus();
				}
			});
			return false;
		}

		// 무료배송비
		if ( gagajf.isNull($("#goodsDetailForm input[name=minOrdAmt]").val())) {
			mcxDialog.alertC("무료 배송 금액을 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=minOrdAmt]").focus();
				}
			});
			return false;
		}
		if (Number($("#goodsDetailForm input[name=minOrdAmt]").val().removeComma()) <= 0) {
			mcxDialog.alertC("무료 배송 금액을 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=minOrdAmt]").focus();
				}
			});
			return false;
		}

		//if (optCheck) return false;

		idx = 0;

		//재고 옵션 관련 확인
		$("#goodsDetailForm input[name=chStockDataYn]").val('N');

		$("#optionList tr").each(function() {
			var optNm1 = $(this).find("input[name=optNm1]").val();
			var optNm2 = $(this).find("input[name=optNm2]").val();
			var hidOptNm1 = $(this).find("input[name=hidOptNm1]").val();
			var hidOptNm2 = $(this).find("input[name=hidOptNm2]").val();
			var baseStockQty = $(this).find("input[name=baseStockQty]").val();
			var hidBaseStockQty = $(this).find("input[name=hidBaseStockQty]").val();
			var dispOrd = $(this).find("input[name=dispOrd]").val();
			var hidDispOrd = $(this).find("input[name=hidDispOrd]").val();
			var dispYn = $(this).find("select[name=dispYn]").val();
			var hidDispYn = $(this).find("input[name=hidDispYn]").val();
			var soldoutYn = $(this).find("select[name=soldoutYn]").val();
			var hidSoldoutYn = $(this).find("input[name=hidSoldoutYn]").val();

			var editCurrStockQty = $(this).find("input[name=editCurrStockQty]").val();	// 입점 확인용
			var currStockQty = $(this).find("input[name=currStockQty]").val();	// 입점 확인용 (hidden)
			
			if(gagajf.isNull(dispOrd)){
				optCheck = true;
				mcxDialog.alertC("우선순위를 입력해주세요", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$("#optionList tr").find("input[name=dispOrd]").eq(idx).focus();
					}
				});
				return false;
			}

			//ERP재고연동여부가 'Y'일 경우 수정여부 확인
		/* 	if ( $('#goodsDetailForm input[name=erpStockLinkYn]:checked').val() == "Y"){
				if (Number(editCurrStockQty) != Number(currStockQty) ){
					optCheck = true;
					mcxDialog.alertC("ERP가용재고가 변경되었습니다.<br/>확인해주세요", {
						sureBtnText: "확인",
						sureBtnClick: function() {
							$("#optionList tr").find("input[name=erpStockLinkYn]").eq(idx).focus();
						}
					});
					return false;
				}
			} */

			// 입점만 체크
			if ("N" == $('#goodsDetailForm input[name=selfGoodsYn]').val()){
				
				if(gagajf.isNull(editCurrStockQty)){
					optCheck = true;
					mcxDialog.alertC("가용재고를 입력해주세요", {
						sureBtnText: "확인",
						sureBtnClick: function() {
							$("#optionList tr").find("input[name=editCurrStockQty]").eq(idx).focus();
						}
					});
					return false;
				}
			}
			
			if(gagajf.isNull(baseStockQty)){
				optCheck = true;
				mcxDialog.alertC("안전재고를 입력해주세요", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$("#optionList tr").find("input[name=baseStockQty]").eq(idx).focus();
					}
				});
				return false;
			}
			
			if (optNm1 != hidOptNm1){
				$("#goodsDetailForm input[name=chStockDataYn]").val('Y');
			}
			
			if (optNm2 != hidOptNm2){
				$("#goodsDetailForm input[name=chStockDataYn]").val('Y');
			}
			
			if (editCurrStockQty != currStockQty){
				$("#goodsDetailForm input[name=chStockDataYn]").val('Y');
			}
			
			if (baseStockQty != hidBaseStockQty){
				$("#goodsDetailForm input[name=chStockDataYn]").val('Y');
			}
			
			if (dispOrd != hidDispOrd){
				$("#goodsDetailForm input[name=chStockDataYn]").val('Y');
			}

			if (dispYn != hidDispYn){
				$("#goodsDetailForm input[name=chStockDataYn]").val('Y');
			}
			
			if (soldoutYn != hidSoldoutYn){
				$("#goodsDetailForm input[name=chStockDataYn]").val('Y');
			}

			idx++;
		});

		if(optCheck) {
			return false;
		}

		var dcRate = 0;
		var listPrice = $("#goodsDetailForm input[name=listPrice]").val().removeComma();
		var currPrice = $("#goodsDetailForm input[name=currPrice]").val().removeComma();
		dcRate =  100 - Math.floor(Number(currPrice) / Number(listPrice) * 100);	//절사
			
		if (dcRate < 0){
			mcxDialog.alertC('할인율이 0보다 작습니다.\n판매가를 확인해주세요.', {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=currPrice]").focus();
				}
			});
			return false;
		}else if (dcRate >= 90){
			mcxDialog.confirmC("할인율이 90%이상입니다. 계속하시겠습니까?", {
				btn: ["아니요","예"],
				btnClick: function(index){
					if (index == 1){
						optCheck = true;
					} else {
						fnNoticheck();
					}
				}
			});

		}else{
			$("#goodsDetailForm").find("#dcRateTxt").html(dcRate);
			$("#goodsDetailForm input[name=dcRate]").val(dcRate);
			
		}

		
		if (optCheck) return false;
		
		if (!fnGoodsComposeCheck()) return false;
		
		//fnNoticheck();

		if($("#goodsDetailForm input:checkbox[name=chkDescKeep]").is(':checked')){
			mcxDialog.confirmC("'정보유지' 체크박스가 선택되어 있어 '상품상세설명' 항목이 저장되지 않습니다.<br/>저장을 원하시면 체크를 해제하세요. 계속하시겠습니까?", {
				btn: ["아니요","예"],
				btnClick: function(index){
					if (index == 1){
						optCheck = true;
					} else {
						fnGoodsSave();
					}
				}
			});
		}else{
			fnGoodsSave();
		}
		
		if (optCheck) return false;
		
		
	});

	// 구성 정보 관련 체크
	var fnGoodsComposeCheck = function(){
		if ($("#goodsDetailForm input[name=goodsType]").val() == "G056_N"){
			return true;	
		}
		
		var allData = gagaAgGrid.getAllRowData(gridGoodsComposeOptions);
		var comSupplyCompCd = '';
		var comSelfGoodsYn = '';
		//기준여부 Y  존재하는지 확인
		var checkBaseYn = false;
		optCheck = false;
		$.each(allData, function(index, item) {
			if (index == 0){
				comSelfGoodsYn = item.selfGoodsYn;
				comSupplyCompCd = item.supplyCompCd;
			}
			
			if (item.baseYn == "Y"){
				checkBaseYn = true;
			}
			
			if (comSelfGoodsYn != item.selfGoodsYn){
				optCheck = true;
				mcxDialog.alertC("구상상품중 자사/입점상품 구분값이 다릅니다.<br/>확인해 주세요", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						gridGoodsComposeOptions.api.setFocusedCell(index, "goodsCd", null);
					}
				});	
				return false;
			}else{
				if (comSelfGoodsYn == "N" && (comSupplyCompCd != item.supplyCompCd)){
					optCheck = true;
					mcxDialog.alertC("구상상품중 입점은 같은 업체 상품만 가능합니다.<br/>확인해 주세요", {
						sureBtnText: "확인",
						sureBtnClick: function() {
							gridGoodsComposeOptions.api.setFocusedCell(index, "goodsCd", null);
						}
					});	
					return false;
				}
			}
			
		});
		
		if(optCheck) {
			return false;
		}
		
		if (!checkBaseYn){
			mcxDialog.alert('구성상품중 기준여부를 선택해 주세요.');
			return false;
		}
		
		return true;
	}

	//저장처리
	var fnGoodsSave = function(){
		mcxDialog.confirm('저장하시겠습니까?', {
			cancelBtnText: "취소",
			sureBtnText: "확인",
			sureBtnClick: function(){
				//gagaSe.getContents('goodsDesc');
				gagaSe.getContents('goodsPcTopDesc');
				gagaSe.getContents('goodsMobileTopDesc');
				gagaSe.getContents('goodsPcDownDesc');
				gagaSe.getContents('goodsMobileDownDesc');

				fnGoodsDeailNotiSave();

				if (fnChangeCheck()){
					$("#goodsDetailForm input[name=chDataYn]").val('Y');
				}else{
					$("#goodsDetailForm input[name=chDataYn]").val('N');
				}
				
				// 코디 상품
				var codiGoodsData = gagaAgGrid.getAllRowData(gridCodiGoodsOptions);
				var jsonDataCodiGoods = JSON.stringify(codiGoodsData);
				$('#goodsDetailForm input[name=codiGoodsList]').val(jsonDataCodiGoods);
				
				//구성상품
				var allData = gagaAgGrid.getAllRowData(gridGoodsComposeOptions);
				var jsonData = JSON.stringify(allData);
				$('#goodsDetailForm input[name=GoodsComposeList]').val(jsonData);
				
				$('#goodsDetailForm input[name=goodsNm]').val($('#goodsDetailForm input[name=goodsNm]').val().trim().replace(/\n|\r/g, "<br/>").replace(/\"/gi, "&quot;").replace(/\'/gi, "&#39;"));
				$('#goodsDetailForm input[name=goodsTnm]').val($('#goodsDetailForm input[name=goodsTnm]').val().trim().replace(/\n|\r/g, "<br/>").replace(/\"/gi, "&quot;").replace(/\'/gi, "&#39;"));
				$('#goodsDetailForm input[name=goodsSnm1]').val($('#goodsDetailForm input[name=goodsSnm1]').val().trim().replace(/\n|\r/g, "<br/>").replace(/\"/gi, "&quot;").replace(/\'/gi, "&#39;"));
	
				gagajf.ajaxFormSubmit("/goods/detail/save", "#goodsDetailForm", fnGoodsSaveCallBack); 
			}
		});
	}

	//미리보기 클릭 시
	$('#btnGoodsDetailPreview').click(function(e) {
		cfnOpenFrontGoodsPopup($('#goodsDetailForm input[name=goodsCd]').val(), $('#goodsDetailForm input[name=siteCd]').val());
	});

	//이미지 클릭 시
	$('#btnGoodsDetailImg').click(function(e) {
		cfnOpenGoodsImagePopup($('#goodsDetailForm input[name=goodsCd]').val());
	});
	
	//창종료
	var fnGoodsDetailClose = function(){
		uiPopupClose('popupGoodsDetail');
	}

	//저장후 callback
	var fnGoodsSaveCallBack = function(){
		var goodsCd = $('#goodsDetailForm input[name=goodsCd]').val();
		fnGoodsDetailClose();
		cfnOpenGoodsDetailPopup('U', goodsCd);
	}

	//고시정보 저장을 위한 데이터 처리
	var fnGoodsDeailNotiSave = function(){

		var goodsCd = $('#goodsDetailForm input[name=goodsCd]').val();
		var goodsInfoList = [];

		var index = 0;
		$("#goodsDetailForm").find("#infoContents tr").each(function() {
			if (index > 0){
				var goodsInfo = {goodsCd: goodsCd
						, niClsfCd : $('#goodsDetailForm input[name=niClsfCd]').val()
						, niItemCd : $(this).find("input[name=niItemCd]").val()
						, niContent : $(this).find("input[name=niContent]").val()
						, dispOrd : $(this).find("input[name=dispOrd]").val()
						};
				goodsInfoList.push(goodsInfo);	
			}
			index++;
		});

		$("#goodsDetailForm input[name=notiList]").val(JSON.stringify(goodsInfoList));
	}

	//상품기본정보 변경여부 확인
	var fnChangeCheck = function(){
		
		//상품타이틀
		if ($("#goodsDetailForm input[name=goodsTnmOrg]").val() != $("#goodsDetailForm input[name=goodsTnm]").val()){
			return true;
		}
		//사용자검색어
		if ($("#goodsDetailForm input[name=goodsSnm1Org]").val() != $("#goodsDetailForm input[name=goodsSnm1]").val()){
			return true;
		}
		//상품명
		if ($("#goodsDetailForm input[name=goodsNmOrg]").val() != $("#goodsDetailForm input[name=goodsNm]").val()){
			return true;
		}
		//상품정상이월구분
		if ($("#goodsDetailForm input[name=formalGbOrg]").val() != $("input:radio[name=formalGb]:checked").val()){
			return true;
		}
		//상품구분
		if ($("#goodsDetailForm input[name=goodsGbOrg]").val() != $("input:radio[name=goodsGb]:checked").val()){
			return true;
		}
		//상품상태
		if ($("#goodsDetailForm input[name=goodsStatOrg]").val() != $("#goodsDetailForm select[name=goodsStat]").val()){
			return true;
		}
		//시즌
		if ($("#goodsDetailForm input[name=seasonCdOrg]").val() != $("#goodsDetailForm select[name=seasonCd]").val()){
			return true;
		}
		//성별
		if ($("#goodsDetailForm input[name=sexGbOrg]").val() != $("#goodsDetailForm select[name=sexGb]").val()){
			return true;
		}
		//판매가
		if ($("#goodsDetailForm input[name=currPriceOrg]").val() != $("#goodsDetailForm input[name=currPrice]").val().removeComma()){
			return true;
		}
		
		//자사일경우만
		if($("#goodsDetailForm input[name=selfGoodsYn]").val() == 'Y' ){
			//ERP재고연동여부
			if ($("#goodsDetailForm input[name=erpStockLinkYnOrg]").val() != $("input[name=erpStockLinkYn]:checked").val()){
				return true;
			}
		}
		//자사몰 노출여부
		if ($("#goodsDetailForm input[name=selfMallYnOrg]").val() != $("input[name=selfMallYn]:checked").val()){
			return true;
		}
		//PC포인트 
		if ($("#goodsDetailForm input[name=pntPrateOrg]").val() != $("#goodsDetailForm input[name=pntPrate]").val()){
			return true;
		}
		//PC 선포인트 사용여부
		if ($("#goodsDetailForm input[name=prePpntUsableYnOrg]").val() != $("input[name=prePpntUsableYn]:checked").val()){
			return true;
		}
		//MOBILE포인트
		if ($("#goodsDetailForm input[name=pntMrateOrg]").val() != $("#goodsDetailForm input[name=pntMrate]").val()){
			return true;
		}
		//MOBILE 선포인트 사용여부
		if ($("#goodsDetailForm input[name=preMpntUsableYnOrg]").val() != $("input[name=preMpntUsableYn]:checked").val()){
			return true;
		}
		//최소주문수량
		if ($("#goodsDetailForm input[name=minOrdQtyOrg]").val() != $("#goodsDetailForm input[name=minOrdQty]").val()){
			return true;
		}
		//최대주문수량
		if ($("#goodsDetailForm input[name=maxOrdQtyOrg]").val() != $("#goodsDetailForm input[name=maxOrdQty]").val()){
			return true;
		}
		//ID당1일최대구매수량
		if ($("#goodsDetailForm input[name=dayMaxOrdQtyOrg]").val() != $("#goodsDetailForm input[name=dayMaxOrdQty]").val()){
			return true;
		}
		//무료배송기준
		if ($("#goodsDetailForm input[name=minOrdAmtOrg]").val() != $("#goodsDetailForm input[name=minOrdAmt]").val().removeComma()){
			return true;
		}

		return false;
	}

	// 상품 고시 선택 버튼 클릭 시
	$('#btnNotinfo').click(function(e) {

		if(gagajf.isNull($("#goodsDetailForm select[name=selNiClsfCd]").val())) {
			mcxDialog.alertC("상품정보제공 고시를 선택해주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm select[name=selNiClsfCd]").focus();
				}
			});
			return false;
		}

		// 고시정보 수정은 맘대로 할수 있음 20200821 신현장 부장 확인
		/* if ($("#goodsDetailForm input[name=niClsfCd]").val() != $("#goodsDetailForm select[name=selNiClsfCd]").val()){
			mcxDialog.alertC("상품의 고시분류는 [" + $("#goodsDetailForm input[name=niClsfNm]").val() +"] 입니다."  , {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm select[name=selNiClsfCd]").focus();
				}
			});
			return false;
		} */

		var params = new Object();
		params.supplyCompCd = $("#goodsDetailForm input[name=supplyCompCd]").val();
		params.niClsfCd = $("#goodsDetailForm select[name=selNiClsfCd]").val();
		params.goodsCd = $("#goodsDetailForm input[name=goodsCd]").val();
		cfnAjaxSubmit("/goods/noti/goodsInfo/list", "json", fnGoodsDetailNotiInfoSearchCallback, params);

	});

	// 품목변경
	$("#btnGoodsItemkindChange").on("click", function(){

		if($("#goodsDetailForm  select[name=itemkindCd]").val() == $("#goodsDetailForm  input[name=orgItemkindCd]").val()){
			mcxDialog.alert("품목코드가 변경되지 않았습니다.");
			return false;
		}

		mcxDialog.confirm('품목변경 하시겠습니까?', {
			cancelBtnText: "취소",
			sureBtnText: "확인",
			sureBtnClick: function(){
				var data = [{  goodsCd : $('#goodsDetailForm input[name=goodsCd]').val()
						, itemkindCd : $("#goodsDetailForm  select[name=itemkindCd]").val()
						, supplyCompCd : $("#goodsDetailForm  input[name=supplyCompCd]").val()
						}];
				var jsonData = JSON.stringify(data);
				gagajf.ajaxJsonSubmit('/goods/itemKind/change/save', jsonData, fnGoodsDeailSearch);
			}
		});
	});
	
	// 구성상품 조회 팝업
	var fnOpenGoodsDetailPopup = function() {
		cfnOpenGoodsPopup('fnGoodsDetailGoodsDeal');
	}

	// 구성상품 조회 팝업 - 상품추가
	var fnGoodsDetailGoodsDeal = function(goodsData) {
		if (goodsData.length < 1) return;
		
		// 기존상품
		var oldGoodsDealList = gagaAgGrid.getAllRowData(gridGoodsComposeOptions);
		var idx = oldGoodsDealList.length+1; 
		
		var isExist = false;
		goodsData.forEach(function(goods){
			isExist = false;

			gridGoodsComposeOptions.api.forEachNode(function(rowNode, index) {

				if (goods.goodsCd == rowNode.data.extendGoodsCd){
					isExist = true;
				}
			});
			
			if (goods.goodsType != 'N'){
				isExist = true;
			}
			if(!isExist){
				
				var data = { 
						  goodsCd : $('#goodsDetailForm input[name=goodsCd]').val()
						, extendGoodsCd: goods.goodsCd
						, goodsType: $('#goodsDetailForm input[name=goodsType]').val()
						, dispOrd: idx
						, qty: 1
						, compsCurrPrice: goods.currPrice
						, extendStaffCurrPrice: goods.currPrice
						, baseYn: 'N'
						, goodsStat : goods.goodsStat
						, useYn: 'Y'
						, extendGoodsOptNm : goods.goodsNm
						, extendGoodsCdNm : goods.goodsNm
						, currPrice : goods.currPrice
						, selfGoodsYn : goods.selfGoodsYn
						, imgType : goods.imgType
						, imgPath1 : goods.imgPath1
						, imgPath6 : goods.imgPath6
						};
				gridGoodsComposeOptions.api.updateRowData({add: [data], addIndex: idx});
				
				idx++;
			
			}
		});
		gridGoodsComposeOptions.api.refreshCells();
	}
	
	// 코디상품 조회 팝업
	var fnOpenCodiGoodsPopup = function() {
		cfnOpenGoodsPopup('fnGoodsDetailCodiGoods');
	}

	// 코디상품 조회 팝업 - 상품추가
	var fnGoodsDetailCodiGoods = function(goodsData) {
		if (goodsData.length < 1) return;
		
		// 기존상품
		var oldCodiGoodsList = gagaAgGrid.getAllRowData(gridCodiGoodsOptions);
		var idx = oldCodiGoodsList.length+1; 
		var goodsCd = $('#goodsDetailForm input[name=goodsCd]').val();
		var isExist = false;
		goodsData.forEach(function(goods){
			isExist = false;

			gridCodiGoodsOptions.api.forEachNode(function(rowNode, index) {

				if (goods.goodsCd == rowNode.data.codiGoodsCd){
					isExist = true;
				}
			});
			
			if (goods.goodsCd == goodsCd) {
				isExist = true;
			}
			
			if(!isExist){
				
				var data = { 
						  goodsCd : goodsCd
						, codiGoodsCd: goods.goodsCd
						, dispOrd: idx
						, delYn: 'N'
						, goodsStat : goods.goodsStat
						, goodsNm : goods.goodsNm
						, currPrice : goods.currPrice
						, formalGb : goods.formalGb
						, imgType : goods.imgType
						, imgPath1 : goods.imgPath1
						, imgPath6 : goods.imgPath6
						};
				gridCodiGoodsOptions.api.updateRowData({add: [data], addIndex: idx});
				
				idx++;
			
			}
		});
		gridGoodsComposeOptions.api.refreshCells();
	}

	// 코디 상품 삭제
	$('#btnCodiGoodsDelete').on('click', function() {
		var selectedData = gridCodiGoodsOptions.api.getSelectedRows();
		if (selectedData.length == 0) {
			mcxDialog.alert('선택된 행이 없습니다.');
			return;
		}

		//화면에서 삭제
		//var removedData_1 = gagaAgGrid.removeRowData(gridCodiGoodsOptions, false);

		var removedData = gagaAgGrid.removeRowData(gridCodiGoodsOptions, false);
		
		if (removedData.length > 0) {

			mcxDialog.confirm('삭제하시겠습니까?', {
				cancelBtnText: "취소",
				sureBtnText: "확인",
				sureBtnClick: function(){
					var deleteData = [];

					$.each(removedData, function(idx, item) {
						deleteData.push(item);
					});

					var jsonData = JSON.stringify(deleteData);
					gagajf.ajaxJsonSubmit('/goods/codi/delete', jsonData);
				}
			});
		}
	});
	
	//엑셀 상품 조회
	$('#btnGoodsDealSearchExcel').on('click', function() {
		cfnExcelUploadPopup('goodsDetailExcelUpload', 'goodsDetailExcelUpload');
	});

	var goodsDetailExcelUpload = function(result){
		var data = {procJob : result.procJob
			,excelFileNm : result.excelFileNm
		};
		var jsonData = JSON.stringify(data);
		gagajf.ajaxJsonSubmit('/goods/search/excelupload/save', jsonData, goodsDetailExcelUploadCallBack);
	}

	var goodsDetailExcelUploadCallBack = function(result){
		gagajf.ajaxJsonSubmit('/goods/excel/upload/goods/list', '', fnGoodsDetailSearchExcel);
	}
	
	var fnGoodsDetailSearchExcel = function(result){
		fnGoodsDetailGoodsDeal(result.goodsExcelList);
	}
		
	$("img").on("error", function () {
		$(this).attr("src",  _uximgUrl+"/image/no.gif");
	});
	
	$(document).ready(function() {

		/* gagaSe.createSmartEditor(seOptions, 'goodsDesc'); */
		gagaSe.createSmartEditor(seOptions, 'goodsPcTopDesc');
		gagaSe.createSmartEditor(seOptions, 'goodsMobileTopDesc');
		gagaSe.createSmartEditor(seOptions, 'goodsPcDownDesc');
		gagaSe.createSmartEditor(seOptions, 'goodsMobileDownDesc');

		gagaAgGrid.createGrid('gridGoodsHstoryList', gridGoodsHstoryOptions);
		gagaAgGrid.createGrid('gridGoodsCodiList', gridCodiGoodsOptions);
		gagaAgGrid.createGrid('gridGoodsComposeList', gridGoodsComposeOptions);

		fnGoodsDeailSearch();

		//기본정보탭 변경여부
		$('#goodsDetailForm').find('#goodstab1').find("input, select, textarea").on('change', function() {
			$('#goodsDetailForm').find('.tabs .tabsNav li:eq(0) a').attr("style", "color:red;");
		});

	});
	
/*]]>*/
</script>
</html>
