Add: maestro, add player page - player allow edit entercode option (checkbox)

This commit is contained in:
2019-03-16 23:08:56 +09:00
parent a03eb243e1
commit 275efabdfb
4 changed files with 164 additions and 1 deletions
+89 -1
View File
@@ -7,6 +7,10 @@ $(document).ready(function() {
} }
}); });
// checkbox-allow-edit-entercode
setCheckboxEvent();
loadAllowEditEnterCode();
addPlayerListManager = new PlayerListManager( addPlayerListManager = new PlayerListManager(
$("#add_player_list"), $("#add_player_list"),
// $(".pagination") // $(".pagination")
@@ -16,6 +20,57 @@ $(document).ready(function() {
addPlayerListManager.setupAddPlayerList(); addPlayerListManager.setupAddPlayerList();
}); });
function setCheckboxEvent() {
$("#checkbox-allow-edit-entercode").change(function() {
if($(this).is(":checked")) {
changeAllowEditEnterCode(true);
} else {
changeAllowEditEnterCode(false);
}
});
}
function changeAllowEditEnterCode(isActivated) {
var allowEditEnterCode = isActivated ? 1 : 0;
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/maestro/set_allow_edit_entercode.php",
"maestro_id=" + maestroID + "&allowEditEnterCode=" + allowEditEnterCode,
(function(jsonData) {
// console.log(jsonData);
if(jsonData["isActivated"] == "0")
showErrorMessage("학생 입장번호 변경 옵션이 비활성화 되었습니다.", "success");
else
showErrorMessage("학생 입장번호 변경 옵션이 활성화 되었습니다.", "success");
}),
(function(errorMessage, errorCode) {
showErrorMessage(errorMessage, "error");
})
);
}
function loadAllowEditEnterCode() {
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/maestro/get_allow_edit_entercode.php",
"maestro_id=" + maestroID,
(function(jsonData) {
var flag = jsonData["AllowEditEnterCode"];
if(flag) {
$("#checkbox-allow-edit-entercode").prop("checked", true);
}
}),
(function(errorMessage, errorCode) {
showErrorMessage(errorMessage, "error");
})
);
}
function addPlayer() { function addPlayer() {
var playerName = $("#player_name").val(); var playerName = $("#player_name").val();
var enterCode = $("#entercode").val(); var enterCode = $("#entercode").val();
@@ -84,7 +139,7 @@ function onErrorPlayerPW(message) {
<div class="row mx-1"> <div class="row mx-1">
<div class="col-5"> <div class="col-5">
<h5 class="my-3">학생 추가</h5> <h5 class="my-3">학생 추가 (일반 등록)</h5>
<form class="mx-2"> <form class="mx-2">
<div class="form-group row"> <div class="form-group row">
@@ -105,6 +160,39 @@ function onErrorPlayerPW(message) {
</div> </div>
</form> </form>
<br/>
<!--
<h5 class="my-3">학생 추가 (임시 입장번호 발급)</h5>
<form class="mx-2">
<div class="form-group row">
<label for="simple_player_name" class="col-sm-3 col-form-label">이름</label>
<div class="col-sm-9">
<input type="text" class="form-control col-sm-9 disabled" id="player_name" placeholder="이름 입력">
<small class="form-text text-muted">1~8 글자 / [ 한글,영문,숫자,-,_ ]</small>
<button type="button" class="col-sm-7 btn btn-primary btn-lg mt-3 disabled" onClick="addPlayer()">추가</button>
</div>
</div>
</form>
<br/>
-->
<h5 class="my-3">학생 입장번호 변경 옵션 활성화</h5>
<div clas됩="row mx-4">
<div class="col">
<div class="form-check col">
<input class="form-check-input" type="checkbox" id="checkbox-allow-edit-entercode" data-app-id="checkbox-allow-edit-entercode" value="">
<label class="form-check-label" for="checkbox-allow-edit-entercode">
학생 로그인 후, 옵션 화면에서 입장번호 변경을 허용
</label>
</div>
</div>
</div>
<!-- <!--
@@ -0,0 +1,43 @@
<?php
header("Content-Type: application/json");
include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";
$maestro_id = $_POST["maestro_id"];
$allow_edit_entercode = get_allow_edit_entercode($maestro_id);
/*
if($allow_edit_entercode !== null) {
set_error_code("no_data");
set_error_message("해당 정보가 없습니다.");
send_result_fail();
exit;
}
*/
set_data("AllowEditEnterCode", $allow_edit_entercode);
send_result_success();
exit;
function get_allow_edit_entercode($maestro_id) {
global $db_conn;
$query = "SELECT AllowEditEnterCode FROM maestro WHERE MaestroID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestro_id);
$stmt->execute();
$stmt->bind_result($allow_edit_entercode);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $allow_edit_entercode;
}
?>
@@ -0,0 +1,31 @@
<?php
header('Content-Type: application/json');
include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";
$maestroID = $_POST["maestro_id"];
$flagAllowEditEnterCode = $_POST["allowEditEnterCode"];
change_allow_edit_entercode($maestroID, $flagAllowEditEnterCode);
set_data("isActivated", $flagAllowEditEnterCode);
send_result_success();
exit;
function change_allow_edit_entercode($maestroID, $flagAllowEditEnterCode) {
global $db_conn;
$query = "
UPDATE maestro
SET AllowEditEnterCode = ?
WHERE MaestroID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("ii", $flagAllowEditEnterCode, $maestroID);
$stmt->execute();
}
?>
+1
View File
@@ -17,6 +17,7 @@ CREATE TABLE maestro (
AvailableActivateDateTime DATETIME NOT NULL, AvailableActivateDateTime DATETIME NOT NULL,
PlayerCount INT UNSIGNED NOT NULL, PlayerCount INT UNSIGNED NOT NULL,
AcceptClausesDateTime DATETIME NOT NULL, AcceptClausesDateTime DATETIME NOT NULL,
AllowEditEnterCode INT UNSIGNED NOT NULL,
MaestroTestID INT UNSIGNED MaestroTestID INT UNSIGNED
); );