/* 페이징 관련 변수 */
let userConsultingChartTotalCount   = 0;
let userConsultingChartTotalPages   = 0;
let selectRows = [];
/*aggird*/
let userConsultingChartAgGridData = [];

let userConsultingChartSelectId = "";

/****************************************************************************
* 진료 콤보데이타 설정
****************************************************************************/
function fn_setTreatmentCombo(paramTarget, allYn, clickCallEvent){
	let target = paramTarget.next(".select_option_list");
	
	let comboData = fn_selectListTreatmentOption2();
	
	// 전체옵션 여부
	if('Y'==allYn){
		comboHTML = ' <li class="option_list_item">';
		comboHTML += '	<input type="hidden" name="comboId" value=""/>';
		comboHTML += '	<span>진료 전체</span>';
		comboHTML += '</li>';
	}
	
	for(let i = 0; i < comboData.length; i++){
		let muTreatmentId     = comboData[i].muTreatmentId;
		let treatmentName     = comboData[i].treatmentName;
		
		comboHTML += '<li class="option_list_item">';
		comboHTML += '	<input type="hidden" name="comboId" value="'+muTreatmentId+'"/>';
		comboHTML += '	<span>'+treatmentName+'</span>';
		comboHTML += '</li>';
	}
	target.html(comboHTML);
	
	target.find("li.option_list_item").click(function () {
		// 1. 선택값 셋팅
		let selectId    = $(this).find('input[name="comboId"]').val();
		let selectName  = $(this).find('span').text(); 
		
		$(this).parent().siblings("button").text(selectName);
		$(this).parent().siblings("input").val(selectId);
		
		if( clickCallEvent )  {
			clickCallEvent(selectId);
		}
	});
	
	// 초기화
	target.find("li:eq(0)").click();
}


/****************************************************************************
* 시술 콤보데이타 설정
****************************************************************************/
function fn_setTreatmentProcedureCombo(paramTarget, param, allYn, clickCallEvent){
	let target = paramTarget.next(".select_option_list");
	
	let comboData = fn_selectListTreatmentProcedureOption(param);
	
	let comboHTML = '';
	
	// 전체옵션 여부
	if('Y'==allYn){
		comboHTML = ' <li class="option_list_item">';
		comboHTML += '	<input type="hidden" name="comboId" value=""/>';
		comboHTML += '	<span>시술 전체</span>';
		comboHTML += '</li>';
	}
	
	for(let i = 0; i < comboData.length; i++){
		let muTreatmentProcedureId = comboData[i].muTreatmentProcedureId;
		let treatmentProcedureName = comboData[i].treatmentProcedureName;
		
		comboHTML += '<li class="option_list_item">';
		comboHTML += '	<input type="hidden" name="comboId" value="'+muTreatmentProcedureId+'"/>';
		comboHTML += '	<span>'+treatmentProcedureName+'</span>';
		comboHTML += '</li>';
	}
	target.html(comboHTML);
	
	target.find("li.option_list_item").click(function () {
		// 1. 선택값 셋팅
		let selectId    = $(this).find('input[name="comboId"]').val();
		let selectName  = $(this).find('span').text(); 
		
		$(this).parent().siblings("button").text(selectName);
		$(this).parent().siblings("input").val(selectId);
		
		if( clickCallEvent )  {
			clickCallEvent(selectId);
		}
	});
	
	// 초기화
	target.find("li:eq(0)").click();
}

