<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : GoodsListForm.html
 * @desc    : 상품목록 Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.10.19   eskim       최초 작성
 *******************************************************************************
 -->
	<div id="main">
		<!-- 메인타이틀 영역 -->
		<div class="main-title">
		</div>
		<!-- //메인타이틀 영역 -->
		
		<!-- 메뉴 설명 -->
		<div class="infoBox menu-desc">
		</div>
		<form id="searchForm" name="searchForm" action="#" th:action="@{'/goods/list'}" >
		<input type="hidden" id="searchGb" name="searchGb" />
		<input type="hidden" id="imageViewYn" name="imageViewYn" />
		<input type="hidden" id="goodsPriceYn" name="goodsPriceYn" value="Y"/> <!-- 즉시할인판매가 조회 -->
		
			<!-- 패널 영역1 -->
		<div class="panelStyle" >
			<!-- 검색조건 영역 -->
			<!-- TITLE -->
			<div class="panelTitle">
				<h3><i class="fa fa-info-circle"></i>아래 검색조건 중 <font color="red">업체, 브랜드, 키워드, 발생일</font>중 하나를 꼭 입력해 주세요.</h3>
				<span class="panelControl">
					<i class="fa fa-chevron-up"></i>
				</span>
			</div>
			<!-- //TITLE -->
			<div class="panelContent">
				<table class="frmStyle">
					<colgroup>
						<col style="width: 7%;"/>
						<col/>
						<col style="width: 7%;"/>
						<col style="width: 16%;"/>
						<col style="width: 7%;"/>
						<col style="width: 18%;"/>
						<col style="width: 7%;"/>
						<col style="width: 16%;"/>
					</colgroup>
					<tr>
						<th>업체<em class="required" title="필수"></em></th>
						<td>
							<input type="text" class="w100" name="supplyCompSearchTxt" id="supplyCompSearchTxt" maxlength="20" />
							<button type="button" class="btn icn" id="btnSearchSupplyComp"><i class="fa fa-search"></i></button>
							<span id="supplyCompText"></span>
							<input type="hidden" name="supplyCompList"/>
						</td>
						<th>브랜드<em class="required" title="필수"></em></th>
						<td>
							<input type="text" class="w100" name="searchTxt" id="searchTxt" maxlength="20" />
							<button type="button" class="btn icn" id="btnSearchBrand"><i class="fa fa-search"></i></button>
							<span id="brandText"></span>
							<input type="hidden" name="brandList"/>
						</td>
						<th>상품타입</th>
						<td>
							<select name="goodsType" id="goodsType">
								<option value="">[전체]</option>
								<option th:if="${goodsTypeList}" th:each="oneData, status : ${goodsTypeList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
						</td>
						<th rowspan="4">키워드<em class="required" title="필수"></em></th>
						<td rowspan="4">
							<select name="search" id="search">
								<option value="searchGoodsCd">상품코드</option>
								<option value="searchGoodsNm">상품명</option>
								<option value="searchGoodsNum">품번</option>
								<option value="searchSupplyGoodsCd">업체상품코드</option>
							</select>
							<textarea class="textareaR3 w70p" name="condition" id="condition"></textarea>
						</td>
					</tr>
					<tr>
						<th>품목</th>
						<td>
							<!-- <div class="multiCheckBox"  style="width:300px">
								<button type="button" class="sltBtn" data-name="[전체]">[전체]</button>
								<ul style="overflow:auto; height:170px;" id="grpItemkind">
									<li><label class="chkBox" onclick="uifnAllCheck(this,'grpItemkind')"><input type="checkbox" name="전체선택" >전체선택</label></li>
									<li th:if="${itemkindList}" th:each="oneData, status : ${itemkindList}"><label class="chkBox" data-group="grpItemkind"><input type="checkbox" name="multiItemkindCd" th:id="${'itemkindCd' + oneData.cd}" th:value="${oneData.cd}" ><th:block th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></th:block></label></li>
								</ul>
							</div> -->
							
							<input type="text" class="w100" name="itemkindSearchTxt" id="itemkindSearchTxt" maxlength="20" />
							<button type="button" class="btn icn" id="btnSearchItemkind"><i class="fa fa-search"></i></button>
							<span id="itemkindText"></span>
							<input type="hidden" name="itemkindList"/>
						</td>
						<th>상품상태</th>
						<td>
							<div class="multiCheckBox"  style="width:200px">
								<button type="button" class="sltBtn" data-name="[전체]">[전체]</button>
								<ul style="overflow:auto; height:170px" id="grpGoodsStat">
									<li><label class="chkBox" onclick="uifnAllCheck(this,'grpGoodsStat')"><input type="checkbox" name="전체선택" >전체선택</label></li>
									<li th:if="${goodsStatList}" th:each="oneData, status : ${goodsStatList}"><label class="chkBox" data-group="grpGoodsStat"><input type="checkbox" name="multiGoodsStat" th:id="${'goodsStat' + oneData.cd}" th:value="${oneData.cd}" ><th:block th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></th:block></label></li>
								</ul>
							</div>
						</td>
						<th>정상/이월 구분</th>
						<td>
							<select  name="formalGb" id="formalGb">
								<option value="">[전체]</option>
								<option th:if="${formalGbList}" th:each="oneData, status : ${formalGbList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
						</td>
					</tr>
					<tr>
						<th>년도/시즌</th>
						<td>
							<div class="multiCheckBox" style="width:140px;">
								<button type="button" class="sltBtn" data-name="[전체]">[전체]</button>
								<ul style="overflow:auto; height:140px" id="grpStyle">
									<li><label class="chkBox" onclick="uifnAllCheck(this,'grpStyle')"><input type="checkbox" name="전체선택" id="multiStyleYear" >전체선택</label></li>
									<li th:if="${styleYearList}" th:each="oneData, status : ${styleYearList}"><label class="chkBox" data-group="grpStyle"><input type="checkbox" name="multiStyleYear" th:id="${'styleYear' + oneData.cd}" th:value="${oneData.cd}" ><th:block th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></th:block></label></li>
								</ul>
							</div>
							<div class="multiCheckBox" style="width:170px;">
								<button type="button" class="sltBtn" data-name="[전체]">[전체]</button>
								<ul style="overflow:auto; height:170px" id="grpSeason">
									<li><label class="chkBox" onclick="uifnAllCheck(this,'grpSeason')"><input type="checkbox" name="전체선택" id="multiSeasonCd" >전체선택</label></li>
									<li th:if="${seasonList}" th:each="oneData, status : ${seasonList}"><label class="chkBox" data-group="grpSeason"><input type="checkbox" name="multiSeasonCd" th:id="${'seasonCd' + oneData.cd}" th:value="${oneData.cd}" ><th:block th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></th:block></label></li>
								</ul>
							</div>		
						</td>
						<th>연령대</th>
						<td>
							<select  name="ageGrpCd" id="ageGrpCd">
								<option value="">[전체]</option>
								<option th:if="${ageGrpCdList}" th:each="oneData, status : ${ageGrpCdList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
						</td>
						<th>성별</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>
						</td>
					</tr>
					<tr>
						<th>재고연동여부</th>
						<td>
							<select  name="erpStockLinkYn" id="erpStockLinkYn">
								<option value="">[전체]</option>
								<option th:if="${useYnList}" th:each="oneData, status : ${useYnList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
						</td>
						<th>자사몰노출여부</th>
						<td>
							<select  name="selfMallYn" id="selfMallYn">
								<option value="">[전체]</option>
								<option th:if="${useYnList}" th:each="oneData, status : ${useYnList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
						</td>
						<th>품절여부</th>
						<td>
							<select  name="soldOutYn" id="soldOutYn">
								<option value="">[전체]</option>
								<option th:if="${useYnList}" th:each="oneData, status : ${useYnList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
						</td>
					</tr>
					<tr>
						<th>반품가능여부</th>
						<td>
							<select  name="returnableYn" id="returnableYn">
								<option value="">[전체]</option>
								<option th:if="${useYnList}" th:each="oneData, status : ${useYnList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
						</td>
						<th>담당MD</th>
						<td>
							<select  name="mdId" id="mdId">
								<option value="">[전체]</option>
								<option th:if="${brandMdList}" th:each="oneData, status : ${brandMdList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}"></option>
							</select>
						</td>
						<th>판매가</th>
						<td>
							<input type="text" class="w90 aR" name="currPriceSt" id="currPriceSt" maxlength="10" data-valid-type="numeric"/>원 ~ <input type="text" class="w90 aR" name="currPriceEd" id="currPriceEd" maxlength="10" data-valid-type="numeric"/>원
						</td>
						<th>할인율</th>
						<td>
							<input type="text" class="w70" name="dcRateSt" id="dcRateSt" maxlength="3" data-valid-type="numeric"/> ％ ~ <input type="text" class="w70" name="dcRateEd" id="dcRateEd" maxlength="3" data-valid-type="numeric"/> ％
						</td>
					</tr>
					<tr>
						<th>발생일<em class="required" title="필수"></em></th>
						<td colspan="7" id="sellTerms"></td>
					</tr>
				</table>
				<ul class="panelBar">
					<li class="center">
						<button type="button" class="btn btn-gray btn-lg" id="btnInit" >초기화</button>
						<button type="button" class="btn btn-info btn-lg" id="btnSearch" >조회</button>
					</li>
				</ul>
			</div>
			<!-- //검색조건 영역 -->
		</div>
		<!-- 패널 영역1 -->
		<div class="panelStyle">
			<!-- 검색결과 영역 -->
			<!-- 상단버튼 영역  -->
			<ul class="panelBar">
				<li>
					<button type="button" class="btn btn-default btn-lg" onclick="fnGoodsExcelDownLoad('');">엑셀다운로드</button>
					<button type="button" class="btn btn-default btn-lg" onclick="fnGoodsExcelDownLoad('Y');">엑셀다운로드(이미지포함)</button>
					<button type="button" class="btn btn-default btn-lg" onclick="cfnDownloadSampleFile('SF003');">상품엑셀조회 양식 다운로드</button>
					<button type="button" class="btn btn-base btn-lg" id="btnGoodsExcelUpLoad">엑셀조회</button>
				</li>
				<li class="right">
					<button type="button" class="btn btn-primary btn-lg"  id="btnGoodsSetMake">세트상품구성</button>
					<button type="button" class="btn btn-primary btn-lg" id="btnGoodsSetDeal">딜상품구성</button>
					검색결과 : <strong><span id="gridRowTotalCount">0</span> 건</strong>&nbsp;
					쪽번호 <span id="pgNo">0</span>/ <strong id="endPgNo">0</strong>&nbsp;&nbsp;
					<select id="pageSize" name="pageSize">
						<option value="50" selected="selected">50개씩 보기</option>
						<option value="100">100개씩 보기</option>
						<option value="500">500개씩 보기</option>
						<!-- <option value="1000">1000개씩 보기</option> -->
					</select>
					<input type="hidden" name="pageNo" id="pageNo" value ="1"/>
				</li>
			</ul>
			<!-- //상단버튼 영역  -->
			<div id="gridList" style="width: 100%; height: 700px;" class="ag-theme-balham lh60"></div>
			<ul class="panelBar">
				<li class="center">
					<div class="tablePaging" id="goodsListPagination"></div>
				</li>
			</ul>
			<ul class="panelBar">
				<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 btn-info btn-sm"  onclick="fnGoodsStatArea();" >상태일괄적용</button>
				</th:block>	
				</li>
			</ul>
			<label class="off">
				<a href="javascript:void(0);" id="GoodsExcelList" style="display: none;">상품목록 엑셀다운로드</a>
			</label>
			<ul class="boxContent off" id="goodsStatArea">
				<li class="pad20">
					<table class="frmStyle">
						<colgroup>
							<col style="width: 7%;"/>
							<col style="width: 18%;"/>
							<col style="width: 7%;"/>
							<col style="width: 18%;"/>
							<col style="width: 7%;"/>
							<col style="width: 18%;"/>
							<col style="width: 7%;"/>
							<col/>
						</colgroup>
						<tr>
							<th>상품상태</th>
							<td>
								<select  name="goodsStatC" id="goodsStatC">
									<option value="">[선택]</option>
									<option th:if="${goodsStatList}" th:each="oneData, status : ${goodsStatList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
								</select>
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('goodsStat')">적용</button>
							</td>
							<th>재고연동여부</th>
							<td >
								<select id="erpStockLinkYnC" name="erpStockLinkYnC">
									<option value="">[선택]</option>
									<option value="Y">연동</option>
									<option value="N">비연동</option>
								</select>
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('erpStockLinkYn')" >적용</button>
							</td>
							<th>정상/이월 구분</th>
							<td>
								<select  name="formalGbC" id="formalGbC">
									<option value="">[선택]</option>
									<option th:if="${formalGbList}" th:each="oneData, status : ${formalGbList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
								</select>
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('formalGb')" >적용</button>
							</td>
							<th>반품가능여부</th>
							<td>
								<select id="returnableYnC" name="returnableYnC">
									<option value="">[선택]</option>
									<option value="Y">가능</option>
									<option value="N">불가</option>
								</select>
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('returnableYn')" >적용</button>
							</td>
						</tr>
						<tr>
							<th>상품타이틀</th>
							<td colspan="3">
								<input id="goodsTnmC" name="goodsTnmC" type="text" class="w200" maxlength="70"/>
								<label class="chkBox"><input type="checkbox" name="blankFlag" value="Y"/>BLANK 적용<span></span></label>
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('goodsTnm')" >적용</button>
							</td>
							<th>교환가능여부</th>
							<td>
								<select id="changeableYnC" name="changeableYnC">
									<option value="">[선택]</option>
									<option value="Y">가능</option>
									<option value="N">불가</option>
								</select>
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('changeableYn')" >적용</button>
							</td>
							<th>ID당1일최대구매수량</th>
							<td>
								<input id="dayMaxOrdQtyC" name="dayMaxOrdQtyC" type="text" class="w100" data-valid-type="numeric" />
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('dayMaxOrdQty')" >적용</button>
							</td>
						</tr>
						<tr>
							<th>최소주문수량</th>
							<td>
								<input id="minOrdQtyC" name="minOrdQtyC" type="text" class="w100" data-valid-type="numeric" />
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('minOrdQty')" >적용</button>
							</td>
							<th>최대주문수량</th>
							<td>
								<input id="maxOrdQtyC" name="maxOrdQtyC" type="text" class="w100" data-valid-type="numeric" />
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('maxOrdQty')" >적용</button>
							</td>
							<th>PC포인트</th>
							<td>
								<input type="text" class="w100 aR" id="pntPrateC" name="pntPrateC" data-valid-type="numeric" maxlength="3"/> ％
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('pntPrate')" >적용</button>
							</td>
							<th>모바일포인트</th>
							<td>
								<input type="text" class="w100 aR" id="pntMrateC" name="pntMrateC" data-valid-type="numeric" maxlength="3"/> ％
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('pntMrate')" >적용</button>
							</td>
						</tr>
						<tr>
							<th>선물 주문가능</th>
							<td>
								<select id="giftPackYnC" name="giftPackYnC">
									<option value="">[선택]</option>
									<option value="Y">가능</option>
									<option value="N">불가</option>
								</select>
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('giftPackYn')" >적용</button>
							</td>
							<th>배송정책</th>
							<td colspan="3">
								<input type="text" class="w100" name="statSupplyCompCd" id="statSupplyCompCd" maxlength="20" />
								<button type="button" class="btn icn" id="btnSearchSupplyCompStat"><i class="fa fa-search"></i></button>
								<select name="delvFeeCdC" id="delvFeeCdC" >
									<option value="">[선택]</option>
								</select>
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('delvFeeCd')" >적용</button>
							</td>
							<th>신규고객 주문가능</th>
							<td>
								<select id="newCustOrdYnC" name="newCustOrdYnC">
									<option value="">[선택]</option>
									<option value="Y">가능</option>
									<option value="N">불가</option>
								</select>
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('newCustOrdYn')" >적용</button>
							</td>
						</tr>
						<tr>
							<th>판매일시</th>
							<td colspan="7">
								<input name="sellStYMDC" id="sellStYMDC" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="판매시작일" />
								<select name="sellStHHC" id="sellStHHC" required="required" data-valid-name="판매 시작시간">
									<th:block th:each="num, index  : ${#numbers.sequence(0,23)}">
									<option  th:value="${#numbers.formatInteger(num,2)}" th:text="|${#numbers.formatInteger(num,2)}시|" th:selected="${#numbers.formatInteger(num,2)}==0 ? 'true'">시간</option>
									</th:block>
								</select>
								<input name="sellStdtC" id="sellStdtC" type="hidden" />
								~
								<input name="sellEdYMDC" id="sellEdYMDC" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="판매 종료일" />
								<select name="sellEdHHC" id="sellEdHHC" required="required" data-valid-name="판매 종료시간">
									<th:block th:each="num: ${#numbers.sequence(0,23)}">
									<option  th:value="${#numbers.formatInteger(num,2)}"  th:text="|${#numbers.formatInteger(num,2)}시|" th:selected="${#numbers.formatInteger(num,2)}==23 ? 'true'">시간</option>
									</th:block>
								</select>
								<input name="sellEddtC" id="sellEddtC" type="hidden" />
								<button type="button" class="btn btn-dark btn-sm" onclick="fnChangeGoodsState('sellDate')" >적용</button>
							</td>
						</tr>	
					</table>
				</li>
			</ul>
			
			<!-- 검색결과 영역 -->
		</div>
		</form>
		<!-- //패널 영역2 -->
