Add: register_maestro
This commit is contained in:
@@ -7,14 +7,163 @@
|
||||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="./../css/module.css">
|
||||
<link rel="stylesheet" type="text/css" href="./../css/color_button.css">
|
||||
<link rel="stylesheet" type="text/css" href="./../css/admin.css">
|
||||
|
||||
<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/maestro_list_manager.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">
|
||||
$(document).ready(function() {
|
||||
$("#header").load("admin_header.html");
|
||||
$("#section").load("admin_section.html");
|
||||
|
||||
loadMaestroList("");
|
||||
});
|
||||
|
||||
function searchMaestro() {
|
||||
let maestroName = $("#search_name").val();
|
||||
|
||||
if(maestroName.length === 0) {
|
||||
// $("#search_name_notice").val("학생 이름을 입력하세요.");
|
||||
$("#search_name").focus();
|
||||
}
|
||||
|
||||
loadMaestroList($maestroName);
|
||||
}
|
||||
|
||||
function loadMaestroList($maestroName) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', './../server/admin/registered_maestro_list.php', true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send("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;
|
||||
}
|
||||
|
||||
updateMaestroList(replyJSON["MaestroList"]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function updateMaestroList(jsonList) {
|
||||
$("#maestro_list_result_contents").empty();
|
||||
printHeader();
|
||||
printContents(jsonList);
|
||||
printFooter();
|
||||
}
|
||||
|
||||
function printHeader() {
|
||||
$("#maestro_list_result_contents").append(
|
||||
"<ul id='search_maestro_list' class='maestro_list'>"
|
||||
+ " <li>"
|
||||
+ " <span class='maestro_name'>이름</span>"
|
||||
+ " <span class='maestro_account_type'>금액</span>"
|
||||
+ " </li>"
|
||||
);
|
||||
}
|
||||
|
||||
function printContents(jsonList) {
|
||||
console.log(jsonList);
|
||||
if(jsonList === undefined || jsonList.length === 0)
|
||||
return;
|
||||
|
||||
for(let i = 0; i < jsonList.length; i++) {
|
||||
$("#maestro_list_result_contents").append(
|
||||
"<li class='search_result_list'>"
|
||||
+ " <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].AccountType + "' class='maestro_account_type'>"
|
||||
+ " <input type='button' class='maestro_register' value='등록' onClick='register(this)'>"
|
||||
+ "</li>"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function printFooter() {
|
||||
$("#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) {
|
||||
console.log(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 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");
|
||||
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;
|
||||
}
|
||||
|
||||
loadMaestroList("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -28,6 +177,19 @@
|
||||
</header>
|
||||
|
||||
<section id="section">
|
||||
<span id="search_maestro_name">
|
||||
<h1>검색</h1>
|
||||
|
||||
마에스트로 이름
|
||||
<input type="text" id="search_name"><input type="submit" name="찾기" onClick="searchMaestro()"><br/>
|
||||
<br/>
|
||||
</span>
|
||||
|
||||
<span id="search_result">
|
||||
검색 결과
|
||||
<div id="maestro_list_result_contents">
|
||||
</div>
|
||||
</span>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
@charset "utf-8";
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
.login {
|
||||
background-color: #ff0000;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.register {
|
||||
background-color: #0000ff;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
|
||||
.hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#section_add_maestro {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#add_maestro {
|
||||
float: left;
|
||||
line-height: 2em;
|
||||
width: 400px;
|
||||
padding: 10px;
|
||||
background-color: #aaaaff;
|
||||
}
|
||||
|
||||
#maestro_list_result {
|
||||
float: right;
|
||||
line-height: 2em;
|
||||
width: 600px;
|
||||
padding: 10px;
|
||||
background-color: #ffaaaa;
|
||||
}
|
||||
|
||||
#maestro_list_result_contents {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.maestro_list {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.maestro_list > li > span {
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.maestro_list > li > .maestro_id {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.maestro_list .maestro_id {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.maestro_list .maestro_name {
|
||||
width: 200px;
|
||||
background-color: #ffdddd;
|
||||
}
|
||||
|
||||
.maestro_list .maestro_account_type {
|
||||
width: 200px;
|
||||
background-color: #ddffdd;
|
||||
}
|
||||
|
||||
.maestro_list .maestro_update {
|
||||
width: 200px;
|
||||
background-color: #ddddff;
|
||||
}
|
||||
|
||||
.maestro_list_navigator {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.maestro_list_navigator > span {
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.maestro_list_navigator > span > a {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#search_maestro {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#search_maestro_name {
|
||||
float: left;
|
||||
line-height: 2em;
|
||||
width: 400px;
|
||||
padding: 10px;
|
||||
background-color: #aaaaff;
|
||||
}
|
||||
|
||||
#search_result {
|
||||
float: right;
|
||||
line-height: 2em;
|
||||
width: 600px;
|
||||
padding: 10px;
|
||||
background-color: #ffaaaa;
|
||||
}
|
||||
|
||||
/*
|
||||
#mouse_app_list {
|
||||
overflow: hidden;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,86 @@
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$maestro_id = $_POST["maestro_id"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
$query = "UPDATE moty_maestro SET ActivateStatus=1 WHERE MaestroID=?";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('i', $maestro_id);
|
||||
$stmt->execute();
|
||||
|
||||
if($stmt->affected_rows <= 0) {
|
||||
send_error_message($replyJSON, "마에스트로 계정 활성화 실패");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$replyJSON["RESULT"] = "ok";
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$maestroName = $_POST["maestro_name"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
$replyJSON = null;
|
||||
|
||||
|
||||
if(strlen($maestroName) === 0)
|
||||
$replyJSON = get_maestro_list();
|
||||
else
|
||||
$replyJSON = get_maestro_list_by_name($maestroName);
|
||||
|
||||
if(strlen($replyJSON) === 0) {
|
||||
send_error_message($replyJSON, "오늘의 랭킹 기록 없음");
|
||||
$db_conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$replyJSON["RESULT"] = "ok";
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
$db_conn->close();
|
||||
|
||||
|
||||
function get_maestro_list() {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT MaestroID, Name, AccountType FROM moty_maestro
|
||||
WHERE ActivateStatus=0
|
||||
ORDER BY MaestroID DESC
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
// $stmt->bind_param('iii', $maestroID, $startNo, $endNo);
|
||||
// $stmt->bind_param('ii', $maestroName, $startNo);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($maestroID, $name, $accountType);
|
||||
|
||||
$maestroList = array();
|
||||
while($stmt->fetch()) {
|
||||
$maestro['MaestroID'] = $maestroID;
|
||||
$maestro['Name'] = $name;
|
||||
$maestro['AccountType'] = $accountType;
|
||||
array_push($maestroList, $maestro);
|
||||
}
|
||||
|
||||
$return_array['MaestroList'] = $maestroList;
|
||||
return $return_array;
|
||||
}
|
||||
|
||||
function get_maestro_list_by_name($maestroName) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT MaestroID, Name, AccountType FROM moty_maestro
|
||||
WHERE Name=? AND ActivateStatus=0
|
||||
ORDER BY MaestroID DESC
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
// $stmt->bind_param('iii', $maestroID, $startNo, $endNo);
|
||||
$stmt->bind_param('s', $maestroName);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($maestroID, $name, $accountType);
|
||||
|
||||
$maestroList = array();
|
||||
while($stmt->fetch()) {
|
||||
$maestro['MaestroID'] = $maestroID;
|
||||
$maestro['Name'] = $name;
|
||||
$maestro['AccountType'] = $accountType;
|
||||
array_push($maestroList, $maestro);
|
||||
}
|
||||
|
||||
$return_array['MaestroList'] = $maestroList;
|
||||
return $return_array;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user