<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : OrderListForm.html
 * @desc    : 주문목록 Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.11.16   jsh77b       최초 작성
 *******************************************************************************
 -->
 <style>
 .ag-neo .ag-cell.top-row-span {
     border-bottom: 0px;
}
.ag-neo .ag-cell.bottom-row-span {
     border-top: 0px;
     text-indent: -100em;
}
 </style>
 
<div id="main">
	<!-- 메인타이틀 영역 -->
	<div class="main-title">
	</div>
	<!-- //메인타이틀 영역 -->
	
	<!-- 메뉴 설명 -->
	<div class="infoBox menu-desc">
	</div>
	
	<form id="searchForm" name="searchForm" action="#" th:action="@{'/order/list'}">
		<input type="hidden" id="searchGb" name="searchGb" />
		
		<!-- 패널 영역1 -->
		<div class="panelStyle" >
			<!-- 검색조건 영역 -->
			<!-- TITLE -->
			<div class="panelTitle">
				<h3>
					<i class="fa fa-info-circle"></i>아래 검색조건 중 <font color="red">주문번호</font> 또는 <font color="red">검색조건</font> 하나를 꼭 입력해 주세요.
				</h3>
				<span class="panelControl">
					<i class="fa fa-chevron-up"></i>
				</span>
			</div>
			
			<div class="panelContent">
				<table class="frmStyle">
					<colgroup>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
					</colgroup>
					<tr>
						<th>사이트</th>
						<td>
							<select name="siteCd">
								<option value="">[전체]</option>
								<option th:if="${siteCdList}" th:each="oneData, status : ${siteCdList}" th:value="${oneData.cd}"
										th:text="|[${oneData.cd}] ${oneData.cdNm}|"></option>
							</select>
						</td>
						<th>몰구분</th>
						<td>
							<select name="mallCd">
								<option value="">[전체]</option>
								<option th:if="${mallGbList}" th:each="oneData, status : ${mallGbList}" th:value="${oneData.cd}"
										th:text="|[${oneData.cd}] ${oneData.cdNm}|"></option>
							</select>
						</td>
						<th>업체</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>브랜드</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>
					</tr>
					<tr>
						<th>주문상태</th>
						<td>
							<div class="multiCheckBox" style="width:270px">
								<button type="button" class="sltBtn" style="overflow-x: hidden; padding-right:5px;">[전체]</button>
								<ul style="display: none; box-shadow: 3px 3px 3px; overflow-y: scroll; height: 112px;">
									<th:block th:each="oneData, status : ${ordDtlStatList}">
										<li>
											<label class="chkBox">
												<!-- 주문상세상태 주문접수 코드값 강제 설정 (입금대기) -->
												<th:block th:if="${oneData.cd} == G013_00">
													<input type="checkbox" name="multiOrdDtlStat" th:value="G013_10" th:text="|[G013_10] ${oneData.cdNm}|">
												</th:block>
												<th:block th:unless="${oneData.cd} == G013_00">
													<input type="checkbox" name="multiOrdDtlStat" th:value="${oneData.cd}" th:text="|[${oneData.cd}] ${oneData.cdNm}|">
												</th:block>
												<!-- //주문상세상태 주문접수 코드값 강제 설정 (입금대기) -->
											</label>
										</li>
									</th:block>
								</ul>
							</div>
						</td>
						<th>결제타입</th>
						<td>
							<select name="pgGb">
								<option value="">[전체]</option>
								<option th:if="${pgGbList}" th:each="oneData, status : ${pgGbList}" th:value="${oneData.cd}"
										th:text="|[${oneData.cd}] ${oneData.cdNm}|"></option>
							</select>
						</td>
						<th>결제수단</th>
						<td>
							<select name="payMeans">
								<option value="">[전체]</option>
								<option th:if="${payMeansList}" th:each="oneData, status : ${payMeansList}" th:value="${oneData.cd}"
										th:text="|[${oneData.cd}] ${oneData.cdNm}|"></option>
							</select>
						</td>
						<th rowspan="5">키워드<i class="star"></i></th>
						<td rowspan="5">
							<select name="search" id="search">
								<option value="searchOrdNo">주문번호</option>
								<option value="searchExtmallOrderId">외부몰주문번호</option>
								<option value="searchAgentOrderId">에이전트주문번호</option>
							</select>
							<textarea class="textareaR3 w70p" name="condition" id="condition"></textarea>
						</td>
					</tr>
					<tr>
						<th>변경구분</th>
						<td>
							<select name="chgGb">
								<option value="">[전체]</option>
								<th:block th:each="oneData, status : ${chgGbList}">
									<th:block th:unless="${oneData.cd} == 'G680_10'">
										<option th:if="${chgGbList}" th:value="${oneData.cd}" th:text="|[${oneData.cd}] ${oneData.cdNm}|"></option>
									</th:block>
								</th:block>
							</select>
						</td>
						<th>변경요청처리상태</th>
						<td>
							<select name="chgStat">
								<option value="">[전체]</option>
								<option value="9999">[품절취소]</option>
								<option th:if="${chgStatList}" th:each="oneData, status : ${chgStatList}" th:value="${oneData.cd}"
										th:text="|[${oneData.cd}] ${oneData.cdNm}|"></option>
							</select>
						</td>
						<th>상품코드</th>
						<td>
							<input type="text" name="goodsCd" placeholder="" maxlength="20"/>
						</td>
					</tr>
					<tr>
						<th>주문자명</th>
						<td>
							<input type="text" name="orderNm" placeholder="" maxlength="20"/>
						</td>
						<th>고객ID</th>
						<td>
							<input type="text" name="custId" placeholder="" maxlength="20"/>
						</td>
						<th>주문자휴대폰번호</th>
						<td>
							<input type="text" name="orderPhnno" placeholder="" maxlength="20"/>
						</td>
					</tr>
					<tr>
						<th>수취인명</th>
						<td>
							<input type="text" name="recipNm" placeholder="" maxlength="20"/>
						</td>
						<th>송장번호</th>
						<td>
							<input type="text" name="invoiceNo" placeholder="" maxlength="20"/>
						</td>
						<th>회수지시전송여부</th>
						<td>
							<select name="wdInvoiceSendYn" class="w150">
								<option value="">전체</option>
								<option value="Y">전송</option>
								<option value="N">미전송</option>
							</select>
						</td>
					</tr>
					<tr>
						<th>조회일자</th>
						<td colspan="7">
							<select name="searchDateGb">
								<option value="ordDt">주문일자</option>
								<option value="delvStdt">출고일자</option>
								<option value="soldoutDt">품절일자</option>
							</select>
							<span id="terms"></span>
						</td>
					</tr>
				</table>
				
				<ul class="panelBar">
					<li class="center">
						<button type="button" class="btn btn-info btn-lg" id="btnOrderSearch">조회</button>
						<button type="button" class="btn btn-gray btn-lg" id="btnInit">초기화</button>
					</li>
				</ul>
				
			</div>
		</div>

		<div class="panelStyle">
			<ul class="panelBar">
				<li>
					<button type="button" class="btn btn-info btn-lg" onclick="fnOrderExcelList();">엑셀다운로드</button>
					<!-- 
					<button type="button" class="btn btn-info btn-lg" th:if="${userNo == 8 or userNo == 14 or userNo == 11}" onclick="fnCreateSampleOrder();">주문생성</button>
					 -->
				</li>
				<li class="aR">
					검색결과 : <strong><span id="rowCntOrderList">0</span> 건</strong>&nbsp;
					쪽번호 <span id="pgNo">0</span>/ <strong id="endPgNo">0</strong>&nbsp;&nbsp;
					<select id="pageSize" name="pageSize">
						<option value="100" selected="selected">100개씩 보기</option>
						<option value="500">500개씩 보기</option>
						<option value="1000">1000개씩 보기</option>
						<option value="5000">5000개씩 보기</option>
					</select>
					<input type="hidden" name="pageNo" id="pageNo" value ="1"/>
				</li>
			</ul>
			
			<div class="panelContent" style="overflow: hidden;">
				<div id="gridOrderList" style="width: 100%; height: 600px;" class="ag-theme-balham lh60"></div>
			</div>

			<ul class="panelBar">
				<li class="center">
					<div class="tablePaging" id="orderListPagination"></div>
				</li>
			</ul>
		</div>

	</form>
