diff --git a/admin/data_management/edit_tourney.php b/admin/data_management/edit_tourney.php new file mode 100644 index 0000000..ae35cdd --- /dev/null +++ b/admin/data_management/edit_tourney.php @@ -0,0 +1,132 @@ + + + + + +
+ + + + + +$tourneyName
"; + echo "$tourneyDate
"; + echo "$tourneyUID
"; + echo "$division
"; + echo "$numPlayers
"; + echo "$bestOf
"; + echo "$winningTeamName
"; + echo "$winningPlayer1
"; + echo "$winningPlayer2
"; + echo "$winningPlayer3
"; + echo "$winningPlayer4
"; + echo "$notes
"; + + + $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 "Redirecting to $address/$tourneyUID...
"; + + echo ""; + + } catch (PDOException $e) { // failed connection + echo "Connection failed: " . $e->getMessage(); + } + + $conn = null; + + ?> + + + + \ No newline at end of file diff --git a/scripts/tools.js b/scripts/tools.js index 5067234..21b85bc 100644 --- a/scripts/tools.js +++ b/scripts/tools.js @@ -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; } \ No newline at end of file diff --git a/styles/tourney_display.css b/styles/tourney_display.css index 4dfbe82..6218edc 100644 --- a/styles/tourney_display.css +++ b/styles/tourney_display.css @@ -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 //// ///////////////*/ \ No newline at end of file diff --git a/tournament/edit.php b/tournament/edit.php new file mode 100644 index 0000000..57efa96 --- /dev/null +++ b/tournament/edit.php @@ -0,0 +1,193 @@ +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(); +} + +?> + + + + + + + + + + + + + + + + + +$notes
"; } + + if ($_SESSION["privileges"] == 1) { + echo ""; + } echo "