Added tournament editing
This commit is contained in:
parent
66fdaf8ebd
commit
40f1dcee6e
132
admin/data_management/edit_tourney.php
Normal file
132
admin/data_management/edit_tourney.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php session_start() ?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
||||
<link rel="stylesheet" href="/styles/db_management.css" />
|
||||
<script src="/scripts/tools.js"></script>
|
||||
<script>//verifyPageInFrame()</script>
|
||||
<title>no title</title>
|
||||
</head>
|
||||
|
||||
<body class="sqlOutput">
|
||||
<?php
|
||||
// USER-DEFINED VARIABLES
|
||||
include("../db_config.php"); // Include database stuff
|
||||
|
||||
|
||||
try { // Try opening the SQL database connection
|
||||
$conn = new PDO("mysql:host=$servername; dbname=$dbName", $dbUsername, $dbPassword);
|
||||
// set the PDO error mode to exception
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
|
||||
// Need to check if values were sent over POST, otherwise set to N/A
|
||||
if (isset($_POST["winningPlayer1"])) {
|
||||
$winningPlayer1 = $_POST["winningPlayer1"];
|
||||
} else {
|
||||
$winningPlayer1 = "N/A";
|
||||
}
|
||||
if (isset($_POST["winningPlayer2"])) {
|
||||
$winningPlayer2 = $_POST["winningPlayer2"];
|
||||
} else {
|
||||
$winningPlayer2 = "N/A";
|
||||
}
|
||||
if (isset($_POST["winningPlayer3"])) {
|
||||
$winningPlayer3 = $_POST["winningPlayer3"];
|
||||
} else {
|
||||
$winningPlayer3 = "N/A";
|
||||
}
|
||||
if (isset($_POST["winningPlayer4"])) {
|
||||
$winningPlayer4 = $_POST["winningPlayer4"];
|
||||
} else {
|
||||
$winningPlayer4 = "N/A";
|
||||
}
|
||||
$tourneyID = $_POST["tourneyID"];
|
||||
$tourneyUID = $_POST["tourneyUID"];
|
||||
$tourneyName = $_POST["tourneyName"];
|
||||
$tourneyDate = $_POST["tourneyDate"];
|
||||
$division = $_POST["division"];
|
||||
$numPlayers = $_POST["numPlayers"];
|
||||
$bestOf = $_POST["bestOf"];
|
||||
$winningTeamName = $_POST["winningTeamName"];
|
||||
$notes = $_POST["notes"];
|
||||
|
||||
echo "<p>$tourneyName</p>";
|
||||
echo "<p>$tourneyDate</p>";
|
||||
echo "<p>$tourneyUID</p>";
|
||||
echo "<p>$division</p>";
|
||||
echo "<p>$numPlayers</p>";
|
||||
echo "<p>$bestOf</p>";
|
||||
echo "<p>$winningTeamName</p>";
|
||||
echo "<p>$winningPlayer1</p>";
|
||||
echo "<p>$winningPlayer2</p>";
|
||||
echo "<p>$winningPlayer3</p>";
|
||||
echo "<p>$winningPlayer4</p>";
|
||||
echo "<p>$notes</p>";
|
||||
|
||||
|
||||
$insert = $conn->prepare("UPDATE " . $tournamentDataTableName . " SET
|
||||
tournamentName = :tournamentName,
|
||||
tournamentDate = :tournamentDate,
|
||||
tournamentDivision = :tournamentDivision,
|
||||
numPlayers = :numPlayers,
|
||||
bestOf = :bestOf,
|
||||
winningTeamName = :winningTeamName,
|
||||
winner1 = :winner1,
|
||||
winner2 = :winner2,
|
||||
winner3 = :winner3,
|
||||
winner4 = :winner4,
|
||||
notes = :notes
|
||||
WHERE tournamentID = :tournamentID
|
||||
");
|
||||
|
||||
|
||||
$insert->bindValue(":tournamentName", $tourneyName);
|
||||
$insert->bindValue(":tournamentDate", $tourneyDate);
|
||||
$insert->bindValue(":tournamentDivision", $division);
|
||||
$insert->bindValue(":numPlayers", $numPlayers);
|
||||
$insert->bindValue(":bestOf", $bestOf);
|
||||
$insert->bindValue(":winningTeamName", $winningTeamName);
|
||||
$insert->bindValue(":winner1", $winningPlayer1);
|
||||
$insert->bindValue(":winner2", $winningPlayer2);
|
||||
$insert->bindValue(":winner3", $winningPlayer3);
|
||||
$insert->bindValue(":winner4", $winningPlayer4);
|
||||
$insert->bindValue(":notes", $notes);
|
||||
$insert->bindValue(":tournamentID", $tourneyID);
|
||||
|
||||
|
||||
|
||||
$insert->execute();
|
||||
|
||||
echo "Successfully edited tournament record";
|
||||
|
||||
// Function from StackOverflow used to get the base URL, to which we append
|
||||
// the redirect (where the user came from)
|
||||
function url(){
|
||||
return sprintf(
|
||||
"%s://%s/tournament",
|
||||
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
|
||||
$_SERVER['SERVER_NAME']
|
||||
);
|
||||
}
|
||||
|
||||
$address = url();
|
||||
echo "<p>Redirecting to <a href=\"$address/$tourneyUID\">$address/$tourneyUID</a>...</p>";
|
||||
|
||||
echo "<script>window.top.location.href = \"" . $address . "/" . $tourneyUID . "\";</script>";
|
||||
|
||||
} catch (PDOException $e) { // failed connection
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
|
||||
$conn = null;
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -42,4 +42,9 @@ function redirect(location, address) {
|
||||
default:
|
||||
window.open(address).focus();
|
||||
}
|
||||
}
|
||||
|
||||
function selectElement(id, valueToSelect) {
|
||||
let element = document.getElementById(id);
|
||||
element.value = valueToSelect;
|
||||
}
|
@ -14,7 +14,6 @@
|
||||
flex-shrink: 1;
|
||||
border-top: 2px solid black;
|
||||
border-bottom: 2px solid black;
|
||||
padding-bottom: 2%;
|
||||
margin-bottom: 2%;
|
||||
}
|
||||
|
||||
@ -40,5 +39,44 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#notes {
|
||||
padding-bottom: 2%;
|
||||
}
|
||||
|
||||
.editButton {
|
||||
margin-top: 2% !important;
|
||||
margin-bottom: 2% !important;
|
||||
margin: auto;
|
||||
padding: 7px 15px;
|
||||
font-size: 100%;
|
||||
font-weight: bold;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
background-color: rgba(255, 255, 255, 0);
|
||||
border-radius: 6px;
|
||||
border: 1px solid rgb(0, 0, 255);
|
||||
box-shadow: 0px 2px 4px;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
.editButton:hover {
|
||||
color: black;
|
||||
background-color: rgba(255, 165, 0, .6);
|
||||
}
|
||||
|
||||
.editButton:active {
|
||||
box-shadow: 0px 0px 2px;
|
||||
transform: translateY(2px);
|
||||
}
|
||||
|
||||
.editButton a {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
margin-top: 1%;
|
||||
margin-bottom: 2%;
|
||||
}
|
||||
|
||||
/*// MOBILE ////
|
||||
///////////////*/
|
193
tournament/edit.php
Normal file
193
tournament/edit.php
Normal file
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
include("../admin/db_config.php"); // Include database stuff
|
||||
|
||||
try { // Try opening the SQL database connection
|
||||
$conn = new PDO("mysql:host=$servername; dbname=$dbName", $dbUsername, $dbPassword);
|
||||
// set the PDO error mode to exception
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$tourneyID = $_GET["tournamentID"];
|
||||
|
||||
// Grab the list of users from the user list
|
||||
// We will also grab all the people that have been registered/won before
|
||||
$sqlGetUserData = $conn->prepare("SELECT username FROM " . $userTableName . "");
|
||||
$sqlGetTourneyData = $conn->prepare("SELECT winner1,winner2,winner3,winner4 FROM " . $tournamentDataTableName . "");
|
||||
$sqlGetAllTourneyData = $conn->prepare("SELECT * FROM " . $tournamentDataTableName . " WHERE tournamentID='" . $tourneyID . "'");
|
||||
|
||||
// Execute SQL query
|
||||
$sqlGetUserData->execute();
|
||||
$sqlGetTourneyData->execute();
|
||||
$sqlGetAllTourneyData->execute();
|
||||
|
||||
// Get results from the USERS table
|
||||
$results = $sqlGetUserData->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Create array to store values
|
||||
$userList = array();
|
||||
|
||||
// Move results to their own array, easier to convert for Javascript
|
||||
foreach ($results as $result) {
|
||||
$userList[] = $result["username"];
|
||||
}
|
||||
|
||||
|
||||
// Get results from the TOURNEY table
|
||||
$results = $sqlGetTourneyData->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Move results to their own array, easier to convert for Javascript
|
||||
foreach ($results as $result) {
|
||||
$userList[] = $result["winner1"];
|
||||
$userList[] = $result["winner2"];
|
||||
$userList[] = $result["winner3"];
|
||||
$userList[] = $result["winner4"];
|
||||
}
|
||||
|
||||
// Make sure we only have each name once
|
||||
$userList = array_unique($userList);
|
||||
// Sort the array to alphabetical order
|
||||
sort($userList);
|
||||
|
||||
$tourneyResults = $sqlGetAllTourneyData->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
// Grab tournament info
|
||||
// Set variables from SQL data
|
||||
$tourneyName = $tourneyResults["tournamentName"];
|
||||
$tourneyUID = $tourneyResults["tournamentUID"];
|
||||
$tourneyDate = $tourneyResults["tournamentDate"];
|
||||
$division = $tourneyResults["tournamentDivision"];
|
||||
$numPlayers = $tourneyResults["numPlayers"];
|
||||
$bestOf = $tourneyResults["bestOf"];
|
||||
$winningTeamName = $tourneyResults["winningTeamName"];
|
||||
$winner1 = $tourneyResults["winner1"];
|
||||
$winner2 = $tourneyResults["winner2"];
|
||||
$winner3 = $tourneyResults["winner3"];
|
||||
$winner4 = $tourneyResults["winner4"];
|
||||
$notes = $tourneyResults["notes"];
|
||||
|
||||
|
||||
} catch (PDOException $e) { // failed connection
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
||||
<link rel="stylesheet" href="/styles/primary.css" />
|
||||
<link rel="stylesheet" href="/styles/admin.css" />
|
||||
<link rel="stylesheet" href="/styles/admin_nav.css" />
|
||||
<link rel="stylesheet" href="/styles/tourney_management.css" />
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.14.1/themes/base/jquery-ui.css">
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.14.1/jquery-ui.js"></script>
|
||||
<script src="/scripts/tourney_management.js"></script>
|
||||
<script src="/scripts/tools.js"></script>
|
||||
<script>//verifyPageInFrame()</script>
|
||||
<script>
|
||||
if (parent.window.screen.width >= 360 && window.screen.width <= 1024) {
|
||||
// If mobile, get the mobile version
|
||||
window.location.replace("/tournament/edit_mobile.php");
|
||||
}
|
||||
</script>
|
||||
<title>TOURNAMENT EDITING FORM</title>
|
||||
<script>
|
||||
$( function() {
|
||||
var userList = <?php echo json_encode($userList); ?>;
|
||||
|
||||
$(".playerInput").autocomplete({
|
||||
source: userList,
|
||||
});
|
||||
} );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body id="body">
|
||||
<div id="contentFrame">
|
||||
<img src="/assets/rl_logo_background.svg" alt="Rocket League logo for background" class="backgroundImage">
|
||||
<?php include_once('../display/header.html'); ?>
|
||||
<div id="tourneyFormPanel">
|
||||
<form id="userForm" action="/admin/data_management/edit_tourney.php" method="POST" autocomplete="off">
|
||||
<h2>EDIT TOURNAMENT</h2>
|
||||
<hr>
|
||||
<p></p>
|
||||
<div id="textInputArea">
|
||||
<label for="tourneyName">Tournament name</label>
|
||||
<input type="text" id="tourneyName" name="tourneyName" value="<?php echo $tourneyName; ?>" maxlength="150" tabindex="1" required>
|
||||
<p class="newLine"></p>
|
||||
<label for="tourneyName">Tournament date</label>
|
||||
<input type="date" id="tourneyDate" name="tourneyDate" max="<?php echo date("Y-m-d"); ?>" value="<?php echo $tourneyDate; ?>" tabindex="1" required>
|
||||
<p class="newLine"></p>
|
||||
</div>
|
||||
<div class="optionsArea">
|
||||
<label for="division">Division:</label>
|
||||
<select id="division" name="division" tabindex="1">
|
||||
<option value="main">Main</option>
|
||||
<option value="intermediate">Intermediate</option>
|
||||
<option value="open">Open</option>
|
||||
</select>
|
||||
<script>selectElement('division', '<?php echo $division; ?>');</script>
|
||||
<p class="newLine"></p>
|
||||
<label for="numPlayers">Players:</label>
|
||||
<select id="numPlayers" name="numPlayers" tabindex="1" onchange="changePlayers()">
|
||||
<option value="1">1v1</option>
|
||||
<option value="2">2v2</option>
|
||||
<option value="3">3v3</option>
|
||||
<option value="4">4v4</option>
|
||||
</select>
|
||||
<script>selectElement('numPlayers', '<?php echo $numPlayers; ?>');</script>
|
||||
<label for="bestOf">Best of:</label>
|
||||
<select id="bestOf" name="bestOf" tabindex="1">
|
||||
<option value="1">1</option>
|
||||
<option value="3">3</option>
|
||||
<option value="5">5</option>
|
||||
<option value="7">7</option>
|
||||
</select>
|
||||
<script>selectElement('bestOf', '<?php echo $bestOf; ?>');</script>
|
||||
</div>
|
||||
<p class="newLine"></p>
|
||||
<div id="playerDataInputArea">
|
||||
<p id="teamNameHeader">WINNING TEAM NAME:</p>
|
||||
<input type="text" name="winningTeamName" class="teamInput" maxlength="30" value="<?php echo $winningTeamName; ?>" tabindex="1">
|
||||
<h4>Roster</h4>
|
||||
<table id="playerData">
|
||||
</table>
|
||||
<script>addPlayers();</script>
|
||||
<script>
|
||||
var winner1 = <?php echo json_encode($winner1, JSON_HEX_TAG); ?>;
|
||||
var winner2 = <?php echo json_encode($winner2, JSON_HEX_TAG); ?>;
|
||||
var winner3 = <?php echo json_encode($winner3, JSON_HEX_TAG); ?>;
|
||||
var winner4 = <?php echo json_encode($winner4, JSON_HEX_TAG); ?>;
|
||||
document.getElementById("1").value = winner1;
|
||||
document.getElementById("2").value = winner2;
|
||||
document.getElementById("3").value = winner3;
|
||||
document.getElementById("4").value = winner4;
|
||||
</script>
|
||||
<p class="newLine"></p>
|
||||
</div>
|
||||
<p class="newLine"></p>
|
||||
<div class="optionsArea">
|
||||
<p class="newLine"></p>
|
||||
<p class="newLine">Notes</p>
|
||||
<textarea name="notes" id="notes" tabindex="4"><?php echo $notes; ?></textarea>
|
||||
<p class="newLine"></p>
|
||||
<input type="hidden" id="tourneyID" name="tourneyID" value="<?php echo $tourneyID; ?>">
|
||||
<input type="hidden" id="tourneyUID" name="tourneyUID" value="<?php echo $tourneyUID; ?>">
|
||||
</div>
|
||||
<p class="newLine"></p>
|
||||
<div id="submitButtonDiv">
|
||||
<p class="newLine"></p>
|
||||
<input type="submit" value="Save" id="submitButton" tabindex="4">
|
||||
</div>
|
||||
<p class="newLine"></p>
|
||||
</form>
|
||||
</div>
|
||||
<?php include_once('../display/subnav.php'); ?>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -44,29 +44,17 @@ if (isset($tourneyResults)) {
|
||||
</head>
|
||||
|
||||
<body id="body">
|
||||
<script>getURL();</script>
|
||||
<div id="contentFrame">
|
||||
<img src="/assets/rl_logo_background.svg" alt="Rocket League logo for background" class="backgroundImage">
|
||||
<div class="header">
|
||||
<div id="headerLeft">
|
||||
<img src="/assets/trojan_image_1.png" alt="Trojan Destiny logo" id="headerImage">
|
||||
</div>
|
||||
<div id="headerCentre">
|
||||
<h1 id="headerText"><a href="/" class="plainLinkBlue">TrojanDestinyRL</a></h1>
|
||||
<div id="youtubeImage" onclick="redirect('this', 'https://www.youtube.com/@TrojanDestinyRL')"><img src="/assets/youtube.svg" alt="youtube logo"></div>
|
||||
<div id="twitchImage" onclick="redirect('this', 'https://www.twitch.tv/trojandestinyrl')"><img src="/assets/twitch.svg" alt="twitch logo"></div>
|
||||
<div id="discordImage" onclick="redirect('this', 'https://discord.gg/bzU5fVxCZJ')"><img src="/assets/discord.svg" alt="discord logo"></div>
|
||||
</div>
|
||||
<div id="headerRight">
|
||||
<img src="/assets/trojan_image_2.png" alt="Trojan Destiny logo" id="headerImage">
|
||||
</div>
|
||||
</div>
|
||||
<p></p>
|
||||
<?php include_once('../display/header.html'); ?>
|
||||
<h1>Tournament Information</h1>
|
||||
<p class="newLine"></p>
|
||||
<div id="tournamentDisplayPanel">
|
||||
<?php
|
||||
if ($tourneyExists) {
|
||||
// TOURNEY PANEL - LEFT PANEL
|
||||
// Set variables from SQL data
|
||||
$tourneyID = $tourneyResults["tournamentID"];
|
||||
$tourneyName = $tourneyResults["tournamentName"];
|
||||
$tourneyDate = $tourneyResults["tournamentDate"];
|
||||
$division = ucfirst($tourneyResults["tournamentDivision"]);
|
||||
@ -81,6 +69,8 @@ if (isset($tourneyResults)) {
|
||||
// Format date
|
||||
$tourneyDate = DateTime::createFromFormat('Y-m-d', $tourneyDate);
|
||||
$tourneyDate = $tourneyDate->format('M j, Y');
|
||||
|
||||
// Print page
|
||||
echo "<div class=\"tournamentDisplay\">";
|
||||
echo "<h3>Details</h2>";
|
||||
echo "<hr class=\"regularLine\">";
|
||||
@ -109,8 +99,14 @@ if (isset($tourneyResults)) {
|
||||
echo "<h4>Notes:</h4>";
|
||||
echo "<p style=\"width:70%;\">$notes</p>";
|
||||
}
|
||||
|
||||
if ($_SESSION["privileges"] == 1) {
|
||||
echo "<p class=\"editButton\"><a href=\"/tournament/edit.php?tournamentID=" . $tourneyID . "\" onclick=\"redirect('this', '/admin/data_management/edit_tourney.php?tourneyID=" . $tourneyID . "');\">Edit</a></p>";
|
||||
}
|
||||
echo "</div>";
|
||||
|
||||
|
||||
// GAME DISPLAY - RIGHT PANEL
|
||||
echo "<div class=\"gameDisplay\">";
|
||||
echo "<h3>Games</h3>";
|
||||
echo "<hr class=\"regularLine\">";
|
||||
@ -118,6 +114,7 @@ if (isset($tourneyResults)) {
|
||||
|
||||
|
||||
} else {
|
||||
// TOURNAMENT NOT FOUND
|
||||
echo "<div class=\"noTourney\">";
|
||||
echo "<hr class=\"regularLine\">";
|
||||
echo "<h1>TOURNAMENT NOT FOUND</h1>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user