</div>

<label class="off">
	<a href="javascript:void(0);" id="hdOrderExcelList" style="display: none;">엑셀다운로드</a>
</label>

<script type="text/javascript" src="/ux/plugins/gaga/gaga.paging.js?v=20210114"></script>

<script th:inline="javascript">
/*<![CDATA[*/
var sessRoleCd 		= [[${sessionInfo.roleCd}]];
var siteCdList 		= gagajf.convertToArray([[${siteCdList}]]);
var mallGbList 		= gagajf.convertToArray([[${mallGbList}]]);
var ordDtlStatList 	= gagajf.convertToArray([[${ordDtlStatList}]]);
var payMeansList 	= gagajf.convertToArray([[${payMeansList}]]);
var chgStatList 	= gagajf.convertToArray([[${chgStatList}]]);
var chgGbList 		= gagajf.convertToArray([[${chgGbList}]]);
var formalGbList 	= gagajf.convertToArray([[${formalGbList}]]);
var frontGbList 	= {'P': 'PC', 'M': 'MO'};
var uploadGoodsUrl 	= [[${@environment.getProperty('upload.goods.view')}]];

// 1. 주문기본정보
var columnDefsOrderList = [
	{
		headerName		: "주문번호"
		, field			: 'ordNo'
		, width			: 80
		, cellClass		: 'text-center'
		, sortable		: true
		, cellRenderer	: function (params) {
			var roleCd = [[${sessionInfo.roleCd}]];
			if (!roleCd.startsWith("C")) {
				return "<a href=\"javascript:void(0);\" onclick=\"fnOpenOrderDetailPopup('" + params.value + "');\">" + params.value + "</a>";
			} else {
				return params.value;
			}
		}
	},
	{
		headerName		: "주문자"
		, field			: "maskingOrdNm"
		, width			: 140
		, cellClass		: 'text-left'
		, sortable		: true
		, cellRenderer	: function (params) {
			var custNo = '';
			if (!gagajf.isNull(params.data.custNo)) {
				custNo = params.data.custNo;
			}
			
			var roleCd = [[${sessionInfo.roleCd}]];
			if (!roleCd.startsWith("C") && !gagajf.isNull(params.data.custNo)  && params.data.mallGb === '10' ) {
				return '<a href="javascript:void(0);" onclick=\"cfnOpenCustDetailPopup(' + params.data.custNo + ');\">' + params.value + ' (' + params.data.custId + ')' + '</a>';
			} else {
				return params.value + ' (' + params.data.custId + ')';
			}
		}
	},
	{headerName: "고객고유번호", field: "custNo"				, width: 120, cellClass: 'text-center', hide: true},
	{headerName: "외부몰"		, field: "extmallNm"			, width: 100, cellClass: 'text-center', sortable: true},
	{headerName: "휴대폰번호"	, field: "maskingOrderPhnno"	, width: 120, cellClass: 'text-center', hide: true},
	{
		headerName		: "사이트"
		, field			: "siteCd"
		, width			: 80
		, cellClass		: 'text-center'
		, hide			: true
		, valueGetter	: function (params) { 
			return gagaAgGrid.lookupValue(siteCdList, params.data.siteCd); 
		}
	},
	{
		headerName		: "프론트"
		, field			: "frontGb"
		, width			: 80
		, cellClass		: 'text-center'
		, sortable		: true
		, valueGetter	: function (params) { 
			return gagaAgGrid.lookupValue(frontGbList, params.data.frontGb); 
		}
	},
	{
		headerName		: "몰구분"
		, field			: "mallGb"
		, width			: 60
		, cellClass		: 'text-center'
		, hide			: true
		, valueGetter	: function (params) { 
			return gagaAgGrid.lookupValue(mallGbList, params.data.mallGb); 
		}
	},
	{
		headerName		: "주문일시"
		, field			: "ordDt"
		, width			: 140
		, cellClass		: 'text-center'
		, sortable		: true
		, valueGetter	: function (params) { 
			return gagaAgGrid.toDateTimeFormat(params.data.ordDt); 
		}
	},
	{
		headerName		: "결제수단"
		, field			: "payMeans"
		, width			: 100
		, cellClass		: 'text-center'
		, hide			: true
		, valueGetter	: function (params) { 
			return gagaAgGrid.lookupValue(payMeansList, params.data.payMeans); 
		}
	},
	{headerName: "원주문/교환"	, field: "exchGbNm"		, width: 100	, cellClass: 'text-center'	, sortable: true},
	{
		headerName		: "주문상태"
		, field			: "ordDtlStatNm"
		, width			: 120
		, cellClass		: 'text-center'
		, sortable		: true
	},
	{headerName: "출고처"		, field: "delvLocNm"	, width: 110	, cellClass: 'text-center'	, sortable: true, hide:true},
	{headerName: "상품코드"	, field: "goodsCd"		, width: 100	, cellClass: 'text-center'	, sortable: true},
	{headerName: "브랜드"		, field: "brandGroupNm"	, width: 100	, cellClass: 'text-center'	, sortable: true},
	{headerName: "구성유형"	, field: "goodsTypeNm"	, width: 100	, cellClass: 'text-center'	, sortable: true},
	{headerName: "상품명"		, field: "goodsNm"		, width: 200	, cellClass: 'text-left'	, sortable: true},
	{
		headerName		: "이미지"
		, field			: "sysImgNm"
		, width			: 100
		, height		: 60
		, cellClass		: 'text-center'
		,cellRenderer	: function(params) {
			return '<img width="60" src="'+ _goodsUrl+ "/" + params.value + '" alt=""  onerror="this.src=\'/image/no.gif\';"/>';
		}
	},
	{headerName: "옵션1"		, field: "colorNm"		, width: 120	, cellClass: 'text-center'	, sortable: true},
	{headerName: "옵션2"		, field: "optCd2"		, width: 120	, cellClass: 'text-center'	, sortable: true},
	{
		headerName		: "외부몰벤더"
		, field			: "vendorId"
		, width			: 110
		, cellClass		: 'text-center'
		, hide			: true
		, valueGetter	: function (params) { 
			return gagaAgGrid.lookupValue(vendorList, params.data.vendorId); 
		}
	},
	{headerName: "외부몰주문번호"	, field: "extmallOrderId"	, width: 120, cellClass: 'textFormat', sortable: true},
	{headerName: "샵링커주문번호"	, field: "agentOrderId"		, width: 120, cellClass: 'textFormat', sortable: true},
	{
		headerName		: "주문수량"
		, field			: "ordQty"
		, width			: 80
		, cellClass		: 'text-center'
		, valueGetter: function (params) { 
			return params.data.ordQty.addComma(); 
		}
	},
	{
		headerName		: "취소수량"
		, field			: "cnclRtnQty"
		, width			: 80
		, cellClass		: 'text-center'
		, valueGetter	: function (params) { 
			return params.data.cnclRtnQty.addComma(); 
		}
	},
	{
		headerName		: "주문금액"
		, field			: "ordAmt"
		, width			: 80
		, cellClass		: 'text-right'
		, valueGetter	: function (params) { 
			return params.data.ordAmt.addComma(); 
		}
	},
	{
		headerName		: "취소/반품금액"
		, field			: "cnclRtnAmt"
		, width			: 120
		, cellClass		: 'text-right'
		, valueGetter	: function (params) { 
			return params.data.cnclRtnAmt.addComma(); 
		}
	},
	{
		headerName		: "총할인금액"
		, field			: "totDcAmt"
		, width			: 120
		, cellClass		: 'text-right'
		, valueGetter: function (params) { 
			return params.data.totDcAmt.addComma(); 
		}
	},
	{
		headerName		: "실판매금액"
		, field			: "realOrdAmt"
		, width			: 100
		, cellClass		: 'text-right'
		, valueGetter	: function (params) { 
			return params.data.realOrdAmt.addComma(); 
		}
	},
	{
		headerName		: "정상/이월"
		, field			: "formalGb"
		, width			: 100
		, cellClass		: 'text-center'
		, sortable		: true 
		, valueGetter	: function (params) { 
			return gagaAgGrid.lookupValue(formalGbList, params.data.formalGb); 
		}
	},
	{
		headerName		: "출고처지정일시"
		, field			: "delvAssignDt"
		, width			: 150
		, cellClass		: 'text-center'
		, valueGetter	: function (params) { 
			return gagaAgGrid.toDateTimeFormat(params.data.delvAssignDt); 
		}
	},
	{headerName: "출고택배사"		, field: "shipCompNm"	, width: 150, cellClass: 'text-center'},
	{headerName: "출고송장"		, field: "invoiceNo"	, width: 150, cellClass: 'text-center'},
	{
		headerName		: "출고일시"
		, field			: "delvStDt"
		, width			: 150
		, cellClass		: 'text-center'
		, valueGetter: function (params) { 
			return gagaAgGrid.toDateTimeFormat(params.data.delvStDt); 
		}
	}
];