/****************************************************************************
* 닥터/상담 콤보데이타 설정
****************************************************************************/
function fn_setReserveMemberCombo(paramTarget, param, allYn, clickCallEvent){
	let target = paramTarget.next(".select_option_list");
	
	let reserveSearchDate   = '';
	
	let comboData = fn_selectListReserveMemberOption(reserveSearchDate, param);
	
	let comboHTML = '';
	
	// 전체옵션 여부
	if('Y'==allYn){
		comboHTML = ' <li class="option_list_item">';
		comboHTML += '	<input type="hidden" name="comboId" value=""/>';
		comboHTML += '	<span>닥터/상담 전체</span>';
		comboHTML += '</li>';
	}
	
	for(let i = 0; i < comboData.length; i++){
		let muMemberId = comboData[i].muMemberId;
		let memberName = comboData[i].memberName;
		let typeName   = comboData[i].typeName;
		
		comboHTML += '<li class="option_list_item">';
		comboHTML += '	<input type="hidden" name="comboId" value="'+muMemberId+'"/>';
		comboHTML += '	<span>'+typeName+' '+memberName+'</span>';
		comboHTML += '</li>';
	}
	target.html(comboHTML);
	
	target.find("li.option_list_item").click(function () {
		// 1. 선택값 셋팅
		let selectId    = $(this).find('input[name="comboId"]').val();
		let selectName  = $(this).find('span').text();
		
		$(this).parent().siblings("button").text(selectName);
		$(this).parent().siblings("input").val(selectId);
		
		if( clickCallEvent )  {
			clickCallEvent(selectId);
		}
	});
	
	// 초기화
	target.find("li:eq(0)").click();
}

