Skip to content

Commit

Permalink
ticket system base [#1]
Browse files Browse the repository at this point in the history
  • Loading branch information
NightDev701 committed Aug 10, 2023
1 parent 1a18683 commit 7535da2
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/bug_report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bug Report erstellen</title>
</head>
<body>
<h1>Bug Report erstellen</h1>
<form action="create_bug.php" method="post">
<label for="title">Titel:</label>
<input type="text" id="title" name="title" required><br>
<label for="description">Beschreibung:</label>
<textarea id="description" name="description" rows="4" required></textarea><br>
<input type="hidden" name="reporter_name" value="GreenDevBlood">
<button type="submit">Bug melden</button>
</form>
</body>
</html>
18 changes: 18 additions & 0 deletions src/create_bug.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
@include 'util.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = $_POST['title'];
$description = $_POST['description'];
$reporter_name = $_POST['reporter_name'];

$query = mysqli_query(database_blogpost(), "INSERT INTO bug_reports (title, description, reporter_name, status, created_at)
VALUES ('$title', '$description', '$reporter_name', 'Open', NOW())");

if ($query) {
echo "Bug erfolgreich gemeldet!";
} else {
echo "Fehler beim Melden des Bugs.";
}
}
?>
1 change: 1 addition & 0 deletions src/downloadpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h1>Downloads</h1>
<nav>
<ul>
<li><a href="index.php">Hauptseite</a></li>
<li><a href="tickets.php">Ticket Ansicht</a></li>
<li><a class="active" href="downloadpage.html">Downloads</a></li>
<li><a href="https://github.com/SunLightScorpion" target="_blank">Github</a></li>
<li><a href="https://discord.gg/DRKeawjsq7" target="_blank">Discord</a></li>
Expand Down
1 change: 1 addition & 0 deletions src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<nav>
<ul>
<li><a href="index.php" class="active">Hauptseite</a></li>
<li><a href="tickets.php">Ticket Ansicht</a></li>
<li><a href="downloadpage.html">Downloads</a></li>
<li><a href="https://github.com/SunLightScorpion" target="_blank">Github</a></li>
<li><a href="https://discord.gg/DRKeawjsq7" target="_blank">Discord</a></li>
Expand Down
80 changes: 80 additions & 0 deletions src/tickets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ticket Ansicht</title>
<link rel="stylesheet" href="style.css">
<link href="sunlight.png" rel="icon">
</head>
<body>

<header>
<h1>Ticket Ansicht</h1>
</header>
<nav>
<ul>
<li><a href="index.php">Hauptseite</a></li>
<li><a href="tickets.php" class="active">Ticket Ansicht</a></li>
<li><a href="downloadpage.html">Downloads</a></li>
<li><a href="https://github.com/SunLightScorpion" target="_blank">Github</a></li>
<li><a href="https://discord.gg/DRKeawjsq7" target="_blank">Discord</a></li>
</ul>
</nav>

<div class="content">
<?php
@include 'util.php';

$per_page = 25;
$current_page = isset($_GET['page']) ? $_GET['page'] : 1;
$offset = ($current_page - 1) * $per_page;

$query = mysqli_query(database_blogpost(), "SELECT * FROM bug_reports ORDER BY created_at DESC LIMIT $offset, $per_page");

if ($query) {
echo "<table>";
echo "<tr><th>BugID</th><th>Beschreibung</th></tr>";

foreach ($query as $bug) {
echo "<tr>";
echo "<td>" . $bug['id'] . "</td>";
echo "<td>" . $bug['title'] . "</td>";
echo "</tr>";
}

echo "</table>";

$total_bugs = mysqli_query(database_bugtracker(), "SELECT COUNT(*) as total FROM bug_reports");
$total_bugs = mysqli_fetch_assoc($total_bugs)['total'];
$total_pages = ceil($total_bugs / $per_page);

if ($total_pages > 1) {
echo "<div class='pagination'>";

if ($current_page > 1) {
echo "<a href='tickets.php?page=" . ($current_page - 1) . "'>Prev</a>";
}

for ($i = 1; $i <= $total_pages; $i++) {
if ($i == $current_page) {
echo "<span class='current'>$i</span>";
} else {
echo "<a href='tickets.php?page=$i'>$i</a>";
}
}

if ($current_page < $total_pages) {
echo "<a href='tickets.php?page=" . ($current_page + 1) . "'>Next</a>";
}

echo "</div>";
}
} else {
echo "Fehler beim Abrufen der Daten.";
}
?>
</div>

</body>
</html>
6 changes: 3 additions & 3 deletions src/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ function database_blogpost(): mysqli {
return new mysqli($envVariables["HOST"], $envVariables["NAME"], $envVariables["PASSWORD"], $envVariables["NAME"]);
}

/*
function get_config(){
$propertiesFile = "config.properties";
$config = parse_ini_file($propertiesFile);

if ($config === false) {
die("Fehler beim Lesen der Properties-Datei: " . error_get_last()['message']);
}

*/
return $config;
}

?>

0 comments on commit 7535da2

Please sign in to comment.