var gridOptionsOrderList = gagaAgGrid.getGridOptions(columnDefsOrderList);

gridOptionsOrderList.rowHeight = 60; //이미지가 있을경우 높이 지정해야함.

// 최근상세보기한 주문번호
var currOrdNo = '';

// 조회
$('#btnOrderSearch').on('click', function () {
	$("#searchForm input[name=pageNo]").val('1');
	fnSearchList();
});

var fnSearchList = function () {
	var ordNo 	= $('#condition').val();
	var stDate 	= $('#stDate').val();
	var edDate 	= $('#edDate').val();

	if (gagajf.isNull(ordNo)) {
		if (gagajf.isNull(stDate)) {
			mcxDialog.alert('시작 기간을 입력하세요.');
			return;
		}

		if (gagajf.isNull(edDate)) {
			mcxDialog.alert('종료 기간을 입력하세요.');
			return;
		}
	}
	
	gagaPaging.init('searchForm', fnSearchCallBack, 'orderListPagination', $('#searchForm').find('#pageSize').val());
	gagaPaging.load($("#searchForm input[name=pageNo]").val());
	
	// 2020.12.08 페이징 처리 때문에 주석 처리
	//gagaAgGrid.fetch($('#searchForm').prop('action'), gridOptionsOrderList, '#searchForm', function (result) {
		//$("#rowCntOrderList").text(gridOptionsOrderList.api.getDisplayedRowCount());
		// 주문리스트 합계 정보
		//gagajf.ajaxFormSubmit('/order/list/sum/info', '#searchForm', fnOrderListSumInfoCallback);
	//});
};

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());
	
	gridOptionsOrderList.api.setRowData(result.orderList);
	gagaPaging.createPagination(result.pageing.pageable);
}

