Fix: revised php code to admin
This commit is contained in:
@@ -11,9 +11,7 @@
|
|||||||
|
|
||||||
<script type="text/javascript" src="./../../../resources/jquery/jquery-3.3.1.min.js"></script>
|
<script type="text/javascript" src="./../../../resources/jquery/jquery-3.3.1.min.js"></script>
|
||||||
<script type="text/javascript" src="./../js/main.js"></script>
|
<script type="text/javascript" src="./../js/main.js"></script>
|
||||||
<script type="text/javascript" src="./../js/maestro_list_manager.js"></script>
|
<script type="text/javascript" src="./../js/request_server.js"></script>
|
||||||
<script type="text/javascript" src="./../js/maestro_list.js"></script>
|
|
||||||
<script type="text/javascript" src="./../js/maestro_list_navigator.js"></script>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#header").load("admin_header.html");
|
$("#header").load("admin_header.html");
|
||||||
@@ -32,45 +30,22 @@
|
|||||||
loadMaestroList(maestroName);
|
loadMaestroList(maestroName);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadMaestroList($maestroName) {
|
function loadMaestroList(maestroName) {
|
||||||
let xhr = new XMLHttpRequest();
|
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
|
||||||
xhr.open('POST', './../server/admin/registered_maestro_list.php', true);
|
"./../server/admin/registered_maestro_list.php",
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
"maestro_name=" + maestroName,
|
||||||
xhr.send("maestro_name=" + $maestroName);
|
|
||||||
xhr.onload = function() {
|
(jsonData) => {
|
||||||
if(xhr.readyState === 4 && xhr.status === 200) {
|
updateMaestroList(jsonData["maestroList"]);
|
||||||
// console.log(xhr.responseText);
|
},
|
||||||
// console.log(xhr.responseText.length);
|
|
||||||
if(xhr.responseText.length === 0 || xhr.responseText === null) {
|
(errorMessage) => {
|
||||||
console.log("no data from server");
|
if($("#error_message").length) {
|
||||||
$("#error_message").text("서버에서 요청을 수행하지 못했습니다.");
|
$("#error_message").text(errorMessage);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let replyJSON = JSON.parse(xhr.responseText);
|
|
||||||
// console.log(replyJSON);
|
|
||||||
|
|
||||||
if(replyJSON === null) {
|
|
||||||
console.log("no data from server");
|
|
||||||
$("#error_message").text("서버에서 데이터가 넘어오지 않았습니다.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
|
|
||||||
console.log(replyJSON["ERROR"]);
|
|
||||||
$("#error_message").text(replyJSON["ERROR"]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(replyJSON["RESULT"] === "fail") {
|
|
||||||
console.log(replyJSON["RESULT"]);
|
|
||||||
$("#error_message").text(replyJSON["ERROR"]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateMaestroList(replyJSON["MaestroList"]);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,9 +74,9 @@
|
|||||||
for(let i = 0; i < jsonList.length; i++) {
|
for(let i = 0; i < jsonList.length; i++) {
|
||||||
$("#maestro_list_result_contents").append(
|
$("#maestro_list_result_contents").append(
|
||||||
"<li class='search_result_list'>"
|
"<li class='search_result_list'>"
|
||||||
+ " <span class='maestro_id hide'>" + jsonList[i].MaestroID + "</span>"
|
+ " <span class='maestro_id hide'>" + jsonList[i].maestroID + "</span>"
|
||||||
+ " <input type='text' value='" + jsonList[i].Name + "' class='maestro_name'>"
|
+ " <input type='text' value='" + jsonList[i].maestroName + "' class='maestro_name'>"
|
||||||
+ " <input type='text' value='" + jsonList[i].AccountType + "' class='maestro_account_type'>"
|
+ " <input type='text' value='" + jsonList[i].accountType + "' class='maestro_account_type'>"
|
||||||
+ " <input type='button' class='maestro_register' value='등록' onClick='register(this)'>"
|
+ " <input type='button' class='maestro_register' value='등록' onClick='register(this)'>"
|
||||||
+ "</li>"
|
+ "</li>"
|
||||||
);
|
);
|
||||||
@@ -112,65 +87,32 @@
|
|||||||
$("#maestro_list_result_contents").append("</ul>");
|
$("#maestro_list_result_contents").append("</ul>");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClickedObjectID(clickedObject) {
|
|
||||||
let tagDiv = $(clickedObject).closest(".player_list");
|
|
||||||
let tagDivID = tagDiv.prop("id");
|
|
||||||
// console.log(tagDivIDName);
|
|
||||||
|
|
||||||
return tagDivID;
|
|
||||||
}
|
|
||||||
|
|
||||||
function register(inputButton) {
|
function register(inputButton) {
|
||||||
console.log(inputButton);
|
|
||||||
|
|
||||||
|
|
||||||
let id = $(inputButton).siblings(".maestro_id");
|
let id = $(inputButton).siblings(".maestro_id");
|
||||||
let maestroID = id.text();
|
let maestroID = id.text();
|
||||||
console.log(maestroID);
|
// console.log(maestroID);
|
||||||
|
|
||||||
let name = $(inputButton).siblings(".maestro_name");
|
// let name = $(inputButton).siblings(".maestro_name");
|
||||||
let maestroName = name.val();
|
// let maestroName = name.val();
|
||||||
console.log(maestroName);
|
// console.log(maestroName);
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
|
||||||
xhr.open('POST', './../server/admin/register_maestro.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");
|
|
||||||
$("#error_message").text("서버에서 요청을 수행하지 못했습니다.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let replyJSON = JSON.parse(xhr.responseText);
|
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
|
||||||
// console.log(replyJSON);
|
"./../server/admin/register_maestro.php",
|
||||||
|
"maestro_id=" + maestroID,
|
||||||
if(replyJSON === null) {
|
|
||||||
console.log("no data from server");
|
|
||||||
$("#error_message").text("서버에서 데이터가 넘어오지 않았습니다.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
|
|
||||||
console.log(replyJSON["ERROR"]);
|
|
||||||
$("#error_message").text(replyJSON["ERROR"]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(replyJSON["RESULT"] === "fail") {
|
|
||||||
console.log(replyJSON["RESULT"]);
|
|
||||||
$("#error_message").text(replyJSON["ERROR"]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
(jsonData) => {
|
||||||
loadMaestroList("");
|
loadMaestroList("");
|
||||||
$("#error_message").text("마에스트로 계정이 정상적으로 등록되었습니다.");
|
$("#error_message").text("마에스트로 계정이 정상적으로 등록되었습니다.");
|
||||||
|
},
|
||||||
|
|
||||||
|
(errorMessage) => {
|
||||||
|
if($("#error_message").length) {
|
||||||
|
$("#error_message").text(errorMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -22,14 +22,14 @@
|
|||||||
let name = $("#maestro_name").val();
|
let name = $("#maestro_name").val();
|
||||||
let password = $("#password").val();
|
let password = $("#password").val();
|
||||||
|
|
||||||
|
|
||||||
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
|
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
|
||||||
"./../server/maestro/login.php",
|
"./../server/maestro/login.php",
|
||||||
"maestro_name=" + name + "&password=" + password,
|
"maestro_name=" + name + "&password=" + password,
|
||||||
|
|
||||||
(jsonData) => {
|
(jsonData) => {
|
||||||
maestroID = jsonData["MaestroID"];
|
maestroID = jsonData["maestroID"];
|
||||||
sessionStorage.setItem("maestroID", maestroID);
|
sessionStorage.setItem("maestroID", maestroID);
|
||||||
|
|
||||||
location.href = 'admin_register_list.html';
|
location.href = 'admin_register_list.html';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
class MaestroListRow {
|
|
||||||
|
|
||||||
constructor(maestroID, maestroName, password, editButton, deleteButton) {
|
|
||||||
this.maestroID = maestroID;
|
|
||||||
this.maestroName = maestroName;
|
|
||||||
this.password = password;
|
|
||||||
this.editButton = editButton;
|
|
||||||
this.deleteButton = deleteButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class MaestroList {
|
|
||||||
|
|
||||||
constructor(tagDiv, parent) {
|
|
||||||
let self = this;
|
|
||||||
this.parent = parent;
|
|
||||||
// console.log(tagDiv);
|
|
||||||
|
|
||||||
this.maestroCount = 0;
|
|
||||||
this.activePageNo = 1;
|
|
||||||
|
|
||||||
let id_list = tagDiv.find(".maestro_id");
|
|
||||||
// console.log(id_list);
|
|
||||||
|
|
||||||
this.listRows = new Array();
|
|
||||||
for(let i = 0; i < id_list.length; i++) {
|
|
||||||
this.listRows[i] = new PaestroListRow(
|
|
||||||
id_list[i], // span
|
|
||||||
$(id_list[i]).siblings(".maestro_name"),
|
|
||||||
$(id_list[i]).siblings(".maestro_password"),
|
|
||||||
$(id_list[i]).siblings(".maestro_edit"),
|
|
||||||
$(id_list[i]).siblings(".maestro_delete")
|
|
||||||
);
|
|
||||||
|
|
||||||
this.disableItem(this.listRows[i]);
|
|
||||||
|
|
||||||
$(id_list[i]).siblings(".maestro_edit").click(function() {
|
|
||||||
parent.editMaestro(this);
|
|
||||||
})
|
|
||||||
|
|
||||||
$(id_list[i]).siblings(".maestro_delete").click(function() {
|
|
||||||
parent.deleteMaestro(this);
|
|
||||||
})
|
|
||||||
// console.log(this.listRows[i].maestroName.val());
|
|
||||||
// console.log(this.listRows[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
disableItem(item) {
|
|
||||||
$(item.maestroID).empty();
|
|
||||||
$(item.maestroName).prop("disabled", true);
|
|
||||||
$(item.password).prop("disabled", true);
|
|
||||||
$(item.editButton).prop("disabled", true);
|
|
||||||
$(item.deleteButton).prop("disabled", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
enableItem(item) {
|
|
||||||
$(item.maestroName).prop("disabled", false);
|
|
||||||
$(item.password).prop("disabled", false);
|
|
||||||
$(item.editButton).prop("disabled", false);
|
|
||||||
$(item.deleteButton).prop("disabled", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
updatemaestroList(jsonData) {
|
|
||||||
// console.log(jsonData);
|
|
||||||
|
|
||||||
for(let i = 0; i < 10; i++) {
|
|
||||||
$(this.listRows[i].maestroID).empty();
|
|
||||||
|
|
||||||
if(i < jsonData.length) {
|
|
||||||
$(this.listRows[i].maestroID).append(jsonData[i]["maestroID"]);
|
|
||||||
$(this.listRows[i].maestroName).val(jsonData[i]["Name"]);
|
|
||||||
$(this.listRows[i].password).val(jsonData[i]["Password"]);
|
|
||||||
|
|
||||||
this.enableItem(this.listRows[i]);
|
|
||||||
} else {
|
|
||||||
$(this.listRows[i].maestroName).val("");
|
|
||||||
$(this.listRows[i].password).val("");
|
|
||||||
|
|
||||||
this.disableItem(this.listRows[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,411 +0,0 @@
|
|||||||
class MaestroListManager {
|
|
||||||
|
|
||||||
constructor(docList, docNav) {
|
|
||||||
let self = this;
|
|
||||||
this.docList = docList;
|
|
||||||
this.docNav = docNav;
|
|
||||||
|
|
||||||
this.list = new MaestroList(this.docList, this);
|
|
||||||
this.listNavigator = new MaestroListNavigator(this.docNav);
|
|
||||||
|
|
||||||
this.maestroCount = 0;
|
|
||||||
this.activePageNo = 1;
|
|
||||||
this.lastPageNo = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
setupRegisteredMaestroList() {
|
|
||||||
let self = this;
|
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
|
||||||
xhr.open('POST', './../server/maestro/registered_maestro_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.maestroCount = replyJSON["Count"];
|
|
||||||
self.lastPageNo = Math.ceil( (self.maestroCount + 1) / 10 );
|
|
||||||
self.activePageNo = 1;
|
|
||||||
|
|
||||||
self.loadRegisteredMaestroListPage(self.activePageNo);
|
|
||||||
self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
loadRegisteredMaestroListPage(pageNo) {
|
|
||||||
self = this;
|
|
||||||
this.activePageNo = pageNo;
|
|
||||||
|
|
||||||
let pageIndex = pageNo - 1;
|
|
||||||
let startNo = pageIndex * 10;
|
|
||||||
let endNo = pageIndex * 10 + 9;
|
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
|
||||||
xhr.open('POST', './../server/maestro/registered_maestro_list.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["MaestroList"]);
|
|
||||||
// updateMaestroListPage(replyJSON["MaestroList"]);
|
|
||||||
self.list.updateMaestroList(replyJSON["MaestroList"]);
|
|
||||||
|
|
||||||
self.maestroCount = replyJSON["MaestroList"].length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
updateRegisteredMaestroListPage(pageNo) {
|
|
||||||
self = this;
|
|
||||||
this.maestroListPage = pageNo;
|
|
||||||
|
|
||||||
let pageIndex = pageNo - 1;
|
|
||||||
let startNo = pageIndex * 10;
|
|
||||||
let endNo = pageIndex * 10 + 9;
|
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
|
||||||
xhr.open('POST', './../server/maestro/registered_maestro_list.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["MaestroList"]);
|
|
||||||
self.list.updateMaestroList(replyJSON["MaestroList"]);
|
|
||||||
|
|
||||||
self.maestroCount = replyJSON["MaestroList"].length;
|
|
||||||
// console.log(self.maestroCount);
|
|
||||||
// self.lastPageNo = Math.ceil( (self.maestroCount + 1) / 10 );
|
|
||||||
// self.activePageNo = 1;
|
|
||||||
|
|
||||||
self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setupUpgradeMaestroList(maestroName) {
|
|
||||||
let self = this;
|
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
|
||||||
xhr.open('POST', './../server/maestro/search_maestro_count.php', true);
|
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
xhr.send("maestro_id=" + maestroID + "&maestro_name=" + maestroName);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.maestroCount = replyJSON["Count"];
|
|
||||||
self.lastPageNo = Math.ceil( (self.maestroCount + 1) / 10 );
|
|
||||||
self.activePageNo = 1;
|
|
||||||
|
|
||||||
self.updateSearchMaestroListPage(maestroName, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateUpgradeMaestroListPage(maestroName, pageNo) {
|
|
||||||
let self = this;
|
|
||||||
this.maestroListPage = pageNo;
|
|
||||||
|
|
||||||
let pageIndex = pageNo - 1;
|
|
||||||
let startNo = pageIndex * 10;
|
|
||||||
let endNo = pageIndex * 10 + 9;
|
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
|
||||||
xhr.open('POST', './../server/maestro/search_maestro_list.php', true);
|
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
xhr.send("maestro_id=" + maestroID + "&maestro_name=" + maestroName + "&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["MaestroList"]);
|
|
||||||
self.list.updateMaestroList(replyJSON["MaestroList"]);
|
|
||||||
|
|
||||||
self.maestroCount = replyJSON["MaestroList"].length;
|
|
||||||
// self.lastPageNo = Math.ceil( (self.maestroCount + 1) / 10 );
|
|
||||||
// self.activePageNo = 1;
|
|
||||||
|
|
||||||
self.listNavigator.updateNavigator(self.activePageNo, self.lastPageNo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
onClickMaestroListPage(pageNo) {
|
|
||||||
switch(pageNo) {
|
|
||||||
case "first":
|
|
||||||
this.activePageNo = 1;
|
|
||||||
self.loadAddMaestroListPage(self.activePageNo);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "prev":
|
|
||||||
if(this.activePageNo > 1)
|
|
||||||
this.activePageNo -= 1;
|
|
||||||
self.loadAddMaestroListPage(self.activePageNo);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "next":
|
|
||||||
if(this.activePageNo < this.lastPageNo)
|
|
||||||
this.activePageNo += 1;
|
|
||||||
self.loadAddMaestroListPage(self.activePageNo);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "last":
|
|
||||||
this.loadAddMaestroListPage(this.lastPageNo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.activePageNo = pageNo;
|
|
||||||
self.loadAddMaestroListPage(self.activePageNo);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
registMaestro(inputButton) {
|
|
||||||
// console.log(inputButton);
|
|
||||||
let clickedObjectID = this.getClickedObjectID(inputButton);
|
|
||||||
|
|
||||||
|
|
||||||
let id = $(inputButton).siblings(".maestro_id");
|
|
||||||
let maestroID = id.text();
|
|
||||||
// console.log(maestroID);
|
|
||||||
|
|
||||||
let name = $(inputButton).siblings(".maestro_name");
|
|
||||||
let maestroName = name.val();
|
|
||||||
// console.log(maestroName);
|
|
||||||
|
|
||||||
let enterCode = $(inputButton).siblings(".maestro_entercode");
|
|
||||||
let maestroEnterCode = enterCode.val();
|
|
||||||
// console.log(maestroEnterCode);
|
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
|
||||||
xhr.open('POST', './../server/maestro/edit_maestro.php', true);
|
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
xhr.send("maestro_id=" + maestroID + "&maestro_id=" + maestroID + "&maestro_name=" + maestroName + "&enter_code=" + maestroEnterCode);
|
|
||||||
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(clickedObjectID);
|
|
||||||
if(clickedObjectID === "registered_maestro_list") {
|
|
||||||
self.setupRegisteredMaestroList();
|
|
||||||
} else if(clickedObjectID === "search_maestro_list") {
|
|
||||||
let maestroName = $("#search_name").val();
|
|
||||||
self.setupUpdateMaestroList(maestroName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteMaestro(inputButton) {
|
|
||||||
let self = this;
|
|
||||||
|
|
||||||
let id = $(inputButton).siblings(".maestro_id");
|
|
||||||
let maestroID = id.text();
|
|
||||||
|
|
||||||
let clickedObjectID = this.getClickedObjectID(inputButton);
|
|
||||||
|
|
||||||
if(maestroID === null || maestroID === "")
|
|
||||||
return;
|
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest(); //new로 생성.
|
|
||||||
xhr.open('POST', './../server/maestro/delete_maestro.php', true);
|
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
xhr.send("maestro_id=" + maestroID + "&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;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(clickedObjectID);
|
|
||||||
if(clickedObjectID === "registered_maestro_list") {
|
|
||||||
self.setupRegisteredMaestroList();
|
|
||||||
} else if(clickedObjectID === "upgrade_maestro_list") {
|
|
||||||
let maestroName = $("#search_name").val();
|
|
||||||
self.setupUpgradeMaestroList(maestroName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getClickedObjectID(clickedObject) {
|
|
||||||
let tagDiv = $(clickedObject).closest(".maestro_list");
|
|
||||||
let tagDivID = tagDiv.prop("id");
|
|
||||||
// console.log(tagDivIDName);
|
|
||||||
|
|
||||||
return tagDivID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
class MaestroListNavigator {
|
|
||||||
|
|
||||||
constructor(pageNoArea) {
|
|
||||||
let self = this;
|
|
||||||
this.pageNoArea = pageNoArea;
|
|
||||||
// console.log(parent);
|
|
||||||
|
|
||||||
this.activePageNo = 1;
|
|
||||||
this.lastPageNo = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateNavigator(activePageNo, lastPageNo) {
|
|
||||||
this.activePageNo = activePageNo;
|
|
||||||
this.lastPageNo = lastPageNo;
|
|
||||||
// this.lastPageNo = Math.ceil( (maestroCount + 1) / 10 );
|
|
||||||
|
|
||||||
$(this.pageNoArea).empty();
|
|
||||||
|
|
||||||
for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
|
|
||||||
$(this.pageNoArea).append(
|
|
||||||
"<a onClick='onClickMaestroListPage(this, " + pageNo + ")'> " + pageNo + " </a>"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onClickMaestroListPage(pageNo) {
|
|
||||||
switch(pageNo) {
|
|
||||||
case "first":
|
|
||||||
this.activePageNo = 1;
|
|
||||||
this.maestroList.loadMaestroListPage(this.activePageNo);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "prev":
|
|
||||||
if(this.activePageNo > 1)
|
|
||||||
this.activePageNo -= 1;
|
|
||||||
this.maestroList.loadMaestroListPage(this.activePageNo);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "next":
|
|
||||||
if(this.activePageNo < this.lastPageNo)
|
|
||||||
this.activePageNo += 1;
|
|
||||||
this.maestroList.loadMaestroListPage(this.activePageNo);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "last":
|
|
||||||
this.maestroList.loadMaestroListPage(this.lastPageNo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.activePageNo = pageNo;
|
|
||||||
this.maestroList.loadMaestroListPage(this.activePageNo);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
header('Content-Type: application/json');
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
|
include "./../lib/send_reply_json.php";
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
$maestro_id = $_POST["maestro_id"];
|
$maestro_id = $_POST["maestro_id"];
|
||||||
|
|
||||||
include "./../setup/connect_db.php";
|
|
||||||
|
|
||||||
$query = "UPDATE moty_maestro SET ActivateStatus=1 WHERE MaestroID=?";
|
$query = "UPDATE moty_maestro SET ActivateStatus=1 WHERE MaestroID=?";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param('i', $maestro_id);
|
$stmt->bind_param("i", $maestro_id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
if($stmt->affected_rows <= 0) {
|
if($stmt->affected_rows <= 0) {
|
||||||
send_error_message($replyJSON, "마에스트로 계정 활성화 실패");
|
set_error_message("마에스트로 계정 활성화 실패");
|
||||||
$db_conn->close();
|
send_result_fail();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$replyJSON["RESULT"] = "ok";
|
send_result_success();
|
||||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
exit;
|
||||||
$db_conn->close();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,28 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
header('Content-Type: application/json');
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
|
include "./../lib/send_reply_json.php";
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
$maestroName = $_POST["maestro_name"];
|
$maestroName = $_POST["maestro_name"];
|
||||||
|
|
||||||
include "./../setup/connect_db.php";
|
|
||||||
|
|
||||||
|
|
||||||
$replyJSON = null;
|
|
||||||
|
|
||||||
|
|
||||||
|
$maestroList = null;
|
||||||
if(strlen($maestroName) === 0)
|
if(strlen($maestroName) === 0)
|
||||||
$replyJSON = get_maestro_list();
|
$maestroList = get_maestro_list();
|
||||||
else
|
else
|
||||||
$replyJSON = get_maestro_list_by_name($maestroName);
|
$maestroList = get_maestro_list_by_name($maestroName);
|
||||||
|
|
||||||
if(strlen($replyJSON) === 0) {
|
if(strlen($maestroList) === 0) {
|
||||||
send_error_message($replyJSON, "오늘의 랭킹 기록 없음");
|
set_error_message("오늘의 랭킹 기록 없음");
|
||||||
$db_conn->close();
|
send_result_fail();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$replyJSON["RESULT"] = "ok";
|
set_data("maestroList", $maestroList);
|
||||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
send_result_success();
|
||||||
$db_conn->close();
|
exit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function get_maestro_list() {
|
function get_maestro_list() {
|
||||||
@@ -34,21 +34,20 @@ function get_maestro_list() {
|
|||||||
ORDER BY MaestroID DESC
|
ORDER BY MaestroID DESC
|
||||||
";
|
";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
// $stmt->bind_param('iii', $maestroID, $startNo, $endNo);
|
// $stmt->bind_param("iii", $maestroID, $startNo, $endNo);
|
||||||
// $stmt->bind_param('ii', $maestroName, $startNo);
|
// $stmt->bind_param("ii", $maestroName, $startNo);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($maestroID, $name, $accountType);
|
$stmt->bind_result($maestroID, $name, $accountType);
|
||||||
|
|
||||||
$maestroList = array();
|
$maestroList = array();
|
||||||
while($stmt->fetch()) {
|
while($stmt->fetch()) {
|
||||||
$maestro['MaestroID'] = $maestroID;
|
$maestro["maestroID"] = $maestroID;
|
||||||
$maestro['Name'] = $name;
|
$maestro["maestroName"] = $name;
|
||||||
$maestro['AccountType'] = $accountType;
|
$maestro["accountType"] = $accountType;
|
||||||
array_push($maestroList, $maestro);
|
array_push($maestroList, $maestro);
|
||||||
}
|
}
|
||||||
|
|
||||||
$return_array['MaestroList'] = $maestroList;
|
return $maestroList;
|
||||||
return $return_array;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_maestro_list_by_name($maestroName) {
|
function get_maestro_list_by_name($maestroName) {
|
||||||
@@ -60,21 +59,20 @@ function get_maestro_list_by_name($maestroName) {
|
|||||||
ORDER BY MaestroID DESC
|
ORDER BY MaestroID DESC
|
||||||
";
|
";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
// $stmt->bind_param('iii', $maestroID, $startNo, $endNo);
|
// $stmt->bind_param("iii", $maestroID, $startNo, $endNo);
|
||||||
$stmt->bind_param('s', $maestroName);
|
$stmt->bind_param("s", $maestroName);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($maestroID, $name, $accountType);
|
$stmt->bind_result($maestroID, $name, $accountType);
|
||||||
|
|
||||||
$maestroList = array();
|
$maestroList = array();
|
||||||
while($stmt->fetch()) {
|
while($stmt->fetch()) {
|
||||||
$maestro['MaestroID'] = $maestroID;
|
$maestro["maestroID"] = $maestroID;
|
||||||
$maestro['Name'] = $name;
|
$maestro["maestroName"] = $name;
|
||||||
$maestro['AccountType'] = $accountType;
|
$maestro["accountType"] = $accountType;
|
||||||
array_push($maestroList, $maestro);
|
array_push($maestroList, $maestro);
|
||||||
}
|
}
|
||||||
|
|
||||||
$return_array['MaestroList'] = $maestroList;
|
return $maestroList;
|
||||||
return $return_array;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
header('Content-Type: application/json');
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
include "./../lib/send_reply_json.php";
|
include "./../lib/send_reply_json.php";
|
||||||
include "./../setup/connect_db.php";
|
include "./../setup/connect_db.php";
|
||||||
@@ -8,10 +8,10 @@ $maestro_name = $_POST["maestro_name"];
|
|||||||
$password = $_POST["password"];
|
$password = $_POST["password"];
|
||||||
/*
|
/*
|
||||||
if(!is_numeric($enterCode)) {
|
if(!is_numeric($enterCode)) {
|
||||||
send_error_code('생년월일이 숫자가 아닙니다. : '.$enterCode);
|
send_error_code("생년월일이 숫자가 아닙니다. : ".$enterCode);
|
||||||
exit;
|
exit;
|
||||||
} else if(strlen($enterCode) != 6) {
|
} else if(strlen($enterCode) != 6) {
|
||||||
send_error_code('6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : '.$enterCode);
|
send_error_code("6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : ".$enterCode);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@@ -30,7 +30,7 @@ if($login_data === null || $login_data[maestroID] === null) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_data("maestroId", $login_data[maestroID]);
|
set_data("maestroID", $login_data[maestroID]);
|
||||||
send_result_success();
|
send_result_success();
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ function get_maestro_id($maestro_name) {
|
|||||||
|
|
||||||
$query = "SELECT MaestroID FROM moty_maestro WHERE Name=?";
|
$query = "SELECT MaestroID FROM moty_maestro WHERE Name=?";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param('s', $maestro_name);
|
$stmt->bind_param("s", $maestro_name);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($maestro_id);
|
$stmt->bind_result($maestro_id);
|
||||||
// while($stmt->fetch()) {
|
// while($stmt->fetch()) {
|
||||||
@@ -58,7 +58,7 @@ function login($maestro_name, $password) {
|
|||||||
|
|
||||||
$query = "SELECT MaestroID FROM moty_maestro WHERE Name=? AND Password=PASSWORD(?)";
|
$query = "SELECT MaestroID FROM moty_maestro WHERE Name=? AND Password=PASSWORD(?)";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param('ss', $maestro_name, $password);
|
$stmt->bind_param("ss", $maestro_name, $password);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($maestro_id);
|
$stmt->bind_result($maestro_id);
|
||||||
// while($stmt->fetch())
|
// while($stmt->fetch())
|
||||||
|
|||||||
Reference in New Issue
Block a user