<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org"        >
<!--
 *******************************************************************************
 * @source  : GoodsSelfRegisterForm.html
 * @desc    : 자사 상품등록
 *============================================================================
 * STYLE24
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2021.06.30   eskim       최초 작성
 *******************************************************************************
 -->
	<div id="main">
		<!-- 메인타이틀 영역 -->
		<div class="main-title">
		</div>
		<!-- //메인타이틀 영역 -->
		<!-- 메뉴 설명 -->
		<div class="infoBox menu-desc">
		</div>
		<form id="goodsDetailForm" name="goodsDetailForm" action="#" th:method="post">
				<input type="hidden" id="mode" name="mode" value="C"/>
				<input type="hidden" id="notiList" name="notiList" />
				<input type="hidden" id="safeNiClsfCd" name="safeNiClsfCd" />
		<div class="panelStyle">
			<div class="panelContent">
				<table class="frmStyle">
					<colgroup>
						<col width="15%"/>
						<col width="50%"/>
						<col width="15%"/>
						<col/>
					</colgroup>
					<tr>
						<th>업체/브랜드<em class="required" title="필수"></em></th>
						<td>
							<select name="supplyCompCd" id="supplyCompCd" required="required" data-valid-name="업체">
								<option value="">[선택]</option>
								<option th:if="${supplyCompList}" th:each="oneData, status : ${supplyCompList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}" th:selected="${sessionInfo.supplyCompCd ==  oneData.cd}"></option>
							</select>
							<select name="brandCd" id="brandCd" required="required" data-valid-name="브랜드">
								<option value="">[선택]</option>
							</select>
						</td>
						<th>상품코드<em class="required" title="필수"></em></th>
						<td><input type="text" class="w200" name="goodsCd" required="required" data-valid-name="상품코드"  onkeyup="$(this).val($(this).val().toUpperCase());"/></td>
					</tr>
				</table>
				<!-- TABS BUTTON AREA -->
				<ul class="panelBar">
					<li>
						<h3 class="marL10 cRed"><i class="fa fa-info-circle" aria-hidden="true"></i>상품이미지는 상품 등록 후 상품목록에서 등록일로 설정, 조회 후 상품상세에서 등록하세요.<br/>
												<i class="fa fa-info-circle" aria-hidden="true"></i>옵션정보는 자동 등록 됩니다.</h3>
					</li>	
					<li class="right">
						<th:block th:if="${sessionInfo.roleCd == 'G001_E000'}">
						<button type="button" class="btn btnRight btn-success btn-lg" id="btnGoodsDetailSave">저장</button>
						</th:block>
					</li>
				</ul>
				<!-- //TABS BUTTON AREA -->
				<!-- TABS SPACE -->
				<div class="tabs">
					<!-- TABS NAVI -->
					<div class="tabsNav">
						<ul>
							<li class="on"><a href="#goodstab1">기본정보</a></li>
							<li><a href="#goodstab3">상품상세정보</a></li>
							<li><a href="#goodstab4">고시정보</a></li>
						</ul>
					</div>
					<!-- //TABS NAVI -->
					<!-- TABS CONTENTS -->
					<ul class="tabsCont">
						<!-- TAB1 : 기본정보 -->
						<li class="tab on" id="goodstab1">
							<!-- TAB1 CONTENTS AREA -->
							<div class="panelStyle">
								<table class="frmStyle">
									<colgroup>
										<col width="12%"/>
										<col width="21%"/>
										<col width="12%"/>
										<col width="21%"/>
										<col width="12%"/>
										<col/>
									</colgroup>
									<tbody>
									<tr>
										<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>/100 bytes</span>
										</td>
									</tr>
									<tr>
										<th>상품명<em class="required" title="필수"></em></th>
										<td colspan="5">
											<input type="text" class="w80p" id="goodsNm" name="goodsNm" required="required" data-valid-name="상품명"></input>
											<span class="byteChk"><em class="cBlue" id="goodsNmLen">0</em>/200 bytes</span>
										</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>
										</td>
									</tr>
									<tr>
										<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}" th:checked="${oneData.cd == 'G009_10'}"/></label>
										</td>
										<th>자사몰 노출여부<em class="required" title="필수"></em></th>
										<td>
											<label class="rdoBtn"><input type="radio" name="selfMallYn" id="selfMallYnY" value="Y"  checked="checked"/>Y</label>
											<label class="rdoBtn"><input type="radio" name="selfMallYn" id="selfMallYnN" value="N"/>N</label>
										</td>
										<th>성인용품여부<em class="required" title="필수"></em></th>
										<td>
											<label class="rdoBtn"><input type="radio" name="adultYn" id="adultYnY" value="Y" />Y</label>
											<label class="rdoBtn"><input type="radio" name="adultYn" id="adultYnN" value="N" checked="checked"/>N</label>
											<input type="hidden" id="adultYnOrg" name="adultYnOrg"/>
										</td>
									</tr>
									<tr>
										<th>시즌<em class="required" title="필수"></em></th>
										<td >
											<select  name="seasonCd" id="seasonCd" required="required" data-valid-name="시즌">
												<option value="">[선택]</option>
												<option th:if="${seasonList}" th:each="oneData, status : ${seasonList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}"></option>
											</select>
										</td>
										<th>성별<em class="required" title="필수" ></em></th>
										<td>
											<select  name="sexGb" id="sexGb" required="required" data-valid-name="성별">
												<option value="">[선택]</option>
												<option th:if="${sexGbList}" th:each="oneData, status : ${sexGbList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}"></option>
											</select>
										</td>
										<th>스타일년도<em class="required" title="필수"></em></th>
										<td><select  name="styleYear" id="styleYear" required="required" data-valid-name="스타일년도">
												<option value="">[선택]</option>
												<option th:if="${styleYearList}" th:each="oneData, status : ${styleYearList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}"></option>
											</select>
										</td>
									</tr>
									<tr>
										<th>원산지<em class="required" title="필수"></em></th>
										<td><select  name="originCd" id="originCd"  required="required" data-valid-name="원산지" >
												<option value="">[선택]</option>
												<option th:if="${originCdList}" th:each="oneData, status : ${originCdList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}" ></option>
											</select>
										</td>
										<th>유통구분<em class="required" title="필수"></em></th>
										<td><select  name="distributionGb" id="distributionGb"  required="required" data-valid-name="유통구분">
												<option value="">[선택]</option>
												<option th:if="${distributionGbList}" th:each="oneData, status : ${distributionGbList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}"></option>
											</select>
										</td>
										<th>상품구분<em class="required" title="필수"></em></th>
										<td>
											<select  name="goodsGb" id="goodsGb" required="required" data-valid-name="상품구분">
												<option value="">[선택]</option>
												<option th:if="${goodsGbList}" th:each="oneData, status : ${goodsGbList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}"></option>
											</select>
										</td>
									</tr>
									<tr>
										<th>해외구매대행여부</th>
										<td><label class="rdoBtn"><input type="radio" name="foreignBuyYn" id="foreignBuyYnY" value="Y" />Y</label>
											<label class="rdoBtn"><input type="radio" name="foreignBuyYn" id="foreignBuyYnN" value="N"  checked="checked"/>N</label>
										</td>
										<th>병행수입여부</th>
										<td><label class="rdoBtn"><input type="radio" name="parallelImportYn" id="parallelImportYnY" value="Y" />Y</label>
											<label class="rdoBtn"><input type="radio" name="parallelImportYn" id="parallelImportYnN" value="N"  checked="checked"/>N</label>
										</td>
										<th>주문제작여부</th>
										<td>
											<label class="rdoBtn"><input type="radio" name="orderMadeYn" id="orderMadeYnY" value="Y" />Y</label>
											<label class="rdoBtn"><input type="radio" name="orderMadeYn" id="orderMadeYnN" value="N"  checked="checked"/>N</label>
										</td>
									</tr>
									<tr>
										<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.cdNm}"></option>
											</select>
										</td>
										<th>선물 주문가능여부<em class="required" title="필수"></em></th>
										<td colspan="3">
											<label class="rdoBtn"><input type="radio" name="giftPackYn" id="giftPackYnY" value="Y" />Y</label>
											<label class="rdoBtn"><input type="radio" name="giftPackYn" id="giftPackYnN" value="N" checked="checked"/>N</label>
										</td>
									</tr>
									<tr id="selfGoodsNSellFeeRate">
										<th>판매수수료율<em class="required" title="필수"></em></th>
										<td><input type="text" class="w100 aR" id="sellFeeRate" name="sellFeeRate"  disabled="disabled" maxlength="10" data-valid-type="numeric" required="required" data-valid-name="판매수수료율"/> ％
										</td>
										<th>과세구분<em class="required" title="필수"></em></th>
										<td colspan="3">
											<select name="taxGb" required="required" data-valid-name="과세구분">
												<option value="">[선택]</option>
												<option value="10">과세</option>
												<option value="20">비과세</option>
												<option value="30">면세</option>
											</select>
										</td>
									</tr>
									<tr>
										<th>품목코드<em class="required" title="필수"></em></th>
										<td colspan="3">
											<select  name="itemkindCd" id="itemkindCd" required="required" data-valid-name="품목코드">
												<option value="">[선택]</option>
												<option th:if="${itemkindList}" th:each="oneData, status : ${itemkindList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}"></option>
											</select>
										</td>
										<th>출고처<em class="required" title="필수"></em></th>
										<td>
											<select name="delvLocCd"  id="delvLocCd" required="required" data-valid-name="출고처">
											</select>
										</td>
									</tr>
									<tr>
										<th>반품여부<em class="required" title="필수"></em></th>
										<td>
											<label class="rdoBtn"><input type="radio" name="returnableYn" id="returnableYnY" value="Y" checked="checked"/>Y</label>
											<label class="rdoBtn"><input type="radio" name="returnableYn" id="returnableYnN" value="N"/>N</label>
										</td>
										<th>교환여부<em class="required" title="필수"></em></th>
										<td colspan="3">
											<label class="rdoBtn"><input type="radio" name="changeableYn" id="changeableYnY" value="Y" checked="checked"/>Y</label>
											<label class="rdoBtn"><input type="radio" name="changeableYn" id="changeableYnN" value="N"/>N</label>
										</td>
									</tr>
									<tr>
										<th>배송비정책<em class="required" title="필수"></em></th>
										<td>
											<select name="delvFeeCd" required="required" data-valid-name="배송비정책">
											</select>
										</td>
										<th>기본배송비</th>
										<td>
											<input type="text" class="w100 aR" id="delvFee" name="delvFee"  disabled="disabled"/> 원
										</td>
										<th>무료배송비기준</th>
										<td>
											<input type="text" class="w100 aR" id="minOrdAmt" name="minOrdAmt" disabled="disabled"/> 원
										</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" value="1"  required="required" data-valid-name="최소주문수량"/>
										</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" value="20" required="required" data-valid-name="최대주문수량"/>
										</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" value="20" required="required" data-valid-name="ID당1일최대구매수량"/>
										</td>
									</tr>
									<tr>
										<th>판매기간<em class="required" title="필수"></em></th>
										<td colspan="5">
											<input name="sellStYMD" id="sellStYMD" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="판매시작일" />
											<select name="sellStHH" id="sellStHH" 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)}시|" >시간</option>
												</th:block>
											</select>
											~
											<input name="sellEdYMD" id="sellEdYMD" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="판매 종료일" />
											<select name="sellEdHH" id="sellEdHH" 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>
										</td>
									</tr>
									</tbody>
								</table>
							</div>
							<!-- //TAB1  CONTENTS AREA -->
						</li>
						<!-- //TAB1 -->
						<li class="tab" id="goodstab3">
							<!-- TAB3 CONTENTS AREA -->
							<div class="panelStyle">
								<!-- TABS SPACE -->
								<div class="tabsJr">
									<!-- TABS NAVI -->
									<ul class="tabsJrNav">
										<li class="on"><a href="#goodstab11">타이틀/내용/특징</a></li>
										<li><a href="#goodstab12">상세html</a></li>
									</ul>
									<!-- //TABS NAVI -->
									<!-- TABS CONTENT -->
									<ul class="tabsJrCont">
										<!-- TAB11 CONTENTS AREA -->
										<!-- TAB -->
										<li class="tabJr on" id="goodstab11">
											<div class="panelStyle">
											<!-- TAB11 CONTENTS AREA -->
											<table class="frmStyle">
											<colgroup>
												<col width="12%"/>
												<col/>
											</colgroup>
											<tr>
												<th>타이틀</th>
												<td class="padT10"><input type="text" class= "w100p" id="goodsTitlesDesc" name="goodsTitlesDesc" maxlength="100" />
												</td>
											</tr>
											<tr>
												<th>내용</th>
												<td class="padT10"><div class="tabJrContArea">
													<textarea class="textareaR3 summernote" name="goodsContentsDesc" id="goodsContentsDesc"></textarea>
													</div>
												</td>
											</tr>
											<tr>
												<th>상품 특징</th>
												<td class="padT10"><div class="tabJrContArea">
													<textarea class="textareaR3 summernote" name="goodsCharacterDesc" id="goodsCharacterDesc"></textarea>
													</div>
												</td>
											</tr>
											</table>
											</div>
										</li>
										<li class="tabJr" id="goodstab12">
											<div class="panelStyle">
												<!-- TAB11 CONTENTS AREA -->
												<table class="frmStyle">
											<colgroup>
												<col width="12%"/>
												<col/>
											</colgroup>
											<tr>
												<th>상품상세</th>
												<td class="padT10"><div class="tabJrContArea">
													<textarea class="textareaR4 summernote" name="goodsDesc" id="goodsDesc"></textarea>
													</div>
												</td>
											</tr>
											<tr>
												<th>상위(PC)</th>
												<td class="padT10"><div class="tabJrContArea">
													<textarea class="textareaR4 summernote" name="goodsPcTopDesc" id="goodsPcTopDesc"></textarea>
													</div>
												</td>
											</tr>
											<tr>
												<th>상위(MOBILE)</th>
												<td class="padT10"><div class="tabJrContArea">
													<textarea class="textareaR4 summernote" name="goodsMobileTopDesc" id="goodsMobileTopDesc"></textarea>
													</div>
												</td>
											</tr>
											<tr>
												<th>하위(PC)</th>
												<td class="padT10"><div class="tabJrContArea">
													<textarea class="textareaR4 summernote" name="goodsPcDownDesc" id="goodsPcDownDesc"></textarea>
													</div>
												</td>
											</tr>
											<tr>
												<th>하위(MOBILE)</th>
												<td class="padT10"><div class="tabJrContArea">
													<textarea class="textareaR4 summernote" name="goodsMobileDownDesc" id="goodsMobileDownDesc"></textarea>
													</div>
												</td>
											</tr>
											</table>
											</div>
										</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:15%"/>
										<col/>
									</colgroup>
									<tr>
										<th>고시분류<em class="required" title="필수"></em></th>
										<td>
											<select id="niClsfCd" name="niClsfCd"  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 : 고시정보 -->
					</ul>
					<!-- //TABS CONTENTS -->
					
				</div>
				<!-- //TABS SPACE -->
			</div>	<!--  class=panelContent -->	
		</div>	<!--  class=panelStyle -->	
			</form>
		
	</div>