// 엑셀조회
$("#btnSearchExcel").on('click', function () {
	cfnExcelUploadPopup('', 'fnExcelUpoadCallback');
});

var fnExcelUpoadCallback = function (data) {
	$("#excelFileNm").val(data.excelFileNm);
	gagaAgGrid.fetch('/order/excel/search', gridOptionsOrderList, '#searchForm', function () {
		$("#rowCntOrderList").text(gridOptionsOrderList.api.getDisplayedRowCount());
	});
};

// 초기화 클릭시
$('#btnInit').on('click', function() {
	$('#searchForm')[0].reset();
	$("#multiBrand").empty();
	$("#searchForm #supplyCompText").text("");
	$("#searchForm #supplyCompText").text();
	$('#searchForm input[name=brandText]').val('');
	$('#searchForm input[name=supplyCompList]').val('');
});

// 엑셀 다운로드
// 2020.12.11 현재는 그리드의 조회 목록을 엑셀 다운로드 하고 있지만 추후 에는 조건의 엑셀 조회 후 다운로드 기능으로 변경 해야 할듯함
// 기존의 주문목록은 페이징 기능이 없었지만 페이징 기능을 추가 하면서 엑셀다운로드시 조회 후 파일다운 기능 필요  
var fnOrderExcelList = function () {
	gagaAgGrid.showOrHideColumn(gridOptionsOrderList	, "custNo", true);
	gagaAgGrid.exportToExcel('주문목록'					, gridOptionsOrderList);
	gagaAgGrid.showOrHideColumn(gridOptionsOrderList	, "custNo", false);
};

