updating incidents

This commit is contained in:
jakani24
2024-06-25 20:31:15 +02:00
parent c8db09ffcf
commit 5fa805e0ac
3 changed files with 21 additions and 9 deletions

View File

@@ -109,7 +109,9 @@
$sql = "CREATE TABLE IF NOT EXISTS incidents (
id INT AUTO_INCREMENT PRIMARY KEY,
status VARCHAR(50) NOT NULL,
description VARCHAR(255) NOT NULL
description VARCHAR(255) NOT NULL,
opened VARCHAR(50),
closed VARCHAR(50)
)";
if ($conn->query($sql) === TRUE) {

View File

@@ -61,8 +61,9 @@ include "../../../api/php/log/add_server_entry.php"; //to log things
$success=0;
die("Connection failed: " . $conn->connect_error);
}
$stmt = $conn->prepare("INSERT INTO incidents (description, status) VALUES (?, 'open')");
$stmt->bind_param("s", $keyword);
$date=date("Y-m-d");
$stmt = $conn->prepare("INSERT INTO incidents (description, status, opened) VALUES (?, 'open', ?)");
$stmt->bind_param("ss", $keyword,$date);
$keyword=htmlspecialchars($_POST["keyword"]);

View File

@@ -114,7 +114,21 @@ if(isset($_GET["update_box_id"])){
</ul>
<div id="overview" style="display:none">
<h4>Incident #<?php echo($_GET["incident_id"]); ?></h4>
<?php
//get some info about the incident from the db
$sql="SELECT * FROM incidents WHERE id = ?";
$stmt = $conn->prepare($sql);
$incident_id=htmlspecialchars($_GET["incident_id"]);
$stmt->bind_param("i", $incident_id);
$stmt->execute();
$results = $stmt->get_result();
$data = $results->fetch_assoc();
echo("<p>Status: ".$data["status"]."</p>");
echo("<p>Description: ".$data["description"]."</p>");
echo("<p>Opened: ".$data["opened"]."</p>");
echo("<p>Closed: ".$data["closed"]."</p>");
?>
</div>
<div id="evidence" style="display:none">
@@ -127,11 +141,6 @@ if(isset($_GET["update_box_id"])){
<a data-bs-target="#add_todo" data-bs-toggle="modal" href="#add_todo" class="btn btn-primary">Add a todo list</a>
<br><br>
<?php
//list todos from all lists
//list todos -> list each entry of each todo
$sql_lists = "SELECT id, name FROM todo_lists WHERE belongs_to_incident = ?";
$stmt = $conn->prepare($sql_lists);
$incident_id=htmlspecialchars($_GET["incident_id"]);