<script type="text/javascript" src="/ux/plugins/summernote/summernote.js?v=2020103001"></script>
<script type="text/javascript" src="/ux/plugins/gaga/gaga.summernote.js?v=2021053101"></script>
<script th:inline="javascript">
/*<![CDATA[*/
	// 인증대상 변경시
	$("#goodsDetailForm input[name=selCertTargetGb]").bind('click', function () {
		var certTargetGb = $(this).val();
		if (certTargetGb == "G083_1"){ 
			$("#goodsDetailForm select[name=certFormGb]").attr('readonly', false);
			$("#goodsDetailForm select[name=certType]").attr('readonly', false);
			$("#goodsDetailForm input[name=certNum]").attr('readonly', false);
		}else{
			$("#goodsDetailForm select[name=certFormGb]").val('');
			$("#goodsDetailForm select[name=certType]").val('');
			$("#goodsDetailForm input[name=certNum]").val('');
			$("#goodsDetailForm select[name=certFormGb]").attr('readonly', true);
			$("#goodsDetailForm select[name=certType]").attr('readonly', true);
			$("#goodsDetailForm input[name=certNum]").attr('readonly', true);
			
			$("#goodsDetailForm").find("#certStateTxt").html('');
			$("#goodsDetailForm").find("#certOrganNameTxt").html('');
			$("#goodsDetailForm").find("#certDtTxt").html('');
			$("#goodsDetailForm").find("#certDivTxt").html('');
			
		}
	});
	
	// 인증타입 변경시
	$("#goodsDetailForm select[name=certType]").bind('click change', function () {
		var certType = $(this).val();
		if (certType == "G081_1" || certType == "G081_2"){ 
			$("#goodsDetailForm input[name=certNum]").attr('readonly', false);
		}else{
			$("#goodsDetailForm input[name=certNum]").val('');
			$("#goodsDetailForm input[name=certNum]").attr('readonly', true);
			
			$("#goodsDetailForm").find("#certStateTxt").html('');
			$("#goodsDetailForm").find("#certOrganNameTxt").html('');
			$("#goodsDetailForm").find("#certDtTxt").html('');
			$("#goodsDetailForm").find("#certDivTxt").html('');
			
		}
	});
	
	
	//상품명 길이표시
	$("#goodsDetailForm input[name=goodsNm]").bind('focus focusout input keyup keydown paste change', function () {
		fnDataLengthCheck('goodsNm',200);
	});

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

	//데이터 길이 확인
	var fnDataLengthCheck = function(id , maxByte){
		var maximumByte = maxByte;
		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);
	}
	
	//업체변경시
	$('#goodsDetailForm select[name=supplyCompCd]').on('change', function() {
		var supplyCompCd = $(this).val();
		// 하위 브랜드
		$("#goodsDetailForm select[name=brandCd] option:gt(0)").remove();
		cfnCreateCombo("/renderer/supplyCompany/brand/list/" + supplyCompCd, $('#goodsDetailForm select[name=brandCd]'), "[선택]", '');
		
		//판매수수료율
		var data = {supplyCompCd : supplyCompCd};
		var jsonData = JSON.stringify(data);
		gagajf.ajaxJsonSubmit('/business/supply/company/list', jsonData, function(result) {
			if (result != null){
				$("#goodsDetailForm input[name=sellFeeRate]").val(result[0].sellFeeRate); 
			}
		});
		
		//배송지 정책
		$("#goodsDetailForm select[name=delvFeeCd] option:gt(0)").remove();
		cfnCreateCombo("/renderer/delvFee/list/" + supplyCompCd, $('#goodsDetailForm select[name=delvFeeCd]'), "[선택]", '');
		
		//출고처
		$("#goodsDetailForm select[name=delvLocCd] option:gt(0)").remove();
		cfnCreateCombo("/renderer/delvLoc/list/" + supplyCompCd, $('#goodsDetailForm select[name=delvLocCd]'), "[선택]", '');
		
	});
	
	//브랜드변경시
	$('#goodsDetailForm select[name=brandCd]').on('change', function() {
		var brandCd = $(this).val();
		//판매수수료율
		//포인트 적용
		var params = new Object();
		params.brandCd = brandCd;
		cfnAjaxSubmit("/business/brand/list", "json", fnBrandCallback, params);
			
	});	
	
	// 브랜드
	var fnBrandCallback = function(result){
		if (result != null){
			$("#goodsDetailForm select[name=distributionGb]").val(result[0].distributionGb); 
		}
	}
	
	//배송비정책변경시
	$('#goodsDetailForm select[name=delvFeeCd]').on('change', function() {
		var delvFeeCd = $("#goodsDetailForm select[name=delvFeeCd]").val();
		
		if (gagajf.isNull(delvFeeCd)){
			$("#goodsDetailForm input[name=delvFee]").val('');
			$("#goodsDetailForm input[name=minOrdAmt]").val('');
		}else{
			var arrDelvFeeed = $('#goodsDetailForm select[name=delvFeeCd] option:selected').text().split('/');
			$("#goodsDetailForm input[name=delvFee]").val(arrDelvFeeed[1].addComma());
			var minOrdAmt = arrDelvFeeed[0].split(']');
			$("#goodsDetailForm input[name=minOrdAmt]").val(minOrdAmt[1].addComma());
		}
	});	
	
	//품목코드변경시
	$('#goodsDetailForm select[name=itemkindCd]').on('change', function() {
		var itemkindCd = $("#goodsDetailForm select[name=itemkindCd]").val();
		var params = new Object();
		params.itemkindCd = itemkindCd;
		cfnAjaxSubmit("/goods/itemkind/list", "json", fnItemkindCallback, params);
		
	});	
	
	var fnItemkindCallback = function(result){
		if (result == null) return;
		$("#goodsDetailForm input[name=safeNiClsfCd]").val(result[0].niClsfCd)
	}
	
	// 상품 고시 선택 버튼 클릭 시
	$('#btnNotinfo').click(function(e) {

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

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

	});
	
	//정보고시 콜백
	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/></colgroup>';
		notiHtml += '<tbody id="infoContents">\n';
		notiHtml += '<tr><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 += '</tr>\n';
		});
		notiHtml += '</tbody></table>';

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

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

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

		// 주문수량
		if (Number($("#goodsDetailForm input[name=minOrdQty]").val()) <= 0) {
			mcxDialog.alertC("최소주문 수량을 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=minOrdQty]").focus();
				}
			});
			return false;
		}
		if (Number($("#goodsDetailForm input[name=maxOrdQty]").val()) <= 0) {
			mcxDialog.alertC("최대주문 수량을 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDetailForm input[name=maxOrdQty]").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(isNaN(Date.parse($("#goodsDetailForm input[name=sellStYMD]").val()))){
			mcxDialog.alertC('날짜형식이 아닙니다.', {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDealForm input[name=sellStYMD]").focus();
				}
			});	
			return false;
		}
		
		if(isNaN(Date.parse($("#goodsDetailForm input[name=sellEdYMD]").val()))){
			mcxDialog.alertC('날짜형식이 아닙니다.', {
				sureBtnText: "확인",
				sureBtnClick: function() {
					$("#goodsDealForm input[name=sellEdYMD]").focus();
				}
			});	
			return false;
		}
	
		idx = 0;
		
		//고시정보가 등록되지 않은 상품 체크
		if($("#goodsDetailForm #notiArea").find("#infoContents tr").length == 0){
			mcxDialog.alert("고시정보를 입력해 주세요");
			return false;
		}
		
		idx = 0;
		//고시정보 필수나 전시표시값 입력여부 확인
		$("#goodsDetailForm #notiArea").find("#infoContents tr").each(function() {
			if (typeof($(this).find("td input[name=niContent]").val()) != 'undefined' && gagajf.isNull($(this).find("td input[name=niContent]").val())){
				optCheck = true;
				mcxDialog.alertC("고시정보를 입력해주세요.");
				return false;
			}

			idx++;
		});
		
		if(optCheck) {
			return false;
		}
		
		fnGoodsSave();
		
	});
	
	//고시정보 저장을 위한 데이터 처리
	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 select[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 fnGoodsSave = function(){
		mcxDialog.confirm('저장하시겠습니까?', {
			cancelBtnText: "취소",
			sureBtnText: "확인",
			sureBtnClick: function(){

				fnGoodsDeailNotiSave();
			
				$('#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/salf/detail/create", "#goodsDetailForm", fnGoodsSaveCallBack); 
			}
		});
	}
	
	//저장후 callback
	var fnGoodsSaveCallBack = function(result){
		mcxDialog.alert("등록상품 코드 : "+ result.goodsCd);
		fnClickLnb('A2021'); // -- 메뉴 클릭
	}
	
	
	$(document).ready(function() {
		
		// 판매일자 설정
		var date = new Date();
		$('#goodsDetailForm  input[name=sellStYMD]').val(date.format("YYYY-MM-DD"));
		$('#goodsDetailForm  input[name=sellEdYMD]').val("2030-12-31");
		
		// Create a summernote
		var snOptions1 = gagaSn.getToolbarOptions('media');
		var snOptions2 = gagaSn.getToolbarOptions('media');
		var snOptions3 = gagaSn.getToolbarOptions('media');
		var snOptions4 = gagaSn.getToolbarOptions('media');
		var snOptions5 = gagaSn.getToolbarOptions('media');
		var snOptions6 = gagaSn.getToolbarOptions('media');
		var snOptions7 = gagaSn.getToolbarOptions('media');
		gagaSn.createSummernote(snOptions1, '#goodsContentsDesc');
		gagaSn.createSummernote(snOptions2, '#goodsCharacterDesc');
		gagaSn.createSummernote(snOptions3, '#goodsDesc');
		gagaSn.createSummernote(snOptions4, '#goodsPcTopDesc');
		gagaSn.createSummernote(snOptions5, '#goodsMobileTopDesc');
		gagaSn.createSummernote(snOptions6, '#goodsPcDownDesc');
		gagaSn.createSummernote(snOptions7, '#goodsMobileDownDesc');
	});
	
/*]]>*/
</script>
</html>