function MaestroAvailableDate() { this.today = new Date(); this.endDate = null; this.endDay = null; } MaestroAvailableDate.prototype.setEndDate = function(endDate) { this.endDate = endDate; this.endDay = new Date(this.endDate); } MaestroAvailableDate.prototype.setEndDateTime = function(endDateTime) { var endDateArray = endDateTime.split(" "); this.setEndDate(endDateArray[0]); // "YY-MM_DD" } MaestroAvailableDate.prototype.getDiffDay = function() { var diffDay = (this.endDay.getTime() - this.today.getTime()) / (1000 * 60 * 60 * 24); return Math.ceil(diffDay); } MaestroAvailableDate.prototype.isExpiredMaestro = function() { if(this.getDiffDay() < 0) return true; return false; } MaestroAvailableDate.prototype.getAvailableDate = function() { return this.endDate; } MaestroAvailableDate.prototype.getNewAvailableDate = function() { var diffDay = this.getDiffDay(); var newDate = null; if(diffDay < 0) // end date is over newDate = new Date(new Date().setFullYear(this.today.getFullYear() + 1)); else newDate = new Date(new Date(this.endDate).setFullYear(this.endDay.getFullYear() + 1)); // console.log("# newDate : " + newDate); var year2Digits = newDate.getFullYear(); var month2Digits = ("0"+(newDate.getMonth()+1)).slice(-2); var day2Digits = ("0" + newDate.getDate()).slice(-2); return year2Digits+ "-" + month2Digits + "-" + day2Digits; } MaestroAvailableDate.prototype.showMaestroExtensionMessage = function(maestroName) { var diffDay = this.getDiffDay(); if(diffDay > 30) return; $("#maestro_extension").removeClass("d-none"); var message = ""; if(diffDay > 0) message = "" + maestroName + " 계정의 유효기간이 얼마 남지 않았습니다.
1년 더 사용하기를 원하신다면 우측의 [유효기간 연장] 버튼을 눌러주세요."; else message = "" + maestroName + " 계정의 유효기간이 지났습니다. 등록된 학생들의 정보는 유지되지만, 로그인이 제한됩니다.
유효기간 연장을 하시면 다시 로그인하고 사용할 수 있게 됩니다."; $("#maestro_extension_message").html(message); } MaestroAvailableDate.prototype.showEndDate = function() { var diffDay = this.getDiffDay(); var newAvailableDate = this.getNewAvailableDate(diffDay); $("#end_day").html(this.endDate); if(diffDay < 0) { $("#maestro_count_down_date").html("유효기간 : ~ " + this.endDate + " (" + Math.abs(diffDay) + "일 경과) "); $("#countdown_day").addClass("bg-danger font-weight-bold text-light"); } else { $("#maestro_count_down_date").html("유효기간 : ~ " + this.endDate + " (남은 기간 : " + diffDay + "일)"); if(diffDay < 10) $("#countdown_day").addClass("bg-danger text-light"); else if(diffDay < 30) $("#countdown_day").addClass("text-danger"); else $("#countdown_day").addClass("text-primary"); } }