/****************************************************************************
* 고객 상세 - 고객 상담차트 정보 리스트 조회 (List)
****************************************************************************/
function fn_selectListUserConsultingChart(){
	let formData = new FormData();
	formData.append("menuClass", menuClass);
	formData.append("sort", userConsultingChartSort);
	formData.append("dir", userConsultingChartDir);
	formData.append("start", userConsultingChartStart);
	formData.append("limit", userConsultingChartLimit);
	formData.append("searchKeywordParam", userConsultingChartSearchKeywordParam);
	formData.append("muTreatmentId", userConsultingChartTreatmentId);
	formData.append("muTreatmentProcedureId", userConsultingChartTreatmentProcedureId);
	formData.append("reserveMemberId", userConsultingChartReserveMemberId);
	formData.append("muUserId", muUserId);

	$.ajax({
		url: encodeURI('/webuserconsultingchart/selectListUserConsultingChart.do'),
		data: formData,
		dataType: "json",
		processData: false,
		contentType: false,
		type: 'POST',
		async: true,
		success: function(data){
			if('0'==data.msgCode){
				// 페이징 처리
				userConsultingChartTotalCount  = data.totalCount;
				//$("#txt_userConsultingChartTotalCount").text(userConsultingChartTotalCount);

				userConsultingChartTotalPages = Math.ceil(userConsultingChartTotalCount/userConsultingChartLimit);
				
				// 리스트 조회
				userConsultingChartAgGridData = data.rows;
				userConsultingChartGridOptions.api.setRowData(userConsultingChartAgGridData);
				
				if(0<data.rows.length){
					//페이징 처리
					window.pagObj = $('#userConsultingChartPagination').twbsPagination({
						startPage    : ((userConsultingChartStart/userConsultingChartLimit)+1),
						totalPages   : (userConsultingChartTotalPages==0)?1:userConsultingChartTotalPages,
						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) {
							fn_userConsultingChartPagination(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(){
			// 로딩열기
			userConsultingChartGridOptions.api.showLoadingOverlay();
		},
		complete:function(){
			
		}
	});
}

/****************************************************************************
* 검색하기
****************************************************************************/
function fn_userConsultingChartSearch(param){
	if("A"!=param && "Y"!=selectUseYn){
		modalEvent.warning("", "조회 권한이 없습니다.");
		return false;
	}
	
	fn_userConsultingChartPaginReset();

	userConsultingChartSearchKeywordParam = $("#userConsultingChartSearchKeyword").val();
	
	userConsultingChartTreatmentId           = $("#userConsultingChartTreatmentId").val();
	userConsultingChartTreatmentProcedureId  = $("#userConsultingChartTreatmentProcedureId").val();
	userConsultingChartReserveMemberId       = $("#userConsultingChartReserveMemberId").val();
	
	fn_selectListUserConsultingChart();
}


/****************************************************************************
* 초기화하기
****************************************************************************/
function fn_userConsultingChartReset(){

	fn_userConsultingChartSearch();
}

/****************************************************************************
* 페이징 처리
****************************************************************************/
function fn_userConsultingChartPagination(param){
	userConsultingChartStart = (parseInt(param)-1)*userConsultingChartLimit;
	
	fn_selectListUserConsultingChart();
}

/****************************************************************************
* 페이징 리셋
****************************************************************************/
function fn_userConsultingChartPaginReset(){

	userConsultingChartStart        = 0;
	userConsultingChartLimit        = 100;
	userConsultingChartTotalCount   = 0;
	userConsultingChartTotalPages   = 0;
	
	//페이징 초기화
	if($("#userConsultingChartPagination").data("twbs-pagination")){
		$("#userConsultingChartPagination").twbsPagination("destroy");
	}
}


/****************************************************************************
* 검색 엔터 이벤트
****************************************************************************/
function fn_userConsultingChartEnter(e){
	if(e.which){
		// 파이어폭스
		if(13 == e.which) {
			//로그인 액션 스크립트
			fn_userConsultingChartSearch();
		}
	}
	else{
		// 윈도우, 사파리, 크롬
		if(13 == event.keyCode) {
			//로그인 액션 스크립트
			fn_userConsultingChartSearch();
		}
	}
}

/****************************************************************************
* 콤보 선택 이벤트
****************************************************************************/
function fn_setComboEvent(param, clickCallEvent, firstCheckYn){
	let target = param.next(".select_option_list");
		
	target.find("li.option_list_item").click(function () {
		// 1. 선택값 셋팅
		let selectId    = $(this).find('input[name="comboId"]').val();
		let selectName  = $(this).find('span').text(); 
		
		$(this).parent().siblings("button").text(selectName);
		$(this).parent().siblings("input").val(selectId);
		
		if( clickCallEvent )  {
			clickCallEvent(selectId);
		}
	});
	
	// 초기화
	if('Y' == firstCheckYn){
		target.find("li:eq(0)").click();
	}
}

/****************************************************************************
* 완료
****************************************************************************/
function fn_userConsultingChartOk(){
	fn_userConsultingChartReset();
}

function fn_userConsultingChartCancel(){
	let pagingParam = "?menuClass="+menuClass;
	pagingParam    += "&userConsultingChartSearchKeywordParam="+userConsultingChartSearchKeywordParam;
	pagingParam    += "&userConsultingChartSort="+userConsultingChartSort;
	pagingParam    += "&userConsultingChartDir="+userConsultingChartDir;
	pagingParam    += "&userConsultingChartStart="+userConsultingChartStart;
	pagingParam    += "&userConsultingChartLimit="+userConsultingChartLimit;
	pagingParam    += "&userConsultingChartTreatmentId="+userConsultingChartTreatmentId;
	pagingParam    += "&userConsultingChartTreatmentProcedureId="+userConsultingChartTreatmentProcedureId;
	pagingParam    += "&userConsultingChartReserveMemberId="+userConsultingChartReserveMemberId;
	pagingParam    += "&muUserId="+muUserId;
	
	fn_leftFormAction("/webuserconsultingchart/selectListUserConsultingChartIntro.do"+pagingParam);
}

/****************************************************************************
* 수정 화면으로 이동.
****************************************************************************/
function fn_updateUserConsultingChartIntro(param){
	if("Y"==updateUseYn){
		// 수정가능
		let pagingParam = "?menuClass="+menuClass;
		pagingParam    += "&userConsultingChartSearchKeywordParam="+userConsultingChartSearchKeywordParam;
		pagingParam    += "&userConsultingChartSort="+userConsultingChartSort;
		pagingParam    += "&userConsultingChartDir="+userConsultingChartDir;
		pagingParam    += "&userConsultingChartStart="+userConsultingChartStart;
		pagingParam    += "&userConsultingChartLimit="+userConsultingChartLimit;
		pagingParam    += "&userConsultingChartTreatmentId="+userConsultingChartTreatmentId;
		pagingParam    += "&userConsultingChartTreatmentProcedureId="+userConsultingChartTreatmentProcedureId;
		pagingParam    += "&userConsultingChartReserveMemberId="+userConsultingChartReserveMemberId;
		pagingParam    += "&muUserId="+muUserId;
		pagingParam    += "&muUserConsultingChartId="+param;
		
		fn_leftFormAction("/webuserconsultingchart/updateUserConsultingChartIntro.do"+pagingParam);
	}
}

/****************************************************************************
* 엑셀 다운 다운로드
****************************************************************************/
function fn_downloadUserReserveHistoryExcel(){
	if("Y"==downloadUseYn){
		// 수정가능
		let pagingParam = "?menuClass="+menuClass;
		pagingParam    += "&searchKeywordParam="+userConsultingChartSearchKeywordParam;
		pagingParam    += "&sort="+userConsultingChartSort;
		pagingParam    += "&dir="+userConsultingChartDir;
		pagingParam    += "&start="+userConsultingChartStart;
		pagingParam    += "&limit="+userConsultingChartLimit;
		pagingParam    += "&muTreatmentId="+userConsultingChartTreatmentId;
		pagingParam    += "&muTreatmentProcedureId="+userConsultingChartTreatmentProcedureId;
		pagingParam    += "&reserveMemberId="+userConsultingChartReserveMemberId;
		pagingParam    += "&muUserId="+muUserId;
		
		let url = encodeURI("/webuserconsultingchart/downloadUserConsultingChartExcel.do"+pagingParam);
		$("#userConsultingChartSelectListForm").prop("action",url);
		$("#userConsultingChartSelectListForm").submit();
	}
	else{
		modalEvent.warning("", "내려받기 권한이 없습니다.");
		return false;
	}
}

let userConsultingChartColumnDefs = [
	{field: "checkbox", headerName:"", minWidth: 50, maxWidth: 50, headerCheckboxSelection: true, checkboxSelection: true},
	/* {field: "rowNum", headerName:"번호", minWidth: columnWidth, maxWidth: columnWidth, sortable: false}, */
	{field: "rowNum", headerName:"번호", minWidth:60,sortable: false, cellStyle:{textAlign: 'center'}},
	{field: "chartNumber", headerName:"차트번호", minWidth: 130, maxWidth: 130, cellStyle:{cursor: 'pointer', color:'#3985EA'}},
	{field: "statusName", headerName:"진료상태", minWidth: 90, maxWidth: 90},
	{field: "userName", headerName:"고객명", minWidth: 120, maxWidth: 120},
	{field: "reserveDate", headerName:"예약날짜", minWidth: 100, maxWidth: 100},
	{field: "reserveTime", headerName:"예약시간", minWidth: 85, maxWidth: 85},
	{field: "treatmentName", headerName:"진료명", minWidth: 120, maxWidth: 120},
	{field: "treatmentProcedureName", headerName:"시술명", minWidth: 150, maxWidth: 150},
	{field: "reserveMemberName", headerName:"닥터/상담자명", minWidth: 120, maxWidth: 120},
	{field: "userEtc", headerName:"특이사항",minWidth: 175, cellStyle: {color: 'red'}},
	{field: "content", headerName:"상담내용",minWidth: 175},
	{field: "writeMemberName", headerName:"작성자", minWidth: 100, maxWidth: 100},
	{field: "writeDate", headerName:"작성일자",minWidth:100, maxWidth:100}
];

// let the grid know which columns and what data to use
let userConsultingChartGridOptions = {
	suppressRowTransform: true,
	columnDefs: userConsultingChartColumnDefs,
	defaultColDef: {		// 리스트 기본 설정
		flex: 1,
		sortable: true,		//정렬 여부
		resizable: true,	//리사이즈
		editable: false,	// 그리드에서 데이터 수정
		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 : userConsultingChartAgGridData,
	suppressRowClickSelection : true, // 로우 클릭시 체크박스 선택 true no, false yes
	localeText : {
		noRowsToShow : '조회 결과가 없습니다.'
	}, //데이터 없을 시 나오는 문구
	rowSelection : 'multiple', // row 다중 선택
	debug : false,
	onCellClicked: function(event){ //셀 클릭 이벤트
		if(event.column.colId=='chartNumber'){
			fn_updateUserConsultingChartIntro(event.data.muUserConsultingChartId);
		}
	},
	onSelectionChanged: function(event){ //체크박스 선택
		selectRows = event.api.getSelectedRows();
	},
	onSortChanged: function(event){
		 //정렬
		userConsultingChartSort = ''; //기존 정렬 초기화
		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){
					userConsultingChartStart = 0;
					userConsultingChartSort += gridSortModel+' '+ gridSort + ',';
				}
				else{
					nullCnt++;
					if(nullCnt == columnArr.length){
						userConsultingChartSort = '';
						userConsultingChartDir = '';
						userConsultingChartStart = 0;
					}
				}
			}
		}
		userConsultingChartSort = userConsultingChartSort.substring(0,userConsultingChartSort.lastIndexOf( ",")); //맨끝 콤마 지우기

		fn_userConsultingChartSearch();
	}
};

// lookup the container we want the Grid to use
let userConsultingChartGridDiv = document.querySelector('#userConsultingChartGrid');

// create the grid passing in the div to use together with the columns & data we want to use
new agGrid.Grid(userConsultingChartGridDiv, userConsultingChartGridOptions);


/****************************************************************************
* 페이지 init
****************************************************************************/
function fn_pageInit(){
	
	// 진료 콤보데이타 설정
	let comboTarget1 = $('#userConsultingChartTreatmentId');
	fn_setTreatmentCombo(comboTarget1, 'Y', function(value){
		let selectId = value;
		
		// 진료시술 콤보 셋팅
		let comboTarget2 = $('#userConsultingChartTreatmentProcedureId');
		fn_setTreatmentProcedureCombo(comboTarget2, selectId, 'Y', function(value){
			let selectId = value;
			
			// 닥터/상담 콤보 셋팅
			let comboTarget3 = $('#userConsultingChartReserveMemberId');
			fn_setReserveMemberCombo(comboTarget3, selectId, 'Y', function(value){});
		});
	});
		
	
	
	fn_userConsultingChartSearch("A");
}

function fn_consultingChartListPrint(html){
	let mywindow = window.open('', 'PRINT', 'height=1200,width=1600');

	// 스타일 적용 방법 1
	mywindow.document.write('<th:block layout:fragment="css"> ');
	mywindow.document.write('<link rel="stylesheet" href="/css/web/modal_customer_sub_consulting_print.css" type="text/css" />');
	mywindow.document.write('</th:block> ');

	mywindow.document.write('<html><head><title>' + document.title + '</title>');
	mywindow.document.write('</head><body>');
	mywindow.document.write('<div id="page">');
	//mywindow.document.write('<h1>' + document.title  + '</h1>');
	mywindow.document.write(html);
	mywindow.document.write('</div>');
	mywindow.document.write('</body></html>');

	mywindow.document.close(); // necessary for IE >= 10

	// 필요 - style loading is async
	setTimeout(function () {
		mywindow.print();
	}, 500);
}

function fn_consultingUserBirthAndAge(birthday, gender) {
	// 오늘 날짜
	let today = new Date();
	// 생일
	let birthDate = new Date(birthday);

	// 나이 계산
	let age = today.getFullYear() - birthDate.getFullYear();
	let monthDifference = today.getMonth() - birthDate.getMonth();
	let dayDifference = today.getDate() - birthDate.getDate();

	// 만 나이 조정
	if (monthDifference < 0 || (monthDifference === 0 && dayDifference < 0)) {
		age--;
	}

	// 원하는 형식의 문자열 만들기
	let formattedDate = birthday.replace(/-/g, '.');
	return  formattedDate + ' (' + gender + ', ' + age + '세)';

}

/****************************************************************************
 * 고객 시술차트 인쇄 리스트 조회
 ****************************************************************************/
function fn_printUserConsultingChart(){
	let consultingChartHtml = ''

	let dataMap = []; // 배열로 초기화
	selectRows.map(row => {
		let data = {};
		data.muUserConsultingChartId = row.muUserConsultingChartId;
		dataMap.push(data);
	});

	let formData = new FormData();
	formData.append("menuClass", menuClass);
	formData.append("muUserConsultingDataList", JSON.stringify(dataMap));

	$.ajax({
		url: encodeURI('/webuserconsultingchart/selectUserConsultingChartList.do'),
		data: formData,
		dataType: "json",
		processData: false,
		contentType: false,
		type: 'POST',
		async: true,
		success: function (data) {
			if (data.msgCode === '0') {
				if(0<data.rows.length){
					data.rows.map((row, index)=>{
						let userBirthDay = fn_consultingUserBirthAndAge(row.birthday,row.gender);
						let treatmentProcedureName = row.treatmentName+'-'+row.treatmentProcedureName;
						let firstVisit = "";
						let returnVisit= "";
						if("Y" == row.visitYn){
							returnVisit="checked"
						}else if("N" == row.visitYn){
							firstVisit="checked"
						}
						let chartNumber		   	=row.chartNumber||''
						let userName		    =row.userName||''
						let userNationality		=row.nationality||''
						let userPhoneNumber		=row.phoneNumber||''
						let userEtc				=row.userEtc||''
						let writeDate			=row.writeDate||''
						let writeMemberName		=row.writeMemberName||''
						let reserveMemberName	=row.reserveMemberName||''
						let reserveDateTime		=row.reserveDate+'-'+row.reserveTime||''
						let receptionDateTime	=row.receptionDateTime||''
						let userMembership		=row.membershipBalance||''
						let content				=row.content||''

						consultingChartHtml+=`<div class="print">
												<div class="print_top">
													<p class="first">상담차트</p>
													<p>
														작성일자 :
														<span class="first">${writeDate}</span>
														담당자 :
														<span>${writeMemberName}</span>
													</p>
												</div>
												<div class="print_btm">
													<div>
														<ul>
															<li>
																<label>성명</label>
																<p>${userName}</p>
															</li>
															<li>
																<label>생년월일</label>
																<p>${userBirthDay}</p>
															</li>
															<li>
																<label>국적</label>
																<p>${userNationality}</p>
															</li>
															<li>
																<label>연락처</label>
																<p>${userPhoneNumber}</p>
															</li>
															<li>
																<label>멤버십</label>
																<p>${userMembership}</p>
															</li>
														</ul>
														<ul>
															<li>
																<label>방문 구분</label>
																<div class="input_box">
																	<div>
																		<input type="radio" name="sortation_${index}" ${firstVisit} id="consultingChartFirstVisit_${index}" readonly/>
																		<label for="consultingChartFirstVisit_${index}">초진</label>
																	</div>
																	<div>
																		<input type="radio" name="sortation_${index}" ${returnVisit} id="consultingChartReturnVisit_${index}" readonly/>
																		<label for="consultingChartReturnVisit_${index}">재진</label>
																	</div>
																</div>
															</li>
															<li>
																<label>예약</label>
																<p>${reserveDateTime}</p>
															</li>
															<li>
																<label>접수</label>
																<p>${receptionDateTime}</p>
															</li>
															<li>
																<label>예약구분</label>
																<p>${treatmentProcedureName}</p>
															</li>
															<li>
																<label>닥터/상담</label>
																<p>${reserveMemberName}</p>
															</li>
														</ul>
														<div class="note">
															<label>고객 특이사항</label>
															<p>${userEtc}</p>
														</div>
													</div>
													<p>상담내용</p>
													<div class="last">
														${content}
													</div>
												</div>
											</div>`
					});
					fn_consultingChartListPrint(consultingChartHtml);
				}
			} else {
				modalEvent.danger("조회 오류", data.msgDesc);
			}

		},
		error: function (xhr, status, error) {
			modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
		},
		beforeSend: function () {
		},
		complete: function () {
		}
	});

}
/****************************************************************************
* 페이지 event
****************************************************************************/
function fn_pageEvent(){
	// 검색 조회 버튼
	$("#btnSearchUserReserveHistory").click(function () {
		fn_userConsultingChartSearch();
	});
	
	// 예약 내역 Excel 다운로드 버튼
	$("#btnDownloadUserReserveHistoryExcel").click(function () {
		fn_downloadUserReserveHistoryExcel();
	});
	$("#btnUserReserveHistoryPrint").click(function () {
		fn_printUserConsultingChart();
	});

}

$(function(){
	// 페이지 init
	fn_pageInit();
	
	// 페이지 event
	fn_pageEvent();
});