진료시간변경

This commit is contained in:
pjs
2025-12-22 22:48:48 +09:00
parent 7f4aa950be
commit 84f062c681
2 changed files with 907 additions and 949 deletions

File diff suppressed because it is too large Load Diff

View File

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