/****************************************************************************
         * 검색필터 조회 (header 공통위해 user.js에서 가져옴.)
         ****************************************************************************/
        function fn_selectCategoryList(){
            let result = []
            let formData = new FormData();            
            $.ajax({
                url: encodeURI('/kiosk/getCategoryList.do'),
                data: formData,
                dataType: "json",
                processData: false,
                contentType: false,
                type: 'POST',
                async: false,
                success: function(data){
                    if('0'==data.msgCode){
                        if(0<data.rows.length){
                            result = data.rows;
                        }
                    }
                    else{
                        modalEvent.danger("조회 오류", data.msgDesc);
                    }
                },
                error : function(xhr, status, error) {
                    modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
                },
                beforeSend:function(){

                },
                complete:function(){

                }
            });
            return result;
        }
        /****************************************************************************
         * 모달 검색필터 조회 (header 공통위해 user.js에서 가져옴.)
         ****************************************************************************/
        function fn_selectModalOtherOption(categoryCode, target){
            let formData = new FormData();
            formData.append('categoryCode', categoryCode);
            $.ajax({
                url: encodeURI('/kiosk/getCategoryItem.do'),
                data: formData,
                dataType: "json",
                processData: false,
                contentType: false,
                type: 'POST',
                async: false,
                success: function(data){			
                    if('0' === data.msgCode){
                        if (data.rows && 0 < Object.keys(data.rows).length) {
        					let categoryName = '';
							if(target!=''){
	        				    $('#'+target+' .select_box button').each(function() {
	        					    categoryName = $(this).text();
	                                if (Object.values(data.rows).some(item => item.categoryname === categoryName)) {
	        						    let ulElement = $(this).parent().find('ul');
	        						    ulElement.html('');
	        						    Object.values(data.rows).forEach(categoryItem => {
	        							    if (categoryItem.categoryname === categoryName) {
	        								    let categoryItemCode = categoryItem.categoryitemcode;
	        								    let categoryItemName = categoryItem.categoryitemname;
	                                            let nationality = '';
	                                            if (categoryItem.categoryname === '국적') {
	        									    nationality = categoryItemName.toLowerCase().includes('한국'.toLowerCase()) ? 'local' : 'foreigner';
	                                            } else if (categoryItem.categoryname === '고객구분') {
	        									    let url = categoryItem.filepath.replace("C:", "");
	                                                categoryItemName = `<img src="${url}">`;
	        										ulElement.html('<li class="option_list_item" data-code="" id="li_">선택안함</li>');
	                                            }
	
	                                            let listHTML = `<li class="option_list_item ${nationality}" data-code="${categoryCode}" id="li_${categoryItemCode}">${categoryItemName}</li>`;
	                                            ulElement.append(listHTML);
	                                        }
	                                    });
	                                }
	                            });
							}else{
								$('.select_box button').each(function() {
								    categoryName = $(this).text();
			                        if (Object.values(data.rows).some(item => item.categoryname === categoryName)) {
									    let ulElement = $(this).parent().find('ul');
									    ulElement.html('');
									    Object.values(data.rows).forEach(categoryItem => {
										    if (categoryItem.categoryname === categoryName) {
											    let categoryItemCode = categoryItem.categoryitemcode;
											    let categoryItemName = categoryItem.categoryitemname;
			                                    let nationality = '';

			                                    if (categoryItem.categoryname === '국적') {
												    nationality = categoryItemName.toLowerCase().includes('한국'.toLowerCase()) ? 'local' : 'foreigner';
			                                    } else if (categoryItem.categoryname === '고객구분') {
												    let url = categoryItem.filepath.replace("C:", "");
			                                        categoryItemName = `<img src="${url}">`;
			                                    }

			                                    let listHTML = `<li class="option_list_item ${nationality}" data-code="${categoryCode}" id="li_${categoryItemCode}">${categoryItemName}</li>`;
			                                    ulElement.append(listHTML);
			                                }
			                            });
			                        }
			                    });
							}
							
        				}
                    } else if(data.msgCode=='-1'){
        				modalEvent.warning("조회 오류", data.msgDesc);
                    } else {
                        modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
                    }
                },
                error : function(xhr, status, error) {
                    modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
                },
                beforeSend:function(){
                },
                complete:function(){
                }
            });
        }
		
		/****************************************************************************
		 * 근무시간 조회
		 ****************************************************************************/
		function fn_searchSetTime(target,searchDate){
			let result = []
			let formData = new FormData();
			$.ajax({
				url: encodeURI('/kiosk/getWorkTime.do'),
				data: formData,
				dataType: "json",
				processData: false,
				contentType: false,
				type: 'POST',
				async: false,
				success: function(data){
					if('0'==data.msgCode){
						if(0<data.rows.length){
							result = data.rows;
							fn_setOperatingHours(target,searchDate,result[0])
						}
					}
					else{
						modalEvent.danger("조회 오류", data.msgDesc);
					}
				},
				error : function(xhr, status, error) {
					modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
				},
				beforeSend:function(){

				},
				complete:function(){

				}
			});
			return result;
		}
		
		/* ##############################################################
		    	설  명 : [Modal]고객 검색 팝업
		    	작성일 : 2024. 04. 02.
		    	작성자 : NTsoft
		    	수정일 	        수정자 	 수정내용
		    	-------         -------- ---------------------------
		    	2024. 03. 14.	NTsoft 	 최초 생성
		    */
		    let userIntroSelectModal = {
		        callback: null,
		        reqParam: null,
		        dataList: null,
		        /* 모달 초기화 작업 */
		        init: function () {
		            $('#userIntroSelectModal').remove();
		            $('body').append(this.HtmlTemplate);
		            //그리드 이벤트
		            this.setEvent();
		        },
		        /* 그리드 이벤트 설정 */
		        setEvent: function () {
		            $('#userIntroSelectModal .btnCancle').on("click", function () {
		                userIntroSelectModal.close();
		            });
		            $('#userIntroSelectModal .btnSave').on("click", function () {
		                userIntroSelectModal.save();
		            });
		            document.getElementById("searchIntroUserBtn").addEventListener('click',()=>{
		                userIntroSelectModal.searchIntroUserList();
		            });
		            document.getElementById("introUserSearchKeyword").addEventListener('keypress',(e)=>{
		                fn_IntroUserEnter(e)
		            });
		        },

		        /* 데이터 선택 */
		        setSelect: function (selectNumber) {
		    		let checkedData = dataList[selectNumber];
		    		if(dataList==null||checkedData==undefined){
		    			return ;
		    		}
		    		
		    		if( userIntroSelectModal.callback )  {
		    			userIntroSelectModal.callback(checkedData);
		    		}
		    		userIntroSelectModal.close();
		        },
		        //저장
		        save: function () {

		        },
		        searchIntroUserList:function (){
		            let searchKeyword = document.querySelector("#introUserSearchKeyword").value;
		            let formData = new FormData();

		            if(2 > searchKeyword.length){
		                modalEvent.warning("", "검색어는 2자 이상으로 입력해 주시기 바랍니다.");

		                return;
		            }
		        
		            formData.append("userSearchKeywordParam", searchKeyword??'');

		            $.ajax({
		                url: encodeURI('/kiosk/getUserOptionList.do'),
		                data: formData,
		                dataType: "json",
		                processData: false,
		                contentType: false,
		                type: 'POST',
		                async: true,
		                success: function (data) {
		                    if ('0' == data.msgCode) {
		                        let tbody = document.querySelector('.list1_modal_table tbody');
		                        while (tbody.firstChild) {
		                            tbody.removeChild(tbody.firstChild);
		                        }
		                        dataList = data.rows;
		                        data.rows.forEach(function(user, index) {
		                            let tr = document.createElement('tr');
		                            tr.innerHTML = '<td id="' + user.muuserid + '">' + user.username + '</td>' +
		                                '<td>' + convertDateFormat(user.birthday) + '</td>' +
		                                '<td>' + user.gender + '</td>' +
		                                '<td>' + fn_setFormatPhone(user.phonenumber) + '</td>' +
		                                '<td>' + user.lastvisitdate + '</td>';
		                            tr.onclick = function() {
		                                userIntroSelectModal.setSelect(index);
		                            };
		                            tbody.appendChild(tr);
		                            
		                        });
		                    }
		                },
		                error: function (xhr, status, error) {
		                    modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
		                },
		                beforeSend: function () {
		                },
		                complete: function () {
		                },
		            })
		        },
		        /*
		         * 팝업
		         * callback : 콜백함수, reqParam: 팝업파라미터
		         */
		        popup: function (callback, reqParam) {
		            // 초기화 후 열기
		            userIntroSelectModal.init();
					
		            //콜백함수 지정.
		            userIntroSelectModal.callback = callback;
		            userIntroSelectModal.reqParam = reqParam;
		            userIntroSelectModal.dataList = null;

		            // userIntroSelectModal.searchIntroUserList();

		            setTimeout(function () {
		                $('#userIntroSelectModal').modal('show')
		            }, 200);

		        },
		        /*
		         * 팝업 닫기
		         */
		        close: function () {
		            $('#userIntroSelectModal').modal('hide');

		    		setTimeout(function(){
		    			$('#userIntroSelectModal').remove();
		    		},500);
		        },
		        HtmlTemplate : `
		            <div id="userIntroSelectModal" class="modal list1_diagnosis fade" tabIndex="-1"
		                 aria-labelledby="exampleModalLabel"
		                 aria-hidden="">
		                <div class="modal-dialog">
		                    <div class="modal-content">
		                        <div class="list1_modal_header">
		                            <label>고객조회</label>
		                        </div>
		                        <div class="list1_modal_body">
		                            <div class="input_box">
		                                <div class="search_box">
		                                    <img src="/image/web/search_B.svg"/>
		                                    <input id="introUserSearchKeyword" type="text" placeholder="성함, 연락처, 생년월일"/>
		                                </div>
		                                <button id="searchIntroUserBtn">검색</button>
		                            </div>
		                            <div class="list1_modal_table">
		                                <table>
		                                    <thead>
		                                    <tr>
		                                        <th>성함</th>
		                                        <th>생년월일</th>
		                                        <th>성별</th>
		                                        <th>연락처</th>
		                                        <th>최근내원</th>
		                                    </tr>
		                                    </thead>
		                                    <tbody>
		                                        <tr>
		                                            <td colspan="5" style="text-align: center;">조회결과가 없습니다.</td>
		                                        </tr>                         
		                                    </tbody>
		                                </table>
		                            </div>
		                        </div>
		                        <div class="list1_modal_footer">
		                            <div class="btn_box">
		                                <button type="button" class="cancel_btn btnCancle">취소</button>
		                            </div>
		                        </div>
		                    </div>
		                </div>
		            </div>`
		    };
		    /****************************************************************************
		     * 검색 엔터 이벤트
		     ****************************************************************************/
		    function fn_IntroUserEnter(e){
		        if(e.which){
		            // 파이어폭스
		            if(13 == e.which) {
		                //로그인 액션 스크립트
		                userIntroSelectModal.searchIntroUserList();
		            }
		        }else{
		            // 윈도우, 사파리, 크롬
		            if(13 == event.keyCode) {
		                //로그인 액션 스크립트
		                userIntroSelectModal.searchIntroUserList();
		            }
		        }
		    }
		    function convertDateFormat(input) {
		    	if(input){
		    		const datePart = input.match(/\d{4}-\d{2}-\d{2}/)[0];
		    		
		    		const date = new Date(datePart);
		    		
		    		const year = date.getFullYear();
		    		const month = ('0' + (date.getMonth() + 1)).slice(-2);
		    		const day = ('0' + date.getDate()).slice(-2);
		    		
		    		return `${year}.${month}.${day}`;
		    	}
		    	
		    	return '';
		    }
			
			

			/* ##############################################################
				설  명 : [Modal]진료/시술 검색 필터 팝업 (페이징처리되는 팝업)
				작성일 : 2023. 01. 19.
				작성자 : NTsoft
				수정일 	        수정자 	 수정내용
				-------         -------- ---------------------------
				2023. 01. 19.	NTsoft 	 최초 생성
			*/
			let treatmentProcedureSearchModal = {
				callback : null,
				reqParam : null,
				dataList : null,
				/*aggrid 및 검색관련*/
				searchKeywordParam : "",
				searchSort         : "",
				searchDir          : "",
				searchStart        : 0,
				searchLimit        : 100,
				totalCount         : 0,
				totalPages         : 0,
				agGridData         : [],
				columnDefs         : [],
				gridOptions        : {},
				/* 모달 초기화 작업 */
				init : function () {
					$('#treatmentProcedureSearchModal').remove();
					$('body').append( this.HtmlTemplate);
					
					//그리드 설정
					this.setGrid();
					
					//그리드 이벤트
					this.setEvent();
				},
				/* 페이징 처리 */
				pagination:function(page){
					searchStart = (parseInt(page)-1)*searchLimit;
					treatmentProcedureSearchModal.search();
				},
				/* 페이징 리셋 */
				paginReset:function(){
					treatmentProcedureSearchModal.searchKeywordParam = '';

					treatmentProcedureSearchModal.searchStart  = 0;
					treatmentProcedureSearchModal.searchLimit  = 100;
					treatmentProcedureSearchModal.totalCount   = 0;
					treatmentProcedureSearchModal.totalPages   = 0;
					
					//페이징 초기화
					if($("#treatmentProcedureSearchModal .pagination").data("twbs-pagination")){
						$("#treatmentProcedureSearchModal .pagination").twbsPagination("destroy");
					}
				},
				/* 검색하기 (초기화 후 검색) */
				resetSearch:function(){
					treatmentProcedureSearchModal.paginReset();
					
					treatmentProcedureSearchModal.searchKeywordParam = $("#treatmentProcedureSearchModal .searchKeyword").val();
					
					treatmentProcedureSearchModal.search();
				},
				/* 그리드 설정 */
				setGrid:function(){
					treatmentProcedureSearchModal.columnDefs = [
						{field: "treatmentname", headerName:"진료구분",minWidth:200, maxWidth:200},
						{field: "treatmentprocedurename", headerName:"시술명", minWidth:200, cellStyle:{cursor: 'pointer', color:'#3985EA'}}
					];
					
					// let the grid know which columns and what data to use
					treatmentProcedureSearchModal.gridOptions = {
						suppressRowTransform: true,
						columnDefs: treatmentProcedureSearchModal.columnDefs,
						defaultColDef: {		// 리스트 기본 설정
							flex: 1,
							sortable: true,		//정렬 여부
							resizable: true,	//리사이즈
							editable: true,	// 그리드에서 데이터 수정
							cellStyle:{textAlign:'left',fontSize:'14px',padding:'0'},
							//suppressSizeToFit:true,		//자동 맞춤
							//enableRowGroup: true,		// 그룹 묶음
							enablePivot: true,
							enableValue : true
						},
						//suppressMultiSort:true,  //단일솔트 true가 단일, false가 다중 shift + sort 시
						headerHeight : 41, // header 높이
						rowHeight : 41, // row 높이
						rowData : treatmentProcedureSearchModal.agGridData,
						suppressRowClickSelection : true, // 로우 클릭시 체크박스 선택 true no, false yes
						localeText : {
							noRowsToShow : '조회 결과가 없습니다.'
						}, //데이터 없을 시 나오는 문구
						rowSelection : 'multiple', // row 다중 선택
						debug : false,
						onCellClicked: function(event){ //셀 클릭 이벤트
							/* alert(event.column.colId); */
							if('treatmentprocedurename'==event.column.colId){
								treatmentProcedureSearchModal.setSelect(event.node.rowIndex);
							}
							
							treatmentProcedureSearchModal.setSelect();
						},
						onSelectionChanged: function(event){ //체크박스 선택
						},
						onSortChanged: function(event){
							 //정렬
							treatmentProcedureSearchModal.searchSort = ''; //기존 정렬 초기화
							let columnArr = event.columnApi.getColumnState();
							if(0<columnArr.length){
								//sort index 순으로 재정렬
								columnArr.sort(function(a,b){
									return a.sortIndex - b.sortIndex;
								});
								
								let nullCnt = 0;
								for(let i=0; i<columnArr.length; i++){
									let gridSortModel = columnArr[i].colId;
									let gridSort = columnArr[i].sort;
									
									if(gridSort != null){
										treatmentProcedureSearchModal.searchStart = 0;
										treatmentProcedureSearchModal.searchSort += gridSortModel+' '+ gridSort + ',';
									}
									else{
										nullCnt++;
										if(nullCnt == columnArr.length){
											treatmentProcedureSearchModal.searchSort  = '';
											treatmentProcedureSearchModal.searchDir   = '';
											treatmentProcedureSearchModal.searchStart = 0;
										}
									}
								}
							}
							treatmentProcedureSearchModal.searchSort = treatmentProcedureSearchModal.searchSort.substring(0,treatmentProcedureSearchModal.searchSort.lastIndexOf( ",")); //맨끝 콤마 지우기
					
							treatmentProcedureSearchModal.resetSearch();
						}
					};
					
					// lookup the container we want the Grid to use
					let gridDiv = document.querySelector('#treatmentProcedureSearchModal .dataGrid');
					
					// create the grid passing in the div to use together with the columns & data we want to use
					new agGrid.Grid(gridDiv, treatmentProcedureSearchModal.gridOptions);
				},
				/* 그리드 이벤트 설정 */
				setEvent:function() {
					$('#treatmentProcedureSearchModal .btnCancle').on("click", function(){
						treatmentProcedureSearchModal.close();
					});
					
					$('#treatmentProcedureSearchModal .btnSave').on("click", function(){
						treatmentProcedureSearchModal.save("I");
					});
					
					/* 검색 */
					$('#treatmentProcedureSearchModal .search_btn').on("click", function(){
						treatmentProcedureSearchModal.resetSearch();
					});
					
					// 엔터 이벤트
					$(document).on('keypress', '#treatmentProcedureSearchModal .searchKeyword', function(e) {
						if(e.which){
							// 파이어폭스
							if(13 == e.which) {
								//로그인 액션 스크립트
								treatmentProcedureSearchModal.resetSearch();
							}
						}
						else{
							// 윈도우, 사파리, 크롬
							if(13 == event.keyCode) {
								//로그인 액션 스크립트
								treatmentProcedureSearchModal.resetSearch();
							}
						}
					});
				},
				/* 데이터 선택 */
				setSelect:function(selectNumber) {
					let checkedData = treatmentProcedureSearchModal.dataList[selectNumber];
					if(treatmentProcedureSearchModal.dataList==null||checkedData==undefined){
						return ;
					}
					
					if( treatmentProcedureSearchModal.callback )  {
						treatmentProcedureSearchModal.callback(checkedData);
					}
					treatmentProcedureSearchModal.close();
				},
				// 상세 조회
				search:function(state) {
					let formData = new FormData();
					formData.append("treatmentProcedureSearchKeywordParam", treatmentProcedureSearchModal.searchKeywordParam);
					formData.append("treatmentProcedureSort", treatmentProcedureSearchModal.searchSort);
					formData.append("treatmentProcedureDir", treatmentProcedureSearchModal.searchDir);
					formData.append("treatmentProcedureStart", treatmentProcedureSearchModal.searchStart);
					formData.append("treatmentProcedureLimit", treatmentProcedureSearchModal.searchLimit);
					
					$.ajax({
						url: encodeURI('/kiosk/getTreatmentProcedureOptionList.do'),
						data: formData,
						dataType: "json",
						processData: false,
						contentType: false,
						type: 'POST',
						async: true,
						success: function(data){
							if('0'==data.msgCode){
								// 페이징 처리
								treatmentProcedureSearchModal.totalCount  = data.totalCount;
								//$("#txt_treatmentProcedureSearchModal.totalCount").text(treatmentProcedureSearchModal.totalCount);
								
								treatmentProcedureSearchModal.totalPages = Math.ceil(treatmentProcedureSearchModal.totalCount/treatmentProcedureSearchModal.searchLimit);
								
								// 리스트 조회
								treatmentProcedureSearchModal.dataList = data.rows;
								
								treatmentProcedureSearchModal.agGridData = data.rows;
								treatmentProcedureSearchModal.gridOptions.api.setRowData(treatmentProcedureSearchModal.agGridData);
				
								if(0<data.rows.length){
									//페이징 처리
									window.pagObj = $('#treatmentProcedureSearchModal .pagination').twbsPagination({
										startPage    : ((treatmentProcedureSearchModal.searchStart/treatmentProcedureSearchModal.searchLimit)+1),
										totalPages   : (treatmentProcedureSearchModal.totalPages==0)?1:treatmentProcedureSearchModal.totalPages,
										visiblePages : 10,
										initiateStartPageClick: false,
										prev         : '<img src="/image/web/page_navigation_arrow.svg" alt="prev">',
										next         : '<img src="/image/web/page_navigation_arrow.svg" alt="next">',
										first        : '',
										last         : '',
										onPageClick: function (event, page) {
											treatmentProcedureSearchModal.pagination(page);
										}
									}).on('page', function (event, page) {
										//console.info(page + ' (from event listening)');
									});
								}
								else{
									
								}
							}
							else{
								modalEvent.danger("조회 오류", data.msgDesc);
							}
						},
						error : function(xhr, status, error) {
							modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
						},
						beforeSend:function(){
							// 로딩열기
							treatmentProcedureSearchModal.gridOptions.api.showLoadingOverlay();
						},
						complete:function(){
							
						}
					});
				},
				/*
				 * 팝업
				 * callback : 콜백함수, reqParam: 팝업파라미터
				 */
				popup:function(callback, reqParam) {
					// 초기화 후 열기
					treatmentProcedureSearchModal.init();
					
					//콜백함수 지정.
					treatmentProcedureSearchModal.callback = callback;
					treatmentProcedureSearchModal.reqParam = reqParam;
					treatmentProcedureSearchModal.dataList = null;
					
					treatmentProcedureSearchModal.resetSearch();
					
					setTimeout(function(){
						$('#treatmentProcedureSearchModal').modal('show')
					}, 200);
				},
				/*
				 * 팝업 닫기
				 */
				close:function() {
					$('#treatmentProcedureSearchModal').modal('hide');

					setTimeout(function(){
						$('#treatmentProcedureSearchModal').remove();
					},500);
				},
				HtmlTemplate : `
				<div id="treatmentProcedureSearchModal" class="modal product_modal fade" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="list1_modal_header">
								<label class="title">진료/시술 검색</label>
							</div>
							
							<div class="list1_modal_body">
								<div class="input_box">
									<div class="search_box">
										<img src="/image/web/search_B.svg"/>
										<input class="searchKeyword" type="text" placeholder="시술명"/>
									</div>
									<button class="search_btn">검색</button>
								</div>
								
								<div class="dataGrid modal_table_box ag-theme-balham"></div>
								
								<!-- 페이지게이션 -->
								<div class="page_box">
									<nav ria-label="Page navigation" class="navigation">
										<ul class="pagination"></ul>
									</nav>
								</div>
							</div>
							
							<div class="list1_modal_footer">
								<div class="btn_box">
									<button type="button" class="cancel_btn btnCancle">취소</button>
								</div>
							</div>
						</div>
					</div>
				</div>
			    `
			};
			
			/****************************************************************************
			* 닥터 /상담자 조회
			****************************************************************************/
			function fn_selectListReserveMemberOption(param, param2){
				let result=[];
				
				if(true != fn_emptyCheck(param2)){
					return result;
				}
				
				let formData = new FormData();
				formData.append("searchDate", param);
				formData.append("muTreatmentProcedureId", param2);
				
				$.ajax({
					url: encodeURI('/kiosk/getMemberDoctorConsultingOptionList.do'),
					data: formData,
					dataType: "json",
					processData: false,
					contentType: false,
					type: 'POST',
					async: false,
					success: function(data){
						if('0'==data.msgCode){
							result=data.rows;
						}
						else if(data.msgCode=='-1'){
							modalEvent.warning("조회 오류", data.msgDesc);
						}
						else{
							modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
						}
					},
					error : function(xhr, status, error) {
						modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
					},
					beforeSend:function(){
					},
					complete:function(){
					}
				});
				return result;
			}
			
			function fn_setOperatingHours(target,searchDate,data) {
				const daysOfWeek = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
				const today = new Date(searchDate).getDay()
				const todayIndex = daysOfWeek[today];
				const openYn = data[`${todayIndex}openyn`];
				if (openYn === 'Y') {
					const openStartTime = data[`${todayIndex}openstarttime`];
					const openEndTime = data[`${todayIndex}openendtime`];
					fn_setWorkTimeValue(target,openStartTime, openEndTime);
				}
			}

			function fn_setWorkTimeValue(target,openStartTime,openEndTime){
				let timeHTML = '';
				let startTime = openStartTime.split(':')[0]
				let endTime = openEndTime.split(':')[0]

				for(let i = startTime; i <= endTime; i++) {
					let hour = i;


					if(0 == i){
						timeHTML += '<li class="option_list_item first">' + hour + ':00</li>';
						timeHTML += '<li class="option_list_item">' + hour + ':30</li>';
					}else if(endTime == i && "00" == openEndTime.split(':')[1]){
						timeHTML += '<li class="option_list_item">' + hour + ':00</li>';
					}else if(endTime == i && "30" == openEndTime.split(':')[1]){
						timeHTML += '<li class="option_list_item">' + hour + ':00</li>';
						timeHTML += '<li class="option_list_item">' + hour + ':30</li>';
					}else{
						timeHTML += '<li class="option_list_item">' + hour + ':00</li>';
						timeHTML += '<li class="option_list_item">' + hour + ':30</li>';
					}
				}
				$('#'+target).empty().html(timeHTML);

				$('#'+target).siblings("button").text(openStartTime);
				$('#'+target).siblings("input").val(openStartTime);

				// 옵션 선택 이벤트
				$('#'+target + '>.option_list_item').on('click', function() {
					let selectedOption = $(this).text();
					$(this).parent().siblings("button").text(selectedOption);
					$(this).parent().siblings("input").val(selectedOption);


					// 예약시간 변경시 초기화
					if(target.includes("reserveInsertModal #list1")){

						let selectIdx = $("#reserveInsertModal #list1 .select_option_list.time").index($(this).closest(".select_option_list.time"));

						// 초기화
						// 예약경로
						$("#reserveInsertModal #list1 [name=modalReserveCategoryItemCode]").eq(selectIdx).val("");
						$("#reserveInsertModal #list1 [name=modalReserveCategoryItemCode]").eq(selectIdx).siblings("button").text("예약경로");
						// 진로유형
						$("#reserveInsertModal #list1 [name=modalTreatmentProcedureId]").eq(selectIdx).val("");
						$("#reserveInsertModal #list1 [name=modalTreatmentProcedureName]").eq(selectIdx).val("");
						// 닥터/상담
						$("#reserveInsertModal #list1 [name=modalReserveMemberId]").eq(selectIdx).val("");
						$("#reserveInsertModal #list1 [name=modalReserveMemberId]").eq(selectIdx).siblings("button").text("닥터/상담");
						$("#reserveInsertModal #list1 [name=modalReserveMemberId]").eq(selectIdx).siblings("ul").find("li").remove();
						// 예약메모
						$("#reserveInsertModal #list1 [name=modalEtc]").eq(selectIdx).val("");
					}else if(target.includes("reserveInsertModal #list2")){

						let selectIdx = $("#reserveInsertModal #list2 .select_option_list.time").index($(this).closest(".select_option_list.time"));

						// 초기화
						// 예약경로
						$("#reserveInsertModal #list2 [name=modalReserveCategoryItemCode]").eq(selectIdx).val("");
						$("#reserveInsertModal #list2 [name=modalReserveCategoryItemCode]").eq(selectIdx).siblings("button").text("예약경로");
						// 진로유형
						$("#reserveInsertModal #list2 [name=modalTreatmentProcedureId]").eq(selectIdx).val("");
						$("#reserveInsertModal #list2 [name=modalTreatmentProcedureName]").eq(selectIdx).val("");
						// 닥터/상담
						$("#reserveInsertModal #list2 [name=modalReserveMemberId]").eq(selectIdx).val("");
						$("#reserveInsertModal #list2 [name=modalReserveMemberId]").eq(selectIdx).siblings("button").text("닥터/상담");
						$("#reserveInsertModal #list2 [name=modalReserveMemberId]").eq(selectIdx).siblings("ul").find("li").remove();
						// 예약메모
						$("#reserveInsertModal #list2 [name=modalEtc]").eq(selectIdx).val("");
					}else if(target.includes("reserveReadyInsertModal #list1")){

						let selectIdx = $("#reserveInsertModal #list2 .select_option_list.time").index($(this).closest(".select_option_list.time"));

						// 초기화
						// 예약경로
						$("#reserveReadyInsertModal #list1 [name=modalReserveCategoryItemCode]").eq(selectIdx).val("");
						$("#reserveReadyInsertModal #list1 [name=modalReserveCategoryItemCode]").siblings("button").text("예약경로");
						// 진로유형
						$("#reserveReadyInsertModal #list1 [name=modalTreatmentProcedureId]").eq(selectIdx).val("");
						$("#reserveReadyInsertModal #list1 [name=modalTreatmentProcedureName]").eq(selectIdx).val("");
						// 닥터/상담
						$("#reserveReadyInsertModal #list1 [name=modalReserveMemberId]").eq(selectIdx).val("");
						$("#reserveReadyInsertModal #list1 [name=modalReserveMemberId]").eq(selectIdx).siblings("button").text("닥터/상담");
						$("#reserveReadyInsertModal #list1 [name=modalReserveMemberId]").eq(selectIdx).siblings("ul").find("li").remove();
						// 예약메모
						$("#reserveReadyInsertModal #list1 [name=modalEtc]").eq(selectIdx).val("");
					}
				});
			}
			function fn_insertAgreementPopup() {
			    let reqParam =  {muUserId :$("[name=modalUserId]").val()}; //고객ID
			    agreementInsertModal.popup(function(obj, reqParam) {
			        fn_selectAgreementList();
			    }, reqParam);
			}
			