<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : PlanDetailForm.html
 * @desc    : 웹 수정 / 웹 등록 팝업 화면 Page
 *============================================================================
 * SISUN
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.02.04   sowon   최초 작성
 *******************************************************************************
 -->
<div class="modalPopup" data-width="1160" id="planRegisterFormDiv">
	<div class="panelStyle">
		<div class="panelTitle">
			<h2 th:text="${'기획전 ' + (mode == 'N' ? '등록' : '수정')}"></h2>
			<button type="button" class="close" onclick="uifnPopupClose('planRegisterFormDiv')"><i class="fa fa-times"></i></button>
		</div>
		
	<!-- 기획전 웹 수정 -->
		<div class="panelContent" th:if="${mode == 'U'}">
		<form th:object="${planInfo}" id="planUpdateForm" name="planUpdateForm" action="#" th:method="post">
			<input type="hidden" name="mode" th:value="${mode}"/>
			<input type="hidden" name="planSq" th:value="*{planSq}"/>

			<div class="cardArea" style="height: 700px;margin: -5px;">
				<table class="frmStyle">
					<colgroup>
						<col style="width:10%"/>
						<col style="width:40%;"/>
						<col style="width:10%;"/>
						<col style="width:35%;"/>
						<col/>
					</colgroup>
					<tr>
						<th>사이트</th>
						<td>
							<select name="siteCd" th:field="*{siteCd}">
								<option value="">선택</option>
								<option th:if="${siteList}" th:each="oneData, status : ${siteList}" th:value="${oneData.cd}" th:text="|${oneData.cdNm}|"></option>
							</select>
						</td>
						<th>기획전구분<em class="required" title="필수"></em></th>
						<td>
							<select name="planGb" id="planGb" th:field="*{planGb}" onchange="fnChangePlanGb(this);">
								<option value="P">기획전</option>
								<option value="E">이벤트</option>
							</select>
						</td>
					</tr>
					<tr>
						<th>프론트 구분<em class="required" title="필수"></em></th>
						<td>
							<select name="frontGb" id="frontGb" th:field="*{frontGb}">
								<option value="A">전체</option>
								<option value="P">웹</option>
								<option value="M">모바일</option>
							</select>
						</td>
						<th>전시순서</th>
						<td>
							<input type="text" name="dispOrd" class="w100 aR" th:value="*{dispOrd}"/>
						</td>
					</tr>
					<tr>
						<th>기획전명<em class="required" title="필수"></em></th>
						<td>
							<input type="text" name="planNm" id="planNm" th:field="*{planNm}"/>
						</td>
						<th>서브제목<em class="required" title="필수"></em></th>
						<td>
							<input type="text" name="dtlTitle1" id="dtlTitle1" th:value="*{dtlTitle1}"/>
						</td>
					</tr>
					<tr>
						<th>진행기간<em class="required" title="필수"></em></th>
						<td colspan="3">
							<input type="text" class="schDate w100" name="startSearchDate" maxlength="10" required="required" data-valid-name="노출기간" th:field="*{startSearchDate}"/>
							<select name="startSearchHour" 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="*{#strings.substring(dispStdt, 11, 13)} == ${#strings.toString(num)} ? 'true'">시간</option>
								</th:block>
							</select>
							<select name="startSearchMin" required="required" data-valid-name="진행기간 시작시간">
								<th:block th:each="num: ${#numbers.sequence(0,59)}">
								<option th:value="${#numbers.formatInteger(num,2)}"  th:text="|${#numbers.formatInteger(num,2)}분|" th:selected="*{#strings.substring(dispStdt, 14, 16)} == ${#strings.toString(num)} ? 'true'">분</option>
								</th:block>
							</select>
							~
							<input type="text" class="schDate w100" name="endSearchDate" maxlength="10" required="required" data-valid-name="노출기간" th:field="*{endSearchDate}"/>
							<select name="endSearchHour" 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="*{#strings.substring(dispEddt, 11, 13)} == ${#strings.toString(num)} ? 'true'">시간</option>
								</th:block>
							</select>
							<select name="endSearchMin" required="required" data-valid-name="진행기간 종료시간">
								<th:block th:each="num: ${#numbers.sequence(0,59)}">
								<option th:value="${#numbers.formatInteger(num,2)}"  th:text="|${#numbers.formatInteger(num,2)}분|" th:selected="*{#strings.substring(dispEddt, 14, 16)} == ${#strings.toString(num)} ? 'true'">분</option>
								</th:block>
							</select>
							<input type="hidden" name="dispStdt" id="dispStdt"/>
							<input type="hidden" name="dispEddt" id="dispEddt"/>
						</td>
						
					</tr>
					<tr>
						<th>코너명노출 여부<em class="required" title="필수"></em></th>
						<td>
							<select name="cornerNmDispYn" th:field="*{cornerNmDispYn}">
								<option th:if="${useYnList}" th:each="oneData, status : ${useYnList}" th:value="${oneData.cd}" th:selected="${oneData.cd} == 'Y'" th:text="|${oneData.cdNm}|"></option>
							</select>
						</td>
						<th>오픈여부<em class="required" title="필수"></em></th>
						<td>
							<select name="openYn" th:field="*{openYn}">
								<option th:if="${useYnList}" th:each="oneData, status : ${useYnList}" th:value="${oneData.cd}" th:selected="${oneData.cd} == 'Y'" th:text="|${oneData.cdNm}|"></option>
							</select>
						</td>
					</tr>
					<tr>
					</tr>
					<tr>
						<th>사용고객등급구분<em class="required" title="필수"></em></th>
						<td>
							<label class="chkBox" th:if="${usableCustGradeList}" th:each="oneData, status : ${usableCustGradeList}">
								<input type="checkbox" name="usableCustGradeArr" th:value="${oneData.cd}" th:text="${oneData.cdNm}"/>
							</label>
						</td>
						<th>사용가능고객구분<em class="required" title="필수"></em></th>
						<td>
							<label class="chkBox" th:if="${usableCustGbList}" th:each="oneData, status : ${usableCustGbList}">
								<input type="checkbox" name="usableCustGbArr" th:value="${oneData.cd}" th:text="${oneData.cdNm}"/>
							</label>
  						</td>
					</tr>
					<tr>
						<th>제휴채널<em class="required" title="필수"></em></th>
						<td colspan="3">
							<label class="chkBox" th:if="${upperAfLinkCdList}" th:each="oneData, status : ${upperAfLinkCdList}">
								<input type="checkbox" name="upperAfLinkCdArr" th:value="${oneData.cd}" th:text="${oneData.cdNm}"/>
							</label>
  						</td>
						
					</tr>
					<tr>
						<th>PC 메인 이미지<i id="pMimgStar"></i><br/>[삭제여부<label class="chkBox"><input type="checkbox" name="orgMainPimgDelYn" value="Y"/></label>]</th>
						<td>
							<div th:if=*{mainPimg} id="mainPimgView" style="float:left;">
								<img id="PreMainPimgUrl" th:src="${@environment.getProperty('upload.image.view') + '/planning/'} + *{mainPimg}" style="max-width:720px;"/>
							</div>
						</td>
						<td colspan="4">
							<div class="uFile w400">
								<input id="registerMainPimg" name="registerMainPimg" type="file" accept="image/*" class="uFileInput w400"/>
								<label for="registerMainPimg" class="uFileLabel w400">파일선택</label>
								<input type="hidden" name="orgMainPimg" id="orgMainPimg" th:value="*{mainPimg}"/>
								<input type="hidden" name="mainPimg" id="mainPimg"/>
							</div>
						</td>
					</tr>
					<tr>
						<th>모바일 메인 이미지<i id="mMimgStar"></i><br/>[삭제여부<label class="chkBox"><input type="checkbox" name="orgMainMimgDelYn" value="Y"/></label>]</th>
						<td>
							<div th:if=*{mainMimg} id="imgFileView" style="float:left;">
								<img id="PreMainMimgUrl" th:src="${@environment.getProperty('upload.image.view') + '/planning/'} + *{mainMimg}" style="max-width:720px;"/>
							</div>
						</td>
						<td colspan="4">
							<div class="uFile w400">
								<input id="registerMainMimg" name="registerMainMimg" type="file" accept="image/*" class="uFileInput w400"/>
								<label for="registerMainMimg" class="uFileLabel w400">파일선택</label>
								<input type="hidden" name="orgMainMimg" id="orgMainMimg" th:value="*{mainMimg}"/>
								<input type="hidden" name="mainMimg" id="mainMimg"/>
							</div>
						</td>
					</tr>
					<tr>
						<th>댓글여부</th>
						<td colspan="3">
							<select name="replyYn" th:field="*{replyYn}">
								<option th:if="${useYnList}" th:each="oneData, status : ${useYnList}" th:value="${oneData.cd}" th:text="|${oneData.cdNm}|"></option>
							</select>
						</td>
					</tr>
					<tr style="display:none" id="append1">
						<th>댓글제목<em class="required" title="필수"></em></th>
						<td>
							<input type="text" name="replyTitle1" id="replyTitle1" maxlength="50" required="required" data-valid-name="댓글제목" th:field="*{replyTitle1}"/>
						</td>
						
						<th>댓글서브제목<em class="required" title="필수"></em></th>
						<td>
							<input type="text" name="replyTitle2" id="replyTitle2" maxlength="50" required="required" data-valid-name="댓글서브제목" th:field="*{replyTitle2}"/>
						</td>
					
					</tr>
					<tr style="display:none" id="append2">
						<th>댓글위치<em class="required" title="필수"></em></th>
						<td>
							<label class="rdoBtn"><input type="radio" name="replyLoc" value="U" />상품리스트 상단</label>
							<label class="rdoBtn"><input type="radio" name="replyLoc" value="D"/>상품리스트 하단</label>
						</td>
						
						<th>투표일련번호<em class="required" title="필수"></em></th>
						<td>
							<input type="text" class="w100 aR" name="pollSq" th:field="*{pollSq}"/>
						</td>
					
					</tr>
					<tr style="display:none" id="append3">
						<th>댓글이미지<em class="required" title="필수"></em><br/>[삭제여부<label class="chkBox"><input type="checkbox" name="orgReplyImgDelYn" value="Y"/></label>]</th>
						<td>
							<div th:if=*{replyImg} id="replyImgView" style="float:left;">
								<img id="replyImgUrl" th:src="${@environment.getProperty('upload.image.view') + '/planning/'} + *{replyImg}" style="max-width:720px;"/>
							</div>
						</td>
						<td colspan="5">
							<div class="uFile w400">
								<input id="registerReplyImg" name="registerReplyImg" type="file" accept="image/*" class="uFileInput w400"/>
								<label for="registerReplyImg" class="uFileLabel w400">파일선택</label>
								<input type="hidden" name="orgReplyImg" id="orgReplyImg" th:value="*{replyImg}"/>
								<input type="hidden" name="replyImg" id="replyImg" th:value="*{replyImg}"/>
							</div>
						</td>
					
					</tr>
				</tbody>
				<tbody>
					<!-- <tr>
						<th>웹용소스</th>
						<td colspan="5">
							<div style="margin-top:5px;">
								<textarea name="fsrcPc" id="fsrcPcDetail" rows="15" cols="95" style="width:1280px;"></textarea>
							</div>
						</td>
					</tr>
					<tr>
						<th>모바일용소스</th>
						<td colspan="5">
							<div style="margin-top:5px;">
								<textarea name="fsrcMobile" id="fsrcMobileDetail" rows="15" cols="95" style="width:1280px;"></textarea>
							</div>
						</td>
					</tr> -->
				</table>
				
				<div class="panelStyle" style="margin: unset;">
						<!-- TITLE -->
						<div class="panelTitle">
							<h2>기획전 컨텐츠 등록</h2>
							<span class="panelControl"> <i
								class="fa inner-fa-chevron-up"></i> <!-- 열림/닫힘 화살표 -->
							</span>
						</div>
						<!-- //TITLE -->
						<div class="inner-panelContent">
							<div class="panelContent">
								<table class="frmStyle">
									<colgroup>
										<col width="10%" />
										<col width="90%" />
									</colgroup>
									<tr>
										<th> &nbsp;기획전 &nbsp; 컨텐츠&nbsp;</th>
										<td>
											<!-- 수정시 프로모션명 입력 : before -->
											<div class="padding10"
												style="display: inline-block; width: 49%;">
												<!--<span>공급업체 설정</span>-->
												<div class="padding10 inner-tb-solid">
													<span class="buttonSpan">
														<button type="button"
															class="btn btnRight btn-success btn-lg"
															onclick="fnPlanTemplatePopup();">기획전 템플릿</button>
													</span> <br />
												</div>
											</div>
										</td>
									</tr>
								</table>
							</div>
						</div>
					</div>
				<div class="panelStyle" style="margin: unset;">
						<!-- TITLE -->
						<div class="panelTitle">
							<h2>카테고리 / 브랜드 등록</h2>
							<span class="panelControl"> <i
								class="fa inner-fa-chevron-up"></i> <!-- 열림/닫힘 화살표 -->
							</span>
						</div>
						<!-- //TITLE -->
						<div class="panelContent">
							<table class="frmStyle">
								<colgroup>
									<col width="10%" />
									<col width="90%" />
								</colgroup>
								<tr>
									<th>카테고리/브랜드</th>
									<td>
										<!-- 수정시 프로모션명 입력 : before -->
										<div class="padding10"
											style="display: inline-block; width: 49%;">
											<!--<span>공급업체 설정</span>-->
											<div class="padding10 inner-tb-solid">
												<span class="buttonSpan">
													<button type="button"
														class="btn btnRight btn-success btn-lg"
														id="btnAddCate">카테고리 추가</button>
													<button type="button"
														class="btn btnRight btn-success btn-lg"
														id="btnDeleteCate">선택삭제</button>
												</span> <br />
												<div id="gridFGCateList"
													style="width: 100%; height: 200px;"
													class="ag-theme-balham"></div>
											</div>
										</div>
										<div class="padding10"
											style="display: inline-block; width: 49%;">
											<!--<span>브랜드 설정</span>-->
											<div class="padding10 inner-tb-solid">
												<span class="buttonSpan">
													<button type="button"
														class="btn btnRight btn-success btn-lg" id="btnAddBrand">브랜드
														추가</button>
													<button type="button"
														class="btn btnRight btn-success btn-lg"
														id="btnDeleteBrand">선택삭제</button>
												</span> <br />
												<div id="gridFGBrandList"
													style="width: 100%; height: 200px;"
													class="ag-theme-balham"></div>
											</div>
										</div>
									</td>
								</tr>
							</table>
						</div>
					</div>
			</div>
			<div style='margin: 13px;'>
			<ul class="panelBar">
				<li class="right" th:if="${mode == 'U'}">
					<button type="button" class="btn btn-success btn-lg" onclick="fnPlanSave('#planUpdateForm');">저장</button>
				</li>
			</ul>
			</div>
		</form>
	</div>
		
	
		<!-- 기획전 웹 등록 -->
		<div class="panelContent" th:if="${mode == 'N'}">
			<form id="planRegisterForm" name="planRegisterForm" action="#" th:action="@{'/system/user/save'}" th:method="post">
			<input type="hidden" name="mode" th:value="${mode}"/>
			<div>
				<table class="frmStyle">
					<colgroup>
						<col style="width:12.5%;"/>
						<col/>
					</colgroup>
					<tr>
						<th>기존 기획전</th>
						<td>
							<!-- <select name="planSq" id="planSq">
								<option value="">선택</option>
								<option th:if="${planList}" th:each="oneData, status : ${planList}" th:value="${oneData.planSq}" th:text="|[${oneData.planSq}]  ${oneData.planNm}|"></option>
							</select> -->
							<input type="text" class="w100" name="searchTxt" id="searchTxt" maxlength="20" readonly="readonly"/>
							<input type="hidden" class="w100" name="planSq_Hideen" id="planSq_Hideen" maxlength="20"/>
							<button type="button" class="btn icn" id="btnPopupSearchPlan"><i class="fa fa-search"></i></button>
							<button type="button" class="btn btn-primary btn-lg" onclick="fnPlanCopyPopup();">기획전 복사</button>
						</td>
					</tr>
				</table>
			</div>
			<div class="cardArea">
				<table class="frmStyle">
					<colgroup>
						<col style="width:10%"/>
						<col style="width:40%;"/>
						<col style="width:10%;"/>
						<col style="width:35%;"/>
						<col/>
					</colgroup>
					<tr>
						<th>사이트<i class="star"></i></th>
						<td>
							<select name="siteCd" required="required" data-valid-name="사이트">
								<option th:if="${siteList}" th:each="oneData, status : ${siteList}" th:value="${oneData.cd}" th:text="|${oneData.cdNm}|"></option>
							</select>
						</td>
						<th>기획전구분<em class="required" title="필수"></em></th>
						<td>
							<select name="planGb" required="required" data-valid-name="기획전구분" onchange="fnChangePlanGb(this);">
								<option value="P">기획전</option>
								<option value="E">이벤트</option>
							</select>
						</td>
					</tr>
					<tr>
						<th>프론트 구분<em class="required" title="필수"></em></th>
						<td>
							<select name="frontGb" id="frontGb" required="required" data-valid-name="프론트 구분">
								<option value="A">전체</option>
								<option value="P">웹</option>
								<option value="M">모바일</option>
							</select>
						</td>
						<th>전시순서</th>
						<td>
							<input type="text" class="w100 aR" name="dispOrd"/>
						</td>
					</tr>
					<tr>
						<th>기획전명<em class="required" title="필수"></em></th>
						<td>
							<input type="text" name="planNm" id="planNm" maxlength="50" required="required" data-valid-name="기획전명"/>
						</td>
						<th>서브제목<em class="required" title="필수"></em></th>
						<td>
							<input type="text" name="dtlTitle1" id="dtlTitle1"/>
						</td>
					</tr>
					<tr>
						<th>진행기간<em class="required" title="필수"></em></th>
						<td colspan="3">
							<input type="text" class="schDate w100" id="viewStartDtNew" name="startSearchDate" maxlength="10" required="required" data-valid-name="노출기간" />
							<select name="startSearchHour" 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>
							<select name="startSearchMin" required="required" data-valid-name="진행기간 시작시간">
								<th:block th:each="num: ${#numbers.sequence(0,59)}">
								<option  th:value="${#numbers.formatInteger(num,2)}"  th:text="|${#numbers.formatInteger(num,2)}분|" >분</option>
								</th:block>
							</select>
							~
							<input type="text" class="schDate w100" id="viewEndDtNew" name="endSearchDate" maxlength="10" required="required" data-valid-name="노출기간"/>
							<select name="endSearchHour" 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)}==23 ? 'true'">시간</option>
								</th:block>
							</select>
							<select name="endSearchMin" required="required" data-valid-name="진행기간 종료시간">
								<th:block th:each="num: ${#numbers.sequence(0,59)}">
								<option th:value="${#numbers.formatInteger(num,2)}"  th:text="|${#numbers.formatInteger(num,2)}분|" th:selected="${#numbers.formatInteger(num,2)}==59 ? 'true'">분</option>
								</th:block>
							</select>
							<input type="hidden" name="dispStdt" id="dispStdt"/>
							<input type="hidden" name="dispEddt" id="dispEddt"/>
						</td>
						
					</tr>
					<tr>
						<th>코너명노출 여부<em class="required" title="필수"></em></th>
						<td>
							<select name="cornerNmDispYn" required="required" data-valid-name="코너명노출 여부">
								<option th:if="${useYnList}" th:each="oneData, status : ${useYnList}" th:value="${oneData.cd}" th:selected="${oneData.cd} == 'Y'" th:text="|${oneData.cdNm}|"></option>
							</select>
						</td>
						<th>오픈여부<em class="required" title="필수"></em></th>
						<td colspan="3">
							<select name="openYn" required="required" data-valid-name="오픈여부">
								<option th:if="${useYnList}" th:each="oneData, status : ${useYnList}" th:value="${oneData.cd}" th:selected="${oneData.cd} == 'Y'" th:text="|${oneData.cdNm}|"></option>
							</select>
						</td>
					</tr>
					<tr>
						
					</tr>
					<tr>
						<th>사용고객등급구분<em class="required" title="필수"></em></th>
						<td>
							<label class="chkBox" th:if="${usableCustGradeList}" th:each="oneData, status : ${usableCustGradeList}">
								<input type="checkbox" name="usableCustGradeArr" th:value="${oneData.cd}" th:text="${oneData.cdNm}"/>
							</label>
						</td>
						<th>사용가능고객구분<em class="required" title="필수"></em></th>
						<td>
							<label class="chkBox" th:if="${usableCustGbList}" th:each="oneData, status : ${usableCustGbList}">
								<input type="checkbox" name="usableCustGbArr" th:value="${oneData.cd}" th:text="${oneData.cdNm}"/>
							</label>
  						</td>
					</tr>
					<tr>
						<th>제휴채널<em class="required" title="필수"></em></th>
						<td colspan="3">
							<label class="chkBox" th:if="${upperAfLinkCdList}" th:each="oneData, status : ${upperAfLinkCdList}">
								<input type="checkbox" name="upperAfLinkCdArr" th:value="${oneData.cd}" th:text="${oneData.cdNm}"/>
							</label>
  						</td>
					</tr>
					<tr>
						<th>PC 메인 이미지<i id="pMimgStar"></i></th>
						<td colspan="5">
							<div class="uFile w400">
								<input id="registerMainPimg" name="registerMainPimg" type="file" accept="image/*" class="uFileInput w400"/>
								<label for="registerMainPimg" class="uFileLabel w400">파일선택</label>
								<input type="hidden" name="mainPimg" id="mainPimg" value=""/>
							</div>
						</td>
					</tr>
					<tr>
						<th>모바일 메인 이미지<i id="mMimgStar"></i></th>
						<td colspan="5">
							<div class="uFile w400">
								<input id="registerMainMimg" name="registerMainMimg" type="file" accept="image/*" class="uFileInput w400"/>
								<label for="registerMainMimg" class="uFileLabel w400">파일선택</label>
								<input type="hidden" name="mainMimg" id="mainMimg" value=""/>
							</div>
						</td>
					</tr>
					<tr>
						<th>댓글여부<em class="required" title="필수"></em></th>
						<td colspan="5">
							<select name="replyYn">
								<option th:if="${useYnList}" th:each="oneData, status : ${useYnList}" th:value="${oneData.cd}" th:selected="${oneData.cd} == 'N'" th:text="|${oneData.cdNm}|"></option>
							</select>
						</td>
					</tr>
					<tr style="display:none" id="append1">
						<th>댓글제목<em class="required" title="필수"></em></th>
						<td>
							<input type="text" name="replyTitle1" id="replyTitle1" maxlength="50" required="required" data-valid-name="댓글제목"/>
						</td>
						
						<th>댓글서브제목<em class="required" title="필수"></em></th>
						<td>
							<input type="text" name="replyTitle2" id="replyTitle3" maxlength="50" required="required" data-valid-name="댓글서브제목"/>
						</td>
					
					</tr>
					<tr style="display:none" id="append2">
						<th>댓글위치<em class="required" title="필수"></em></th>
						<td>
							<label class="rdoBtn"><input type="radio" name="replyLoc" value="U"/>상품리스트 상단</label>
							<label class="rdoBtn"><input type="radio" name="replyLoc" value="D"/>상품리스트 하단</label>
						</td>
						
						<th>투표일련번호<em class="required" title="필수"></em></th>
						<td>
							<input type="text" class="w100 aR" name="pollSq"/>
						</td>
					
					</tr>
					<tr style="display:none" id="append3">
						<th>댓글이미지<em class="required" title="필수"></em></th>
						<td colspan="5">
							<div class="uFile w400">
								<input id="registerReplyImg" name="registerReplyImg" type="file" accept="image/*" class="uFileInput w400"/>
								<label for="registerReplyImg" class="uFileLabel w400">파일선택</label>
								<input type="hidden" name="replyImg" id="replyImg" value=""/>
							</div>
						</td>
					
					</tr>
				</tbody>
				<tbody>
				</table>
					<div class="panelStyle" style="margin: unset;">
						<!-- TITLE -->
						<div class="panelTitle">
							<h2>카테고리 / 브랜드 등록</h2>
							<span class="panelControl"> <i
								class="fa inner-fa-chevron-up"></i> <!-- 열림/닫힘 화살표 -->
							</span>
						</div>
						<!-- //TITLE -->
						<div class="inner-panelContent">
							<div class="panelContent">
								<table class="frmStyle">
									<colgroup>
										<col width="10%" />
										<col width="90%" />
									</colgroup>
									<tr>
										<th>카테고리/브랜드</th>
										<td>
											<!-- 수정시 프로모션명 입력 : before -->
											<div class="padding10"
												style="display: inline-block; width: 49%;">
												<!--<span>공급업체 설정</span>-->
												<div class="padding10 inner-tb-solid">
													<span class="buttonSpan">
														<button type="button"
															class="btn btnRight btn-success btn-lg"
															id="btnAddCate">카테고리 추가</button>
														<button type="button"
															class="btn btnRight btn-success btn-lg"
															id="btnDeleteCate">선택삭제</button>
													</span> <br />
													<div id="gridFGCateList"
														style="width: 100%; height: 200px;"
														class="ag-theme-balham"></div>
												</div>
											</div>
											<div class="padding10"
												style="display: inline-block; width: 49%;">
												<!--<span>브랜드 설정</span>-->
												<div class="padding10 inner-tb-solid">
													<span class="buttonSpan">
														<button type="button"
															class="btn btnRight btn-success btn-lg" id="btnAddBrand">브랜드
															추가</button>
														<button type="button"
															class="btn btnRight btn-success btn-lg"
															id="btnDeleteBrand">선택삭제</button>
													</span> <br />
													<!-- 브랜드 선택 팝업(단수 선택 팝업... 복수를 새로 만들어야하는지 ? 아니면 변수처리해야하는지 ? -->
													<div id="gridFGBrandList"
														style="width: 100%; height: 200px;"
														class="ag-theme-balham"></div>
												</div>
											</div>
										</td>
									</tr>
								</table>
							</div>
						</div>
					</div>
				</div>
				<ul class="panelBar">
					<li class="right" th:if="${mode == 'N'}">
						<button type="button" class="btn btn-info btn-lg" onclick="fnPlanSave('#planRegisterForm');">저장</button>
					</li>
				</ul>
			</form>
		</div>
	</div>
</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=2020103001"></script>
<script th:inline="javascript">
/*<![CDATA[*/

	var mode = [[${mode}]];
	var planInfo = [[${planInfo}]];
	var fsrcPc = [[${fsrcPc}]];
	var fsrcMobile = [[${fsrcMobile}]];
	var planBrandList = [[${planBrandList}]];
	var planCateList = [[${planCateList}]];
	var custGbList = [[${gbList}]];
	var custGradeList =	[[${gradeList}]]; 
	var snOptions;

	// 카테고리 전시 여부
	var fnCataCheck = function(is, formId) {
		if (is.checked) {
			$(formId + ' input[name=cateDispYn]').val('Y');
			// 추후 카테고리 표시
		} else {
			$(formId + ' input[name=cateDispYn]').val('N');
		}
	}

	// 상품제한여부
	var fnGoodsCheck = function(is, formId) {
		if (is.checked) {
			$(formId + ' input[name=goodsLimitYn]').val('Y');
			$(formId + ' input[name=goodsLimitQty]').show();
			$(formId + ' input[name=goodsLimitQty]').focus();
			// 추후 카테고리 표시
		} else {
			$(formId + ' input[name=goodsLimitYn]').val('N');
			$(formId + ' input[name=goodsLimitQty]').hide();
		}
	}
	
	//템플릿 유형 설정
	var fnPlanTemplatePopup = function () {
		var actionUrl = "/marketing/planning/detail/template/form?mode=C&planSq=" + planInfo.planSq;
		cfnOpenModalPopup(actionUrl,'popupPlanTemplate');
	}
	
	// 기존 기획전 조회 선택시
	$('#btnPopupSearchPlan').on('click', function(result) {
		cfnOpenPlanPopup('popupPlan');
		
	});
	
	var popupPlan = function (result) {
		$("#planSq_Hideen").val(result[0].planSq);
		$("#searchTxt").val("[" + result[0].planSq + "] " +result[0].planNm);
		
	}
	
	// 댓글여부에 입력창 추가
	$('select[name=replyYn]').on('change', function() {
		if($('select[name=replyYn]').val() == 'Y'){
			$("#append1").removeAttr('style');
			$("#append2").removeAttr('style');
			$("#append3").removeAttr('style');
		}else{
			$("#append1").css('display','none');
			$("#append2").css('display','none');
			$("#append3").css('display','none');
		}
	})
	
	// 불러오기 댓글
	if($('#planUpdateForm select[name=replyYn]').val()=='Y'){
			$("#append1").removeAttr('style');
			$("#append2").removeAttr('style');
			$("#append3").removeAttr('style');
			
			if(custGbList.length > 0){
				var chkboxCnt = $('#planUpdateForm input:checkbox[name=usableCustGbArr]').length;
				var dataCnt = custGbList.length;
				for(let i=0; i<chkboxCnt; i++){
					for(let j=0; j<dataCnt; j++){
						var data = custGbList[j].custGb;
						if($('#planUpdateForm input:checkbox[name=usableCustGbArr]').eq(i).val() == data){
							$('#planUpdateForm input:checkbox[name=usableCustGbArr]').eq(i).prop('checked', true);
							$("#planUpdateForm input:checkbox[name=usableCustGbArr]").eq(i).parent().addClass('checked');
						}
					}
				}
			}
			
			if(custGradeList.length > 0){
				var chkboxCnt = $('#planUpdateForm input:checkbox[name=usableCustGradeArr]').length;
				var dataCnt = custGradeList.length;
				for(let i=0; i<chkboxCnt; i++){
					for(let j=0; j<dataCnt; j++){
						var data = custGradeList[j].custGrade;
						if($('#planUpdateForm input:checkbox[name=usableCustGradeArr]').eq(i).val() == data){
							$('#planUpdateForm input:checkbox[name=usableCustGradeArr]').eq(i).prop('checked', true);
							$("#planUpdateForm input:checkbox[name=usableCustGradeArr]").eq(i).parent().addClass('checked');
						}
					}
				}
			}
	}else{
		$("#append1").css('display','none');
		$("#append2").css('display','none');
		$("#append3").css('display','none');
	}
	
	

	// 기획전 복사
	var fnPlanCopyPopup = function() {
		var planSq = $("#planSq_Hideen").val(); 

		if (gagajf.isNull(planSq)) {
			mcxDialog.alert('복사할 기획전을 선택하세요.');
			return;
		}

		mcxDialog.confirm('선택 된 기획전을 복사 하시겠습니까?', {
			cancelBtnText: "취소",
			sureBtnText: "확인",
			sureBtnClick: function() {
				var actionUrl = '/marketing/planning/copy';
				var data = {copyPlanSq : planSq};
				var jsonData = JSON.stringify(data);

				gagajf.ajaxJsonSubmit(actionUrl, jsonData, fnCopyCallback);
			}
		});
	}

	// 기획전 복사 callback
	var fnCopyCallback = function(result) {
		uifnPopupClose('planRegisterFormDiv');
		fnPlanListSearch();

		var actionUrl = "/marketing/planning/detail/form?mode=U&planSq=" + result.planSq;
		cfnOpenModalPopup(actionUrl,'popupPlan');
	}

	var fnPlanSave = function(formId) {
		if (!gagajf.validation(formId))
			return;

		// 날짜 유효성 체크
		var stDate = $(formId + ' input[name=startSearchDate]').val().replaceAll("-", "");
		var edDate = $(formId + ' input[name=endSearchDate]').val().replaceAll("-", "");
		var toDate = _today.replaceAll("-", "");

		if (Number(stDate) > Number(edDate)) {
			mcxDialog.alert('종료일자는 시작일자 보다 클 수 없습니다.');
			return;
		}

		if (Number(stDate) < Number(toDate) && mode == 'N') {
			mcxDialog.alert('시작일자는 오늘포함 이후로 등록해주세요.');
			return;
		}

		if (Number(edDate) < Number(toDate) && mode == 'N') {
			mcxDialog.alert('종료일자는 오늘포함 이후로 등록해주세요.');
			return;
		}
		
		stDate = $(formId + ' input[name=startSearchDate]').val();
		edDate = $(formId + ' input[name=endSearchDate]').val();
		$(formId + ' input[name=dispStdt]').val(stDate + ' ' + $(formId + ' select[name=startSearchHour]').val() + ':' + $(formId + ' select[name=startSearchMin]').val() + ':00');
		$(formId + ' input[name=dispEddt]').val(edDate + ' ' + $(formId + ' select[name=endSearchHour]').val() + ':' + $(formId + ' select[name=endSearchMin]').val() + ':59');

		
	/* 	if ($('#replyYn').val() == 'Y') {
			var replyLoc = $(':radio[name="replyLoc"]:checked').val();

			if (typeof replyLoc == 'undefined') {
				mcxDialog.alert('댓글 사용 시 댓글위치를 선택해야합니다.');
				return;
			}
		}  */

		// poll 관리일련번호 유효성 체크
		/* if (!gagajf.isNull($(formId + ' input[name=pollSq]').val())) {
			gagajf.ajaxFormSubmit('/marketing/poll/list', formId, function(result) {
				console.log(result);
				if (result.length < 1) {
					mcxDialog.alert('입력하신 투표 일련번호가 존재 하지않습니다.');
					return;
				}
			});
		} */

		var privacyPolicy = '';
		var frontGb = $('#frontGb').val();
		if (mode =='U') {
			//if($("#planGb").val()=='E'){
			//	privacyPolicy = gagaSn.getContents('privacyPolicyDetail');
			//}
			
			// 이미지 처리
			if ((!$('input[name=orgMainPimgDelYn]').is(':checked') ? true : false) &&
				(gagajf.isNull($(formId + ' input[name=mainPimg]').val()) == true)   ) {
				$(formId + ' input[name=mainPimg]').val($(formId + ' input[name=orgMainPimg]').val());
			}

			if ((!$('input[name=orgMainMimgDelYn]').is(':checked') ? true : false) &&
				(gagajf.isNull($(formId + ' input[name=mainMimg]').val()) == true)  ) {
				$(formId + ' input[name=mainMimg]').val($(formId + ' input[name=orgMainMimg]').val());
			}

			if ((!$('input[name=orgDtlPimgDelYn]').is(':checked') ? true : false) &&
				(gagajf.isNull($(formId + ' input[name=dtlPimg]').val()) == true)  ) {
				$(formId + ' input[name=dtlPimg]').val($(formId + ' input[name=orgDtlPimg]').val());
			}

			if ((!$('input[name=orgDtlMimgDelYn]').is(':checked') ? true : false) &&
				(gagajf.isNull($(formId + ' input[name=dtlMimg]').val()) == true)  ) {
				$(formId + ' input[name=dtlMimg]').val($(formId + ' input[name=orgDtlMimg]').val());
			}

			if ((!$('input[name=orgReplyImgDelYn]').is(':checked') ? true : false) &&
				(gagajf.isNull($(formId + ' input[name=replyImg]').val()) == true) ) {
				$(formId + ' input[name=replyImg]').val($(formId + ' input[name=orgReplyImg]').val());
			}
		} else {
			//gagaSn.getContents('fsrcPcRegister');
			//gagaSn.getContents('fsrcMobileRegister');
			//if($("#planGb").val()=='E'){
			//	privacyPolicy = gagaSn.getContents('privacyPolicyRegister');
			//}
		}

		if(!gagajf.isNull($(formId + ' input[name=planQtitle]').val()) && gagajf.isNull(privacyPolicy.replace(/<br>/gi, '').replace(/<p>/gi, '').replace(/<\/\p>/gi, ''))){
			mcxDialog.alert('입력항목 등록 시 개인정보 수집동의를 입력해 주세요.');
			return;
		}

		//var jsonData = JSON.stringify($("#planRegisterForm").serializeObject());
		
		let allBrandData = gagaAgGrid.getAllRowData(gridOptionsFGBrandList);
		var multiBrand = [];
		$.each(allBrandData, function(idx, item) {
			multiBrand.push(item.brandGroupNo);
		});
		
		let allCateData = gagaAgGrid.getAllRowData(gridOptionsFGCateList);
		var multiCate = [];
		$.each(allCateData, function(idx, item) {
			multiCate.push(item.cateNo);
		});
		
		var usableCustGradeArr = [];
		var chkCustGrade = $('#planRegisterForm input:checkbox[name=usableCustGradeArr]:checked');
		for(let i=0; i< chkCustGrade.length; i++){
			usableCustGradeArr.push(chkCustGrade.eq(i).val());
		}
		
		var usableCustGbArr = [];
		var chkCustGb = $('#planRegisterForm input:checkbox[name=usableCustGbArr]:checked');
		for(let i=0; i< chkCustGb.length; i++){
			usableCustGbArr.push(chkCustGb.eq(i).val());
		}
		
		// 기획전 등록
		if (formId == '#planRegisterForm') {
			mcxDialog.confirm('등록 하시겠습니까?', {
				cancelBtnText: "취소",
				sureBtnText: "확인",
				sureBtnClick: function() {
					
					let data = {
							 multiBrand : multiBrand
							,brandList : allBrandData
							,multiCate : multiCate
							,CateList : allCateData
							,usableCustGradeArr : usableCustGradeArr
							,usableCustGbArr : usableCustGbArr
						    ,mode : $('#planRegisterForm input[name=mode]').val()
						    ,planSq : $('#planRegisterForm input[name=planSq]').val()
							,planGb	: $('#planRegisterForm select[name=planGb]').val()
							,frontGb : $('#planRegisterForm select[name=frontGb]').val()
							,planNm : $('#planRegisterForm input[name=planNm]').val()
							,startSearchDate : $('#planRegisterForm input[name=startSearchDate]').val()
							,startSearchHour : $('#planRegisterForm input[name=startSearchHour]').val()
							,startSearchMin : $('#planRegisterForm input[name=startSearchMin]').val()
							,endSearchDate : $('#planRegisterForm input[name=endSearchDate]').val()
							,endSearchHour : $('#planRegisterForm input[name=endSearchHour]').val()
							,endSearchMin : $('#planRegisterForm input[name=endSearchMin]').val()
							,dispStdt : $('#planRegisterForm input[name=dispStdt]').val()
							,dispEddt : $('#planRegisterForm input[name=dispEddt]').val()
							,dtlTitle1 : $('#planRegisterForm input[name=dtlTitle1]').val()
							,cornerNmDispYn :  $('#planRegisterForm select[name=cornerNmDispYn]').val()
							,openYn :  $('#planRegisterForm select[name=openYn]').val()
							,siteCd :$('#planRegisterForm select[name=siteCd]').val()
							,dispOrd : $('#planRegisterForm input[name=dispOrd]').val()
							,replyYn : $('#planRegisterForm select[name=replyYn]').val()
							,mainPimg :$('#planRegisterForm input[name=mainPimg]').val()
							,mainMimg : $('#planRegisterForm input[name=mainMimg]').val()
							,fsrcPc :  $('#planRegisterForm input[name=fsrcPc]').val()
							,fsrcMobile : $('#planRegisterForm input[name=fsrcMobile]').val()
							,replyImg : $('#planRegisterForm input[name=replyImg]').val()
							,replyLoc : $('#planRegisterForm input:radio[name="replyLoc"]:checked').val()
							,replyTitle1 : $('#planRegisterForm input[name=replyTitle1]').val()
							,replyTitle2 : $('#planRegisterForm input[name=replyTitle2]').val()
							,pollSq : $('#planRegisterForm input[name=pollSq]').val()
							 
						}	
					
					var jsonData =  JSON.stringify(data);
					gagajf.ajaxJsonSubmit("/marketing/planning/detail/create", jsonData, fnPlanDetailCallBack); 
					uifnPopupClose('planRegisterFormDiv');
					fnPlanListSearch();
					//fnPlanDetailClose();
				}
			});
		} else { // 기획전 수정
			mcxDialog.confirm('저장 하시겠습니까?', {
				cancelBtnText: "취소",
				sureBtnText: "확인",
				sureBtnClick: function() {
					
					let data = {
							 multiBrand : multiBrand
							,brandList : allBrandData
							,multiCate : multiCate
							,CateList : allCateData
						    ,mode : $('#planUpdateForm input[name=mode]').val()
						    ,planSq : $('#planUpdateForm input[name=planSq]').val()
							,planGb	: $('#planUpdateForm select[name=planGb]').val()
							,frontGb : $('#planUpdateForm select[name=frontGb]').val()
							,planNm : $('#planUpdateForm input[name=planNm]').val()
							,startSearchDate : $('#planUpdateForm input[name=startSearchDate]').val()
							,startSearchHour : $('#planUpdateForm input[name=startSearchHour]').val()
							,startSearchMin : $('#planUpdateForm input[name=startSearchMin]').val()
							,endSearchDate : $('#planUpdateForm input[name=endSearchDate]').val()
							,endSearchHour : $('#planUpdateForm input[name=endSearchHour]').val()
							,endSearchMin : $('#planUpdateForm input[name=endSearchMin]').val()
							,dispStdt : $('#planUpdateForm input[name=dispStdt]').val()
							,dispEddt : $('#planUpdateForm input[name=dispEddt]').val()
							,dtlTitle1 : $('#planUpdateForm input[name=dtlTitle1]').val()
							,cornerNmDispYn :  $('#planUpdateForm select[name=cornerNmDispYn]').val()
							,openYn :  $('#planUpdateForm select[name=openYn]').val()
							,siteCd :$('#planUpdateForm select[name=siteCd]').val()
							,dispOrd : $('#planUpdateForm input[name=dispOrd]').val()
							,replyYn : $('#planUpdateForm select[name=replyYn]').val()
							,mainPimg :$('#planUpdateForm input[name=mainPimg]').val()
							,mainMimg : $('#planUpdateForm input[name=mainMimg]').val()
							,fsrcPc :  $('#planUpdateForm input[name=fsrcPc]').val()
							,fsrcMobile : $('#planUpdateForm input[name=fsrcMobile]').val()
						}	
					
					
					var actionUrl = '/marketing/plan/detail/update';
					var jsonData =  JSON.stringify(data);
					gagajf.ajaxJsonSubmit(actionUrl, jsonData, fnPlanDetailCallBack); 
						uifnPopupClose('planRegisterFormDiv');
						fnPlanListSearch();
						//fnPlanDetailClose();
				}
			});
		}
	}

	// 이미지 첨부
	$('input[name=registerMainPimg],input[name=registerMainMimg],input[name=registerDtlPimg],input[name=registerDtlMimg],input[name=registerReplyImg]').on('change', function() {
		var name = $(this)[0].name;

		var file = this.files[0];

		gagajf.ajaxFileUpload('/common/file/upload?subDir=/planning'
				, file
				, function(result) {
					if (name == 'registerMainPimg')
						$('input[name=mainPimg]').val(result.newFileName);

					if (name == 'registerMainMimg')
						$('input[name=mainMimg]').val(result.newFileName);

					if (name == 'registerDtlPimg')
						$('input[name=dtlPimg]').val(result.newFileName);

					if (name == 'registerDtlMimg')
						$('input[name=dtlMimg]').val(result.newFileName);

					if (name == 'registerReplyImg')
						$('input[name=replyImg]').val(result.newFileName);
				}
				, 'image'
		);
	});


	var fnChangePlanGb = function(obj) {
		if($(obj).val()=='E'){
			$("#questionEventInsert").show();
			$("#questionEventUpdate").show();
			if (mode =='U') {
				if($("#privacyPolicyDetail").closest('div').children('#the_iframe').length==0){
					gagaSn.createSummernote(snOptions, '#privacyPolicyDetail');
				}
			}else{
				if($("#privacyPolicyRegister").closest('div').children('#the_iframe').length==0){
					gagaSn.createSummernote(snOptions, '#privacyPolicyRegister');
				}
			}
		}else{
			$("#questionEventInsert").hide();
			$("#questionEventUpdate").hide();
		}
	}

	var fnAddRow = function(obj){
		var html = '<div>';
		html += '<input type="text" class="w200" name="planQtitle"/>';
		html += '<label class="chkBox"><input type="checkbox" onclick="fnAttachYnClick(this);" />첨부파일</label>';
		html += '<button type="button" class="btn icn" onclick="fnDeleteRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button>';
		html += '<input type="hidden" name="attachYn" value="N"/>';
		html += '</div>';
		$(obj).closest('td').append(html);
	}

	var fnDeleteRow = function(obj){
		$(obj).closest('div').remove();
	}

	var fnAttachYnClick = function(obj){
		var val = 'N';
		if($(obj).prop('checked')){
			val = 'Y';
		}
		$(obj).closest('div').find('input[name="attachYn"]').val(val);
	}

	var fnPlanDetailCallBack = function() {
		uifnPopupClose('planRegisterForm');
		fnPlanListSearch();
		
	}
	
	// 브랜드 리스트 설정
	var columnBrandList = [
		{width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
		{headerName: "브랜드그룹NO", field: "brandGroupNo", width: 110, cellClass: 'text-center'},
		{headerName: "브랜드그룹명", field: "brandGroupKnm", width: 120, cellClass: 'text-center'},
		{headerName: "브랜드영문명", field: "brandGroupEnm", width: 150, cellClass: 'text-center'},
		{headerName: "", field: "brandKnm", width: 150, cellClass: 'text-center'},
		/* {headerName: "적용대상", field: "targetGb", width: 150, cellClass: 'text-center', hide: true},
		{headerName: "시퀀스", field: "tmtbGoodsSq", width: 150, cellClass: 'text-center', hide: true},
		{headerName: "삭제여부", field: "delYn", width: 150, cellClass: 'text-center', hide: true}  */
	];
	
	// 브랜드 그리드 설정
	var gridOptionsFGBrandList = gagaAgGrid.getGridOptions(columnBrandList);
	gridOptionsFGBrandList.rowSelection = "multiple";
	gridOptionsFGBrandList.suppressRowClickSelection = true;
	
	// 브랜드 추가 버튼 클릭시 (복수 브랜드때 수정 필요)
	$('#btnAddBrand').on('click', function() {
		cfnOpenBrandGroupListPopup("fnSetPopupBrandInfo", "S", "C");
	});
	
	 // 브랜드 설정 선택삭제 버튼 클릭시
    $('#btnDeleteBrand').on('click', function() {
        gridOptionsFGBrandList.api.updateRowData({remove:gagaAgGrid.selectedRowData(gridOptionsFGBrandList)});
    });
	
	// 브랜드 설정 / 브랜드 추가 콜백함수 (단수로 가져오므로 복수일 경우에 수정 확인 필요)
	var fnSetPopupBrandInfo = function(result) {
		for(let i = 0 ; i < result.length ; i++) {
			let addChk = true, gridListValue = gagaAgGrid.getAllRowData(gridOptionsFGBrandList);		// 받아온 모든 데이터

			// 받아온 data for
			for(let j = 0 ; j < gridListValue.length ; j++) {
				if(gridListValue[j].brandGroupNo == result[i].brandGroupNo) {	addChk = false;	}					// 중복체크
			}

			// 중복되지 않은 데이터 리스트에 추가
			if(addChk) {
				gagaAgGrid.addRowData(gridOptionsFGBrandList, {"brandGroupNo" : result[i].brandGroupNo, "brandGroupKnm" : result[i].brandGroupKnm, "brandGroupEnm" : result[i].brandGroupEnm});
			}
		}
	};
	
	// 카테고리 리스트 설정
	var columnCateList = [
		{width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
		{headerName: "사이트", field: "siteCd", width: 120, cellClass: 'text-center'},
		{headerName: "카테고리 구분", field: "cateGb", width: 110, cellClass: 'text-center'},
		{headerName: "카테고리 이름", field: "cateNm", width: 120, cellClass: 'text-center'},
		{headerName: "번호", field: "cateNo", width: 150, cellClass: 'text-center', hide: true},
		/* {headerName: "시퀀스", field: "tmtbGoodsSq", width: 150, cellClass: 'text-center', hide: true},
		{headerName: "삭제여부", field: "delYn", width: 150, cellClass: 'text-center', hide: true}  */
	];
	
	// 카테고리 그리드 설정
	var gridOptionsFGCateList = gagaAgGrid.getGridOptions(columnCateList);
	gridOptionsFGCateList.rowSelection = "multiple";
	gridOptionsFGCateList.suppressRowClickSelection = true;
	
	// 브랜드 설정 선택삭제 버튼 클릭시
    $('#btnDeleteCate').on('click', function() {
    	gridOptionsFGCateList.api.updateRowData({remove:gagaAgGrid.selectedRowData(gridOptionsFGCateList)});
    });
	
	
	
	// 카테고리 추가
	$('#btnAddCate').on('click' , function () {
		cfnOpenCategoryPopup("fnSetPopupCategoryInfo");
	});
	
	// 카테고리 추가 콜백 함수
	var fnSetPopupCategoryInfo = function (result) {
		// 기존 리스트 데이터 for
		for(let i = 0 ; i < result.length ; i++) {
			let addChk = true, gridListValue = gagaAgGrid.getAllRowData(gridOptionsFGCateList);		// 받아온 모든 데이터

			// 받아온 data for
			for(let j = 0 ; j < gridListValue.length ; j++) {
				// 동일한 data는 추가하지 않음
				if(gridListValue[j].cateNo == result[i].cateNo) {	addChk = false;	}		// 중복체크
			}

			// 중복되지 않은 데이터 리스트에 추가
			if(addChk) {
				if(result[i].cate2No!=null)
				{
					mcxDialog.alert('카테고리1에서 선택하세요.');
					return;
				}
				gagaAgGrid.addRowData(gridOptionsFGCateList, {"siteCd":result[i].siteCd , "cateGb":result[i].cateGb, "cateNm":result[i].cateNm, "cateNo":result[i].cateNo});
			}
		}
	}
	
	

	$(document).ready(function() {
		
		snOptions = gagaSn.getToolbarOptions('media');
		
		// 썸머노트 그리기
		gagaSn.createSummernote(snOptions, '#fsrcPcDetail');
		gagaSn.createSummernote(snOptions, '#fsrcMobileDetail');
		
		// 그리드 그리기
		gagaAgGrid.createGrid("gridFGBrandList", gridOptionsFGBrandList);
		gagaAgGrid.createGrid("gridFGCateList", gridOptionsFGCateList);
		
		 if (mode =='U') {
			/* $('#planDetailForm input[name=badgeFcolor]').spectrum({
				preferredFormat: "hex",
				showInput: true,
				allowEmpty: true
			});

			$('#planDetailForm input[name=badgeBcolor]').spectrum({
				preferredFormat: "hex",
				showInput: true,
				allowEmpty: true
			}); */
			
			gridOptionsFGBrandList.api.setRowData(planBrandList);
			gridOptionsFGCateList.api.setRowData(planCateList);

			if (planInfo.goodsLimitYn == 'N') {
				$('#planDetailForm input[name=goodsLimitQty]').hide();
			} else {
				$('#planDetailForm input[name=goodsLimitQty]').show();
			}

			// 썸머노트 값 설정
			$('#fsrcPcDetail').summernote('code', fsrcPc.fsrc);
			$('#fsrcMobileDetail').summernote('code', fsrcMobile.fsrc);

			if($("#planGb").val()!='E'){
				$("#questionEventInsert").hide();
				$("#questionEventUpdate").hide();
			}else{
				gagaSn.createSummernote(snOptions, '#privacyPolicyRegister');
			}

		} else {
			/* $('#planRegisterForm input[name=badgeFcolor]').spectrum({
				preferredFormat: "hex",
				showInput: true,
				allowEmpty: true
			});

			$('#planRegisterForm input[name=badgeBcolor]').spectrum({
				preferredFormat: "hex",
				showInput: true,
				allowEmpty: true
			}); */

			$("#viewStartDtNew").val(_today);
			$("#viewEndDtNew").val(_today);

			$("#questionEventInsert").hide();
			$("#questionEventUpdate").hide();
		} 
		$('#frontGb').trigger('change');
	});

/*]]>*/
</script>

</html>