
/* ##############################################################
	설  명 : [Modal]예약 등록 팝업
	작성일 : 2023. 01. 19.
	작성자 : NTsoft
	수정일 	        수정자 	 수정내용
	-------         -------- ---------------------------
	2023. 01. 19.	NTsoft 	 최초 생성
*/
let reserveInsertModal = {
	callback : null,
	reqParam : null,
	dataList : null,
	/* 모달 초기화 작업 */
	init : function () {
		$('#reserveInsertModal').remove();
		$('body').append( this.HtmlTemplate);
		//그리드 이벤트
		this.setEvent();
	},
	/* 그리드 이벤트 설정 */
	setEvent:function() {
		// tab1, tab2 : 취소
		$('#reserveInsertModal #list1 .btnCancle, #reserveInsertModal #list2 .btnCancle').on("click", function(){
			reserveInsertModal.close();
		});
		
		// tab1 : 예약등록
		$('#reserveInsertModal #list1 .btnSave').on("click", function(){
			reserveInsertModal.save("I");
		});
		
		// tab1 : 예약추가
		$('#reserveInsertModal #list1 .btnReserveAdd').on("click", function(){
			reserveInsertModal.addRow();
		});
		
		// tab1 : 담당자 수정하기 이벤트
		$('#reserveInsertModal #list1 .manager_btn').on("click", function(){
			$('#reserveInsertModal #list1 .read_box').hide();
			$('#reserveInsertModal #list1 .search_box.member_box').show();
		});
		
		// tab1 : 담당자 수정 취소하기 이벤트
		$('#reserveInsertModal #list1 .cancel_btn').on("click", function(){
			$('#reserveInsertModal #list1 .read_box').show();
			$('#reserveInsertModal #list1 .search_box.member_box').hide();
		});
		
		// tab1 : 담당자 변경 이벤트
		let modalMemberTarget = $('#reserveInsertModal #list1 input[name="modalMemberName"]');
		modalMemberTarget.on("click", function(){
			let reqParam = {};
			memberSearchModal.popup(function (obj) {
				modalMemberTarget.val(obj.selectMemberName);
				modalMemberTarget.closest('.search_box').siblings('input[name="modalMemberId"]').val(obj.selectMemberId);
			}, reqParam);
		});

		// tab1 : 고객조회 팝업
		$('#reserveInsertModal #list1 input[name="modalUserName"]').on("click", function(){
			let reqParam = {};
			userIntroSelectModal.popup(function (obj, reqParam) {
				$('#reserveInsertModal #list1 input[name="modalUserId"]').val(obj.muUserId);
				$('#reserveInsertModal #list1 input[name="modalUserName"]').val(obj.userName);
				
				$('#reserveInsertModal #list1 .modalPhoneNumber').text(fn_setFormatPhone(obj.phoneNumber));

				let userType = obj.userType=='T'||obj.userType=='Y'?
									'-':'<img src="'+obj.userType.replace("C:", "")+'" alt="고객구분" />'
				$('#reserveInsertModal #list1 .modalUserType').html(userType);
				$('#reserveInsertModal #list1 .modalBirthday').text(obj.birthday);
				$('#reserveInsertModal #list1 .modalGender').text(obj.gender);
				$('#reserveInsertModal #list1 .modalNationality').text(obj.nationality);
				$('#reserveInsertModal #list1 .modalMemo').text(obj.memo);

			}, reqParam);
		});
		
		// tab2 : 간편예약등록
		$('#reserveInsertModal #list2 .btnSave').on("click", function(){
			reserveInsertModal.saveReserveSimple("I");
		});

		// tab2 : 생년월일
		$('#reserveInsertModal #list2').find('input[name="modalBirthday"]').datetimepicker({
			/*allowInputToggle: false,*/
			format: 'YYYY-MM-DD',
			useCurrent: false // 현재 날짜 자동 선택
		});
		
		// tab2 : 예약 일자
		$('#reserveInsertModal #list2').find('input[name="modalReserveDate"]').datetimepicker({
			allowInputToggle: true,
			format: 'YYYY-MM-DD',
			defaultDate: moment()
		}).on("dp.change", function(e){
			// 날짜가 변경될 때 실행
			// console.log(e.oldDate.format("YYYY-MM-DD"));
			// console.log(e.date.format("YYYY-MM-DD"));

			// 예약 시간 셋팅
			fn_searchSetTime('reserveInsertModal #list2 .modal_table_content:last .select_option_list.time',e.date.format("YYYY-MM-DD"));

			// 초기화
			// 예약경로
			$("#reserveInsertModal #list2 [name=modalReserveCategoryItemCode]").val("");
			$("#reserveInsertModal #list2 [name=modalReserveCategoryItemCode]").siblings("button").text("예약경로");
			// 진로유형
			$("#reserveInsertModal #list2 [name=modalTreatmentProcedureId]").val("");
			$("#reserveInsertModal #list2 [name=modalTreatmentProcedureName]").val("");
			// 닥터/상담
			$("#reserveInsertModal #list2 [name=modalReserveMemberId]").val("");
			$("#reserveInsertModal #list2 [name=modalReserveMemberId]").siblings("button").text("닥터/상담");
			$("#reserveInsertModal #list2 [name=modalReserveMemberId]").siblings("ul").find("li").remove();
			// 예약메모
			$("#reserveInsertModal #list2 [name=modalEtc]").val("");
		});
		$('#reserveInsertModal #list2').find('input[name="modalReserveDate"]').data("DateTimePicker").minDate(fn_getToDate());
		
		// tab2: 예약경로 콤보 셋팅
		 reserveInsertModal.setReserveCategoryCombo();
		// $('#reserveInsertModal #list2').find('input[name="modalReserveCategoryItemId"]').next(".select_option_list").html(comboHTML);
		
		let selectDate = $('#reserveInsertModal #list2').find('input[name="modalReserveDate"]').val();
		// tab2 : 예약 시간 셋팅
		fn_searchSetTime('reserveInsertModal #list2 .select_option_list.time',selectDate);

		// tab2 : 담당자 수정하기 이벤트
		$('#reserveInsertModal #list2 .manager_btn').on("click", function(){
			$('#reserveInsertModal #list2 .read_box').hide();
			$('#reserveInsertModal #list2 .search_box.member_box').show();
		});
		
		// tab2 : 담당자 수정 취소하기 이벤트
		$('#reserveInsertModal #list2 .cancel_btn').on("click", function(){
			$('#reserveInsertModal #list2 .read_box').show();
			$('#reserveInsertModal #list2 .search_box.member_box').hide();
		});
		
		// tab2 : 담당자 변경 이벤트
		let modalMemberTarget2 = $('#reserveInsertModal #list2 input[name="modalMemberName"]');
		modalMemberTarget2.on("click", function(){
			let reqParam = {};
			memberSearchModal.popup(function (obj) {
				modalMemberTarget2.val(obj.selectMemberName);
				modalMemberTarget2.closest('.search_box').siblings('input[name="modalMemberId"]').val(obj.selectMemberId);
			}, reqParam);
		});
		
		// 콤보 이벤트
		$('#reserveInsertModal #list2').find(".select_option_list").not('.time').find("li.option_list_item").click(function () {
			// 1. 선택값 셋팅
			let selectIdArr = $(this).prop("id").split('_');
			let selectId    = selectIdArr[1];
			let selectName  = $(this).text();
			
			$(this).parent().siblings("button").text(selectName);
			$(this).parent().siblings("input").val(selectId);
		});
		
		// 진료/시술 검색 팝업 이벤트
		let treatmentProcedureTarget = $('#reserveInsertModal #list2').find('input[name="modalTreatmentProcedureName"]');
		treatmentProcedureTarget.on("click", function(){
			let reqParam = {};
			treatmentProcedureSearchModal.popup(function (obj, reqParam) {
				treatmentProcedureTarget.prev().val(obj.muTreatmentProcedureId);
				treatmentProcedureTarget.val(obj.treatmentProcedureName);
				
				// 닥터/상담자 콤보 셋팅
				let reserveMemberTarget = $('#reserveInsertModal #list2').find('input[name="modalReserveMemberId"]').next(".select_option_list");
				
				let modalReserveDate = $('#reserveInsertModal #list2').find('input[name="modalReserveDate"]').val();
				let modalReserveTime = $('#reserveInsertModal #list2').find('input[name="modalReserveTime"]').val();
				let reserveMemberHTML = reserveInsertModal.setReserveMemberCombo(modalReserveDate, obj.muTreatmentProcedureId, modalReserveTime);
				reserveMemberTarget.html(reserveMemberHTML);
				reserveMemberTarget.siblings("button").text("닥터/상담");
		
				reserveMemberTarget.find("li.option_list_item").click(function () {
					// 1. 선택값 셋팅
					let selectIdArr = $(this).prop("id").split('_');
					let selectId    = selectIdArr[1];
					let selectName  = $(this).text();
					
					$(this).parent().siblings("button").text(selectName);
					$(this).parent().siblings("input").val(selectId);
				});
			}, reqParam);
		});

		// tab3 : 일괄등록 양식 다운로드
		$('#reserveInsertModal #list3 .btnDownloadReserveExcelSample').on("click", function(){
			let url = encodeURI("/webreserve/downloadReserveSampleExcel.do?fileName=Reserve_Upload_Sample.xlsx");
			
			let newForm = $("<form><form/>");
			newForm.attr("name", "excelForm");
			newForm.attr("method", "POST");
			newForm.attr("target", "_blank");
			newForm.attr("action", url);
			newForm.appendTo('body');
			newForm.submit();
		});
		
		// tab3 : 참고엑셀 다운로드
		$('#reserveInsertModal #list3 .btnDownloadReserveColumnExcel').on("click", function(){
			let url = encodeURI("/webreserve/downloadReserveColumnExcel.do");
			
			let newForm = $("<form><form/>");
			newForm.attr("name", "columnExcelForm");
			newForm.attr("method", "POST");
			newForm.attr("target", "_blank");
			newForm.attr("action", url);
			newForm.appendTo('body');
			newForm.submit();
		});
		
		// tab3 : 일괄예약등록
		$('#reserveInsertModal #list3 .btnSave').on("click", function(){
			reserveInsertModal.saveUploadReserve("I");
		});

		// tab3 : 취소(닫기)
		$('#reserveInsertModal #list3 .btnCancle').on("click", function(){
			reserveInsertModal.close();
		});
	},
    // 파일 읽기 및 파싱
    readFile: function (file) {
        const reader = new FileReader();
        reader.onload = function (e) {
            const data = new Uint8Array(e.target.result);
            const workbook = XLSX.read(data, { type: 'array' });
            const sheetName = workbook.SheetNames[0];
            const worksheet = workbook.Sheets[sheetName];
            const json = XLSX.utils.sheet_to_json(worksheet);
            reserveInsertModal.displayFileData(json);
        };
        reader.readAsArrayBuffer(file);
    },
	// 파일 데이터를 HTML로 표시
	displayFileData: function (data) {
		let listHTML = '';

		if (data.length > 0) {
			for (let i = 1; i < data.length; i++) {
				const row = data[i];
				listHTML += '<tr>';

				listHTML += `<td data-col-name="num" title="" style="text-align:center;">${i}</td>`;
				listHTML += `<td data-col-name="rowCheck" title="" style="text-align:center;"></td>`;
				listHTML += `<td data-col-name="rowMsgDesc" title="" style="text-align:left;"></td>`;
				listHTML += `<td data-col-name="reserveDate" title="" style="text-align:center;">${convertExcelDate(row.__EMPTY) || ''}</td>`;
				listHTML += `<td data-col-name="reserveTime" title="" style="text-align:center;">${row.__EMPTY_1 || ''}</td>`;
				listHTML += `<td data-col-name="reserveCategoryItemId" title="" style="text-align:center;">${row.__EMPTY_2 || ''}</td>`;
				listHTML += `<td data-col-name="userName" title="" style="text-align:center;">${row.__EMPTY_3 || ''}</td>`;
				listHTML += `<td data-col-name="phoneNumber" title="" style="text-align:center;">${row.__EMPTY_4 || ''}</td>`;
				listHTML += `<td data-col-name="birthday" title="" style="text-align:center;">${convertExcelDate(row.__EMPTY_5) || ''}</td>`;
				listHTML += `<td data-col-name="nationalityCategoryItemCode" title="" style="text-align:center;">${row.__EMPTY_6 || ''}</td>`;
				listHTML += `<td data-col-name="muTreatmentProcedureId" title="" style="text-align:center;">${row.__EMPTY_7 || ''}</td>`;
				listHTML += `<td data-col-name="reserveMemberCode" title="" style="text-align:center;">${row.__EMPTY_8 || ''}</td>`;
				listHTML += `<td data-col-name="etc" title="" style="text-align:left;">${row.__EMPTY_9 || ''}</td>`;

				listHTML += '</tr>';
			}

			$("#reserveInsertModal #list3 .list3_table_box table tbody").empty().html(listHTML).trigger("create");

		} else {
			listHTML = '<tr class="searchEmpty"><td colspan="13">데이터가 없습니다.</td></tr>';
			$("#reserveInsertModal #list3 .list3_table_box table tbody").empty().html(listHTML).trigger("create");
		}
	},
	/* 예약경로 콤보데이터 설정 (동적추가) */
	setReserveCategoryCombo:function() {
		// let comboData = fn_selectListReserveCategoryItemOption();
		// let comboHTML = '';
		// for(let i = 0; i < comboData.length; i++){
		// 	let muCategoryItemId = comboData[i].muCategoryItemId;
		// 	let categoryItemCode = comboData[i].categoryItemCode;
		// 	let categoryItemName = comboData[i].categoryItemName;
		//
		// 	comboHTML += '<li id="li_'+muCategoryItemId+'" class="option_list_item">'+categoryItemName+'</li>';
		// }
		// return comboHTML;
		let category = fn_selectCategoryList2();
		let reservationCategory = category.find(cat => cat.categoryName === '예약경로');

		if (reservationCategory) {
			fn_selectModalOtherOption2(reservationCategory.categoryCode);
		}
		const target =  $('#reserveInsertModal input[name="modalReserveCategoryItemCode"]').siblings("ul.select_option_list");
		target.find("li.option_list_item").click(function () {
		// 1. 선택값 셋팅
		let selectIdArr = $(this).prop("id").split('_');
		let selectId    = selectIdArr[1];
		let selectName  = $(this).text();

		$(this).parent().siblings("button").text(selectName);
		$(this).parent().siblings("input").val(selectId);
	});
	},
	/* 닥터/상담 콤보데이터 설정 (동적추가) */
	setReserveMemberCombo:function(param, param2, param3) {
		let comboData = fn_selectListReserveMemberOption(param, param2, param3);
		let comboHTML = '';
		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 id="li_'+muMemberId+'" class="option_list_item">'+typeName+' '+memberName+'</li>';
		}
		return comboHTML;
	},
	/* tab1 : 예약 추가 */
	addRow:function() {
		let addRowHtml = '';
		addRowHtml += '<li class="modal_table_content">';
		addRowHtml += '	<div class="first">';
		addRowHtml += '		<div class="calendar_box">';
		addRowHtml += '			<div class="date_box">';
		addRowHtml += '				<img src="/image/web/calendar.svg" alt="calendar"/>';
		addRowHtml += '				<input type="date" class="date_picker" name="modalReserveDate">';
		addRowHtml += '			</div>';
		addRowHtml += '		</div>';
		addRowHtml += '		<div class="select_box dropdown">';
		addRowHtml += '			<button class="label" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">00:00</button>';
		addRowHtml += '			<input type="hidden" name="modalReserveTime">';
		
		addRowHtml += '			<ul class="select_option_list dropdown-menu time"></ul>';
		addRowHtml += '		</div>';
		addRowHtml += '	</div>';
		addRowHtml += '	<div>';
		addRowHtml += '		<div class="select_box dropdown">';
		addRowHtml += '			<button class="label" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">예약경로</button>';
		addRowHtml += '			<input type="hidden" name="modalReserveCategoryItemCode">';
		addRowHtml += '			<ul class="select_option_list dropdown-menu">';
		addRowHtml += '			</ul>';
		addRowHtml += '		</div>';
		addRowHtml += '	</div>';
		addRowHtml += '	<div>';
		addRowHtml += '		<div class="search_box" data-target=".medical_type" style="transition: all 0.2s ease-in-out 0s;">';
		addRowHtml += '			<img src="/image/web/search_B.svg" alt="search"/>';
		addRowHtml += '			<input type="hidden" name="modalTreatmentProcedureId" />';
		addRowHtml += '			<input type="text" name="modalTreatmentProcedureName" readonly />';
		addRowHtml += '		</div>';
		addRowHtml += '	</div>';
		addRowHtml += '	<div>';
		addRowHtml += '		<div class="select_box dropdown">';
		addRowHtml += '			<button class="label" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">닥터/상담</button>';
		addRowHtml += '			<input type="hidden" name="modalReserveMemberId">';
		addRowHtml += '			<ul class="select_option_list dropdown-menu"></ul>';
		addRowHtml += '		</div>';
		addRowHtml += '	</div>';
		addRowHtml += '	<div>';
		addRowHtml += '		<div class="input_box last">';
		addRowHtml += '			<input type="text" name="modalEtc" placeholder="-"/>';
		addRowHtml += '		</div>';
		addRowHtml += '		<div class="subtract_box" style="">';
		addRowHtml += '			<button class="add_btn" onclick="javascript:reserveInsertModal.removeRow(this);">';
		addRowHtml += '				<img src="/image/web/subtract.svg" style="width:100%;" alt="삭제">';
		addRowHtml += '			</button>';
		addRowHtml += '		</div>	';
		addRowHtml += '	</div>';
		addRowHtml += '</li>';
		$('#reserveInsertModal #list1 .reserveRowBox').append(addRowHtml).trigger("create");
		reserveInsertModal.setReserveCategoryCombo();

		// 현재 row
		let parentTarget = $('#reserveInsertModal #list1 .modal_table_content:last');

		// 예약 일자
		parentTarget.find('input[name="modalReserveDate"]').datetimepicker({
			allowInputToggle: true,
			format: 'YYYY-MM-DD',
			defaultDate: moment()
		}).on("dp.change", function(e){
			// 날짜가 변경될 때 실행
			// console.log(e.oldDate.format("YYYY-MM-DD"));
			// console.log(e.date.format("YYYY-MM-DD"));
			let selectIdx = $("#reserveInsertModal #list1 input[name=modalReserveDate]").index($(this));

			// 예약 시간 셋팅
			fn_searchSetTime('reserveInsertModal #list1 .modal_table_content:last .select_option_list.time',e.date.format("YYYY-MM-DD"));

			// 초기화
			// 예약경로
			$("#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("");
		});
		parentTarget.find('input[name="modalReserveDate"]').data("DateTimePicker").minDate(fn_getToDate());
		let selectDate = $('#reserveInsertModal #list1').find('input[name="modalReserveDate"]').val();
		// 예약 시간 셋팅
		fn_searchSetTime('reserveInsertModal #list1 .modal_table_content:last .select_option_list.time',selectDate);
		
		// 콤보 이벤트
		parentTarget.find(".select_option_list").not('.time').find("li.option_list_item").click(function () {
			// 1. 선택값 셋팅
			let selectIdArr = $(this).prop("id").split('_');
			let selectId    = selectIdArr[1];
			let selectName  = $(this).text();
			
			$(this).parent().siblings("button").text(selectName);
			$(this).parent().siblings("input").val(selectId);
		});
		
		// 진료/시술 검색 팝업 이벤트
		let treatmentProcedureTarget = parentTarget.find('input[name="modalTreatmentProcedureName"]');
		treatmentProcedureTarget.on("click", function(){
			let reqParam = {};
			treatmentProcedureSearchModal.popup(function (obj, reqParam) {
				treatmentProcedureTarget.prev().val(obj.muTreatmentProcedureId);
				treatmentProcedureTarget.val(obj.treatmentProcedureName);
				
				// 닥터/상담자 콤보 셋팅
				let reserveMemberTarget = parentTarget.find('input[name="modalReserveMemberId"]').next(".select_option_list");
				
				let modalReserveDate = parentTarget.find('input[name="modalReserveDate"]').val();
				let modalReserveTime = parentTarget.find('input[name="modalReserveTime"]').val();
				let reserveMemberHTML = reserveInsertModal.setReserveMemberCombo(modalReserveDate, obj.muTreatmentProcedureId, modalReserveTime);
				reserveMemberTarget.html(reserveMemberHTML);
				reserveMemberTarget.siblings("button").text("닥터/상담");
		
				reserveMemberTarget.find("li.option_list_item").click(function () {
					// 1. 선택값 셋팅
					let selectIdArr = $(this).prop("id").split('_');
					let selectId    = selectIdArr[1];
					let selectName  = $(this).text();
					
					$(this).parent().siblings("button").text(selectName);
					$(this).parent().siblings("input").val(selectId);
				});
			}, reqParam);
		});
		
	},
	/* 예약 행 삭제 */
	removeRow : function(param){
		let rowCount = $(param).closest(".modal_table_box").find(".modal_table_content").length;
		
		if(1 == rowCount){
			modalEvent.warning("등록", "예약은 최소 1건이 추가되어야 합니다. 삭제할 수 없습니다.");
			return;
		}
		else{
			$(param).closest(".modal_table_content").remove();
			return;
		}
	},
	setFileName : function(param){
		reserveInsertModal.readFile(param.files[0]);

		var fileValue = $(param).val().split("\\");
		var fileName = fileValue[fileValue.length-1]; // 파일명
		
		if(fileName==null||fileName==''){
			$(param).val('');
			$(param).siblings('.upload-name').val('파일을 업로드해주세요.');
		}else{
			$(param).siblings('.upload-name').val(fileName);
		}
	},
	/* 데이터 선택 */
	setSelect:function(selectNumber) {
		let checkedData = dataList[selectNumber];
		if(dataList==null||checkedData==undefined){
			return ;
		}
		
		if( reserveInsertModal.callback )  {
			reserveInsertModal.callback(checkedData);
		}
		reserveInsertModal.close();
	},
	// 고객 조회
	searchUser:function(state) {
		let muUserId = reserveInsertModal.reqParam.muUserId;

		if(true != fn_emptyCheck(muUserId)){
			modalEvent.warning("", "고객 정보가 없습니다.");
			return;
		}
		
		let formData = new FormData();
		formData.append("menuClass", menuClass);
		formData.append("muUserId", muUserId);

		$.ajax({
			url: encodeURI('/webuser/selectUser.do'),
			data: formData,
			dataType: "json",
			processData: false,
			contentType: false,
			type: 'POST',
			async: true,
			success: function(data){
				if('0'==data.msgCode){
					
					$('#reserveInsertModal #list1 input[name="modalUserId"]').val(data.userDetail[0].muUserId);
					$('#reserveInsertModal #list1 input[name="modalUserName"]').val(data.userDetail[0].userName);
					
					$('#reserveInsertModal #list1 .modalPhoneNumber').text(fn_setFormatPhone(data.userDetail[0].phoneNumber));
					
					if("T" == data.userDetail[0].userType2){
						// 간편예약 고객
						$('#reserveInsertModal #list1 .modalUserType').html('-');
						$('#reserveInsertModal #list1 .modalBirthday').text('-');
						$('#reserveInsertModal #list1 .modalGender').text('-');
						$('#reserveInsertModal #list1 .modalNationality').text('-');
						$('#reserveInsertModal #list1 .modalMemo').text('-');
					}
					else{
						// 일반고객
						$('#reserveInsertModal #list1 .modalUserType').html('<img src="'+data.userDetail[0].filePath+'" alt="고객구분" />');
						$('#reserveInsertModal #list1 .modalBirthday').text(data.userDetail[0].birthday);
						$('#reserveInsertModal #list1 .modalGender').text(data.userDetail[0].gender);
						$('#reserveInsertModal #list1 .modalNationality').text(data.userDetail[0].nationalityName);
						$('#reserveInsertModal #list1 .modalMemo').text(data.userDetail[0].memo);
					}
					
				}
				else{
					modalEvent.danger("조회 오류", data.msgDesc);
				}
			},
			error : function(xhr, status, error) {
				modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
			},
			beforeSend:function(){

			},
			complete:function(){

			}
		});
	},
	// tab1 : 예약 등록
	save:function(state) {
		// tab1 : 예약등록
		
		let muUserId                = $('#reserveInsertModal #list1 input[name="modalUserId"]').val();
		let userName                = $('#reserveInsertModal #list1 input[name="modalUserName"]').val();
		let muMemberId              = $('#reserveInsertModal #list1 input[name="modalMemberId"]').val();
		
		// 예약 정보
		let reserveArray   = new Object();
		
		if(true != fn_emptyCheck(muUserId)){
			modalEvent.warning("등록", "고객 정보가 없습니다.");	
			return;
		}
		
		if(true != fn_emptyCheck(userName)){
			modalEvent.warning("등록", "고객명 정보가 없습니다.");	
			return;
		}
		else{
			if(true != fn_lengthCheck(userName, 255)) {
				modalEvent.warning("등록", "고객명 정보는 255자를 넘을 수 없습니다.");	
				return;
			}
		}
		
		if(true != fn_emptyCheck(muMemberId)){
			modalEvent.warning("등록", "담당자 정보가 없습니다.");	
			return;
		}
		
		// 예약 정보
		let reserveTr = $('#reserveInsertModal #list1 .reserveRowBox').children('li.modal_table_content');
		let reserveTempArray = new Array();
		for(let i=0 ; i < reserveTr.length; i++){
			let reserveDate             = reserveTr.eq(i).find('input[name="modalReserveDate"]').val();
			let reserveTime             = reserveTr.eq(i).find('input[name="modalReserveTime"]').val();
			let reserveCategoryItemCode   = reserveTr.eq(i).find('input[name="modalReserveCategoryItemCode"]').val();
			let reserveCategoryItemName   = reserveTr.eq(i).find('input[name="modalReserveCategoryItemCode"]').siblings('button').text();
			let muTreatmentProcedureId  = reserveTr.eq(i).find('input[name="modalTreatmentProcedureId"]').val();
			let reserveMemberId         = reserveTr.eq(i).find('input[name="modalReserveMemberId"]').val();
			let etc                     = reserveTr.eq(i).find('input[name="modalEtc"]').val();
			
			if(true != fn_emptyCheck(reserveDate)){
				modalEvent.warning("등록", "예약일자 정보가 없습니다.");
				return;
			}
			
			if(true != fn_emptyCheck(reserveTime)){
				modalEvent.warning("등록", "예약시간 정보가 없습니다.");
				return;
			}
			
			if(true != fn_emptyCheck(reserveCategoryItemCode)){
				modalEvent.warning("등록", "예약경로 정보가 없습니다.");
				return;
			}
			
			if(true != fn_emptyCheck(muTreatmentProcedureId)){
				modalEvent.warning("등록", "진료유형 정보가 없습니다.");	
				return;
			}
			
			if(true != fn_emptyCheck(reserveMemberId)){
				modalEvent.warning("등록", "닥터/상담자 정보가 없습니다.");
				return;
			}
			
			let arr_sub = new Object();
			arr_sub.reserveDate            = reserveDate;
			arr_sub.reserveTime            = reserveTime;
			arr_sub.reserveCategoryItemCode  = reserveCategoryItemCode;
			arr_sub.reserveCategoryItemName  = reserveCategoryItemName;
			arr_sub.muTreatmentProcedureId = muTreatmentProcedureId;
			arr_sub.reserveMemberId        = reserveMemberId;
			arr_sub.etc                    = etc;
			reserveTempArray.push(arr_sub);
			
			reserveArray.data = reserveTempArray;
		}
		
		modalEvent.info("등록", "예약 정보를 등록하시겠습니까?", function(){
			let formData = new FormData();
			formData.append("menuClass", menuClass);
			formData.append("muUserId", muUserId);
			formData.append("userName", userName);
			formData.append("muMemberId", muMemberId);
			formData.append("reserveRows",JSON.stringify(reserveArray));
	
			$.ajax({
				url: encodeURI('/webreserve/insertReserve.do'),
				data: formData,
				dataType: "json",
				processData: false,
				contentType: false,
				type: 'POST',
				async: true,
				success: function(data){
					if('0'==data.msgCode){
						modalEvent.success("등록 성공", data.msgDesc, function(){
							if( reserveInsertModal.callback )  {
								reserveInsertModal.callback();
							}
							reserveInsertModal.close();
						});
					}
					else{
						modalEvent.danger("등록 오류", data.msgDesc);
					}
				},
				error : function(xhr, status, error) {
					modalEvent.danger("등록 오류", "등록 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
				},
				beforeSend:function(){
					
				},
				complete:function(){
					
				}
			});
		});
	},
	// tab2 : 간편예약
	saveReserveSimple:function(state) {
		// tab2 : 간편예약
		let userName                = $('#reserveInsertModal #list2 input[name="modalUserName"]').val();
		let phoneNumber             = $('#reserveInsertModal #list2 input[name="modalPhoneNumber"]').val().replace(/-/g, '');
		let birthday                = $('#reserveInsertModal #list2 input[name="modalBirthday"]').val();
		let reserveDate             = $('#reserveInsertModal #list2 input[name="modalReserveDate"]').val();
		let reserveTime             = $('#reserveInsertModal #list2 input[name="modalReserveTime"]').val();
		let reserveCategoryItemCode = $('#reserveInsertModal #list2 input[name="modalReserveCategoryItemCode"]').val();
		let reserveCategoryItemName = $('#reserveInsertModal #list2 input[name="modalReserveCategoryItemCode"]').siblings('button').text();
		let muTreatmentProcedureId  = $('#reserveInsertModal #list2 input[name="modalTreatmentProcedureId"]').val();
		let reserveMemberId         = $('#reserveInsertModal #list2 input[name="modalReserveMemberId"]').val();
		let etc                     = $('#reserveInsertModal #list2 textarea[name="modalEtc"]').val();
		let muMemberId              = $('#reserveInsertModal #list2 input[name="modalMemberId"]').val();
		
		if(true != fn_emptyCheck(userName)){
			modalEvent.warning("등록", "고객명 정보가 없습니다.");
			return;
		}
		else{
			if(true != fn_lengthCheck(userName, 255)) {
				modalEvent.warning("등록", "고객명 정보는 255자를 넘을 수 없습니다.");	
				return;
			}
		}
		
		if(true != fn_emptyCheck(phoneNumber)){
			modalEvent.warning("등록", "연락처 정보가 없습니다.");	
			return;
		}

		if(true != fn_emptyCheck(reserveDate)){
			modalEvent.warning("등록", "예약일자 정보가 없습니다.");
			return;
		}
		
		if(true != fn_emptyCheck(reserveTime)){
			modalEvent.warning("등록", "예약시간 정보가 없습니다.");
			return;
		}
		
		if(true != fn_emptyCheck(reserveCategoryItemCode)){
			modalEvent.warning("등록", "예약경로 정보가 없습니다.");
			return;
		}
		
		if(true != fn_emptyCheck(muTreatmentProcedureId)){
			modalEvent.warning("등록", "진료유형 정보가 없습니다.");	
			return;
		}
			
		if(true != fn_emptyCheck(reserveMemberId)){
			modalEvent.warning("등록", "닥터/상담자 정보가 없습니다.");
			return;
		}
		
		if(true != fn_emptyCheck(muMemberId)){
			modalEvent.warning("등록", "담당자 정보가 없습니다.");	
			return;
		}

		modalEvent.info("등록", "간편예약 정보를 등록하시겠습니까?", function(){
			let formData = new FormData();
			formData.append("menuClass", menuClass);
			formData.append("userName", userName);
			formData.append("phoneNumber", phoneNumber);
			formData.append("birthday", birthday);
			formData.append("reserveDate", reserveDate);
			formData.append("reserveTime", reserveTime);
			formData.append("reserveCategoryItemCode", reserveCategoryItemCode);
			formData.append("reserveCategoryItemName", reserveCategoryItemName);
			formData.append("muTreatmentProcedureId", muTreatmentProcedureId);
			formData.append("reserveMemberId", reserveMemberId);
			formData.append("etc",etc);
			formData.append("muMemberId",muMemberId);
	
			$.ajax({
				url: encodeURI('/webreserve/insertReserveSimple.do'),
				data: formData,
				dataType: "json",
				processData: false,
				contentType: false,
				type: 'POST',
				async: true,
				success: function(data){
					if('0'==data.msgCode){
						modalEvent.success("등록 성공", data.msgDesc, function(){
							if( reserveInsertModal.callback )  {
								reserveInsertModal.callback();
							}
							reserveInsertModal.close();
						});
					}
					else{
						modalEvent.danger("등록 오류", data.msgDesc);
					}
				},
				error : function(xhr, status, error) {
					modalEvent.danger("등록 오류", "등록 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
				},
				beforeSend:function(){
					
				},
				complete:function(){
					
				}
			});
		});
	},
	// tabs3 : 일괄예약등록
	saveUploadReserve:function(){
		var popExcelFile = $("#reserveInsertModal #list3 #modalReserveFile")[0].files[0];
		
		if(!popExcelFile){
			modalEvent.warning("입력 오류", "엑셀파일 정보가 없습니다. 파일을 선택하세요.");
			return;
		}
		
		modalEvent.info("일괄 등록", "예약 일괄 등록하시겠습니까?", function(){
			var formData = new FormData();
			formData.append("file", popExcelFile);
			formData.append("menuClass", menuClass);

			$.ajax({
				url: encodeURI('/webreserve/uploadReserveExcel.do'),
				data: formData,
				enctype: 'multipart/form-data',
				dataType: "json",
				processData: false,
				contentType: false,
				cache:false,
				type: 'POST',
				async: true,
				success: function(data){
					if(data.msgCode=='0'){

						modalEvent.success("일괄등록 성공", data.msgDesc, function(){
							var listHTML = '';
							var succCnt = 0;
							var okCnt   = 0;
							var errCnt  = 0;

							if(data.rows.length>0){
								for(var i = 0; i < data.rows.length; i++){
									if(data.rows[i].rowCheck=="0"||data.rows[i].rowCheck=="1"){
										listHTML +='<tr>';
									}
									else{
										listHTML +='<tr style="color:#e85872;">';
									}

									listHTML +='	<td data-col-name="num" title="" style="text-align:center;" class="">';
									listHTML +='		<div class="break">'+(data.rows[i].number)+'</div>';
									listHTML +='	</td>';

									if(data.rows[i].rowCheck=="0"){
										succCnt++;

										listHTML +='	<td data-col-name="rowCheck" title="" style="text-align:center;" class="">';
										listHTML +='		<div class="break">성공</div>';
										listHTML +='	</td>';
									}
									else if(data.rows[i].rowCheck=="1"){
										okCnt++;

										listHTML +='	<td data-col-name="rowCheck" title="" style="text-align:center;" class="">';
										listHTML +='		<div class="break">정상</div>';
										listHTML +='	</td>';
									}
									else{
										errCnt++;

										listHTML +='	<td data-col-name="rowCheck" title="" style="text-align:center;" class="">';
										listHTML +='		<div class="break">실패</div>';
										listHTML +='	</td>';
									}

									listHTML +='	<td data-col-name="rowMsgDesc" title="" style="text-align:left;" class="">';
									listHTML +='		<div class="break" style="white-space:normal;padding:0 5px;">'+fn_formatNull(data.rows[i].rowMsgDesc)+'</div>';
									listHTML +='	</td>';

									listHTML +='	<td data-col-name="reserveDate" title="" style="text-align:center;" class="">';
									listHTML +='		<div class="break">'+fn_formatNull(data.rows[i].reserveDate)+'</div>';
									listHTML +='	</td>';

									listHTML +='	<td data-col-name="reserveTime" title="" style="text-align:center;" class="">';
									listHTML +='		<div class="break">'+fn_formatNull(data.rows[i].reserveTime)+'</div>';
									listHTML +='	</td>';

									listHTML +='	<td data-col-name="reserveCategoryItemCode" title="" style="text-align:center;" class="">';
									listHTML +='		<div class="break">'+fn_formatNull(data.rows[i].reserveCategoryItemCode)+'</div>';
									listHTML +='	</td>';

									listHTML +='	<td data-col-name="userName" title="" style="text-align:center;" class="">';
									listHTML +='		<div class="break">'+fn_formatNull(data.rows[i].userName)+'</div>';
									listHTML +='	</td>';

									listHTML +='	<td data-col-name="phoneNumber" title="" style="text-align:center;" class="">';
									listHTML +='		<div class="break">'+fn_formatNull(data.rows[i].phoneNumber)+'</div>';
									listHTML +='	</td>';

									// listHTML +='	<td data-col-name="birthday" title="" style="text-align:center;" class="">';
									// listHTML +='		<div class="break">'+fn_formatNull(data.rows[i].birthday)+'</div>';
									// listHTML +='	</td>';
									//
									// listHTML +='	<td data-col-name="nationalityCategoryItemCode" title="" style="text-align:center;" class="">';
									// listHTML +='		<div class="break">'+fn_formatNull(data.rows[i].nationalityCategoryItemCode)+'</div>';
									// listHTML +='	</td>';

									listHTML +='	<td data-col-name="muTreatmentProcedureId" title="" style="text-align:center;" class="">';
									listHTML +='		<div class="break">'+fn_formatNull(data.rows[i].muTreatmentProcedureId)+'</div>';
									listHTML +='	</td>';

									listHTML +='	<td data-col-name="reserveMemberCode" title="" style="text-align:center;" class="">';
									listHTML +='		<div class="break">'+fn_formatNull(data.rows[i].reserveMemberCode)+'</div>';
									listHTML +='	</td>';

									listHTML +='	<td data-col-name="etc" title="" style="text-align:left;" class="">';
									listHTML +='		<div class="break">'+fn_formatNull(data.rows[i].etc)+'</div>';
									listHTML +='	</td>';

									listHTML +='</tr>';
								}

								$("#reserveInsertModal #list3 .list3_table_box table tbody").empty().html(listHTML).trigger("create");

							}else{
								var listHTML = '';
								listHTML += '<tr class="searchEmpty">';
								listHTML += '	<td colspan="13"></td>';
								listHTML += '</tr>';

								$("#reserveInsertModal #list3 .list3_table_box table tbody").empty().html(listHTML).trigger("create");
							}

							$("#reserveInsertModal #list3 .succCnt").text(succCnt);
							$("#reserveInsertModal #list3 .okCnt").text(okCnt);
							$("#reserveInsertModal #list3 .errCnt").text(errCnt);

							$("#reserveInsertModal #list3 #modalReserveFile").val('');
							$("#reserveInsertModal #list3 #modalReserveFile").siblings('.upload-name').val('파일을 업로드해주세요.');

							// 닫기버튼 시 새로고침
							$('#reserveInsertModal #list3 .btnCancle').off("click");
							$('#reserveInsertModal #list3 .btnCancle').on("click", function(){
								reserveInsertModal.close('R');
							});
						});
					}
					else if(data.msgCode=='-1'){
						modalEvent.warning("일괄등록 오류", data.msgDesc);
					}
					else{
						modalEvent.danger("일괄등록 오류", "일괄등록 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
					}
				},
				error : function(xhr, status, error) {
					modalEvent.danger("일괄등록 오류", "일괄등록 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
				},
				beforeSend:function(){
					// 로딩열기
					$(".loading-image-layer").show();
				},
				complete:function(){
					// 로딩닫기
					$(".loading-image-layer").hide();
				}
			});
		});
	},
	/*
	 * 팝업
	 * callback : 콜백함수, reqParam: 팝업파라미터
	 */
	popup:function(callback, reqParam) {
		// 초기화 후 열기
		reserveInsertModal.init();
		
		//콜백함수 지정.
		reserveInsertModal.callback = callback;
		reserveInsertModal.reqParam = reqParam;
		reserveInsertModal.dataList = null;
		
		// tab1 : 예약
		reserveInsertModal.addRow();
		
		// 담당자
		$('#reserveInsertModal input[name="modalMemberId"]').val(loginMemberId);
		$('#reserveInsertModal input[name="modalMemberName"]').val(loginMemberName);
		
		let muUserId = reserveInsertModal.reqParam.muUserId;
		
		if(null==muUserId||''==muUserId){
			
		}
		else{
			reserveInsertModal.searchUser();
		}

		// 예약일자와 예약시간이 있으면
		let reserveDate = reserveInsertModal.reqParam.reserveDate;
		let reserveTime = reserveInsertModal.reqParam.reserveTime;

		if(true == fn_emptyCheck(reserveDate)){
			$('#reserveInsertModal #list1').find('input[name="modalReserveDate"]').val(reserveDate);
			$('#reserveInsertModal #list2').find('input[name="modalReserveDate"]').val(reserveDate);
		}

		if(true == fn_emptyCheck(reserveTime)){
			// 예약시간 파라미터와 맞으면 클릭 이벤트
			let tempObj  = $('#reserveInsertModal #list1').find(".select_option_list.time").find("li.option_list_item");
			let tempObj2 = $('#reserveInsertModal #list2').find(".select_option_list.time").find("li.option_list_item");

			for(let i=0; i<tempObj.length; i++){
				if(reserveTime == tempObj.eq(i).text()){
					tempObj.eq(i).click();
					tempObj2.eq(i).click();

					break;
				}
			}
		}

		setTimeout(function(){
			$('#reserveInsertModal').modal({keyboard:false, backdrop:'static'});
		}, 200);
	},
	/*
	 * 팝업 닫기
	 */
	close:function(type) {
		$('#reserveInsertModal').modal('hide');
		
		if('R'==type){
			if( reserveInsertModal.callback )  {
				reserveInsertModal.callback();
			}
		}
		
		setTimeout(function(){
			$('#reserveInsertModal').remove();
		},500);
	},
	HtmlTemplate : `
	<div id="reserveInsertModal" class="modal reservation_modal fade" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<ul class="nav nav-tabs" role="tablist">
						<li role="presentation" class="active">
							<a class="active" href="#list1" aria-controls="list1" role="tab" data-toggle="tab">
								<p>예약등록</p>
							</a>
						</li>

						<li role="presentation">
							<a href="#list2" aria-controls="list2" role="tab" data-toggle="tab">
								<p>간편예약</p>
							</a>
						</li>

						<li role="presentation">
							<a href="#list3" aria-controls="list3" role="tab" data-toggle="tab">
								<p>예약일괄등록</p>
							</a>
						</li>
					</ul>
				</div>
	
				<div class="modal-body">
					<div class="tab-content">
						<div role="tabpanel" class="tab-pane active" id="list1">
							<div class="form_box">
								<div class="input_box first">
									<label>고객</label>
									<div class="search_box" data-toggle="modal" data-target=".client_inquiry" style="transition: all 0.2s ease-in-out 0s;">
										<img src="/image/web/search_B.svg" alt="search"/>
										<input type="hidden" name="modalUserId" />
										<input type="text" name="modalUserName" placeholder="검색 (고객명, 연락처, 생년월일)" readonly/>
									</div>
								</div>

								<ul class="modal_table_box">
									<li class="modal_table_title">
										<p>고객등급</p>
										<p>생년월일</p>
										<p>성별</p>
										<p>국적</p>
										<p>연락처</p>
										<p>특이사항</p>
									</li>
									<li class="modal_table_content">
										<p class="modalUserType">-</p>
										<p class="modalBirthday">-</p>
										<p class="modalGender">-</p>
										<p class="modalNationality">-</p>
										<p class="modalPhoneNumber">-</p>
										<p class="modalMemo">-</p>
									</li>
								</ul>

								<ul class="modal_table_box last reserveRowBox">
									<li class="modal_table_title">
										<p>예약일시</p>
										<p>예약경로</p>
										<p>진료유형</p>
										<p>닥터/상담</p>
										<p>예약메모</p>
									</li>
								</ul>

								<div class="button_box">
									<button class="btnReserveAdd">
										<img src="/image/web/add1.svg" alt="예약추가" alt="예약추가"/>
										예약 추가
									</button>
								</div>

								<div class="input_box">
									<label>담당자</label>
									<input type="hidden" name="modalMemberId"/>
									
									<div class="search_box member_box" style="display:none;">
										<img src="/image/web/search_B.svg" alt="search"/>
										<input type="text" name="modalMemberName" readonly style="padding-left: 40px;"/>
										<button class="cancel_btn" style="position: relative; font-size: 14px; font-weight: 700; color: rgb(57, 133, 234); padding: 0px 10px; background: none;">취소</button>
									</div>
									
									<div class="read_box">
										<input type="text" name="modalMemberName" placeholder="" disabled>
										<button class="manager_btn"><img src="/image/web/menu_6_off.svg" alt="수정하기"></button>
									</div>
								</div>
							</div>
							
							<div class="form_footer_box">
								<div class="btn_box">
									<button type="button" class="cancel_btn btnCancle">취소</button>
									<button type="button" class="registration_bth btnSave">저장</button>
								</div>
							</div>
						</div>
		
						<div role="tabpanel" class="tab-pane" id="list2">
							<div class="form_box">
								<div class="input_box first">
									<label>예약자정보</label>
									<input type="text" name="modalUserName" placeholder="고객명">
									<input type="text" name="modalPhoneNumber" onchange="this.value = fn_setFormatPhone(this.value)" placeholder="'-' 제외한 연락처">
								</div>
								
								<div class="input_box first">
									<label>생년월일</label>
									<input type="text" name="modalBirthday" placeholder="연도-월-일"/>
									<img class="userBirthday" src="/image/web/calendar.svg" alt="calendar">
									<p class="identity txtAge"></p>
								</div>
								
								<div class="box_box">
									<label>예약일시</label>
									<div class="calendar_box">
										<div class="date_box">
											<img src="/image/web/calendar.svg" alt="calendar"/>
											<input type="date" class="date_picker" name="modalReserveDate">
										</div>
									</div>
									<div class="select_box dropdown">
										<button class="label" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">00:00</button>
										<input type="hidden" name="modalReserveTime"/>
										
										<ul class="select_option_list dropdown-menu time"></ul>
									</div>
								</div>
								
								<div class="input_box">
									<label>예약경로</label>
									<div class="select_box dropdown">
										<button class="label" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">예약경로</button>
										<input type="hidden" name="modalReserveCategoryItemCode">
										
										<ul class="select_option_list dropdown-menu"></ul>
									</div>
								</div>
								
								<div class="input_box">
									<label>진료유형</label>
									<div class="search_box">
										<img src="/image/web/search_B.svg" alt="search"/>
										<input type="hidden" name="modalTreatmentProcedureId" />
										<input type="text" name="modalTreatmentProcedureName" readonly />
									</div>
								</div>
								
								<div class="input_box">
									<label>닥터/상담</label>
									<div class="select_box dropdown">
										<button class="label" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">닥터/상담</button>
										<input type="hidden" name="modalReserveMemberId">
										
										<ul class="select_option_list dropdown-menu"></ul>
									</div>
								</div>
								
								<div class="textarea_box">
									<label>예약메모</label>
									<textarea name="modalEtc" placeholder="메모를 입력해주세요."></textarea>
								</div>
								
								<div class="input_box">
									<label>담당자</label>
									<input type="hidden" name="modalMemberId"/>
									
									<div class="search_box member_box" style="display:none;">
										<img src="/image/web/search_B.svg" alt="search"/>
										<input type="text" name="modalMemberName" readonly style="padding-left: 40px;"/>
										<button class="cancel_btn" style="position: relative; font-size: 14px; font-weight: 700; color: rgb(57, 133, 234); padding: 0px 10px; background: none;">취소</button>
									</div>
									
									<div class="read_box">
										<input type="text" name="modalMemberName" placeholder="" disabled>
										<button class="manager_btn"><img src="/image/web/menu_6_off.svg" alt="수정하기"></button>
									</div>
								</div>
							</div>
							
							<div class="form_footer_box">
								<div class="btn_box">
									<button type="button" class="cancel_btn btnCancle">취소</button>
									<button type="button" class="registration_bth btnSave">저장</button>
								</div>
							</div>
						</div>
		
						<div role="tabpanel" class="tab-pane" id="list3">
							<div class="form_box">
								<div class="file_box">
									<label>예약</label>
									<input class="upload-name" placeholder="파일을 업로드해주세요.">
									<label for="modalReserveFile" class="file_btn"><img src="/image/web/add.svg" alt="파일찾기"></label> 
									<input type="file" id="modalReserveFile"  accept=".xlsx" class="file-upload" onChange="javascript:reserveInsertModal.setFileName(this);">
									<button class="btnDownloadReserveExcelSample">양식다운로드</button>
									<button class="btnDownloadReserveColumnExcel">항목참고다운로드</button>
								</div>
								<div class="total_box">
									<label>등록된 예약수</label>
									<ul class="total">
										<li>등록 <span class="succCnt">00</span>개</li>
									</ul>
									
									
									<label style="margin-left: 50px;">미등록 예약수</label>
									<ul class="total">
										<li>정상 <span class="okCnt">00</span>개</li>
										<li class="error">오류 <span class="errCnt">00</span>개</li>
									</ul>
								</div>
								<div class="list3_table_box">
									<label>등록내역</label>

									<div class="table_scroll_box">
										<table>
											<thead>
												<tr>
													<th>번호</th>
													<th>등록여부</th>
													<th>실패사유</th>
													<th>예약일자</th>
													<th>예약시간</th>
													<th>예약경로 코드</th>
													<th>고객명</th>
													<th>연락처</th>
													<th>진료유형(시술)식별자</th>
													<th>닥터/상담 사번 코드</th>
													<th>예약메모</th>
												</tr>
											</thead>
											<tbody>
												<tr>
													<td></td>
													<td></td>
												</tr>
											</tbody>
										</table>
									</div>
								</div>
							</div>
							
							<div class="form_footer_box">
								<div class="btn_box">
									<button type="button" class="cancel_btn btnCancle">취소</button>
									<button type="button" class="registration_bth btnSave">저장</button>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
    `
};

function convertExcelDate(excelDate) {
	if (!excelDate || isNaN(excelDate)) {
		return excelDate;
	}
	const date = new Date((excelDate - 25569) * 86400 * 1000);
	const year = date.getFullYear();
	const month = ('0' + (date.getMonth() + 1)).slice(-2);
	const day = ('0' + date.getDate()).slice(-2);
	return `${year}-${month}-${day}`;
}