var fnOpenOrderDetailPopup = function (ordNo) {
	currOrdNo = ordNo;
	cfnOpenOrderDetailPopup(ordNo);
};

var fnReOpenOrderDetailPopup = function () {
	cfnOpenOrderDetailPopup(currOrdNo);
};
	
// 자사/입점 변경여부
$("#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();

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

	if(sessRoleCd == "G001_B000"){
		actionUrl = '/renderer/brand/AuthBrandlist';
	}

	cfnCreateMultiCombo(actionUrl, "multiBrand",  "[전체]", null, 'Y');
});

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

// 초기설정
$(document).ready(function() {
	// 달력기능 활성화
	cfnCreateCalendar('#terms', 'stDate', 'edDate', true, '주문', 'X');
	$('.btnRecentWeek').trigger('click');
	gagaAgGrid.createGrid('gridOrderList', gridOptionsOrderList);
	gridOptionsOrderList.api.hideOverlay();
});

var fnCreateSampleOrder = function() {
	var actionUrl = "/order/sample/create/form";
	cfnOpenModalPopup(actionUrl, "popupOrderSample");
}

var fnRemoveEmojis = function (str) {
	var regex = /(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g;
	return str.replace(regex, '');
};

// 엔터키 조회
$('#searchForm input[name=orderPhnno], #searchForm input[name=condition]').on('keypress' ,function (event) {
	if (event.which === 13) {
		$("#searchForm input[name=pageNo]").val('1');
		fnSearchList();
	}
});

// 휴대폰 자동 하이픈
$('#searchForm input[name=orderPhnno]').on('input keyup keydown paste change', function () {
	cfnCellPhonnHypen(this);
});

//2021.07.13 업체,브랜드 검색방법 변경
// 업체 조회 선택시
$('#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);
}

// 브랜드 조회 선택시
$('#btnSearchBrand').on('click', function() {
	cfnOpenBrandListPopup('fnSetBrandInfo', 'M');
});

// 브랜드 조회 팝업에서 호출
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);
}
</script>

</html>





