Add: upgrade maestro account type

This commit is contained in:
2018-08-04 06:06:05 +09:00
parent d32db6493a
commit 9c7a67c561
7 changed files with 347 additions and 5 deletions
+64
View File
@@ -0,0 +1,64 @@
<?php
header("Content-Type: application/json");
include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";
$maestroUpgradeID = $_POST["maestro_upgrade_id"];
$maestroID = $_POST["maestro_id"];
$newAccountType = $_POST["new_account_type"];
upgrade_maestro($maestroID, $newAccountType);
change_upgrade_request_status_to_close($maestroID);
change_upgrade_request_status_to_applied($maestroUpgradeID);
// set_data("maestroUpgradeID", $maestroUpgradeID);
// set_data("maestroID", $maestroID);
// set_data("newAccountType", $newAccountType);
send_result_success();
exit;
function upgrade_maestro($maestroID, $newAccountType) {
global $db_conn;
$query = "
UPDATE moty_maestro
SET AccountType = ?, ActivateStatus = 1, AvailableActivateDateTime = DATE_ADD(NOW(), INTERVAL 1 YEAR)
WHERE MaestroID = ?;
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("ii", $newAccountType, $maestroID);
$stmt->execute();
}
function change_upgrade_request_status_to_close($maestroID) {
global $db_conn;
$query = "
UPDATE moty_maestro_upgrade
SET Status = 2
WHERE MaestroID = ? AND Status = 1;
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestroID);
$stmt->execute();
}
function change_upgrade_request_status_to_applied($maestroUpgradeID) {
global $db_conn;
$query = "
UPDATE moty_maestro_upgrade
SET Status = 3
WHERE MaestroUpgradeID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestroUpgradeID);
$stmt->execute();
}
?>