<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
body { font-family: "맑은 고딕", sans-serif; margin: 20px; }
h2, h3 { text-align: center; margin-bottom: 20px; }
.greeting-box { border: 1px solid #ccc; border-radius: 8px; padding: 15px; background-color: #f9f9f9; margin-bottom: 20px; line-height: 1.6; }
table { border-collapse: collapse; width: 100%; max-width: 800px; margin: 0 auto 30px auto; text-align: center; }
table, th, td { border: 1px solid #999; }
th, td { padding: 10px; }
th { background-color: #f0f0f0; }
.form-section { max-width: 600px; margin: 0 auto; }
.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 5px; font-weight: bold; }
input[type="text"], select, textarea { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; }
textarea { height: 80px; resize: vertical; }
.radio-group { display: flex; gap: 20px; }
.submit-btn { display: inline-block; background-color: #4CAF50; color: white; padding: 10px 20px; font-size: 16px; border: none; border-radius: 6px; cursor: pointer; transition: background-color 0.3s ease; }
.submit-btn:hover { background-color: #45a049; }
</style>
<script>
function submitForm() {
const name = document.getElementById("studentName").value.trim();
const date = document.getElementById("dateSelect").value;
const time = document.querySelector("input[name='time']:checked")?.value || "";
const note = document.getElementById("note").value.trim();
if (!name || !date || !time) {
alert("학생 이름, 날짜, 시간을 모두 입력해주세요.");
return;
}
google.script.run
.withSuccessHandler(function(response) {
const btn = document.getElementById("submitBtn");
if (response === "success") {
btn.innerText = "전송 완료";
btn.disabled = true;
btn.style.backgroundColor = "#999";
alert("상담 예약이 완료되었습니다.");
loadReservationData(); // 저장 후 표 갱신
} else if (response === "duplicate") {
alert("이미 예약이 존재합니다. 다른 날짜 또는 시간을 택해주세요.");
} else {
alert("예약 중 오류가 발생했습니다. 다시 시도해주세요.");
}
})
.saveReservation(name, date, time, note);
}
// 서버에서 시트 데이터 읽어와 표에 표시
function loadReservationData() {
google.script.run.withSuccessHandler(function(data) {
const times = ["19:00-20:00","20:00-21:00"];
const dates = ["9.15.(월)","9.16.(화)","9.17.(수)","9.18.(목)","9.19.(금)"];
times.forEach((time, rowIdx) => {
dates.forEach((date, colIdx) => {
const cell = document.querySelectorAll("table tr")[rowIdx + 2].cells[colIdx + 1];
cell.textContent = data[time][date] || "";
});
});
}).getReservationData();
}
window.onload = function() {
loadReservationData(); // 페이지 로드 시 예약 현황 표시
};
</script>
</head>
<body>
<h2>아이좋아고등학교 3학년 1반 학부모 상담 예약</h2>
<div class="greeting-box">
안녕하십니까. 3학년 1반 학부모님. 학기초 상담주간을 맞이하여 학부모 상담을 실시하고자 합니다.
바쁘시겠지만 시간을 내시어, 자녀의 학교 생활 및 교우 관계, 진로진학과 관련하여 알찬 시간이 될 수 있도록 많은 참석 부탁드립니다.
원하는 날짜와 시간을 선택하셔서 상담 예약을 부탁드립니다.
</div>
<table>
<tr>
<td></td>
<td>월</td>
<td>화</td>
<td>수</td>
<td>목</td>
<td>금</td>
</tr>
<tr>
<td></td>
<td>9.15.</td>
<td>9.16.</td>
<td>9.17.</td>
<td>9.18.</td>
<td>9.19.</td>
</tr>
<tr>
<td>19:00-20:00</td>
<td></td><td></td><td></td><td></td><td></td>
</tr>
<tr>
<td>20:00-21:00</td>
<td></td><td></td><td></td><td></td><td></td>
</tr>
</table>
<h3>상담 신청</h3>
<div class="form-section">
<div class="form-group">
<label>1. 학생의 이름을 적어주세요</label>
<input type="text" id="studentName" placeholder="예: 홍길동">
</div>
<div class="form-group">
<label>2. 원하시는 날짜를 택해주세요</label>
<select id="dateSelect">
<option value="">-- 선택하세요 --</option>
<option value="9.15.(월)">9.15.(월)</option>
<option value="9.16.(화)">9.16.(화)</option>
<option value="9.17.(수)">9.17.(수)</option>
<option value="9.18.(목)">9.18.(목)</option>
<option value="9.19.(금)">9.19.(금)</option>
</select>
</div>
<div class="form-group">
<label>3. 원하시는 시간을 택해주세요</label>
<div class="radio-group">
<label><input type="radio" name="time" value="19:00-20:00"> 19:00-20:00</label>
<label><input type="radio" name="time" value="20:00-21:00"> 20:00-21:00</label>
</div>
</div>
<div class="form-group">
<label>4. 참고사항이 있다면 적어주세요.</label>
<textarea id="note" placeholder="예: 아이의 성향, 특별히 상담하고 싶은 내용 등"></textarea>
</div>
<button id="submitBtn" class="submit-btn" onclick="submitForm()">전송</button>
</div>
</body>
</html>
댓글 남기기