<script type="text/javascript" src="/ux/plugins/gaga/gaga.paging.js?v=20210114"></script>
<script th:inline="javascript">
/*<![CDATA[*/
	var sessRoleCd = [[${sessionInfo.roleCd}]];
	var goodsStatList = gagajf.convertToArray([[${goodsStatList}]]);
	var formalGbList = gagajf.convertToArray([[${formalGbList}]]);
	var seasonList = gagajf.convertToArray([[${seasonList}]]);
	var columnDefs = [];
	columnDefs = [
		{width: 40, minWidth: 40, cellClass: 'text-right', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
		{headerName: 'No', width: 60, cellClass: 'text-center',
			valueGetter: function(params) { return cfnGridNumner('searchForm',params.node.rowIndex, 'A');}
		},
		{headerName: "이미지", field: "sysImgNm", width: 100, height: 60, cellClass: 'text-center'
			,cellRenderer: function(params) {
				return '<img width="60" src="'+ _goodsUrl+ "/" + params.value + '?RS=60" alt="" onclick="cfnOpenImagePreViewPopup(\'goodsImgView\', \''+ _goodsUrl+ "/" + params.value +'\')" onerror="this.src=\'/image/no.png\';"/>';
			}
		},
		{headerName: "브랜드", field: "brandCd", width: 80, cellClass: 'text-center'},
		{headerName: "브랜드명", field: "brandEnm", width: 130, cellClass: 'text-center'},
		{headerName: "상품코드", field: "goodsCd", width: 140, cellClass: 'text-center'},
		{headerName: "상품명", field: "goodsNm", width: 200, cellClass: 'text-left'
			,cellRenderer: function(params) {
				return '<a href="javascript:void(0);">' + params.value + '</a>';
			}
		},
		{headerName: "품목", field: "itemkindNm", width: 150, cellClass: 'text-center',
			cellRenderer: function (params) {
				if (gagajf.isNull( params.value)){
					return  params.value;
				}else{
					return  params.value.replaceAll("&gt;", ">");
				}
			}
		},
		{headerName: "전시재고", field: "stockQtySum", width: 120, cellClass: 'text-right',
			valueFormatter: function(params) {	return params.value.addComma();},
			cellStyle : function(params){
				if ("00" == params.data.goodsStat  || "10" == params.data.goodsStat || "20" == params.data.goodsStat || "30" == params.data.goodsStat) {
					return;
				}
				var color = "";
				if (params.value <= 0){
					color = '#ff96689c';
				}
				return { 'background-color': color};
			} 
		},
		{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: "styleYear" , width: 80, cellClass: 'text-center'},
		{headerName: "시즌", field: "seasonCd" , width: 80, cellClass: 'text-center',
			cellEditorParams: { values: gagaAgGrid.extractValues(seasonList) },
			valueFormatter: function (params) { return gagaAgGrid.lookupValue(seasonList, params.value); },
			valueParser: function (params) { return gagaAgGrid.lookupKey(seasonList, params.newValue); }
		},
		{headerName: "수수료율", field: "sellFeeRate" , width: 80, cellClass: 'text-center'},
		{headerName: "정상가", field: "listPrice" , width: 100, cellClass: 'text-right'
			,valueFormatter: function(params) {return params.value.addComma();},
			cellEditor: 'textCellEditor',
			cellEditorParams: { maxlength: 14, validType: 'numeric'}
		},
		{headerName: "판매가", field: "currPrice" , width: 100, cellClass: 'text-right'
			,valueFormatter: function(params) {return params.value.addComma();},
			cellEditor: 'textCellEditor',
			cellEditorParams: { maxlength: 14, validType: 'numeric'}
		},
		{headerName: "자사즉시할인가", field: "benefitPrice" , width: 120, cellClass: 'text-right'
			,valueFormatter: function(params) {
				if (params.value > 0) {
					return params.value.addComma();
				}else{
					return '';
				}
			}
		},
		{headerName: "가격변경일", field: "priceUpdDt", 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: "ERP재고연동여부", field: "erpStockLinkYn", width: 120, cellClass: 'text-center'},
		{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: "returnableYn" , width: 90, cellClass: 'text-center'},
		{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'}
	];

	// Get GridOptions
	var gridOptions = gagaAgGrid.getGridOptions(columnDefs);

	// 중복 선택 가능
	gridOptions.rowSelection = 'multiple';
 	gridOptions.suppressRowClickSelection = true;
	gridOptions.rowHeight = 60; //이미지가 있을경우 높이 지정해야함.

	// Row Click
	gridOptions.onCellClicked = function(event) {
		var goodsCd = event.data.goodsCd;
		if (event.colDef.field == "goodsNm"){
			cfnOpenGoodsDetailPopup('U',goodsCd);
		}else if (event.colDef.field == "goodsCd"){

			//cfnOpenFrontGoodsPopup(goodsCd, event.data.siteCd);
		}
	}

	gridOptions.getRowStyle = function(params) {
		if ("G008_00" == params.data.goodsStat  || "G008_10" == params.data.goodsStat || "G008_20" == params.data.goodsStat || "G008_30" == params.data.goodsStat) {
			return { background: '#B5EAD7' };
		}
	}

	// 초기화 클릭시
	$('#btnInit').on('click', function() {

		$('#searchForm')[0].reset();
		//$("#searchForm input[type=radio]").removeClass("checked");
		$("#searchForm input[type=checkbox]").removeClass("checked");
		//$("#searchForm input[type=radio]").parent("label").removeClass("checked");
		$("#searchForm input[type=checkbox]").parent("label").removeClass("checked");
		$("#searchForm input[type=radio][checked]").parent("label").addClass("checked");
		$("#multiBrand").empty();
		$('#searchForm input[name=brandList]').val('');
		$('#searchForm').find('#brandText').html('');
		$('#searchForm input[name=supplyCompList]').val('');
		$('#searchForm').find('#supplyCompText').html('');
		$('#searchForm input[name=itemkindList]').val('');
		$('#searchForm').find('#itemkindText').html('');
		
		$(document).find('#searchForm').find(".multiCheckBox").each(function(i, e){
			let btnNm = $(this).find(".sltBtn").attr("data-name");
			$(this).find(".sltBtn").text(btnNm);
		});
		
	});

	// 조회클릭시
	$('#btnSearch').on('click', function() {
		$("#searchForm input[name=pageNo]").val('1');
		fnGoodsListSearch('BASIC');
	});

	// 조회
	var fnGoodsListSearch = function(gbn) {

		if (typeof(gbn) != 'undefined' &&  gbn == 'EXCEL'){
			$("#searchForm input[name=searchGb]").val("EXCEL");
		}else{
			$("#searchForm input[name=searchGb]").val("BASIC");
		}

		if(!fnConditionCheck()) return;

		gagaPaging.init('searchForm', fnSearchCallBack, 'goodsListPagination', $('#searchForm').find('#pageSize').val());
		gagaPaging.load($("#searchForm input[name=pageNo]").val());
	}

	//검색 조건 확인
	var fnConditionCheck = function(){
		var formId = '#searchForm';
		var form = document.searchForm;
		
		if (event.keyCode === 13) return false;

		if($("#searchForm input[name=searchGb]").val() == "EXCEL") return true;

		var searchFlag = false;
		var cnt = 0;

		if( !gagajf.isNull($("#searchForm input[name=supplyCompList]").val()) 
				|| !gagajf.isNull($("#searchForm textarea[name=condition]").val())
				|| (!gagajf.isNull($("#searchForm input[name=stDate]").val()) && !gagajf.isNull($("#searchForm input[name=edDate]").val()))
				|| !gagajf.isNull($("#searchForm input[name=brandList]").val())
			){
			searchFlag = true;
		}else{
			/* for (i = 0; i < form.elements.length; i++ ) {
				var el = form.elements[i];

				if ($(el).prop("type") == "text" || ($(el).prop("type") == "select-one" && el.name != "search" && el.name != "pageSize")) {
					if (!(el.value == null || el.value == "")) {
						cnt++;
					}
				}
			}

			if(cnt > 0) searchFlag = true; */
		}

		if(searchFlag == false){
			mcxDialog.alert("검색조건을 입력하세요.");
			return false;
		}

		if(!gagajf.isNull($("#searchForm input[name=currPriceSt]").val()) && !gagajf.isNull($("#searchForm input[name=currPriceEd]").val())){
			if (Number($("#searchForm input[name=currPriceSt]").val().removeComma()) > Number($("#searchForm input[name=currPriceEd]").val().removeComma()) ){
				mcxDialog.alertC("판매가를 확인해 주세요.", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$("#searchForm input[name=currPriceEd]").focus();
					}
				});
				return false;
			}
		}

		if(!gagajf.isNull($("#searchForm input[name=dcRateSt]").val()) && !gagajf.isNull($("#searchForm input[name=dcRateEd]").val())){
			if (Number($("#searchForm input[name=dcRateSt]").val().removeComma()) > Number($("#searchForm input[name=dcRateEd]").val().removeComma()) ){
				mcxDialog.alertC("할인율를 확인해 주세요.", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$("#searchForm input[name=dcRateEd]").focus();
					}
				});
				return false;
			}
		}

		var fromDate = $('#searchForm input[name=stDate]').val();
		var toDate = $('#searchForm input[name=edDate]').val();

		if (!gagajf.isNull(fromDate) || !gagajf.isNull(toDate)) {

			if (gagajf.isNull(fromDate) || gagajf.isNull(toDate)) {
				mcxDialog.alertC("등록일 조회시 시작일자와 종료일자를 입력하세요.", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$('#searchForm input[name=stDate]').focus();
					}
				});
				return false;
			}

			if (fromDate > toDate) {
				mcxDialog.alertC("등록 시작일자는 종료일자 보다 클 수 없습니다.", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$('#searchForm input[name=stDate]').focus();
					}
				});
				return false;
			}
		}
	
		if (!gagajf.isNull($('#searchForm textarea[name=condition]').val())){
			var arrData = $('#searchForm textarea[name=condition]').val().replace(/\r\n/g,"\n").split("\n"); 
			if (arrData.length > 500){
				mcxDialog.alertC("키워드 조회값을 500 이하로 조회 하세요.", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$('#searchForm textarea[name=condition]').focus();
					}
				});
				return false;
			}
		}
		
		return true;
	}

	var fnSearchCallBack = function(result){

		$('#searchForm').find('#gridRowTotalCount').html(result.pageing.pageable.totalCount.addComma());
		$('#searchForm').find('#pageNo').val(result.pageing.pageable.pageNo.addComma());
		$('#searchForm').find('#pgNo').html(result.pageing.pageable.pageNo.addComma());
		$('#searchForm').find('#endPgNo').html(result.pageing.pageable.totalPage.addComma());
		gridOptions.api.setRowData(result.goodsList);
		gagaPaging.createPagination(result.pageing.pageable);
		
	}

	//페이징
	$('#searchForm select[name=pageSize]').on('change', function() {
		$("#searchForm input[name=pageNo]").val('1');
		fnGoodsListSearch($("#searchForm input[name=searchGb]").val());
	});

	//업체변경시
	$('#searchForm select[name=supplyCompCd]').on('change', function() {
		var actionUrl = '/renderer/supplyCompany/brand/list/' + $(this).val();

		if(sessRoleCd == "G001_B000"){
			actionUrl = '/renderer/brand/AuthBrandlist';
		}
		
		//$("#searchForm select[name=brandCd] option:gt(0)").remove();
		//cfnCreateCombo(actionUrl, $('#searchForm select[name=brandCd]'), "[전체]", brandCd);
		cfnCreateMultiCombo(actionUrl,"multiBrand",  "[전체]",null, 'Y');
	});

	//엑셀다운로드
	var fnGoodsExcelDownLoad = function(flag){
		var formId = '#searchForm';
		if (gridOptions.api.getDisplayedRowCount() <= 0){
			mcxDialog.alert("조회된 데이터가 없습니다.<br/>다시 조회 후 다운로드 받으세요.");
			return;
		}
		$("#searchForm input[name=imageViewYn]").val(flag);

		var params =  $(formId).serialize();
		$('#GoodsExcelList').attr({ href : '/goods/info/excel/list?' + params }).get(0).click();
	}

	//엑셀 상품 조회
	$('#btnGoodsExcelUpLoad').on('click', function() {
		cfnExcelUploadPopup('goodsExcelUpload', 'goodsExcelUpload');
	});

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

	var fnGoodsExcelUploadCallBack = function(result){
		$("#searchForm input[name=pageNo]").val('1');
		fnGoodsListSearch("EXCEL");
	}

	//상품상태 변경시
	var fnChangeGoodsState = function(proc){

		var objId = '#'+proc+"C";
		if (proc == "goodsTnm"){
			if(gagajf.isNull($(objId).val()) && !$("#searchForm input:checkbox[name=blankFlag]").is(':checked')){
				mcxDialog.alertC('적용하실 항목을 선택해주세요.', {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$(objId).focus();
					}
				});
				return;
			}else if(!gagajf.isNull($(objId).val()) && $("#searchForm input:checkbox[name=blankFlag]").is(':checked')){
				mcxDialog.alertC('적용하실 항목을 하나만 선택해주세요.', {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$(objId).focus();	
					}
				});
				return;
			}
		}else if (proc == "sellDate"){
			if(isNaN(Date.parse($("#searchForm input[name=sellStYMDC]").val()))){
				mcxDialog.alertC('날짜형식이 아닙니다.', {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$("#searchForm input[name=sellStYMDC]").focus();
					}
				});	
				return false;
			}
			
			if(isNaN(Date.parse($("#searchForm input[name=sellEdYMDC]").val()))){
				mcxDialog.alertC('날짜형식이 아닙니다.', {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$("#searchForm input[name=sellEdYMDC]").focus();
					}
				});	
				return false;
			}
			
			var fromDate = $("#searchForm input[name=sellStYMDC]").val().replaceAll('-', '')+ $("#searchForm select[name=sellStHHC]").val();
			var toDate = $("#searchForm input[name=sellEdYMDC]").val().replaceAll('-', '')+ $("#searchForm select[name=sellEdHHC]").val();

			if (fromDate > toDate) {
				mcxDialog.alertC("판매기간의 시작일시는 종료일시 보다 클 수 없습니다.", {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$('#searchForm input[name=sellStYMDC]').focus();
					}
				});
				return false;
			}

		}else{
			if (gagajf.isNull($(objId).val())){
				mcxDialog.alertC('적용하실 항목을 선택(입력)해주세요.', {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$(objId).focus();
					}
				});
				return;
			}
		}
		var selectedData = gridOptions.api.getSelectedRows();

		if (selectedData.length == 0) {
			mcxDialog.alert('선택된 행이 없습니다.');
			return;
		}

		var goodsStatVal  = '';
		var erpStockLinkYnVal= '';
		var formalGbVal= '';
		var returnableYnVal= '';
		var changeableYnVal= '';
		var goodsTnmVal  = '';
		var blankFlagVal = '';
		var minOrdAmtVal = '';
		var minOrdQtyVal = '';
		var maxOrdQtyVal = '';
		var dayMaxOrdQtyVal = '';
		var pntPrateVal = '';
		var pntMrateVal = '';
		var giftPackYnVal = '';
		var delvFeeCdVal = '';
		var newCustOrdYnVal = '';
		var sellStdtVal = '';
		var sellEddtVal = '';

		if (proc == "goodsStat") {
			goodsStatVal = $(objId).val();
		}else if (proc == "erpStockLinkYn") {
			erpStockLinkYnVal = $(objId).val();
		}else if (proc == "formalGb") {
			formalGbVal = $(objId).val();
		}else if (proc == "returnableYn") {
			returnableYnVal = $(objId).val();
		}else if (proc == "changeableYn") {
			changeableYnVal = $(objId).val();	
		}else if (proc == "goodsTnm"){
			if($("#searchForm input:checkbox[name=blankFlag]").is(':checked')){
				blankFlagVal = "Y";
			}else{
				goodsTnmVal = $(objId).val();
			}
		}else if (proc == "minOrdAmt") {
			minOrdAmtVal = $(objId).val().removeComma();
		}else if (proc == "minOrdQty") {
			if($(objId).val()<=0){
				mcxDialog.alertC('0보다 큰값을 입력 해주세요.', {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$(objId).focus();
					}
				});
				return;
			}
			minOrdQtyVal = $(objId).val();
		}else if (proc == "maxOrdQty") {
			if($(objId).val()<=0){
				mcxDialog.alertC('0보다 큰값을 입력 해주세요.', {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$(objId).focus();
					}
				});
				return;
			}
			maxOrdQtyVal = $(objId).val();
		}else if (proc == "dayMaxOrdQty") {
			if($(objId).val()<=0){
				mcxDialog.alertC('0보다 큰값을 입력 해주세요.', {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$(objId).focus();
					}
				});
				return;
			}
			dayMaxOrdQtyVal = $(objId).val();	
		}else if (proc == "pntPrate") {
			if($(objId).val()>100){
				mcxDialog.alertC('100보다 작거나 같은 값을 입력 해주세요.', {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$(objId).focus();
					}
				});
				return;
			}
			pntPrateVal = $(objId).val();
		}else if (proc == "pntMrate") {
			if($(objId).val()>100){
				mcxDialog.alertC('100보다 작거나 같은 값을 입력 해주세요.', {
					sureBtnText: "확인",
					sureBtnClick: function() {
						$(objId).focus();
					}
				});
				return;
			}
			pntMrateVal = $(objId).val();
		}else if (proc == "giftPackYn") {
			giftPackYnVal = $(objId).val();
		}else if (proc == "newCustOrdYn") {
			newCustOrdYnVal = $(objId).val();	
		}else if (proc == "delvFeeCd") {
		/* 	if (!fnGoodsDelFeeCdCheck(selectedData)){
				return;
			} */
			
			var statSupplyCompCd = $('#searchForm input[name=statSupplyCompCd]').val();
			var chkFlag = false;
			$.each(selectedData, function(idx, item) {

				if (item.supplyCompCd != statSupplyCompCd){
					mcxDialog.alert(item.goodsCd +" 상품은 배송정책의 업체와 상이합니다.");
					chkFlag = true;
					 false;
				}
			});
			if (chkFlag){
				return;
			}
			
			delvFeeCdVal = $(objId).val();
		}else if (proc == "sellDate") {
			sellStdtVal = $("#searchForm input[name=sellStYMDC]").val().replaceAll('-', '')+ $("#searchForm select[name=sellStHHC]").val()+"0000";
			sellEddtVal = $("#searchForm input[name=sellEdYMDC]").val().replaceAll('-', '')+ $("#searchForm select[name=sellEdHHC]").val()+"5959";
		}else{
			return;
		}
		
		mcxDialog.confirm('적용 하시겠습니까?', {
			cancelBtnText: "취소",
			sureBtnText: "확인",
			sureBtnClick: function(){
				var arrGoodsCd = [];

				$.each(selectedData, function(idx, item) {
					arrGoodsCd.push(item.goodsCd);
				});

				var data = {arrGoodsCd: arrGoodsCd
							,goodsStat : goodsStatVal
							,erpStockLinkYn : erpStockLinkYnVal
							,formalGb : formalGbVal
							,returnableYn : returnableYnVal
							,changeableYn : changeableYnVal
							,goodsTnm : goodsTnmVal
							,blankFlag : blankFlagVal
							,minOrdAmt : minOrdAmtVal
							,maxOrdQty : maxOrdQtyVal
							,dayMaxOrdQty : dayMaxOrdQtyVal
							,pntPrate : pntPrateVal
							,pntMrate : pntMrateVal
							,giftPackYn : giftPackYnVal
							,delvFeeCd : delvFeeCdVal
							,newCustOrdYn : newCustOrdYnVal
							,sellStdt : sellStdtVal
							,sellEddt : sellEddtVal
							,procJob : proc
							};

				var jsonData = JSON.stringify(data);
				gagajf.ajaxJsonSubmit('/goods/state/update', jsonData, fnChangeGoodsStateCollback);

			}
		});
	}
	
	// 배송비정책 관련 확인
	var fnGoodsDelFeeCdCheck = function(selectedData){
		
		var statSupplyCompCd = $('#searchForm input[name=statSupplyCompCd]').val();
		
		$.each(selectedData, function(idx, item) {

			if (item.supplyCompCd != statSupplyCompCd){
				mcxDialog.alert(item.goodsCd +" 상품은 배송정책의 업체와 상이합니다.");
				return false;
			}
		});
		
		return true;	
	}

	var fnChangeGoodsStateCollback = function(result){
		if (result.resultFlag == "FAIL"){
			mcxDialog.alert("[ " + result.returnGoods + " ]은<br/> 필수 이미지나 가격이나 고시정보가 등록되지 않아 '승인대기'나 '승인완료' 상태로 변경할 수 없습니다.<br/>상품을 확인하시고, 다시 시도해주세요.");
			return false;
		}else{
			mcxDialog.alert('성공적으로 저장되었습니다.');
		}
		fnGoodsListSearch($("#searchForm input[name=searchGb]").val());
	}

	//상태일괄변경 버튼 클릭시
	var fnGoodsStatArea = function(){
		if ($("#searchForm").find("#goodsStatArea").hasClass('off')) {
			$("#searchForm").find("#goodsStatArea").removeClass('off');
			$("#searchForm").find("#goodsStatArea").addClass('on');
		}else{
			$("#searchForm").find("#goodsStatArea").removeClass('on');
			$("#searchForm").find("#goodsStatArea").addClass('off');
		}
	}
	
	//세트상품구성 클릭 시
	$('#btnGoodsSetMake').click(function(e) {
		cfnOpenGoodsSetPopup();
	});
	
	//딜상품구성 클릭 시
	$('#btnGoodsSetDeal').click(function(e) {
		cfnOpenGoodsDealPopup();
	});

	// 자사/입점 변경여부
	$("#searchForm input[name=selfYn]").bind('click change', function () {
		var radioValue = $(this).val();
		var selfGb = "S";	// 자사 공급 업체
		if (radioValue == "N"){
			selfGb = "E";	//입점 공급업체
		}
		
		var actionUrl = '/renderer/supply/company/list/'+ selfGb;	

		$('#searchForm').find('#multiBrand').empty();
		//$("#searchForm select[name=brandCd] option:gt(0)").remove();

		cfnCreateCombo(actionUrl, $('#searchForm select[name=supplyCompCd]'), "[전체]", "");
		
	});
	
	// 상태일괄변경 자사/입점 변경여부
