진료시간변경
This commit is contained in:
@@ -99,28 +99,32 @@
|
||||
|
||||
<th:block layout:fragment="layoutContentScript">
|
||||
<script>
|
||||
// 비활성화할 특정 날짜들 (YYYY-MM-DD 형식) - 필요에 따라 수정하세요
|
||||
// 휴일(완전 휴무) 설정
|
||||
const disabledSpecificDates = [
|
||||
'2025-10-03', // 개천절
|
||||
'2025-10-04', // 추석연휴
|
||||
'2025-10-06', // 추석
|
||||
'2025-10-07', // 추석연휴
|
||||
'2025-10-08', // 추석 대체휴일
|
||||
'2025-10-09', // 한글날
|
||||
'2026-01-01', // 신정
|
||||
'2025-12-18', // 신정
|
||||
'2025-12-19', // 신정
|
||||
'2025-12-20', // 신정
|
||||
// 필요에 따라 날짜 추가
|
||||
'2025-12-25', // 크리스마스
|
||||
'2026-01-01', // 신정
|
||||
// 필요 시 추가
|
||||
];
|
||||
|
||||
// 날짜가 비활성화 목록에 있는지 확인하는 함수
|
||||
// 단축 진료일 (15:30까지) 설정
|
||||
const shortWorkingDates = [
|
||||
'2025-12-24', // 크리스마스 이브
|
||||
'2025-12-31' // 연말
|
||||
];
|
||||
|
||||
// 날짜가 휴무일인지 확인
|
||||
function isDateDisabled(date) {
|
||||
const dateStr = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
||||
return disabledSpecificDates.includes(dateStr);
|
||||
}
|
||||
|
||||
// 생년월일 검증 클래스
|
||||
// 단축 근무일인지 확인
|
||||
function isShortWorkingDate(date) {
|
||||
const dateStr = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
||||
return shortWorkingDates.includes(dateStr);
|
||||
}
|
||||
|
||||
// 생년월일 검증 클래스 (기존 그대로 유지)
|
||||
class BirthDateValidator {
|
||||
constructor(inputId, options = {}) {
|
||||
this.inputElement = document.getElementById(inputId);
|
||||
@@ -294,11 +298,12 @@
|
||||
|
||||
// 전역 변수
|
||||
let birthDateValidator;
|
||||
let selectedTreatments = [];
|
||||
|
||||
// 초기화
|
||||
fn_SelectReservation(category_div_cd, category_no, post_no, procedure_id);
|
||||
|
||||
// 개선된 시술 삭제 함수
|
||||
// 시술 삭제 함수
|
||||
function removeService(el) {
|
||||
const serviceItems = document.querySelectorAll('.service-item');
|
||||
const serviceCount = serviceItems.length;
|
||||
@@ -329,7 +334,6 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
// 총 금액 업데이트 함수
|
||||
function updateTotalPrice() {
|
||||
const serviceItems = document.querySelectorAll('.service-item');
|
||||
let totalPrice = 0;
|
||||
@@ -343,7 +347,6 @@
|
||||
document.getElementById('total-price').textContent = totalPrice.toLocaleString() + '원';
|
||||
}
|
||||
|
||||
// 시술 개수 및 삭제 버튼 상태 업데이트 함수
|
||||
function updateServiceCount() {
|
||||
const serviceItems = document.querySelectorAll('.service-item');
|
||||
const serviceCount = serviceItems.length;
|
||||
@@ -398,7 +401,6 @@
|
||||
});
|
||||
agree.addEventListener('change', checkForm);
|
||||
|
||||
// 개선된 checkForm 함수
|
||||
function checkForm() {
|
||||
const name = document.getElementById('customer-name').value.trim();
|
||||
|
||||
@@ -498,87 +500,101 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 캘린더 렌더링 - 수요일 및 특정 날짜 비활성화
|
||||
function renderCalendar(year, month) {
|
||||
calendarTitle.textContent = `${year}.${(month+1).toString().padStart(2,'0')}`;
|
||||
const firstDay = new Date(year, month, 1);
|
||||
const lastDay = new Date(year, month+1, 0);
|
||||
const now = new Date();
|
||||
const todayDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
// 새로운 진료시간 설정
|
||||
const diettimes_mon_wed_fri = [
|
||||
"10:00","10:30","11:00","11:30","12:00","12:30",
|
||||
"13:00","13:30","14:00","14:30","15:00","15:30",
|
||||
"16:00","16:30","17:00","17:30","18:00","18:30"
|
||||
];
|
||||
|
||||
let html = '<thead><tr>';
|
||||
['일','월','화','수','목','금','토'].forEach(d => html += `<th>${d}</th>`);
|
||||
html += '</tr></thead><tbody><tr>';
|
||||
const diettimes_tue_thu = [
|
||||
"10:00","10:30","11:00","11:30","12:00","12:30",
|
||||
"13:00","13:30","14:00","14:30","15:00","15:30",
|
||||
"16:00","16:30","17:00","17:30","18:00","18:30",
|
||||
"19:00","19:30"
|
||||
];
|
||||
|
||||
for(let i = 0; i < firstDay.getDay(); i++) {
|
||||
html += '<td class="disabled"></td>';
|
||||
}
|
||||
const diettimes_sat_short = [
|
||||
"10:00","10:30","11:00","11:30","12:00","12:30",
|
||||
"13:00","13:30","14:00","14:30","15:00","15:30"
|
||||
];
|
||||
|
||||
for(let d = 1; d <= lastDay.getDate(); d++) {
|
||||
const dateObj = new Date(year, month, d);
|
||||
let classes = [];
|
||||
// 캘린더 렌더링 (일요일만 휴무)
|
||||
function renderCalendar(year, month) {
|
||||
calendarTitle.textContent = `${year}.${(month+1).toString().padStart(2,'0')}`;
|
||||
const firstDay = new Date(year, month, 1);
|
||||
const lastDay = new Date(year, month+1, 0);
|
||||
const now = new Date();
|
||||
const todayDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
|
||||
const isPastDate = dateObj < todayDate;
|
||||
const isWednesday = dateObj.getDay() === 3;
|
||||
const isSpecificDisabled = isDateDisabled(dateObj); // 특정 날짜 체크
|
||||
let html = '<thead><tr>';
|
||||
['일','월','화','수','목','금','토'].forEach(d => html += `<th>${d}</th>`);
|
||||
html += '</tr></thead><tbody><tr>';
|
||||
|
||||
if(dateObj.toDateString() === today.toDateString()) classes.push('today');
|
||||
if(selectedDate && dateObj.toDateString() === selectedDate.toDateString()) classes.push('selected');
|
||||
|
||||
// 과거 날짜, 일요일, 수요일, 특정 비활성화 날짜 모두 체크
|
||||
if(isPastDate || dateObj.getDay() === 0 || isWednesday || isSpecificDisabled) {
|
||||
classes.push('disabled');
|
||||
}
|
||||
for(let i = 0; i < firstDay.getDay(); i++) {
|
||||
html += '<td class="disabled"></td>';
|
||||
}
|
||||
|
||||
const clickHandler = (isPastDate || dateObj.getDay() === 0 || isWednesday || isSpecificDisabled) ?
|
||||
'' : `onclick="selectDate(${year},${month},${d})"`;
|
||||
html += `<td class="${classes.join(' ')}" ${clickHandler}>${d}</td>`;
|
||||
for(let d = 1; d <= lastDay.getDate(); d++) {
|
||||
const dateObj = new Date(year, month, d);
|
||||
let classes = [];
|
||||
|
||||
if((firstDay.getDay()+d) % 7 === 0 && d !== lastDay.getDate()) html += '</tr><tr>';
|
||||
}
|
||||
const isPastDate = dateObj < todayDate;
|
||||
const isSunday = dateObj.getDay() === 0;
|
||||
const isHoliday = isDateDisabled(dateObj);
|
||||
|
||||
for(let i = (lastDay.getDay()+1) % 7; i && i < 7; i++) {
|
||||
html += '<td class="disabled"></td>';
|
||||
}
|
||||
html += '</tr></tbody>';
|
||||
calendarTable.innerHTML = html;
|
||||
checkForm();
|
||||
}
|
||||
if(dateObj.toDateString() === today.toDateString()) classes.push('today');
|
||||
if(selectedDate && dateObj.toDateString() === selectedDate.toDateString()) classes.push('selected');
|
||||
|
||||
// ✅ 수요일 완전 제거! 일요일 + 공휴일만 비활성화
|
||||
if(isPastDate || isSunday || isHoliday) {
|
||||
classes.push('disabled');
|
||||
}
|
||||
|
||||
// 날짜 선택 - 수요일 및 특정 날짜 체크 추가
|
||||
function selectDate(y, m, d) {
|
||||
const tempDate = new Date(y, m, d);
|
||||
const now = new Date();
|
||||
const todayDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
const clickHandler = (isPastDate || isSunday || isHoliday) ?
|
||||
'' : `onclick="selectDate(${year},${month},${d})"`;
|
||||
html += `<td class="${classes.join(' ')}" ${clickHandler}>${d}</td>`;
|
||||
|
||||
if (tempDate < todayDate) {
|
||||
alert('과거 날짜는 선택할 수 없습니다.');
|
||||
return;
|
||||
}
|
||||
if((firstDay.getDay()+d) % 7 === 0 && d !== lastDay.getDate()) html += '</tr><tr>';
|
||||
}
|
||||
|
||||
if (tempDate.getDay() === 0) {
|
||||
alert('일요일은 선택할 수 없습니다.');
|
||||
return;
|
||||
}
|
||||
for(let i = (lastDay.getDay()+1) % 7; i && i < 7; i++) {
|
||||
html += '<td class="disabled"></td>';
|
||||
}
|
||||
html += '</tr></tbody>';
|
||||
calendarTable.innerHTML = html;
|
||||
checkForm();
|
||||
}
|
||||
|
||||
if (tempDate.getDay() === 3) {
|
||||
alert('수요일은 휴원일 입니다.');
|
||||
return;
|
||||
}
|
||||
function selectDate(y, m, d) {
|
||||
const tempDate = new Date(y, m, d);
|
||||
const now = new Date();
|
||||
const todayDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
|
||||
// 특정 비활성화 날짜 체크 추가
|
||||
if (isDateDisabled(tempDate)) {
|
||||
alert('해당 날짜는 예약할 수 없습니다.');
|
||||
return;
|
||||
}
|
||||
if (tempDate < todayDate) {
|
||||
alert('과거 날짜는 선택할 수 없습니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
selectedDate = tempDate;
|
||||
renderCalendar(y, m);
|
||||
renderTimeSlots();
|
||||
checkForm();
|
||||
}
|
||||
if (tempDate.getDay() === 0) {
|
||||
alert('일요일은 휴무일입니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
// 월 이동 버튼 이벤트
|
||||
if (isDateDisabled(tempDate)) {
|
||||
alert('해당 날짜는 휴무일입니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
// ✅ 수요일 체크 완전 제거!
|
||||
selectedDate = tempDate;
|
||||
renderCalendar(y, m);
|
||||
renderTimeSlots();
|
||||
checkForm();
|
||||
}
|
||||
|
||||
|
||||
// 월 이동 버튼
|
||||
document.getElementById('prev-month').onclick = function() {
|
||||
if(selectedMonth === 0) {
|
||||
selectedYear--;
|
||||
@@ -602,46 +618,29 @@
|
||||
renderTimeSlots();
|
||||
checkForm();
|
||||
};
|
||||
|
||||
// 시간대 정의
|
||||
const diettimes_mon_fri = [
|
||||
"10:00","10:30", "11:00","11:30", "12:00","12:30",
|
||||
"13:00","13:30", "15:00","15:30", "16:00","16:30", "17:00","17:30",
|
||||
"18:00","18:30"
|
||||
];
|
||||
|
||||
const diettimes_tue_ths = [
|
||||
"10:00","10:30", "11:00","11:30", "12:00","12:30",
|
||||
"13:00","13:30", "15:00","15:30", "16:00","16:30", "17:00","17:30",
|
||||
"18:00","18:30", "19:00","19:30"
|
||||
];
|
||||
|
||||
const diettimes_wes_sat = [
|
||||
"10:00","10:30", "11:00","11:30", "12:00","12:30",
|
||||
"13:00","13:30", "14:00","14:30", "15:00","15:30"
|
||||
];
|
||||
|
||||
// 시간 슬롯 렌더링 - 수요일 및 특정 날짜 처리
|
||||
// 시간 슬롯 렌더링 (새로운 진료시간 적용)
|
||||
function renderTimeSlots() {
|
||||
let html = '';
|
||||
let dayOfWeek = selectedDate ? selectedDate.getDay() : null;
|
||||
let slotArr = [];
|
||||
|
||||
// 일요일, 수요일, 특정 비활성화 날짜는 시간 슬롯을 표시하지 않음
|
||||
if (dayOfWeek === 0 || dayOfWeek === 3 || (selectedDate && isDateDisabled(selectedDate))) {
|
||||
if (!selectedDate || dayOfWeek === 0 || isDateDisabled(selectedDate)) {
|
||||
timeSlots.innerHTML = '';
|
||||
personCount.textContent = selectedDate ? 1 : '-';
|
||||
return;
|
||||
}
|
||||
|
||||
if (dayOfWeek !== null) {
|
||||
if (dayOfWeek === 1 || dayOfWeek === 5) { // 월(1), 금(5)
|
||||
slotArr = diettimes_mon_fri;
|
||||
} else if (dayOfWeek === 2 || dayOfWeek === 4) { // 화(2), 목(4)
|
||||
slotArr = diettimes_tue_ths;
|
||||
} else if (dayOfWeek === 6) { // 토(6)
|
||||
slotArr = diettimes_wes_sat;
|
||||
}
|
||||
// 요일별 / 특수일별 시간대 설정
|
||||
if (isShortWorkingDate(selectedDate)) {
|
||||
// 12/24, 12/31 단축 근무: 10:00~15:30
|
||||
slotArr = diettimes_sat_short;
|
||||
} else if ([1,3,5].includes(dayOfWeek)) { // 월(1), 수(3), 금(5)
|
||||
slotArr = diettimes_mon_wed_fri; // 10:00~18:30
|
||||
} else if ([2,4].includes(dayOfWeek)) { // 화(2), 목(4)
|
||||
slotArr = diettimes_tue_thu; // 10:00~19:30
|
||||
} else if (dayOfWeek === 6) { // 토(6)
|
||||
slotArr = diettimes_sat_short; // 10:00~15:30
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
@@ -673,7 +672,6 @@
|
||||
personCount.textContent = selectedDate ? 1 : '-';
|
||||
}
|
||||
|
||||
// 시간 선택 시 selectedTime 설정 및 onClickTime 호출
|
||||
function selectTimeAndCall(t, el) {
|
||||
const now = new Date();
|
||||
const todayDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
@@ -700,7 +698,6 @@
|
||||
checkForm();
|
||||
}
|
||||
|
||||
// 선택된 날짜를 yyyymmdd 문자열로 반환
|
||||
function getSelectedDateStr() {
|
||||
if (!selectedDate) return '';
|
||||
const yyyy = selectedDate.getFullYear();
|
||||
@@ -714,10 +711,9 @@
|
||||
renderTimeSlots();
|
||||
}
|
||||
|
||||
// 날짜 선택 초기화 - 일요일, 수요일, 특정 비활성화 날짜 제외
|
||||
// 초기 날짜 설정 (일요일/공휴일 제외)
|
||||
let initDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
||||
// 일요일(0), 수요일(3), 특정 비활성화 날짜이면 다음 날로 이동
|
||||
while (initDate.getDay() === 0 || initDate.getDay() === 3 || isDateDisabled(initDate)) {
|
||||
while (initDate.getDay() === 0 || isDateDisabled(initDate)) {
|
||||
initDate.setDate(initDate.getDate() + 1);
|
||||
}
|
||||
selectDate(initDate.getFullYear(), initDate.getMonth(), initDate.getDate());
|
||||
@@ -738,8 +734,6 @@
|
||||
checkForm();
|
||||
};
|
||||
|
||||
let selectedTreatments = [];
|
||||
|
||||
function fn_reservation(){
|
||||
let formData = new FormData();
|
||||
if (selectedDate) {
|
||||
@@ -827,7 +821,7 @@
|
||||
li.innerHTML = `
|
||||
<span>${item.TREATMENT_PROCEDURE_NAME}</span>
|
||||
<span>
|
||||
<span style="text-decoration:line-through; color:#bbb; font-size:0.95em; margin-right:6px;">${item.DISCOUNT_PRICE != null ? (item.PRICE || 0).toLocaleString() : ''}</span>
|
||||
<span style="text-decoration:line-through; color:#bbb; font-size:0.95em; margin-right:6px;">${item.DISCOUNT_PRICE != null ? (item.PRICE || 0).toLocaleString() : ''}원</span>
|
||||
<span class="price">${Number(price).toLocaleString()}원</span>
|
||||
<span class="del" title="삭제" onclick="removeService(this)">×</span>
|
||||
</span>
|
||||
@@ -840,12 +834,6 @@
|
||||
} else {
|
||||
modalEvent.danger("조회 오류", data.msgDesc);
|
||||
}
|
||||
|
||||
var date = new Date();
|
||||
if(String(new Date()).split(" ") == "Sun") {
|
||||
date = new Date();
|
||||
date.setDate(date.getDate() + 1);
|
||||
}
|
||||
},
|
||||
error : function(xhr, status, error) {
|
||||
modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
|
||||
@@ -864,10 +852,10 @@
|
||||
if (el) el.classList.add('active');
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append('SELECTED_DATE', selectedDate.toString().substr(0, 4) + '-' + selectedDate.toString().substr(4, 2) + '-' + selectedDate.toString().substr(6, 2));
|
||||
formData.append('SELECTED_DATE', selectedDate);
|
||||
formData.append('TIME', time);
|
||||
|
||||
res_date = selectedDate.toString().substr(0, 4) + '-' + selectedDate.toString().substr(4, 2) + '-' + selectedDate.toString().substr(6, 2);
|
||||
res_date = selectedDate;
|
||||
res_time = time;
|
||||
|
||||
$.ajax({
|
||||
@@ -905,7 +893,6 @@
|
||||
// PhoneValidator 초기화
|
||||
try {
|
||||
if (typeof PhoneValidator !== 'undefined' && PhoneValidator.init) {
|
||||
console.log('Initializing PhoneValidator from common.js');
|
||||
PhoneValidator.init('customer-phone', {
|
||||
showMessage: true,
|
||||
realTimeValidation: true,
|
||||
@@ -915,8 +902,6 @@
|
||||
setTimeout(checkForm, 10);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn('PhoneValidator not found in common.js');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('PhoneValidator initialization error:', e);
|
||||
@@ -924,7 +909,6 @@
|
||||
|
||||
// BirthDateValidator 초기화
|
||||
try {
|
||||
console.log('Initializing BirthDateValidator');
|
||||
birthDateValidator = new BirthDateValidator('birthDate', {
|
||||
showMessage: true,
|
||||
realTimeValidation: true,
|
||||
@@ -936,16 +920,11 @@
|
||||
setTimeout(checkForm, 10);
|
||||
}
|
||||
});
|
||||
console.log('BirthDateValidator initialized successfully');
|
||||
} catch (e) {
|
||||
console.error('BirthDateValidator initialization error:', e);
|
||||
}
|
||||
|
||||
$('#customer-phone').on('input keyup blur paste', function() {
|
||||
setTimeout(checkForm, 50);
|
||||
});
|
||||
|
||||
$('#birthDate').on('input keyup blur paste', function() {
|
||||
$('#customer-phone, #birthDate').on('input keyup blur paste', function() {
|
||||
setTimeout(checkForm, 50);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user