From 740115ee532cf40f2183e135ccee15b5038206b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Wed, 3 Oct 2018 21:45:17 +0900 Subject: [PATCH] Add: show availableActivateDateTime of maestro --- src/web/js/lib/maestro_info.js | 2 ++ src/web/module/maestro_section_main.html | 24 +++++++++++++++++++++--- src/web/server/maestro/maestro_info.php | 6 ++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/web/js/lib/maestro_info.js b/src/web/js/lib/maestro_info.js index c85a8c8..0fe9905 100644 --- a/src/web/js/lib/maestro_info.js +++ b/src/web/js/lib/maestro_info.js @@ -2,6 +2,7 @@ function MaestroInfo() { this.maestroID = sessionStorage.getItem("maestroID"); this.maestroName = ""; this.accountType = 0; + this.availableActivateDateTime = ""; this.playerCount = 0; } @@ -15,6 +16,7 @@ MaestroInfo.prototype.loadMaestroInfo = function(onSuccess, onFail) { function(jsonData) { self.maestroName = jsonData["name"]; self.accountType = jsonData["accountType"]; + self.availableActivateDateTime = jsonData["availableActivateDateTime"]; self.playerCount = jsonData["playerCount"]; onSuccess(); diff --git a/src/web/module/maestro_section_main.html b/src/web/module/maestro_section_main.html index 3ae89a3..fadee13 100644 --- a/src/web/module/maestro_section_main.html +++ b/src/web/module/maestro_section_main.html @@ -22,9 +22,26 @@ function isExperienceMaestroAccount() { return false; } +function showEndDate(date) { + var endDateArray = date.split(" "); + var endDate = endDateArray[0]; // "YY-MM_DD" + + var today = new Date(); + var endDay = new Date(endDate); + var diffDay = (endDay.getTime() - today.getTime()) / (1000 * 60 * 60 * 24); + + $("#maestro_count_down_date").html("~ " + endDate + "
유효 기간 : " + Math.ceil(diffDay) + "일"); + if(diffDay < 30) + $("#maestro_count_down_date").addClass("text-danger"); + else if(diffDay < 10) + $("#maestro_count_down_date").addClass("bg-danger text-light"); + else if(diffDay < 0) + $("#maestro_count_down_date").addClass("bg-secondary text-light"); +} function onLoadSuccessMaestroInfo() { - $("#maestro_info_id").text(maestroInfo.maestroName + "님, 환영합니다."); + $("#maestro_info_id").text("[ " + maestroInfo.maestroName + " ] 님, 환영합니다."); + showEndDate(maestroInfo.availableActivateDateTime); $("#maestro_info_player_count").val("학생수 : " + maestroInfo.getRegisteredPlayerCount() + " / " + maestroInfo.getMaxPlayerCount()); if(maestroInfo.getRegisteredPlayerCount() === maestroInfo.getMaxPlayerCount()) { @@ -120,8 +137,9 @@ function deactivateApp(appID) {
-
-
+
+ +
diff --git a/src/web/server/maestro/maestro_info.php b/src/web/server/maestro/maestro_info.php index e297dbc..e8ba1f7 100644 --- a/src/web/server/maestro/maestro_info.php +++ b/src/web/server/maestro/maestro_info.php @@ -18,6 +18,7 @@ $playerCount = getPlayerCount($maestroID); set_data("name", $info["name"]); set_data("email", $info["email"]); set_data("accountType", $info["accountType"]); +set_data("availableActivateDateTime", $info["availableActivateDateTime"]); set_data("playerCount", $playerCount); send_result_success(); exit; @@ -27,14 +28,14 @@ function get_maestro_info($maestroID) { global $db_conn; $query = " - SELECT Name, Email, AccountType, PlayerCount + SELECT Name, Email, AccountType, AvailableActivateDateTime, PlayerCount FROM maestro WHERE MaestroID = ? "; $stmt = $db_conn->prepare($query); $stmt->bind_param("s", $maestroID); $stmt->execute(); - $stmt->bind_result($name, $email, $accountType, $playerCount); + $stmt->bind_result($name, $email, $accountType, $availableActivateDateTime, $playerCount); // while($stmt->fetch()) $stmt->fetch(); $stmt->close(); @@ -42,6 +43,7 @@ function get_maestro_info($maestroID) { $info["name"] = $name; $info["email"] = $email; $info["accountType"] = $accountType; + $info["availableActivateDateTime"] = $availableActivateDateTime; $info["playerCount"] = $playerCount; return $info;