From 732c08530919dd8267f8bce7b5d1a52774c44b5c 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: Thu, 19 Jul 2018 18:27:11 +0900 Subject: [PATCH] Add: maestro_info --- src/web/js/lib/maestro_info.js | 47 +++++++++++++++++++ src/web/js/player_list_manager.js | 9 +++- src/web/maestro/main_menu.html | 1 + .../module/maestro_section_add_player.html | 30 +++++++----- src/web/module/maestro_section_main.html | 30 ++++++++++++ src/web/server/lib/maestro_account_type.php | 16 +++++++ src/web/server/maestro/maestro_info.php | 47 +++++++++++++++++++ src/web/server/player/add_player.php | 3 +- 8 files changed, 168 insertions(+), 15 deletions(-) create mode 100644 src/web/js/lib/maestro_info.js create mode 100644 src/web/server/lib/maestro_account_type.php create mode 100644 src/web/server/maestro/maestro_info.php diff --git a/src/web/js/lib/maestro_info.js b/src/web/js/lib/maestro_info.js new file mode 100644 index 0000000..11ec986 --- /dev/null +++ b/src/web/js/lib/maestro_info.js @@ -0,0 +1,47 @@ +class MaestroInfo { + + constructor() { + this.maestroID = sessionStorage.getItem("maestroID"); + this.maestroName = ""; + this.accountType = 0; + this.playerCount = 0; + } + + loadMaestroInfo(onSuccess, onFail) { + let self = this; + + sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); + "./../server/maestro/maestro_info.php", + "maestro_id=" + this.maestroID, + + (jsonData) => { + self.maestroName = jsonData["name"]; + self.accountType = jsonData["accountType"]; + self.playerCount = jsonData["playerCount"]; + + onSuccess(); + }, + + (errorMessage, errorCode) => { + onFail(errorMessage, errorCode); + } + + ); + } + + getMaxPlayerCount() { + switch(this.accountType) { + case 1: + return 20; + case 2: + return 50; + case 3: + return 100; + } + } + + getRegisteredPlayerCount() { + return this.playerCount; + } + +} diff --git a/src/web/js/player_list_manager.js b/src/web/js/player_list_manager.js index 8146226..694fef8 100644 --- a/src/web/js/player_list_manager.js +++ b/src/web/js/player_list_manager.js @@ -41,7 +41,7 @@ } loadAddPlayerListPage(pageNo) { - self = this; + let self = this; this.activePageNo = pageNo; let pageIndex = pageNo - 1; @@ -68,7 +68,7 @@ updateAddPlayerListPage(pageNo) { - self = this; + let self = this; this.playerListPage = pageNo; let pageIndex = pageNo - 1; @@ -149,6 +149,8 @@ onClickPlayerListPage(pageNo) { + let self = this; + switch(pageNo) { case "first": this.activePageNo = 1; @@ -178,6 +180,7 @@ editPlayer(inputButton) { + let self = this; // console.log(inputButton); let clickedObjectID = this.getClickedObjectID(inputButton); @@ -238,6 +241,8 @@ let playerName = $("#search_name").val(); self.setupSearchPlayerList(playerName); } + + onChangePlayerCount(); }, (errorMessage, errorCode) => { diff --git a/src/web/maestro/main_menu.html b/src/web/maestro/main_menu.html index 709cc6e..e6ffab8 100644 --- a/src/web/maestro/main_menu.html +++ b/src/web/maestro/main_menu.html @@ -12,6 +12,7 @@ + diff --git a/src/web/module/maestro_section_add_player.html b/src/web/module/maestro_section_add_player.html index 24b6018..c94de20 100644 --- a/src/web/module/maestro_section_add_player.html +++ b/src/web/module/maestro_section_add_player.html @@ -15,17 +15,6 @@ function addPlayer() { let playerName = $("#add_player_name").val(); let enterCode = $("#add_player_enter_code").val(); - if(!accountValidator.isValidPlayerID(playerName)) { - console.log("Error - playerName : " + playerName); - onErrorPlayerID(accountValidator.messageForInvalidPlayerID(playerName)); - return; - } else if(!accountValidator.isValidPlayerPW(enterCode)) { - console.log("Error - enterCode : " + enterCode); - onErrorPlayerPW(accountValidator.messageForInvalidPlayerPW(enterCode)); - return; - } - - /* if(playerName.length === 0) { // $("#add_player_notice").val("학생 이름을 입력하세요."); $("#error_message").text("학생 이름을 입력하세요."); @@ -37,7 +26,22 @@ function addPlayer() { $("#add_player_enter_code").focus(); return; } - */ + + + if(maestroInfo.getRegisteredPlayerCount() >= maestroInfo.getMaxPlayerCount()) { + $("#error_message").text("학생을 더 이상 추가할 수 없습니다. (더 많은 학생수로 업그레이드 하세요)"); + return; + } + + if(!accountValidator.isValidPlayerID(playerName)) { + console.log("Error - playerName : " + playerName); + onErrorPlayerID(accountValidator.messageForInvalidPlayerID(playerName)); + return; + } else if(!accountValidator.isValidPlayerPW(enterCode)) { + console.log("Error - enterCode : " + enterCode); + onErrorPlayerPW(accountValidator.messageForInvalidPlayerPW(enterCode)); + return; + } sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); "./../server/player/add_player.php", @@ -45,6 +49,8 @@ function addPlayer() { (jsonData) => { addPlayerListManager.updateAddPlayerListPage(1); + + onChangePlayerCount(); }, (errorMessage, errorCode) => { diff --git a/src/web/module/maestro_section_main.html b/src/web/module/maestro_section_main.html index f34fc4b..224f11e 100644 --- a/src/web/module/maestro_section_main.html +++ b/src/web/module/maestro_section_main.html @@ -1,17 +1,47 @@ 
+
+ 마에스트로 계정 이름 + + 학생수 ? / ? + + 업그레이드 버튼 + +
+ +
  • 학생 목록
  • diff --git a/src/web/server/lib/maestro_account_type.php b/src/web/server/lib/maestro_account_type.php new file mode 100644 index 0000000..6e6d2c9 --- /dev/null +++ b/src/web/server/lib/maestro_account_type.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/src/web/server/maestro/maestro_info.php b/src/web/server/maestro/maestro_info.php new file mode 100644 index 0000000..3507ddf --- /dev/null +++ b/src/web/server/maestro/maestro_info.php @@ -0,0 +1,47 @@ +prepare($query); + $stmt->bind_param("s", $maestroID); + $stmt->execute(); + $stmt->bind_result($name, $accountType, $playerCount); + // while($stmt->fetch()) + $stmt->fetch(); + $stmt->close(); + + $info["name"] = $name; + $info["accountType"] = $accountType; + $info["playerCount"] = $playerCount; + + return $info; +} + +?> \ No newline at end of file diff --git a/src/web/server/player/add_player.php b/src/web/server/player/add_player.php index 1149f31..299a647 100644 --- a/src/web/server/player/add_player.php +++ b/src/web/server/player/add_player.php @@ -2,6 +2,7 @@ header("Content-Type: application/json"); include "./../lib/send_reply_json.php"; +include "./../lib/maestro_account_type.php"; include "./../setup/connect_db.php"; $maestroID = $_POST["maestro_id"]; @@ -27,7 +28,7 @@ if($result !== null) { $maestroAccountType = get_maestro_account_type($maestroID); $playerCount = get_player_count($maestroID); -if($playerCount >= $maestroAccountType * 10) { +if($playerCount >= get_max_player_count($maestroAccountType)) { set_error_message("학생을 더 이상 추가할 수 없습니다. (더 많은 학생수로 업그레이드 하세요)"); send_result_fail(); exit;