/*	$("#searchForm input[name=statSelfYn]").bind('click change', function () {
		var radioValue = $(this).val();
		var selfGb = "S";	// 자사 공급 업체
		if (radioValue == "N"){
			selfGb = "E";	//입점 공급업체
		}
		
		var actionUrl = '/renderer/supply/company/list/'+ selfGb;
		$("#searchForm select[name=delvFeeCdC] option:gt(0)").remove();
		cfnCreateCombo(actionUrl, $('#searchForm select[name=statSupplyCompCd]'), "[전체]", "");
		
	});
	
	// 상태일괄변경 업체변경시
	$('#searchForm select[name=statSupplyCompCd]').on('change', function() {
		$("#searchForm select[name=delvFeeCdC] option:gt(0)").remove();
		cfnCreateCombo('/renderer/delvFee/list/' + $('#searchForm select[name=statSupplyCompCd]').val(), $('#searchForm select[name=delvFeeCdC]'), "[선택]");
	});
*/	
	// 업체 조회 선택시
	$('#btnSearchSupplyComp').on('click', function() {
		cfnOpenCompanyListPopup('fnSetSupplyCompInfo', 'M');
	});
	
	// 업체 조회 팝업에서 호출
	var fnSetSupplyCompInfo = function(result) {
		var arrSupplyComp = [];
		var supplyCompText = "";
		var sIndex = 0;
		$('#searchForm').find('#supplyCompText').html('');
		$('#searchForm input[name=supplyCompSearchTxt]').val('');
		result.forEach(function(supplyComp){
			sIndex++; 
			arrSupplyComp.push(supplyComp.supplyCompCd);
		});

		// 조회값이 하나일 경우 화면에 코드 노출 그외는 갯수 처리 
		if (sIndex == 1) {
			$('#searchForm input[name=supplyCompSearchTxt]').val(arrSupplyComp[0]);
		}else{
			supplyCompText = sIndex + " 개";
			$('#searchForm').find('#supplyCompText').html(supplyCompText);	
		}
		var jsonData = JSON.stringify(arrSupplyComp);
		$("#searchForm input[name=supplyCompList]").val(jsonData);
	}
	
	// 브랜드 조회 팝업에서 호출
	var fnSetBrandInfo = function(result) {
		var arrbrandCd = [];
		var brandText = "";
		var bIndex = 0;
		$('#searchForm').find('#brandText').html('');
		$('#searchForm input[name=searchTxt]').val('');
		result.forEach(function(brand){
			bIndex++; 
			arrbrandCd.push(brand.brandCd);
		});

		// 조회값이 하나일 경우 화면에 코드 노출 그외는 갯수 처리 
		if (bIndex == 1) {
			$('#searchForm input[name=searchTxt]').val(arrbrandCd[0]);
		}else{
			brandText = bIndex + " 개";
			$('#searchForm').find('#brandText').html(brandText);	
		}
		var jsonData = JSON.stringify(arrbrandCd);
		$("#searchForm input[name=brandList]").val(jsonData);
	}
	
	// 브랜드 조회 선택시
	$('#btnSearchBrand').on('click', function() {
		/* if (gagajf.isNull($("#searchForm input[name=searchTxt]").val())){
			mcxDialog.alert('브랜드 검색어를 입력하세요.');
			return false;
		} */
		cfnOpenBrandListPopup('fnSetBrandInfo', 'M');
	});
	
	// 품목 조회 선택시
	$('#btnSearchItemkind').on('click', function() {
		cfnOpenItemkindListPopup('fnSetItemkindInfo', 'M');
	});
	
	// 품목 조회 팝업에서 호출
	var fnSetItemkindInfo = function(result) {
		var arrItemkind = [];
		var itemkindText = "";
		var sIndex = 0;
		$('#searchForm').find('#itemkindText').html('');
		$('#searchForm input[name=itemkindSearchTxt]').val('');
		result.forEach(function(itemkind){
			sIndex++; 
			arrItemkind.push(itemkind.itemkindCd);
		});

		// 조회값이 하나일 경우 화면에 코드 노출 그외는 갯수 처리 
		if (sIndex == 1) {
			$('#searchForm input[name=itemkindSearchTxt]').val(arrItemkind[0]);
		}else{
			itemkindText = sIndex + " 개";
			$('#searchForm').find('#itemkindText').html(itemkindText);	
		}
		var jsonData = JSON.stringify(arrItemkind);
		$("#searchForm input[name=itemkindList]").val(jsonData);
	}
	
	// 상태일괄변경 - 배송정책 
	$('#btnSearchSupplyCompStat').on('click', function() {
		cfnOpenCompanyListPopup('fnSetSupplyCompInfoStat', 'S');
	});
	
	// 업체 조회 팝업에서 호출
	var fnSetSupplyCompInfoStat = function(result) {
		var arrSupplyComp = [];
		var supplyCompText = "";
		var sIndex = 0;
		$('#searchForm input[name=statSupplyCompCd]').val('');
		result.forEach(function(supplyComp){
			sIndex++; 
			arrSupplyComp.push(supplyComp.supplyCompCd);
		});

		$('#searchForm input[name=statSupplyCompCd]').val(arrSupplyComp[0]);
		cfnCreateDelvPolicyCombo( $('#searchForm input[name=statSupplyCompCd]').val(), $('#searchForm select[name=delvFeeCdC]'), "[선택]");
	}
	
	// 상품이미지 미리보기 레이어에서 창 종료 이벤트
	$(document).on("mouseleave","#goodsImgView",function(){
		$("#goodsImgView").remove();
	});
	
	$(document).ready(function() {

		cfnCreateCalendar('#sellTerms', 'stDate', 'edDate', true, '등록일', 'X');

		var selectCode = '<select  name="dateGbn" id="dateGbn">';
		selectCode += '<option value="R" seledted>상품등록일</option>';
		selectCode += '<option value="P">가격변경일</option>';
		selectCode += '<option value="S">최초승인일</option>';
		selectCode += '</select>';

		$("#searchForm").find('#sellTerms').prepend(selectCode);

		// Create a agGrid
		gagaAgGrid.createGrid('gridList', gridOptions);

	});

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