Add: registered_player_list_page
This commit is contained in:
@@ -70,6 +70,108 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
let maestroID = -1;
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
maestroID = sessionStorage.getItem("maestroID");
|
||||||
|
console.log("maestroID : " + maestroID);
|
||||||
|
|
||||||
|
loadPlayerList();
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadPlayerList() {
|
||||||
|
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||||
|
xhr.open('POST', './../server/user/registered_player_count.php', true);
|
||||||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
xhr.send("maestro_id=" + maestroID);
|
||||||
|
xhr.onload = function() {
|
||||||
|
if(xhr.readyState === 4 && xhr.status === 200) {
|
||||||
|
// console.log(xhr.responseText);
|
||||||
|
// console.log(xhr.responseText.length);
|
||||||
|
if(xhr.responseText.length === 0 || xhr.responseText === null) {
|
||||||
|
console.log("no data from server");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let replyJSON = JSON.parse(xhr.responseText);
|
||||||
|
// console.log(replyJSON);
|
||||||
|
|
||||||
|
if(replyJSON === null) {
|
||||||
|
console.log("no data from server");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
|
||||||
|
console.log(replyJSON["ERROR"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(replyJSON["RESULT"] === "fail") {
|
||||||
|
console.log(replyJSON["RESULT"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let playerCount = replyJSON["Count"];
|
||||||
|
console.log("registered player count : " + playerCount);
|
||||||
|
loadPlayerListPage(playerCount, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadPlayerListPage(playerCount, pageNo) {
|
||||||
|
let startNo = 0;
|
||||||
|
let endNo = 9;
|
||||||
|
|
||||||
|
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||||
|
xhr.open('POST', './../server/user/registered_player_list_page.php', true);
|
||||||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
xhr.send("maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo);
|
||||||
|
xhr.onload = function() {
|
||||||
|
if(xhr.readyState === 4 && xhr.status === 200) {
|
||||||
|
// console.log(xhr.responseText);
|
||||||
|
// console.log(xhr.responseText.length);
|
||||||
|
if(xhr.responseText.length === 0 || xhr.responseText === null) {
|
||||||
|
console.log("no data from server");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let replyJSON = JSON.parse(xhr.responseText);
|
||||||
|
// console.log(replyJSON);
|
||||||
|
|
||||||
|
if(replyJSON === null) {
|
||||||
|
console.log("no data from server");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
|
||||||
|
console.log(replyJSON["ERROR"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(replyJSON["RESULT"] === "fail") {
|
||||||
|
console.log(replyJSON["RESULT"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(replyJSON["PlayerList"]);
|
||||||
|
updatePlayerListPage(replyJSON["PlayerList"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updatePlayerListPage(playerList) {
|
||||||
|
for(let i = 0; i < playerList.length; i++) {
|
||||||
|
$("#registered_player_list").append(
|
||||||
|
"<li>"
|
||||||
|
+ "<input type='text' value='" + playerList[i]["Name"] + "' class='registered_player_list_name'>"
|
||||||
|
+ "<input type='text' value='" + playerList[i]["EnterCode"] + "' class='registered_player_list_entercode'>"
|
||||||
|
+ "<input type='button' value='수정'>"
|
||||||
|
+ "</li>"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function tabClicked(tabNo) {
|
function tabClicked(tabNo) {
|
||||||
for(let i = 0; i < 4; i++) {
|
for(let i = 0; i < 4; i++) {
|
||||||
$("#page-tabs li").filter(":eq(" + i + ")").removeClass("activated");
|
$("#page-tabs li").filter(":eq(" + i + ")").removeClass("activated");
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$maestroID = $_POST["maestro_id"];
|
||||||
|
/*
|
||||||
|
if(!is_numeric($enterCode)) {
|
||||||
|
send_error_code('생년월일이 숫자가 아닙니다. : '.$enterCode);
|
||||||
|
exit;
|
||||||
|
} else if(strlen($enterCode) != 6) {
|
||||||
|
send_error_code('6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : '.$enterCode);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
|
$result = getPlayerCount($maestroID);
|
||||||
|
if($result === null) {
|
||||||
|
send_error_message($replyJSON, "등록된 학생이 없습니다.");
|
||||||
|
// $db_conn->close();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$replyJSON["Count"] = $result;
|
||||||
|
$replyJSON["RESULT"] = "ok";
|
||||||
|
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||||
|
$db_conn->close();
|
||||||
|
|
||||||
|
|
||||||
|
function getPlayerCount($maestroID) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "SELECT COUNT(UserID) FROM moty_user WHERE MaestroID=?";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param('i', $maestroID);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($userCount);
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $userCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$maestroID = $_POST["maestro_id"];
|
||||||
|
$startNo = $_POST["start_no"];
|
||||||
|
$endNo = $_POST["end_no"];
|
||||||
|
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
|
|
||||||
|
$replyJSON = get_player_list_page($maestroID, $startNo, $endNo);
|
||||||
|
if($replyJSON.length === 0) {
|
||||||
|
send_error_message($replyJSON, "오늘의 랭킹 기록 없음");
|
||||||
|
$db_conn->close();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$replyJSON["RESULT"] = "ok";
|
||||||
|
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||||
|
$db_conn->close();
|
||||||
|
|
||||||
|
|
||||||
|
function get_player_list_page($maestroID, $startNo, $endNo) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT UserID, Name, EnterCode FROM moty_user
|
||||||
|
WHERE MaestroID=?
|
||||||
|
ORDER BY UserID DESC
|
||||||
|
LIMIT ?, ?;
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param('iii', $maestroID, $startNo, $endNo);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($userID, $name, $enterCode);
|
||||||
|
|
||||||
|
$playerList = array();
|
||||||
|
while($stmt->fetch()) {
|
||||||
|
$player['UserID'] = $userID;
|
||||||
|
$player['Name'] = $name;
|
||||||
|
$player['EnterCode'] = $enterCode;
|
||||||
|
array_push($playerList, $player);
|
||||||
|
}
|
||||||
|
|
||||||
|
$return_array['PlayerList'] = $playerList;
|
||||||
|
return $return_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user