aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-04-30 10:03:14 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2021-04-30 10:03:14 +0300
commit86d87b985ce10c51cf044c68bcb3382a20a1f6bc (patch)
tree92296d171b8c5bebeb7ea0f65b03f7a137d5cca5
parentbug/view: show associated reports (diff)
downloadbugtracker-86d87b985ce10c51cf044c68bcb3382a20a1f6bc.tar.xz
Reports can be bound to bugs
-rw-r--r--bug/view.php2
-rw-r--r--report/edit.php14
-rw-r--r--report/update.php5
3 files changed, 17 insertions, 4 deletions
diff --git a/bug/view.php b/bug/view.php
index 6b26860..5b627db 100644
--- a/bug/view.php
+++ b/bug/view.php
@@ -38,7 +38,7 @@ if($reports->rowCount() > 0) {
<tr><th>Title</th><th>Description</th><th>Submitted by</th></tr>
<?php
foreach ($reports as $row) {
- echo "<tr><td><a href=report/view.php?id=$row[id]>$row[title]</a></td> <td>" . truncate($row['description']) . "</td> <td>$row[user]</td></tr>\n";
+ echo "<tr><td><a href={$config['urls']['base']}/report/view.php?id=$row[id]>$row[title]</a></td> <td>" . truncate($row['description']) . "</td> <td>$row[user]</td></tr>\n";
}
?>
</table>
diff --git a/report/edit.php b/report/edit.php
index ef289bd..cd2e1a8 100644
--- a/report/edit.php
+++ b/report/edit.php
@@ -14,8 +14,9 @@ $title = "";
$submitter = $_SESSION['user_name'];
$description = "";
+$conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
+
if($id != "") {
- $conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
$query = $conn->prepare("SELECT title, description, users.username AS submitter FROM reports
JOIN users ON reports.author=users.id
WHERE reports.id=:report_id");
@@ -28,6 +29,9 @@ if($id != "") {
$description = $result['description'];
}
+# get bug id's
+$bugs = $conn->query("SELECT id, title FROM bugs");
+
?>
<form action="update.php?id=<?php echo $id; ?>" method="post">
@@ -35,6 +39,14 @@ if($id != "") {
<p>Title: <input name="title" type="text" value="<?php echo $title; ?>"></p>
<p>Submitted by: <?php echo $submitter; ?></p>
<p>Description: <br><textarea name="description" rows=25 cols=80><?php echo $description; ?></textarea></p>
+<p>Assign to bug: <select name="bug_id">
+<option value="">None</option>
+<?php
+foreach($bugs as $bug) {
+ echo "<option value=$bug[id]>$bug[title]</option>";
+}
+?>
+</select></p>
<input type="submit" value="submit" >
</form>
diff --git a/report/update.php b/report/update.php
index 0fadb53..c8ef12b 100644
--- a/report/update.php
+++ b/report/update.php
@@ -7,8 +7,8 @@ require_once(LIBRARY_PATH . "/functions.php");
if(session_set()) {
$conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
$query = $_POST['id'] == "" ?
- $conn->prepare("INSERT INTO reports (author, title, description) VALUES (:user_id, :title, :description)")
- : $conn->prepare("UPDATE reports SET title=:title, description=:description WHERE id=:report_id");
+ $conn->prepare("INSERT INTO reports (author, title, description, bug) VALUES (:user_id, :title, :description, :bug_id)")
+ : $conn->prepare("UPDATE reports SET title=:title, description=:description, bug=:bug_id WHERE id=:report_id");
if($_POST['id'] == "") {
$query->bindParam(':user_id', $_SESSION['user_id']);
} else {
@@ -16,6 +16,7 @@ if(session_set()) {
}
$query->bindParam(':title', $_POST['title']);
$query->bindParam(':description', $_POST['description']);
+ $query->bindValue(':bug_id', $_POST['bug_id'] == "" ? null : $_POST['bug_id']);
if($query->execute()) {
echo "<h2>report submitted</h2>";
} else {