Fix: show all app list and disable some buttons

This commit is contained in:
2018-08-30 20:33:42 +09:00
parent bc24bea9d1
commit c061e305f0
8 changed files with 120 additions and 66 deletions
+69 -36
View File
@@ -3,27 +3,60 @@ header("Content-Type: application/json");
$maestro_id = $_POST["maestro_id"];
include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";
$replyJSON = array();
$replyJSON["MouseAppList"] = get_mouse_app_list($maestro_id);
$replyJSON["TypingPracticeAppCount"] = get_typing_practice_app_count($maestro_id);
$replyJSON["TypingTestAppCount"] = get_typing_test_app_count($maestro_id);
$replyJSON["TypingAppList"] = get_typing_app_list($maestro_id);
$db_conn->close();
$mouseAppList = get_app_list(100);
$typingAppList = get_app_list(50);
$mouseActiveAppList = get_active_mouse_app_list($maestro_id);
$typingActiveAppList = get_active_typing_app_list($maestro_id);
$typingPracticeAppCount = get_typing_practice_app_count($maestro_id);
$typingTestAppCount = get_typing_test_app_count($maestro_id);
if($replyJSON.length === 0) {
send_error_message($replyJSON, "앱 목록 가져오기 실패");
$db_conn->close();
set_error_code("no_app_list");
set_error_message("앱 목록을 가져오지 못했습니다.");
send_result_fail();
exit;
}
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
set_data("MouseAppList", $mouseAppList);
set_data("TypingAppList", $typingAppList);
set_data("MouseActiveAppList", $mouseActiveAppList);
set_data("TypingActiveAppList", $typingActiveAppList);
set_data("TypingPracticeAppCount", $typingPracticeAppCount);
set_data("TypingTestAppCount", $typingTestAppCount);
send_result_success();
exit;
function get_mouse_app_list($maestro_id) {
function get_app_list($appType) {
global $db_conn;
$query = "
SELECT AppID, AppName, KoreanName
FROM app
WHERE AppType = ? AND Status = 1
ORDER BY AppID ASC";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('i', $appType);
$stmt->execute();
$stmt->bind_result($app_id, $app_name, $korean_name);
$return_array = array();
while($stmt->fetch()) {
$row_array['AppID'] = $app_id;
$row_array['AppName'] = $app_name;
$row_array['KoreanName'] = $korean_name;
array_push($return_array, $row_array);
}
$stmt->close();
return $return_array;
}
function get_active_mouse_app_list($maestro_id) {
global $db_conn;
$query = "
@@ -48,6 +81,31 @@ function get_mouse_app_list($maestro_id) {
return $return_array;
}
function get_active_typing_app_list($maestro_id) {
global $db_conn;
$query = "
SELECT A.AppID, A.AppName, A.KoreanName, A.AppType
FROM app AS A
INNER JOIN active_app AS AA ON A.AppID = AA.AppID AND A.AppType = 50 AND AA.MaestroID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestro_id);
$stmt->execute();
$stmt->bind_result($app_id, $app_name, $korean_name, $app_type);
$return_array = array();
while($stmt->fetch()) {
$row_array["AppID"] = $app_id;
$row_array["AppName"] = $app_name;
$row_array["KoreanName"] = $korean_name;
$row_array["AppType"] = $app_type;
array_push($return_array, $row_array);
}
$stmt->close();
return $return_array;
}
function get_typing_practice_app_count($maestro_id) {
global $db_conn;
@@ -82,29 +140,4 @@ function get_typing_test_app_count($maestro_id) {
return $typing_practice_app_count;
}
function get_typing_app_list($maestro_id) {
global $db_conn;
$query = "
SELECT A.AppID, A.AppName, A.KoreanName, A.AppType
FROM app AS A
INNER JOIN active_app AS AA ON A.AppID = AA.AppID AND A.AppType = 50 AND AA.MaestroID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestro_id);
$stmt->execute();
$stmt->bind_result($app_id, $app_name, $korean_name, $app_type);
$return_array = array();
while($stmt->fetch()) {
$row_array["AppID"] = $app_id;
$row_array["AppName"] = $app_name;
$row_array["KoreanName"] = $korean_name;
$row_array["AppType"] = $app_type;
array_push($return_array, $row_array);
}
$stmt->close();
return $return_array;
}
?>
+2 -2
View File
@@ -2,11 +2,11 @@ USE moty;
INSERT INTO `maestro` (`MaestroID`, `Name`, `Password`, `Email`, `AccountType`, `ActivateStatus`, `AvailableActivateDateTime`, `PlayerCount`, `AcceptClausesDateTime`, `MaestroTestID`) VALUES
(1, 'testplayer', '', 'test@jinaju.com', 100, 1, '2100-12-31 00:00:00', 0, '2018-05-27 17:13:35', 1),
(2, '마에스트로 체험', '', 'test@jinaju.com', 101, 1, '2100-12-31 00:00:00', 0, '2018-07-08 00:00:00', 2);
(2, '체험 마에스트로', '', 'test@jinaju.com', 101, 1, '2100-12-31 00:00:00', 0, '2018-07-08 00:00:00', 2);
INSERT INTO `player` (`PlayerID`, `MaestroID`, `Name`, `EnterCode`, `AccountType`) VALUES
(1, 1, '학생 체험', '', 0),
(1, 1, '체험 학생', '', 0),
(2, 2, '마에스트로', '', 0);
INSERT INTO `admin` (`AdminID`, `Name`, `Password`, `Email`, `AccountType`, `ActivateStatus`) VALUES