Add: maestro extension php, send e-mail

This commit is contained in:
2019-10-17 18:00:32 +09:00
parent 6ed7028e90
commit d431371aa3
7 changed files with 510 additions and 0 deletions
+243
View File
@@ -0,0 +1,243 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta charset="UTF-8">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-85912788-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-85912788-2');
</script>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-N8PB4F3');</script>
<!-- End Google Tag Manager -->
<title>마우스 타자 관리자 페이지</title>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link href="../../../resources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="./../../../resources/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="./../../game/lib/util/number_util.js"></script>
<script type="text/javascript" src="./../js/main.js"></script>
<script type="text/javascript" src="./../js/request_server.js"></script>
<script type="text/javascript" src="./../js/lib/account_info.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#search_name").keydown(function(key) {
if(key.keyCode == 13) {
searchMaestroExtension();
}
});
$("#header").load("admin_header.html");
loadMaestroExtensionList("");
});
function loadMaestroExtensionList(maestroName) {
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/admin/maestro_extension_list.php",
"maestro_name=" + maestroName,
function(jsonData) {
updateMaestroExtensionList(jsonData["maestroExtensionList"]);
},
function(errorMessage, errorCode) {
console.log(errorMessage);
if($("#error_message").length) {
$("#error_message").text(errorMessage);
}
}
);
}
function updateMaestroExtensionList(jsonList) {
$("#maestro_list_result_contents").empty();
printContents(jsonList);
}
function printContents(jsonList) {
if(jsonList === undefined || jsonList.length === 0) {
$("#maestro_list_result_contents").append(
"<div class='alert alert-danger text-center' role='alert'>"
+ "마에스트로 계정 정보가 없습니다."
+ "</div>"
);
return;
}
for(var i = 0; i < jsonList.length; i++) {
if(jsonList[i].status == 1) {
$("#maestro_list_result_contents").append(
"<div class='form-group player-list row mx-2 mb-1'>"
+ " <input type='text' class='maestro_extension_id d-none' disabled value='" + jsonList[i].maestroExtensionID + "'>"
+ " <input type='text' class='maestro_id d-none' disabled value='" + jsonList[i].maestroID + "'>"
+ " <input type='text' class='maestro_name col-sm' disabled value='" + jsonList[i].maestroName + "'>"
+ " <input type='text' class='registered_account_type col-sm text-right' disabled value='" + accountType(jsonList[i].registeredAccountType) + "'>"
+ " <input type='text' class='col-sm text-right' disabled value='" + jsonList[i].availableActivateDateTime.substring(0, 10) + "'>"
// + " <input type='text' class='new_account_type col-sm text-right' disabled value='" + accountType(jsonList[i].requestedAccountType) + "'>"
+ " <input type='text' class='col-sm text-right' disabled value='" + jsonList[i].requestedDateTime.substring(0, 10) + "'>"
// + " <input type='text' class='col-sm text-right' disabled value='" + NumberUtil.numberWithCommas(price(jsonList[i].requestedAccountType, jsonList[i].registeredAccountType)) + "'>"
+ " <input type='text' class='col-sm' disabled value='" + status(jsonList[i].status) + "'>"
+ " <input type='button' class='col-sm-1' value='↑' onClick='extend(this)'>"
+ "</div>"
);
} else {
$("#maestro_list_result_contents").append(
"<div class='form-group player-list row mx-2 mb-1'>"
+ " <input type='text' class='maestro_extension_id d-none' disabled value='" + jsonList[i].maestroExtensionID + "'>"
+ " <input type='text' class='maestro_id d-none' disabled value='" + jsonList[i].maestroID + "'>"
+ " <input type='text' class='maestro_name col-sm text-success' disabled value='" + jsonList[i].maestroName + "'>"
+ " <input type='text' class='registered_account_type col-sm text-right text-success' disabled value='" + accountType(jsonList[i].registeredAccountType) + "'>"
+ " <input type='text' class='col-sm text-right' disabled value='" + jsonList[i].availableActivateDateTime.substring(0, 10) + "'>"
// + " <input type='text' class='new_account_type col-sm text-right text-success' disabled value='" + accountType(jsonList[i].requestedAccountType) + "'>"
+ " <input type='text' class='col-sm text-success text-right' disabled value='" + jsonList[i].requestedDateTime.substring(0, 10) + "'>"
// + " <input type='text' class='col-sm text-success' disabled value='" + NumberUtil.numberWithCommas(price(jsonList[i].requestedAccountType, jsonList[i].registeredAccountType)) + "'>"
+ " <input type='text' class='col-sm text-success' disabled value='" + status(jsonList[i].status) + "'>"
+ " <input type='button' class='col-sm-1' disabled value='Ω' onClick='extend(this)'>"
+ "</div>"
);
}
}
}
function searchMaestroExtension() {
var maestroName = $("#search_name").val();
if(maestroName.length === 0) {
$("#error_message").text("마에스트로 아이디를 입력하세요.");
$("#search_name").focus();
}
loadMaestroExtensionList(maestroName);
}
function extend(inputButton) {
// var extensionID = $(inputButton).siblings(".maestro_extension_id");
// var maestroExtensionID = extensionID.text();
// var maestroID = $(inputButton).siblings(".maestro_id");
// var id = maestroID.text();
// var accountType = $(inputButton).siblings(".requested_account_type");
var children = inputButton.parentElement.childNodes;
var maestroExtensionID;
var maestroID;
var maestroName;
var registeredAccountType;
for (var i=0; i < children.length; i++) {
// console.log(children);
if (children[i].className == "maestro_extension_id d-none") {
maestroExtensionID = children[i].value;
continue;
} else if (children[i].className == "maestro_id d-none") {
maestroID = children[i].value;
continue;
} else if (children[i].className == "maestro_name col-sm") {
maestroName = children[i].value;
continue;
} else if (children[i].className == "maestro_name col-sm text-success") {
maestroName = children[i].value;
continue;
} else if (children[i].className == "registered_account_type col-sm text-right") {
registeredAccountType = accountTypeValue(children[i].value);
continue;
}
}
console.log(maestroExtensionID);
console.log(maestroID);
console.log(maestroName);
console.log(registeredAccountType);
return;
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/admin/extension_maestro.php",
"maestro_extension_id=" + maestroExtensionID + "&maestro_id=" + maestroID + + "&maestro_name=" + maestroName + "&registered_account_type=" + registeredAccountType,
function(jsonData) {
loadMaestroExtensionList("");
$("#error_message").text(jsonData.maestroName + " 계정의 유효 기간이 1년 연장되었습니다.");
},
function(errorMessage, errorCode) {
if($("#error_message").length) {
$("#error_message").text(errorMessage);
}
}
);
}
</script>
</head>
<body bgcolor="white">
<header id="header"></header>
<div class="container mt-3">
<div class="row mx-1">
<h3 class="my-3">마에스트로 유효 기간 연장 목록</h3>
</div>
<div id="message_box"></div>
<div class="row mx-1">
<div class="col">
<h5 class="my-3">마에스트로 검색</h5>
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="search_name">마에스트로 아이디</label>
</div>
<input type="text" class="form-control" id="search_name" placeholder="Input maestro ID here" aria-label="Recipient's username" aria-describedby="basic-addon2">
<div class="input-group-append">
<button type="button" class="btn btn-primary" onClick="searchMaestroExtension()">검색 실행</button>
</div>
</div>
</div>
</div>
<div class="row mx-1">
<div class="col border border-warning rounded" style="background-color: #ffeab6">
<h5 class="my-3">검색 결과</h5>
<form id="search_player_list">
<div class="form-group row mx-2 mb-0 font-weight-bold">
<label class="col-form-label d-none">Extension ID</label>
<label class="col-form-label col-sm text-left">아이디</label>
<label class="col-form-label col-sm text-right">요금제</label>
<label class="col-form-label col-sm text-right">유효기간</label>
<label class="col-form-label col-sm text-right">연장 신청일</label>
<label class="col-form-label col-sm text-left">상태</label>
<label class="col-form-label col-sm-1 text-center">승인</label>
</div>
<div id="maestro_list_result_contents"></div>
</form>
</div> <!-- 학생 목록 -->
</div>
</div> <!-- container -->
</body>
</html>
+1
View File
@@ -37,6 +37,7 @@
<div class="eyebrow ml-auto mt-0 d-md-flex align-items-center">
<a class="btn btn-outline-warning btn-lg mr-2" href="./../admin/admin_all_list.html">전체</a>
<a class="btn btn-outline-warning btn-lg mr-2" href="./../admin/admin_register_list.html">신규 등록</a>
<a class="btn btn-outline-warning btn-lg mr-2" href="./../admin/admin_extension_list.html">연장</a>
<a class="btn btn-outline-warning btn-lg mr-2" href="./../admin/admin_upgrade_list.html">업그레이드</a>
<a class="btn btn-outline-warning btn-lg mr-2" href="./../admin/admin_expiration_list.html">계정 만료</a>
<a class="btn btn-primary btn-lg" href="./../admin/admin_send_email.html">이메일 발송</a>
+63
View File
@@ -179,6 +179,63 @@
}
function sendMailExtensionBankInfo() {
var maestroName = "삼화초";
var maestroEmail = "jisangs@daum.net";
var availableDate = "2019-11-16";
var newAvailableDate = "2020-11-16";
var registeredAccountType = 3;
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/mail/send_mail_test.php",
"type=sendMailExtensionBankInfo"
// $maestro_name, $available_date, $new_available_date, $maestro_email, $registered_account_type
+ "&maestro_name=" + maestroName
+ "&available_date=" + availableDate
+ "&new_available_date=" + newAvailableDate
+ "&email=" + maestroEmail
+ "&registered_account_type=" + registeredAccountType,
function(jsonData) {
console.log(jsonData);
// showErrorMessage("마에스트로 계정이 정상적으로 등록되었습니다.", "success");
// loadMaestroList("");
},
function(errorMessage, errorCode) {
showErrorMessage(errorMessage, "error");
}
);
}
function sendMailExtensionDone() {
var maestroName = "삼화초";
var maestroEmail = "jisangs@daum.net";
var newAvailableDate = "2020-11-16";
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
// "./../server/mail/send_mail_bank_info.php",
"./../server/mail/send_mail_test.php",
"type=sendMailExtensionDone"
// $maestro_name, $new_available_date, $maestro_email
+ "&maestro_name=" + maestroName
+ "&email=" + maestroEmail
+ "&new_available_date=" + newAvailableDate,
function(jsonData) {
console.log(jsonData);
// showErrorMessage("마에스트로 계정이 정상적으로 등록되었습니다.", "success");
// loadMaestroList("");
},
function(errorMessage, errorCode) {
showErrorMessage(errorMessage, "error");
}
);
}
function getMaestroData() {
var maestroID = 1;
var maestroName = "삼화초";
@@ -238,6 +295,12 @@
<br/>
<br/>
<button type="button" class="btn btn-primary" onClick="sendMailExtensionBankInfo()">[ 마에 ] 연장 신청</button>
<button type="button" class="btn btn-primary" onClick="sendMailExtensionDone()">[ 마에 ] 연장 승인</button>
<br/>
<br/>
<button type="button" class="btn btn-secondary" onClick="getMaestroData()">마에스트로 데이터 테스트</button>
@@ -0,0 +1,73 @@
<?php
header("Content-Type: application/json");
include "./../setup/connect_db.php";
include "./../lib/send_reply_json.php";
include "./../lib/db_maestro.php";
include "./../lib/maestro_log.php";
include "./../lib/maestro_account_info.php";
include "./../mail/mail_setting.php";
include "./../mail/send_mail.php";
$maestro_extension_id = $_POST["maestro_extension_id"];
$maestro_id = $_POST["maestro_id"];
$maestro_name = $_POST["maestro_name"];
$registered_account_type = $_POST["registered_account_type"];
extension_maestro($maestro_id);
change_extension_request_status_to_close($maestro_id);
change_extension_request_status_to_applied($maestro_extension_id);
$maestro_data = get_maestro_data($maestro_id);
// sendMailExtensionDone($maestro_data["name"], $maestro_data["email"], $registered_account_type);
insertMaestroLog("extension_maestro", $maestro_id, $maestro_name."(".$registered_account_type.")");
// set_data("maestro_extension_id", $maestro_extension_id);
// set_data("maestro_id", $maestro_id);
set_data("maestroName", $maestro_name);
send_result_success();
exit;
function extension_maestro($maestro_id) {
global $db_conn;
$query = "
UPDATE maestro
SET AccountType = ?, ActivateStatus = 1, AvailableActivateDateTime = DATE_ADD(NOW(), INTERVAL 1 YEAR)
WHERE MaestroID = ?;
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestro_id);
$stmt->execute();
}
function change_extension_request_status_to_close($maestro_id) {
global $db_conn;
$query = "
UPDATE maestro_extension
SET Status = 2
WHERE MaestroID = ? AND Status = 1;
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestro_id);
$stmt->execute();
}
function change_extension_request_status_to_applied($maestro_extension_id) {
global $db_conn;
$query = "
UPDATE maestro_extension
SET Status = 3
WHERE MaestroExtensionID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestro_extension_id);
$stmt->execute();
}
?>
@@ -0,0 +1,87 @@
<?php
header("Content-Type: application/json");
include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";
$maestroName = $_POST["maestro_name"];
$maestroExtensionList = null;
if(strlen($maestroName) === 0)
$maestroExtensionList = get_maestro_extension_list();
else
$maestroExtensionList = get_maestro_extension_list_by_name($maestroName);
if(strlen($maestroExtensionList) === 0) {
set_error_message("마에스트로 업그레이드 요청 목록 없음");
send_result_fail();
exit;
}
set_data("maestroExtensionList", $maestroExtensionList);
send_result_success();
exit;
function get_maestro_extension_list() {
global $db_conn;
$query = "
SELECT E.MaestroExtensionID, E.MaestroID, M.Name, E.AccountType, E.RequestedDateTime, M.AvailableActivateDateTime, E.Status
FROM maestro_extension E, maestro M
WHERE E.Status < 2 AND E.MaestroID = M.MaestroID
ORDER BY E.MaestroExtensionID DESC
";
$stmt = $db_conn->prepare($query);
// $stmt->bind_param("iii", $maestroID, $startNo, $endNo);
// $stmt->bind_param("ii", $maestroName, $startNo);
$stmt->execute();
$stmt->bind_result($maestroExtensionID, $maestroID, $maestroName, $registeredAccountType, $requestedDateTime, $availableActivateDateTime, $status);
$maestroExtensionList = array();
while($stmt->fetch()) {
$maestro["maestroExtensionID"] = $maestroExtensionID;
$maestro["maestroID"] = $maestroID;
$maestro["maestroName"] = $maestroName;
$maestro["registeredAccountType"] = $registeredAccountType;
$maestro["requestedDateTime"] = $requestedDateTime;
$maestro["availableActivateDateTime"] = $availableActivateDateTime;
$maestro["status"] = $status;
array_push($maestroExtensionList, $maestro);
}
return $maestroExtensionList;
}
function get_maestro_extension_list_by_name($searchMaestroName) {
global $db_conn;
$query = "
SELECT E.MaestroExtensionID, E.MaestroID, M.Name, E.AccountType, E.RequestedDateTime, M.AvailableActivateDateTime, E.Status
FROM maestro_extension E, maestro M
WHERE M.Name LIKE CONCAT('%', ?, '%') AND E.MaestroID = M.MaestroID
ORDER BY E.MaestroExtensionID DESC
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("s", $searchMaestroName);
$stmt->execute();
$stmt->bind_result($maestroExtensionID, $maestroID, $maestroName, $registeredAccountType, $requestedDateTime, $availableActivateDateTime, $status);
$maestroExtensionList = array();
while($stmt->fetch()) {
$maestro["maestroExtensionID"] = $maestroExtensionID;
$maestro["maestroID"] = $maestroID;
$maestro["maestroName"] = $maestroName;
$maestro["registeredAccountType"] = $registeredAccountType;
$maestro["requestedDateTime"] = $requestedDateTime;
$maestro["availableActivateDateTime"] = $availableActivateDateTime;
$maestro["status"] = $status;
array_push($maestroExtensionList, $maestro);
}
return $maestroExtensionList;
}
?>
+36
View File
@@ -141,6 +141,42 @@ function sendMailUpdateMaestroEmail($maestro_name, $maestro_email, $maestro_emai
}
function sendMailExtensionBankInfo($maestro_name, $available_date, $new_available_date, $maestro_email, $registered_account_type) {
// echo("$maestro_email : ".$maestro_email." / ");
// echo("$available_date : ".$available_date);
// return;
$postParamData = makeDefaultPostParamData($maestro_name, $maestro_email);
$postParamData["templateSid"] = "335";
$postParamData["parameters"] = array(
"account_type" => get_accout_type($registered_account_type),
"bank_account_no" => "3333-07-4977969",
"bank_name" => "카카오뱅크",
"bank_owner_name" => "박지상",
"maestro_email" => $maestro_email,
"maestro_name" => $maestro_name,
"available_date" => $available_date,
"new_available_date" => $new_available_date,
"price" => number_format(get_price($registered_account_type))
);
sendEmail($postParamData);
}
function sendMailExtensionDone($maestro_name, $new_available_date, $maestro_email) {
$postParamData = makeDefaultPostParamData($maestro_name, $maestro_email);
$postParamData["templateSid"] = "336";
$postParamData["parameters"] = array(
"maestro_name" => $maestro_name,
"new_available_date" => $new_available_date
);
sendEmail($postParamData);
}
function sendEmail($postParamData) {
global $host_name_url, $request_url, $access_key, $secret_key, $api_key, $method, $request_id;
global $sender_name, $sender_address;
+7
View File
@@ -12,9 +12,12 @@ $type = $_POST["type"];
$maestro_id = $_POST["maestro_id"];
$maestro_name = $_POST["maestro_name"];
$password = $_POST["password"];
$available_date = $_POST["available_date"];
$new_available_date = $_POST["new_available_date"];
$maestro_email = $_POST["email"];
$account_type = $_POST["account_type"];
$upgrade_account_type = $_POST["upgrade_account_type"];
$registered_account_type = $_POST["registered_account_type"];
$maestro_name_prev = $_POST["maestro_name_prev"];
$maestro_email_prev = $_POST["email_prev"];
@@ -31,6 +34,10 @@ if($type == "sendMailRegisterBankInfo") {
sendMailUpdateMaestroName($maestro_name, $maestro_name_prev, $maestro_email);
} else if($type == "sendMailUpdateMaestroEmail") {
sendMailUpdateMaestroEmail($maestro_name, $maestro_email, $maestro_email_prev);
} else if($type == "sendMailExtensionBankInfo") {
sendMailExtensionBankInfo($maestro_name, $available_date, $new_available_date, $maestro_email, $registered_account_type);
} else if($type == "sendMailExtensionDone") {
sendMailExtensionDone($maestro_name, $new_available_date, $maestro_email);
} else if($type == "get_maestro_data") {
// maestro data
$maestro_data = get_maestro_data($maestro_id);